master
Jan Ehehalt 6 years ago
parent 828420c9e6
commit 4ffd5aed9e

@ -19,6 +19,9 @@ import model.Level;
import model.Projectile;
import view.Gamescreen;
import view.Levelscreen;
import com.badlogic.gdx.math.Intersector;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.utils.Timer;
import com.badlogic.gdx.utils.viewport.ExtendViewport;
import com.badlogic.gdx.utils.viewport.FitViewport;
@ -85,12 +88,21 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
gs = null;
ws = new Winscreen(GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, false);
}
else{
gs.step(level);
level.step();
gs.step(level);
for(Rectangle rect : gs.getGoalRects()){
if(Intersector.overlaps(gs.getProjectileCirc(), rect)){
if(rect.getHeight() == 1){
level.horizontalCollision();
}
else if(rect.getWidth() == 1){
level.verticalCollision();
}
break;
}
}
for(
}
}
}

@ -63,11 +63,11 @@ public class Level {
}
public void horizontalCollision(){
this.projectile.setvY(-this.projectile.getvY);
this.projectile.setvY(-this.projectile.getvY());
}
public void verticalCollision(){
this.projectile.setvX(-this.projectile.getvX);
this.projectile.setvX(-this.projectile.getvX());
}
public void step(){

@ -151,5 +151,12 @@ public class Gamescreen{
return win;
}
public Rectangle[] getGoalRects(){
return goalRects;
}
public Circle getProjectileCirc(){
return projectileCirc;
}
}

Loading…
Cancel
Save