package uk.co.alynn.games.ld30;

public class Tutorial {
    private int m_tutorialStage = 0;
    // stage 0: need to latch
    // stage 1: need to unlatch
    // stage 2: need to shoot
    // stage 3: done

    public void update(float deltaTime) {
    }

    public boolean isFinished() {
        return m_tutorialStage == 3;
    }

    public boolean noBulletsYet() {
        return m_tutorialStage < 2;
    }

    public void didShoot() {
        if (m_tutorialStage == 2) {
            m_tutorialStage = 3;
        }
    }

    public void didLatchToPlanet() {
        if (m_tutorialStage == 0) {
            m_tutorialStage = 1;
        }
    }

    public void didUnlatch() {
        if (m_tutorialStage == 1) {
            m_tutorialStage = 2;
        }
    }

    public void render(Renderer renderer) {
        switch (m_tutorialStage) {
        case 0:
            renderer.text("Right-click to latch to a planet", 10, 16, 1.0f);
            break;
        case 1:
            renderer.text("Right-click again to unlatch", 10, 16, 1.0f);
            break;
        case 2:
            renderer.text("Left-click to shoot", 10, 16, 1.0f);
            break;
        default:
            break;
        }
    }

}

@@ -87,16 +87,60 @@
 ge = 0;%0A
+    private float m_timeSinceSwitch = 0.0f;%0A
     // s
@@ -243,16 +243,122 @@
  3: done
+%0A    %0A    private final static float TEXT_FADE_TIME = 0.3f;%0A    private final static float GL_TIME = 6.0f;
 %0A%0A    pu
@@ -389,24 +389,64 @@
 eltaTime) %7B%0A
+        m_timeSinceSwitch += deltaTime;%0A
     %7D%0A%0A    p
@@ -691,24 +691,62 @@
 lStage = 3;%0A
+            m_timeSinceSwitch = 0.0f;%0A
         %7D%0A  
@@ -856,16 +856,54 @@
 ge = 1;%0A
+            m_timeSinceSwitch = 0.0f;%0A
         
@@ -1007,24 +1007,62 @@
 lStage = 2;%0A
+            m_timeSinceSwitch = 0.0f;%0A
         %7D%0A  
@@ -1122,77 +1122,874 @@
     
-switch (m_tutorialStage) %7B%0A        case 0:%0A            renderer.text(
+float alpha;%0A        int stageText = m_tutorialStage;%0A        if (m_timeSinceSwitch %3E (2*TEXT_FADE_TIME)) %7B%0A            alpha = 1.0f;%0A        %7D else if (m_timeSinceSwitch %3E TEXT_FADE_TIME) %7B%0A            alpha = (m_timeSinceSwitch - TEXT_FADE_TIME) / TEXT_FADE_TIME;%0A        %7D else %7B%0A            alpha = (TEXT_FADE_TIME - m_timeSinceSwitch) / TEXT_FADE_TIME;%0A            --stageText;%0A        %7D%0A        %0A        if (stageText == 3 && m_timeSinceSwitch %3E TEXT_FADE_TIME + GL_TIME) %7B%0A            float displayTime = m_timeSinceSwitch - TEXT_FADE_TIME - GL_TIME;%0A            if (displayTime %3C TEXT_FADE_TIME) %7B%0A                alpha = (TEXT_FADE_TIME - displayTime) / TEXT_FADE_TIME;%0A            %7D else %7B%0A                alpha = 0.0f;%0A            %7D%0A        %7D%0A        %0A        String displayedText;%0A        switch (stageText) %7B%0A        case 0:%0A            displayedText = 
 %22Rig
@@ -2018,31 +2018,16 @@
  planet%22
-, 10, 16, 1.0f)
 ;%0A      
@@ -2067,30 +2067,32 @@
         
-renderer.text(
+displayedText = 
 %22Right-c
@@ -2113,31 +2113,16 @@
 unlatch%22
-, 10, 16, 1.0f)
 ;%0A      
@@ -2166,22 +2166,24 @@
     
-renderer.text(
+displayedText = 
 %22Lef
@@ -2203,89 +2203,262 @@
 oot%22
-, 10, 16, 1.0f);%0A            break;%0A        default:%0A            break;%0A        %7D
+;%0A            break;%0A        case 3:%0A            displayedText = %22Destroy things that move. Good luck!%22;%0A            break;%0A        default:%0A            displayedText = %22%22;%0A            break;%0A        %7D%0A        renderer.text(displayedText, 10, 16, alpha);
 %0A   

Add introductory text fading