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

joyau générable

parent 7756e750
No related branches found
No related tags found
No related merge requests found
package com.platventure.game.generateStruct;
import com.badlogic.gdx.math.Circle;
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.CircleShape;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.World;
public class Joyau {
CircleShape shapeStruct;
public Joyau(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 CircleShape();
shapeStruct.setRadius((float)(0.15*tailleUnite));
shapeStruct.setPosition(new Vector2((float) (x*tailleUnite + 0.5*tailleUnite), (float) ((y-1)*tailleUnite + 0.5*tailleUnite)));
fixtureDefStruct.shape = shapeStruct;
fixtureDefStruct.isSensor = true; //traversable
structBody.createFixture(fixtureDefStruct);
shapeStruct.dispose();
}
}
...@@ -25,7 +25,7 @@ public class Water { ...@@ -25,7 +25,7 @@ public class Water {
FixtureDef fixtureDefStruct = new FixtureDef(); FixtureDef fixtureDefStruct = new FixtureDef();
shapeStruct = new PolygonShape(); shapeStruct = new PolygonShape();
ptsStruct = new Vector2[]{new Vector2(newX, newY), new Vector2(newX+tailleUnite, newY), new Vector2(newX+tailleUnite, newY+tailleUnite), new Vector2(newX, newY+tailleUnite)}; ptsStruct = new Vector2[]{new Vector2(newX, (float) (newY + 0.2*tailleUnite)), new Vector2(newX+tailleUnite, (float) (newY + 0.2*tailleUnite)), new Vector2(newX+tailleUnite, (newY+tailleUnite)), new Vector2(newX,(newY+tailleUnite))};
shapeStruct.set(ptsStruct); shapeStruct.set(ptsStruct);
......
...@@ -9,6 +9,7 @@ import com.badlogic.gdx.physics.box2d.Box2DDebugRenderer; ...@@ -9,6 +9,7 @@ import com.badlogic.gdx.physics.box2d.Box2DDebugRenderer;
import com.badlogic.gdx.physics.box2d.FixtureDef; import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.PolygonShape; import com.badlogic.gdx.physics.box2d.PolygonShape;
import com.badlogic.gdx.physics.box2d.World; import com.badlogic.gdx.physics.box2d.World;
import com.platventure.game.generateStruct.Joyau;
import com.platventure.game.generateStruct.Platform; import com.platventure.game.generateStruct.Platform;
import com.platventure.game.generateStruct.Water; import com.platventure.game.generateStruct.Water;
...@@ -149,6 +150,11 @@ public class worldPerso { ...@@ -149,6 +150,11 @@ public class worldPerso {
break; break;
case 'W': case 'W':
new Water(j, i, FabriqueUnite.getUnite(), world); new Water(j, i, FabriqueUnite.getUnite(), world);
break;
case '1':
case '2':
new Joyau(j, i, FabriqueUnite.getUnite(), world);
break;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment