GAme is finished jajajaajajaj

master
Jonathan Hager 5 years ago
parent 3324560023
commit d731feb06a

@ -61,8 +61,8 @@ public class Model {
} }
// Generation of new projectiles // Generation of new projectiles
int value = (int) (Math.random() * 5) + difficulty; int value = (int) (Math.random() * 15);
if(value > 0){ if(value < (difficulty * 3)){
projectiles.add(spawnProjectile()); projectiles.add(spawnProjectile());
} }
} }
@ -96,6 +96,10 @@ public class Model {
break; break;
} }
} }
if(Intersector.overlapConvexPolygons(tempPolygon, monster.getMonsterPolygon())){
possible = false;
}
/* /*
for(Projectile projectile : projectiles){ for(Projectile projectile : projectiles){
if(Intersector.overlapConvexPolygons(tempPolygon,projectile.getPolygon())){ if(Intersector.overlapConvexPolygons(tempPolygon,projectile.getPolygon())){

@ -99,16 +99,7 @@ public class Monster {
this.yPos += this.movementY; this.yPos += this.movementY;
// Collisions // Collisions
float[] verticesMonster = new float[8]; Polygon monsterPolygon = getMonsterPolygon();
verticesMonster[0] = xPos;
verticesMonster[1] = yPos;
verticesMonster[2] = xPos + WIDTH;
verticesMonster[3] = yPos;
verticesMonster[4] = xPos + WIDTH;
verticesMonster[5] = yPos + HEIGHT;
verticesMonster[6] = xPos;
verticesMonster[7] = yPos + HEIGHT;
Polygon monsterPolygon = new Polygon(verticesMonster);
hp--; hp--;
@ -122,6 +113,16 @@ public class Monster {
if(hp <= 0){ if(hp <= 0){
die(); die();
} }
for(int i = walls.size() - 1; i >= 0; i--){
Polygon wall = walls.get(i).getPolygon();
if(Intersector.overlapConvexPolygons(monsterPolygon, wall)){
setxPos(getxPos() - (int) movementX);
setyPos(getyPos() - (int) movementY);
generateNewTarget();
}
}
} }
private void hit(){ private void hit(){
@ -131,6 +132,19 @@ public class Monster {
} }
} }
public Polygon getMonsterPolygon(){
float[] verticesMonster = new float[8];
verticesMonster[0] = xPos;
verticesMonster[1] = yPos;
verticesMonster[2] = xPos + WIDTH;
verticesMonster[3] = yPos;
verticesMonster[4] = xPos + WIDTH;
verticesMonster[5] = yPos + HEIGHT;
verticesMonster[6] = xPos;
verticesMonster[7] = yPos + HEIGHT;
return new Polygon(verticesMonster);
}
private void checkTarget(){ private void checkTarget(){
if(this.xPos == this.xPosTarget && this.yPos == this.yPosTarget){ if(this.xPos == this.xPosTarget && this.yPos == this.yPosTarget){
this.generateNewTarget(); this.generateNewTarget();

Loading…
Cancel
Save