From c45497ba0785a1498f7ceb69a7262c96521a14c7 Mon Sep 17 00:00:00 2001
From: timeo <timeo.jacquier@gmail.com>
Date: Sun, 12 Dec 2021 22:26:48 +0100
Subject: [PATCH] Waiting screen

---
 core/src/com/mygdx/game/PlatVenture.java | 31 +++++++++++++++++
 core/src/etat/WaitingScreen.java         | 44 ++++++++++++++++++++++++
 core/src/handlers/GameStateManager.java  |  9 +++--
 3 files changed, 82 insertions(+), 2 deletions(-)
 create mode 100644 core/src/etat/WaitingScreen.java

diff --git a/core/src/com/mygdx/game/PlatVenture.java b/core/src/com/mygdx/game/PlatVenture.java
index b8d9b8c..92e5016 100644
--- a/core/src/com/mygdx/game/PlatVenture.java
+++ b/core/src/com/mygdx/game/PlatVenture.java
@@ -21,6 +21,8 @@ public class PlatVenture extends ApplicationAdapter {
 
 	public static final float STEP = 1 /60f; // Pas entre deux images
 	private float accum;
+	private float compteurIntro = 0;
+	private boolean hasPassedIntro = false;
 
 	private SpriteBatch batch;
 	private OrthographicCamera cam;
@@ -42,6 +44,7 @@ public class PlatVenture extends ApplicationAdapter {
 		hudCam = new OrthographicCamera();
 		hudCam.setToOrtho(false, largeur, hauteur);
 		gsm = new GameStateManager(this);
+		loadContent();
 	}
 
 	@Override
@@ -50,6 +53,15 @@ public class PlatVenture extends ApplicationAdapter {
 
 		// update seulement si suffisamment de temps est passé depuis la dernière étape
 		while (accum >= STEP){
+			if (compteurIntro < 3){
+				compteurIntro += STEP;
+			}else{
+				//compteurIntro = 0;
+				if (!hasPassedIntro) {
+					gsm.setState(GameStateManager.PLAY);
+					hasPassedIntro = true;
+				}
+			}
 			accum -= STEP;
 			gsm.update(STEP);
 			gsm.render();
@@ -74,4 +86,23 @@ public class PlatVenture extends ApplicationAdapter {
 	public OrthographicCamera getHudCam() {
 		return hudCam;
 	}
+
+	private void loadContent(){
+		res.loadTexture("Platform_J.png", "platJ");
+		res.loadTexture("Platform_K.png", "platK");
+		res.loadTexture("Platform_L.png", "platL");
+		res.loadTexture("Brick_A.png", "brickA");
+		res.loadTexture("Brick_B.png", "brickB");
+		res.loadTexture("Brick_C.png", "brickC");
+		res.loadTexture("Brick_D.png", "brickD");
+		res.loadTexture("Brick_E.png", "brickE");
+		res.loadTexture("Brick_F.png", "brickF");
+		res.loadTexture("Brick_G.png", "brickG");
+		res.loadTexture("Brick_H.png", "brickH");
+		res.loadTexture("Brick_I.png", "brickI");
+		res.loadTexture("Exit_Z.png", "exit");
+		res.loadTexture("Back.png", "back");
+		res.loadTexture("Idle__000.png", "idle_000");
+		res.loadTexture("Water.png", "water");
+	}
 }
diff --git a/core/src/etat/WaitingScreen.java b/core/src/etat/WaitingScreen.java
new file mode 100644
index 0000000..31f286c
--- /dev/null
+++ b/core/src/etat/WaitingScreen.java
@@ -0,0 +1,44 @@
+package etat;
+
+import static handlers.B2DVars.PPM;
+
+import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.graphics.GL20;
+import com.mygdx.game.PlatVenture;
+
+import handlers.Content;
+import handlers.GameStateManager;
+
+public class WaitingScreen extends GameState{
+
+    private Content res;
+
+    public WaitingScreen(GameStateManager gsm) {
+        super(gsm);
+        res = new Content();
+        res.loadTexture("Intro.png", "intro");
+    }
+
+    @Override
+    public void handleInput() {
+
+    }
+
+    @Override
+    public void update(float dt) {
+
+    }
+
+    @Override
+    public void render() {
+        batch.setProjectionMatrix(cam.combined);
+        batch.begin();
+        batch.draw(res.getTexture("intro"),  0, 0, PlatVenture.largeur, PlatVenture.hauteur);
+        batch.end();
+    }
+
+    @Override
+    public void dispose() {
+
+    }
+}
diff --git a/core/src/handlers/GameStateManager.java b/core/src/handlers/GameStateManager.java
index 9f72771..2a0c840 100644
--- a/core/src/handlers/GameStateManager.java
+++ b/core/src/handlers/GameStateManager.java
@@ -6,18 +6,20 @@ import java.util.Stack;
 
 import etat.GameState;
 import etat.Play;
+import etat.WaitingScreen;
 
 public class GameStateManager {
 
     private PlatVenture platVenture;
     private Stack<GameState> gameStates;
 
-    public static final int PLAY = 4646;
+    public static final int PLAY = 1;
+    public static final int WAIT = 0;
 
     public GameStateManager(PlatVenture game){
         this.platVenture = game;
         gameStates = new Stack<GameState>();
-        pushState(PLAY);
+        pushState(WAIT);
     }
 
     public PlatVenture getPlatVenture(){
@@ -36,6 +38,9 @@ public class GameStateManager {
          if (state == PLAY){
              return new Play(this);
          }
+         if (state == WAIT){
+             return new WaitingScreen(this);
+         }
          return null;
     }
 
-- 
GitLab