master
Jan Ehehalt 6 years ago
parent 0939c3bb7c
commit 9745412044

@ -78,12 +78,16 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
public void run() {
if(gs != null){
if(level.getProjectile().getxPos() > Gdx.graphics.getWidth() || level.getProjectile().getxPos() < 0 || level.getProjectile().getyPos() < 0){
gs.step(level);
level.reset();
gs.dispose();
stepTimer.stop();
gs = null;
ws = new Winscreen(GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, false);
}
else{
gs.step(level);
level.step();
}
}
@ -111,6 +115,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
gs.render(batch, level);
if(gs.getWin()){
gs.dispose();
stepTimer.stop();
gs = null;
ws = new Winscreen(GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, true);
}
@ -159,6 +164,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
else{
ls.dispose();
ls = null;
level = new Level(new Goal(500,200,150,50, 0.2f), new Projectile(0,0,0),200,200);
gs = new Gamescreen(level, GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera.combined);
stepTimer.start();
}
@ -173,10 +179,14 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
ls = new Levelscreen(levelAmount, GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT);
}
else if(x < Gdx.graphics.getWidth() * 0.66){
level = new Level(new Goal(500,200,150,50, 0.2f), new Projectile(0,0,0),200,200);
gs = new Gamescreen(level, GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera.combined);
stepTimer.start();
}
else{
level = new Level(new Goal(500,200,150,50, 0.2f), new Projectile(0,0,0),200,200);
gs = new Gamescreen(level, GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera.combined);
stepTimer.start();
}
ws = null;
}

@ -10,6 +10,8 @@ import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Circle;
import com.badlogic.gdx.math.Intersector;
import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
@ -41,6 +43,8 @@ public class Gamescreen{
int pivotY;
Rectangle[] goalRects;
Rectangle goalRect;
Circle projectileCirc;
// 0: Left, 1: LeftTop, 2: CenterLeft, 3: CenterBottom, 4: CenterRight, 5: RightTop, 6: Right, 7: Bottom
float GAME_WORLD_WIDTH;
float GAME_WORLD_HEIGHT;
@ -74,6 +78,9 @@ public class Gamescreen{
goalRects[6] = new Rectangle(x + w-1 ,y ,1 ,h );
goalRects[7] = new Rectangle(x ,y ,w ,1 );
goalRect = new Rectangle(x + w*th, y + h*th, w * th * 3, h * 0.1f);
projectileCirc = new Circle((float)level.getProjectile().getxPos(), (float)level.getProjectile().getyPos(), level.getProjectile().getRadius());
shapeRenderer = new ShapeRenderer();
shapeRenderer.setProjectionMatrix(matrix);
@ -86,6 +93,7 @@ public class Gamescreen{
pivotY = level.getPivotY();
g = level.getGoal();
shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
shapeRenderer.setColor(Color.BLACK);
@ -107,26 +115,41 @@ public class Gamescreen{
shapeRenderer.rect(x + th *w + th*3 * w, y, th * w,h);
shapeRenderer.circle((float) p.getxPos(), (float) p.getyPos(), p.getRadius());
shapeRenderer.setColor(Color.RED);
/*
//goal hitboxes
for(int i = 0; i < goalRects.length; i++){
shapeRenderer.rect(goalRects[i].getX(), goalRects[i].getY(), goalRects[i].getWidth(), goalRects[i].getHeight());
}
// projectile hitbox
shapeRenderer.circle(projectileCirc.x, projectileCirc.y, projectileCirc.radius);*/
// goal hitbox
shapeRenderer.setColor(Color.GREEN);
shapeRenderer.rect(goalRect.getX(), goalRect.getY(), goalRect.getWidth(), goalRect.getHeight());/*
// full goal size hitbox;
shapeRenderer.rect(g.getxPos(), g.getyPos(), g.getSizeX(), g.getSizeY());
*/
//shapeRenderer.rect(g.getxPos(), g.getyPos(), g.getSizeX(), g.getSizeY());
shapeRenderer.setColor(Color.GRAY);
shapeRenderer.circle(pivotX, pivotY, 5);
shapeRenderer.end();
if(p.getxPos() > x + w*th && p.getxPos() < x+w*4*th && p.getyPos() > y + h * th && p.getyPos() < y + h ){
win = true;
}
}
public void dispose() {
}
public void step(Level level){
projectileCirc = new Circle((float)level.getProjectile().getxPos(), (float)level.getProjectile().getyPos(), level.getProjectile().getRadius());
if(Intersector.overlaps(projectileCirc, goalRect)) win = true;
}
public boolean getWin(){
return win;
}
}

Loading…
Cancel
Save