Jonathan Hager 6 years ago
parent a824ed5930
commit 5ebc77d7c0

@ -1 +1 @@
{goal:{xPos:764,yPos:492,sizeX:300,sizeY:200,thickness:0.2},projectile:{xPos:401,yPos:501,mass:5,radius:10},math:{},xPosPivot:401,yPosPivot:351,isTraceInitialised:[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],traces:[{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10}],objects:[{x:356,y:468,width:200,height:100}]} {goal:{xPos:1530,yPos:853,sizeX:300,sizeY:200,thickness:0.2},projectile:{xPos:740,yPos:600,mass:5,radius:10},math:{},xPosPivot:740,yPosPivot:450,isTraceInitialised:[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],traces:[{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10}],objects:[{x:633,y:620,width:200,height:100},{x:792,y:590,width:200,height:100},{x:908,y:520,width:200,height:100},{x:953,y:447,width:200,height:100},{x:902,y:368,width:200,height:100},{x:879,y:306,width:200,height:100},{x:806,y:218,width:200,height:100},{x:688,y:154,width:200,height:100},{x:532,y:200,width:200,height:100},{x:386,y:265,width:200,height:100},{x:358,y:355,width:200,height:100},{x:348,y:443,width:200,height:100},{x:410,y:538,width:200,height:100},{x:510,y:591,width:200,height:100}]}

@ -53,7 +53,6 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
int levelAmount; int levelAmount;
SpriteBatch batch; SpriteBatch batch;
Timer stepTimer; Timer stepTimer;
boolean isColliding;
ArrayList<ArrayList<Level>> level; ArrayList<ArrayList<Level>> level;
ArrayList<Level> ownLevels; ArrayList<Level> ownLevels;
int currentLevel; int currentLevel;
@ -92,18 +91,17 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
viewport.apply(); viewport.apply();
camera.position.set(GAME_WORLD_WIDTH/2, GAME_WORLD_HEIGHT/2, 0); camera.position.set(GAME_WORLD_WIDTH/2, GAME_WORLD_HEIGHT/2, 0);
isColliding = false;
level = new ArrayList<>(); level = new ArrayList<>();
for(int i = 0; i < 5; i++){ for(int i = 0; i < 6; i++){
level.add(new ArrayList<Level>()); level.add(new ArrayList<Level>());
} }
ownLevels = new ArrayList<>(); ownLevels = new ArrayList<>();
currentLevel = 0; currentLevel = 0;
currentChapter = 1; currentChapter = 0;
Json json = new Json(); Json json = new Json();
/*
Level lol = new Level(new Goal(1000,580,350,100, 0.2f), new Projectile(0,0,0),200,200); Level lol = new Level(new Goal(1000,580,350,100, 0.2f), new Projectile(0,0,0),200,200);
FileHandle fileblub = Gdx.files.local("levellol.json"); FileHandle fileblub = Gdx.files.local("levellol.json");
fileblub.writeString(json.toJson(lol), false); fileblub.writeString(json.toJson(lol), false);
@ -124,9 +122,10 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
FileHandle directory; FileHandle directory;
FileHandle[] files; FileHandle[] files;
for(int chapter = 0; chapter < level.size(); chapter++) { for(int chapter = 0; chapter < level.size() - 1; chapter++) {
directory = Gdx.files.internal("levels/chapter" + (chapter + 1)); directory = Gdx.files.internal("levels/chapter" + (chapter + 1));
System.out.println("levels/chapter" + (chapter + 1));
files = directory.list(); files = directory.list();
for(FileHandle file : files){ for(FileHandle file : files){
@ -171,12 +170,14 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
if(Intersector.overlaps(gs.getProjectileCirc(), rect)) { if(Intersector.overlaps(gs.getProjectileCirc(), rect)) {
collision = true; collision = true;
level.get(currentChapter).get(currentLevel).getProjectile().setxPos(tempX);
level.get(currentChapter).get(currentLevel).getProjectile().setyPos(tempY);
if (rect.getHeight() == 1) { if (rect.getHeight() == 1) {
level.get(currentChapter).get(currentLevel).horizontalCollision(); level.get(currentChapter).get(currentLevel).horizontalCollision();
} else if (rect.getWidth() == 1) { } else if (rect.getWidth() == 1) {
level.get(currentChapter).get(currentLevel).verticalCollision(); level.get(currentChapter).get(currentLevel).verticalCollision();
} }
break; //break;
} }
} }
if(gs.getObjectRects() != null) { if(gs.getObjectRects() != null) {
@ -184,22 +185,19 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
if (Intersector.overlaps(gs.getProjectileCirc(), rect)) { if (Intersector.overlaps(gs.getProjectileCirc(), rect)) {
collision = true; collision = true;
level.get(currentChapter).get(currentLevel).getProjectile().setxPos(tempX);
level.get(currentChapter).get(currentLevel).getProjectile().setyPos(tempY);
if (rect.getHeight() == 1) { if (rect.getHeight() == 1) {
level.get(currentChapter).get(currentLevel).horizontalCollision(); level.get(currentChapter).get(currentLevel).horizontalCollision();
} else if (rect.getWidth() == 1) { } else if (rect.getWidth() == 1) {
level.get(currentChapter).get(currentLevel).verticalCollision(); level.get(currentChapter).get(currentLevel).verticalCollision();
} }
break; //break;
} }
} }
} }
if(collision){
level.get(currentChapter).get(currentLevel).getProjectile().setxPos(tempX);
level.get(currentChapter).get(currentLevel).getProjectile().setyPos(tempY);
}
} }
} }
} }
@ -343,7 +341,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
} }
else if (cs.touchDown(x,y) >= 0 && cs.touchDown(x,y) <= 5){ else if (cs.touchDown(x,y) >= 0 && cs.touchDown(x,y) <= 5){
currentChapter = cs.touchDown(x,y); currentChapter = cs.touchDown(x,y) -1 ;
cs = null; cs = null;
ls = new Levelscreen(level.get(currentChapter).size()-1, GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera.combined); ls = new Levelscreen(level.get(currentChapter).size()-1, GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera.combined);
} }

@ -0,0 +1 @@
{goal:{xPos:1000,yPos:580,sizeX:350,sizeY:100,thickness:0.2},projectile:{xPos:350,yPos:200,mass:5,radius:10},math:{},xPosPivot:200,yPosPivot:200,isTraceInitialised:[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],traces:[{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10}],objects:[]}

@ -1 +1 @@
{goal:{xPos:1126,yPos:430,sizeX:300,sizeY:200,thickness:0.2},projectile:{xPos:528,yPos:629,mass:5,radius:10},math:{},xPosPivot:528,yPosPivot:479,isTraceInitialised:[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],traces:[{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10}],objects:[{x:464,y:556,width:200,height:100}]} {goal:{xPos:1530,yPos:853,sizeX:300,sizeY:200,thickness:0.2},projectile:{xPos:740,yPos:600,mass:5,radius:10},math:{},xPosPivot:740,yPosPivot:450,isTraceInitialised:[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],traces:[{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10},{x:-10,y:-10}],objects:[{x:633,y:620,width:200,height:100},{x:792,y:590,width:200,height:100},{x:908,y:520,width:200,height:100},{x:953,y:447,width:200,height:100},{x:902,y:368,width:200,height:100},{x:879,y:306,width:200,height:100},{x:806,y:218,width:200,height:100},{x:688,y:154,width:200,height:100},{x:532,y:200,width:200,height:100},{x:386,y:265,width:200,height:100},{x:358,y:355,width:200,height:100},{x:348,y:443,width:200,height:100},{x:410,y:538,width:200,height:100},{x:510,y:591,width:200,height:100}]}
Loading…
Cancel
Save