diff --git a/core/src/com/platventure/game/generateStruct/Panneau.java b/core/src/com/platventure/game/generateStruct/Panneau.java new file mode 100644 index 0000000000000000000000000000000000000000..46cb54d76bc388a6f622a0c9e4e6bcd216d371b9 --- /dev/null +++ b/core/src/com/platventure/game/generateStruct/Panneau.java @@ -0,0 +1,40 @@ +package com.platventure.game.generateStruct; + +import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.physics.box2d.Body; +import com.badlogic.gdx.physics.box2d.BodyDef; +import com.badlogic.gdx.physics.box2d.FixtureDef; +import com.badlogic.gdx.physics.box2d.PolygonShape; +import com.badlogic.gdx.physics.box2d.World; + +public class Panneau { + + PolygonShape shapeStruct; + Vector2[] ptsStruct; + public Panneau(int x, int y, float tailleUnite, World world) { + BodyDef bodyDef = new BodyDef(); + bodyDef.type = BodyDef.BodyType.StaticBody; + bodyDef.position.set(0f, 0f); + + Body structBody = world.createBody(bodyDef); + + FixtureDef fixtureDefStruct = new FixtureDef(); + shapeStruct = new PolygonShape(); + + float newX = x * tailleUnite; + float newY = (y-1) * tailleUnite; + + ptsStruct = new Vector2[]{new Vector2(newX, newY), new Vector2(newX+tailleUnite, newY), new Vector2(newX+tailleUnite, newY+tailleUnite), new Vector2(newX, newY+tailleUnite)}; + shapeStruct.set(ptsStruct); + + fixtureDefStruct.shape = shapeStruct; + fixtureDefStruct.restitution = 0.6f; + fixtureDefStruct.density = 1f; + fixtureDefStruct.friction = 0.25f; + fixtureDefStruct.isSensor = true; + + + structBody.createFixture(fixtureDefStruct); + shapeStruct.dispose(); + } +} diff --git a/core/src/com/platventure/game/worldPerso.java b/core/src/com/platventure/game/worldPerso.java index 3c99703ee1b1e88da6b97a72ac7c56598cf12ccd..43c62570f9b4575c5d259c91dff99369dcb417a3 100644 --- a/core/src/com/platventure/game/worldPerso.java +++ b/core/src/com/platventure/game/worldPerso.java @@ -10,6 +10,7 @@ import com.badlogic.gdx.physics.box2d.FixtureDef; import com.badlogic.gdx.physics.box2d.PolygonShape; import com.badlogic.gdx.physics.box2d.World; import com.platventure.game.generateStruct.Joyau; +import com.platventure.game.generateStruct.Panneau; import com.platventure.game.generateStruct.Platform; import com.platventure.game.generateStruct.Water; @@ -129,13 +130,13 @@ public class worldPerso { System.out.print(current); switch (current){ case 'J': - new Platform(j, i-1, FabriqueUnite.getUnite(), "bord_gauche", world); + new Platform(j, i, FabriqueUnite.getUnite(), "bord_gauche", world); break; case 'K': - new Platform(j, i-1, FabriqueUnite.getUnite(), "rectangle", world); + new Platform(j, i, FabriqueUnite.getUnite(), "rectangle", world); break; case 'L': - new Platform(j, i-1, FabriqueUnite.getUnite(), "bord_droit", world); + new Platform(j, i, FabriqueUnite.getUnite(), "bord_droit", world); break; case 'A': case 'B': @@ -151,6 +152,9 @@ public class worldPerso { case 'W': new Water(j, i, FabriqueUnite.getUnite(), world); break; + case 'Z': + new Panneau(j, i, FabriqueUnite.getUnite(), world); + break; case '1': case '2': new Joyau(j, i, FabriqueUnite.getUnite(), world);