rich5tig lol

master
Jonathan Hager 6 years ago
parent 530f258a54
commit c810a30d8d

@ -8,6 +8,7 @@ package controller;
import com.badlogic.gdx.ApplicationAdapter; import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputProcessor; import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
@ -23,7 +24,9 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.util.ArrayList; import java.util.ArrayList;
import model.Goal;
import model.Level; import model.Level;
import model.Projectile;
import view.Gamescreen; import view.Gamescreen;
import view.Levelscreen; import view.Levelscreen;
import view.Titlescreen; import view.Titlescreen;
@ -80,8 +83,14 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
isColliding = false; isColliding = false;
level = new ArrayList<>(); level = new ArrayList<>();
currentLevel = 0; currentLevel = 0;
Json json = new Json();
/*
Level lol = new Level(new Goal(1000,200,450,100, 0.2f), new Projectile(0,0,0),200,200);
FileHandle file = Gdx.files.local("levels/level0.json");
file.writeString(json.toJson(lol), false);
*/
/* /*
level[0] = new Level(new Goal(500,200,450,100, 0.2f), new Projectile(0,0,0),200,200);
level[1] = new Level(new Goal(700,200,450,100, 0.2f), new Projectile(0,0,0),200,200); level[1] = new Level(new Goal(700,200,450,100, 0.2f), new Projectile(0,0,0),200,200);
level[2] = new Level(new Goal(560,400,450,100, 0.2f), new Projectile(0,0,0),200,200); level[2] = new Level(new Goal(560,400,450,100, 0.2f), new Projectile(0,0,0),200,200);
level[3] = new Level(new Goal(900,150,450,100, 0.2f), new Projectile(0,0,0),200,200); level[3] = new Level(new Goal(900,150,450,100, 0.2f), new Projectile(0,0,0),200,200);
@ -92,25 +101,20 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
level[8] = new Level(new Goal(760,460,450,100, 0.2f), new Projectile(0,0,0),200,200); level[8] = new Level(new Goal(760,460,450,100, 0.2f), new Projectile(0,0,0),200,200);
level[9] = new Level(new Goal(1000,580,350,100, 0.2f), new Projectile(0,0,0),200,200); level[9] = new Level(new Goal(1000,580,350,100, 0.2f), new Projectile(0,0,0),200,200);
level[9].addRectangle(400, 400, 50,200); level[9].addRectangle(400, 400, 50,200);
*/ */
Json json = new Json();
File levelJson; FileHandle levelJson;
for(int i = 0; i < 1000; i++){ for(int i = 0; i < 10; i++){
try{ //levelJson = Gdx.files.local("levels/level" + i + ".json");
levelJson = new File(filesDir, "level" + i + ".json"); levelJson = Gdx.files.local("levels/level0.json");
if(levelJson == null){ if(!levelJson.exists()){
break;
}
else{
Level tempLevel = json.fromJson(Level.class, new FileInputStream(levelJson));
level.add(tempLevel);
}
}
catch(FileNotFoundException e){
e.printStackTrace();
break; break;
} }
else{
Level tempLevel = json.fromJson(Level.class, levelJson.readString());
level.add(tempLevel);
}
} }
stepTimer = new Timer(); stepTimer = new Timer();
@ -191,7 +195,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
if(ts != null) ts.render(batch); if(ts != null) ts.render(batch);
else if(ls != null){ else if(ls != null){
currentLevel = ls.getSelectedLevel(); currentLevel = ls.getSelectedLevel();
ls.render(batch, level.get(currentLevel); ls.render(batch, level.get(currentLevel));
} }
else if(gs != null){ else if(gs != null){
gs.render(batch, level.get(currentLevel)); gs.render(batch, level.get(currentLevel));

@ -15,6 +15,9 @@ public class Goal {
this.sizeY = sizeY; this.sizeY = sizeY;
this.thickness = thickness; this.thickness = thickness;
} }
public Goal(){
}
public int getxPos() { public int getxPos() {
return xPos; return xPos;

@ -56,6 +56,8 @@ public class Level {
traces[i] = new Vector2(-10, -10); traces[i] = new Vector2(-10, -10);
} }
} }
public Level(){
}
public void projectileReleased(){ public void projectileReleased(){
this.isReleased = true; this.isReleased = true;

@ -25,6 +25,10 @@ public class Projectile {
} }
} }
public Projectile(){
type = 0;
}
public double getxPos() { public double getxPos() {
return xPos; return xPos;
} }

@ -0,0 +1 @@
{goal:{xPos:1000,yPos:200,sizeX:450,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:[]}
Loading…
Cancel
Save