From 242f2f1f430a8225072f62f02c05a747400cfbaa Mon Sep 17 00:00:00 2001
From: timeo <timeo.jacquier@hotmail.com>
Date: Wed, 8 Dec 2021 21:51:14 +0100
Subject: [PATCH] =?UTF-8?q?scroll=20cam=C3=A9ra=20ok?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 core/src/etat/Play.java | 27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/core/src/etat/Play.java b/core/src/etat/Play.java
index 00331f5..aff4f01 100644
--- a/core/src/etat/Play.java
+++ b/core/src/etat/Play.java
@@ -48,7 +48,7 @@ public class Play extends GameState {
         b2dr = new Box2DDebugRenderer();
 
 
-        createWorld("assets/level_001.txt");
+        createWorld("assets/level_002.txt");
         createPlayer();
 
         //Init b2dCam
@@ -59,20 +59,19 @@ public class Play extends GameState {
     public void handleInput() {
         if (InputPerso.isPressed(0)){
             if (cl.isPlayerOnGround()) {
-                System.out.println("aled 2");
                 player.applyForceToCenter(0, 2 / PPM, true);
             }
         }
 
         if (InputPerso.isDown(2)){
             if (cl.isPlayerOnGround()) {
-                player.setLinearVelocity(0.75f, player.getLinearVelocity().y);
+                player.setLinearVelocity(0.5f, player.getLinearVelocity().y);
             }
         }
 
         if (InputPerso.isDown(1)){
             if (cl.isPlayerOnGround()) {
-                player.setLinearVelocity(-1*0.75f, player.getLinearVelocity().y);
+                player.setLinearVelocity(-1*0.5f, player.getLinearVelocity().y);
             }
         }
     }
@@ -89,7 +88,25 @@ public class Play extends GameState {
             System.out.println("score = " + score);
         }
         joyauToRemove.clear();
-        //b2dCam.position.set(player.getPosition(), 0);
+
+        // Bouger la caméra en x
+        if (player.getPosition().x * PPM > (float) (PlatVenture.largeur / 2) && 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){
+                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) {
+
+            b2dCam.position.set(PlatVenture.largeur / PPM / 2, player.getPosition().y, 0);
+        }
+
         b2dCam.update();
 
         /*TODO remettre à 1 quand j'aurai bien compris, on a pas besoin d'autant de précisions
-- 
GitLab