Skip to content
Snippets Groups Projects
Commit 242f2f1f authored by timeo's avatar timeo
Browse files

scroll caméra ok

parent c65b006d
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment