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

carré généré à l'envers

parent 27e2ac2f
No related branches found
No related tags found
No related merge requests found
package body;
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, World world){
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyDef.BodyType.StaticBody;
bodyDef.position.set(x, y);
Body structBody = world.createBody(bodyDef);
FixtureDef fixtureDefStruct = new FixtureDef();
shapeStruct = new CircleShape();
fixtureDefStruct.shape = shapeStruct;
fixtureDefStruct.isSensor = true; //traversable
structBody.createFixture(fixtureDefStruct);
shapeStruct.dispose();
}
}
\ No newline at end of file
package body;
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, World world) {
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyDef.BodyType.StaticBody;
bodyDef.position.set(x, y);
Body structBody = world.createBody(bodyDef);
FixtureDef fixtureDefStruct = new FixtureDef();
shapeStruct = new PolygonShape();
ptsStruct = new Vector2[]{};
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();
}
}
\ No newline at end of file
package body;
import static handlers.B2DVars.PPM;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef;
......@@ -10,7 +12,7 @@ import com.badlogic.gdx.physics.box2d.World;
public class Platform {
PolygonShape shapeStruct;
Vector2[] ptsStruct;
public Platform(int x, int y, String type, World world){
public Platform(float x, float y, String type, World world){
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyDef.BodyType.StaticBody;
bodyDef.position.set(x, y);
......@@ -28,7 +30,7 @@ public class Platform {
}
if (type.equals("carre")){
ptsStruct = new Vector2[]{};
ptsStruct = new Vector2[]{new Vector2(0, 0), new Vector2(10/PPM, 0), new Vector2(10/PPM, 10/PPM), new Vector2(0, 10/PPM)};
shapeStruct.set(ptsStruct);
}
......
......@@ -38,11 +38,12 @@ public class Play extends GameState {
b2dr = new Box2DDebugRenderer();
BodyDef bdef = new BodyDef();
bdef.position.set(55/PPM, 6/PPM);
bdef.position.set(0/PPM, 0/PPM);
bdef.type = BodyDef.BodyType.StaticBody;
Body body = world.createBody(bdef);
Vector2[] pts = new Vector2[]{new Vector2(20/PPM, 65/PPM), new Vector2(30/PPM, 65/PPM), new Vector2(30/PPM, 55/PPM), new Vector2(20/PPM, 55/PPM)};
Vector2[] pts = new Vector2[]{new Vector2(0/PPM, 0/PPM), new Vector2(10/PPM, 0/PPM),
new Vector2(10/PPM, 10/PPM), new Vector2(0/PPM, 10/PPM)};
PolygonShape shape = new PolygonShape();
shape.set(pts);
......@@ -50,6 +51,8 @@ public class Play extends GameState {
fdef.shape = shape;
body.createFixture(fdef).setUserData("platform");
//new Platform(10/PPM, 10/PPM, "carre", world);
bdef.position.set(80/PPM, 100/PPM);
bdef.type = BodyDef.BodyType.DynamicBody;
......@@ -105,12 +108,12 @@ public class Play extends GameState {
hauteur = Integer.parseInt(premiereLigne[1]);
temps = Integer.parseInt(premiereLigne[2]);
for (int i = 1; i < hauteur+1; i++){
for (int i = 1; i < (hauteur+1); i++){
for (int j = 0; j < largeur; j++){
char current = ligne[i].charAt(j);
System.out.print(current);
/*switch (current){
case 'J':
switch (current){
/*case 'J':
new Platform(j, i, "bord_gauche", world);
break;
case 'K':
......@@ -118,7 +121,7 @@ public class Play extends GameState {
break;
case 'L':
new Platform(j, i, "bord_droit", world);
break;
break;*/
case 'A':
case 'B':
case 'C':
......@@ -128,9 +131,9 @@ public class Play extends GameState {
case 'G':
case 'H':
case 'I':
new Platform(j, i, "carre", world);
new Platform((j*10)/PPM, ((i-1)*10)/PPM, "carre", world);
break;
case 'W':
/*case 'W':
new Water(j, i, world);
break;
case 'Z':
......@@ -139,9 +142,9 @@ public class Play extends GameState {
case '1':
case '2':
//new Joyau(j, i, FabriqueUnite.getUnite(), world);
break;
break;*/
}*/
}
}
System.out.println();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment