GammelJan 6 years ago
parent 803131d896
commit 14cb073dd1

@ -5,6 +5,7 @@
*/ */
package model; package model;
import com.badlogic.gdx.math.Polygon;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import com.throwgame.main.ThrowMath; import com.throwgame.main.ThrowMath;
@ -30,6 +31,7 @@ public class Level {
private int traceIndex; private int traceIndex;
public boolean[] isTraceInitialised; public boolean[] isTraceInitialised;
public Vector2[] traces; public Vector2[] traces;
Polygon[] polygons;
public Level(Goal goal, Projectile projectile, int xPosPivot, int yPosPivot){ public Level(Goal goal, Projectile projectile, int xPosPivot, int yPosPivot){
this.goal = goal; this.goal = goal;
@ -43,6 +45,9 @@ public class Level {
this.yPosPivot = yPosPivot; this.yPosPivot = yPosPivot;
this.angle = 0; this.angle = 0;
this.angleSpeed = 0; this.angleSpeed = 0;
polygons = new Polygon[1];
polygons[0] = new Polygon(new float[]{500,500,502,500,602,600,600,600});
traceIndex = 0; traceIndex = 0;
isTraceInitialised = new boolean[50]; isTraceInitialised = new boolean[50];
@ -144,4 +149,7 @@ public class Level {
public boolean released(){ public boolean released(){
return isReleased; return isReleased;
} }
public Polygon[] getPolygons(){
return polygons;
}
} }

@ -14,7 +14,9 @@ import com.badlogic.gdx.math.Circle;
import com.badlogic.gdx.math.Intersector; import com.badlogic.gdx.math.Intersector;
import com.badlogic.gdx.math.Matrix4; import com.badlogic.gdx.math.Matrix4;
import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Polygon;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import java.awt.Point;
import model.Goal; import model.Goal;
import model.Level; import model.Level;
@ -48,6 +50,7 @@ public class Gamescreen{
// 0: Left, 1: LeftTop, 2: CenterLeft, 3: CenterBottom, 4: CenterRight, 5: RightTop, 6: Right, 7: Bottom // 0: Left, 1: LeftTop, 2: CenterLeft, 3: CenterBottom, 4: CenterRight, 5: RightTop, 6: Right, 7: Bottom
float GAME_WORLD_WIDTH; float GAME_WORLD_WIDTH;
float GAME_WORLD_HEIGHT; float GAME_WORLD_HEIGHT;
Polygon[] objects;
boolean win; boolean win;
@ -57,6 +60,7 @@ public class Gamescreen{
pivotX = level.getPivotX(); pivotX = level.getPivotX();
pivotY = level.getPivotY(); pivotY = level.getPivotY();
g = level.getGoal(); g = level.getGoal();
objects = level.getPolygons();
x = g.getxPos(); x = g.getxPos();
y = g.getyPos(); y = g.getyPos();
w = g.getSizeX(); w = g.getSizeX();
@ -77,7 +81,7 @@ public class Gamescreen{
goalRects[5] = new Rectangle(x + th*4 * w ,y + h - 1f ,w *th ,1 ); 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[6] = new Rectangle(x + w-1 ,y ,1 ,h );
goalRects[7] = new Rectangle(x ,y ,w ,1 ); goalRects[7] = new Rectangle(x ,y ,w ,1 );
goalRect = new Rectangle(x + w*th, y + h*th, w * th * 3, h * 0.1f); 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()); projectileCirc = new Circle((float)level.getProjectile().getxPos(), (float)level.getProjectile().getyPos(), level.getProjectile().getRadius());
@ -109,6 +113,8 @@ public class Gamescreen{
shapeRenderer.rectLine((float) level.getPivotX(), (float) level.getPivotY(), (float) level.getProjectile().getxPos(), (float) level.getProjectile().getyPos(), 3); shapeRenderer.rectLine((float) level.getPivotX(), (float) level.getPivotY(), (float) level.getProjectile().getxPos(), (float) level.getProjectile().getyPos(), 3);
} }
shapeRenderer.setColor(Color.BLACK); shapeRenderer.setColor(Color.BLACK);
shapeRenderer.rect(x, y,th * w, h); shapeRenderer.rect(x, y,th * w, h);
shapeRenderer.rect(x + th * w,y, th*3 * w,th * h); shapeRenderer.rect(x + th * w,y, th*3 * w,th * h);
@ -132,6 +138,16 @@ public class Gamescreen{
shapeRenderer.setColor(Color.GRAY); shapeRenderer.setColor(Color.GRAY);
shapeRenderer.circle(pivotX, pivotY, 5); shapeRenderer.circle(pivotX, pivotY, 5);
shapeRenderer.end();
shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
shapeRenderer.setColor(Color.BLACK);
for(Polygon object : objects){
shapeRenderer.polygon(objects[0].getVertices());
}
shapeRenderer.end(); shapeRenderer.end();

Loading…
Cancel
Save