|
|
|
|
@ -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;
|
|
|
|
|
@ -40,7 +42,9 @@ public class Gamescreen{
|
|
|
|
|
int pivotX;
|
|
|
|
|
int pivotY;
|
|
|
|
|
|
|
|
|
|
Rectangle[] goalRects;
|
|
|
|
|
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;
|
|
|
|
|
@ -73,7 +77,10 @@ public class Gamescreen{
|
|
|
|
|
goalRects[5] = new Rectangle(x + th*4 * w ,y + h - 1f ,w *th ,1 );
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
@ -85,7 +92,8 @@ public class Gamescreen{
|
|
|
|
|
pivotX = level.getPivotX();
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//shapeRenderer.rect(g.getxPos(), g.getyPos(), g.getSizeX(), g.getSizeY());
|
|
|
|
|
// 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.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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|