From 27634a76a2d4d687452693845fb1e4539f7da8e3 Mon Sep 17 00:00:00 2001
From: timeo <timeo.jacquier@gmail.com>
Date: Sun, 12 Dec 2021 21:29:31 +0100
Subject: [PATCH] blocage de cam en x et y + exit le jeu avec esc

---
 core/src/etat/Play.java                    | 20 ++++++++++++--------
 core/src/handlers/InputPerso.java          |  7 ++++++-
 core/src/handlers/InputProcessorPerso.java |  4 ++++
 3 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/core/src/etat/Play.java b/core/src/etat/Play.java
index 771daaa..8f4378c 100644
--- a/core/src/etat/Play.java
+++ b/core/src/etat/Play.java
@@ -89,9 +89,10 @@ public class Play extends GameState {
             }
         }
 
+        if (InputPerso.isDown(3)){
+            Gdx.app.exit();
+        }
 
-        /*TODO echap pour quitter */
-        /*TODO saut écouteur tactile*/
     }
 
     @Override
@@ -131,20 +132,23 @@ public class Play extends GameState {
         if (isInside()) {
             cl.setTriggerEndLevel(false);
             // Bouger la caméra en x
-            /* TODO bloquer la caméra à droite */
-            if (player.getPosition().x * PPM > (float) (PlatVenture.largeur / 2) && player.getPosition().y * PPM <= (float) (PlatVenture.hauteur / 2)
+            if (player.getPosition().x * PPM > (float) (PlatVenture.largeur / 2)
+                    && player.getPosition().x < ((largeur / 10f)) - PlatVenture.largeur / (2f * PPM)
+                    && player.getPosition().y * PPM <= (float) (PlatVenture.hauteur / 2)
                     && largeur > 16) {
                 b2dCam.position.set(player.getPosition().x, PlatVenture.hauteur / PPM / 2, 0);
             }
 
             // Bouger la caméra en x et y
-            if (player.getPosition().x * PPM > (float) (PlatVenture.largeur / 2) && player.getPosition().y * PPM > (float) (PlatVenture.hauteur / 2)
-                    && largeur > 16 && hauteur > 12) {
+            if (player.getPosition().x * PPM > (float) (PlatVenture.largeur / 2)
+                    && player.getPosition().x < ((largeur / 10f)) - PlatVenture.largeur / (2f * PPM)
+                    && player.getPosition().y * PPM > (float) (PlatVenture.hauteur / 2)
+                    && player.getPosition().y * PPM < (float) (3* PlatVenture.hauteur / 4) && hauteur > 12 && largeur > 16) {
                 b2dCam.position.set(player.getPosition().x, player.getPosition().y, 0);
             }
             //bouger la caméra en y
             if (player.getPosition().x * PPM < (float) (PlatVenture.largeur / 2) && player.getPosition().y * PPM > (float) (PlatVenture.hauteur / 2)
-                    && hauteur > 12) {
+                    && player.getPosition().y * PPM < (float) (3* PlatVenture.hauteur / 4) && hauteur > 12) {
 
                 b2dCam.position.set(PlatVenture.largeur / PPM / 2, player.getPosition().y, 0);
             }
@@ -168,7 +172,7 @@ public class Play extends GameState {
         batch.draw(res.getTexture("idle_001"),  player.getPosition().x - 5f/PPM, player.getPosition().y - 2f/PPM, 1/10f, 1/10f);
         batch.end();
         //dessine le monde box2d
-        b2dr.render(world, b2dCam.combined);
+       // b2dr.render(world, b2dCam.combined);
     }
 
     @Override
diff --git a/core/src/handlers/InputPerso.java b/core/src/handlers/InputPerso.java
index 44d1ca7..924e110 100644
--- a/core/src/handlers/InputPerso.java
+++ b/core/src/handlers/InputPerso.java
@@ -9,7 +9,7 @@ public class InputPerso {
     public static int x;
     public static int y;
 
-    public static final int NUM_KEYS = 3;
+    public static final int NUM_KEYS = 4;
 
     /**
      * Saut
@@ -24,6 +24,11 @@ public class InputPerso {
      */
     public static final int BUTTON3 = 2;
 
+    /**
+     * Exit
+     */
+    public static final int BUTTON4 = 3;
+
     static{
         keys = new boolean[NUM_KEYS];
         pkeys = new boolean[NUM_KEYS];
diff --git a/core/src/handlers/InputProcessorPerso.java b/core/src/handlers/InputProcessorPerso.java
index ec6de7e..bf4efee 100644
--- a/core/src/handlers/InputProcessorPerso.java
+++ b/core/src/handlers/InputProcessorPerso.java
@@ -67,6 +67,10 @@ public class InputProcessorPerso extends InputAdapter {
         if (k == Input.Keys.RIGHT){
             InputPerso.setKey(InputPerso.BUTTON3, true);
         }
+
+        if (k == Input.Keys.ESCAPE){
+            InputPerso.setKey(InputPerso.BUTTON4, true);
+        }
         return true;
     }
 
-- 
GitLab