help line added, helps where the closest enemy is
This commit is contained in:
@@ -18,8 +18,6 @@ public class Enemy extends DrawObject {
|
||||
public Enemy(int pathID,int lengthOfEnemy,Color c,Path path){
|
||||
super();
|
||||
this.length = lengthOfEnemy;
|
||||
// System.out.println(this.length*this.length/2);
|
||||
// System.out.println(Math.sqrt(Math.pow(this.length,2)/2));
|
||||
lengthOf1Side = Math.sqrt(Math.pow(lengthOfEnemy,2)/2);
|
||||
this.c = c;
|
||||
this.index = pathID;
|
||||
@@ -65,7 +63,6 @@ public class Enemy extends DrawObject {
|
||||
endY += beginY;
|
||||
|
||||
enemy = new Line2D.Double(beginX, beginY, endX, endY);
|
||||
// System.out.println("Enemy added on path: "+pathID);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,8 +86,7 @@ public class Enemy extends DrawObject {
|
||||
angleX = Math.cos(Math.toRadians(45))*distanceFromStart;
|
||||
angleY = Math.sin(Math.toRadians(45))*distanceFromStart;
|
||||
|
||||
// System.out.println(Math.toRadians(45)*distanceFromStart);
|
||||
// System.out.println(angleX+" - "+angleY);
|
||||
|
||||
|
||||
switch(index){
|
||||
case 0:
|
||||
@@ -98,7 +94,6 @@ public class Enemy extends DrawObject {
|
||||
y2 = y1 - length;
|
||||
break;
|
||||
case 1:
|
||||
// x1 -= speedX;
|
||||
x1 = path.getX1() - angleX;
|
||||
x2 = x1 + lengthOf1Side;
|
||||
|
||||
|
||||
@@ -92,6 +92,7 @@ public class PlayState extends GameState {
|
||||
|
||||
oldProgress = progress;
|
||||
|
||||
Enemy closedEnemy = null;
|
||||
player.update(factor);
|
||||
for (Path path : area.paths) {
|
||||
|
||||
@@ -100,13 +101,18 @@ public class PlayState extends GameState {
|
||||
while (enemyIterator.hasNext()) {
|
||||
|
||||
Enemy e = enemyIterator.next();
|
||||
|
||||
// System.out.println("Path: "+e.getIndex()+"\tDistance: "+(Enemy.distanceToOctagon-e.getDistanceFromStart()));
|
||||
if (e.getDistanceFromStart() > Enemy.distanceToOctagon + (sizeOfEnemy * 1.5)) {
|
||||
enemyIterator.remove();
|
||||
lifePoints -= 5;
|
||||
comboScore /= 2;
|
||||
}
|
||||
|
||||
if(closedEnemy == null){
|
||||
closedEnemy = e;
|
||||
}
|
||||
if((Enemy.distanceToOctagon-closedEnemy.getDistanceFromStart()) > (Enemy.distanceToOctagon-e.getDistanceFromStart())){
|
||||
closedEnemy = e;
|
||||
}
|
||||
e.update(factor);
|
||||
}
|
||||
}
|
||||
@@ -123,6 +129,11 @@ public class PlayState extends GameState {
|
||||
|
||||
infoPanel.updateIPanel();
|
||||
area.count();
|
||||
if(closedEnemy == null){
|
||||
area.pathPainted(-1, null);
|
||||
}else{
|
||||
area.pathPainted(closedEnemy.getIndex(), closedEnemy.getColor());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,10 +21,10 @@ public class PlayArea {
|
||||
public List<Path> paths;
|
||||
private Polygon innerHitAreaBorder,outsideHitAreaBorder;
|
||||
private GeneralPath hitArea;
|
||||
private Color hitAreaColor;
|
||||
private Color hitAreaColor,pathColor = null;
|
||||
private VolatileImage background;
|
||||
private boolean hit = false;
|
||||
private int count = 0,maxCount = 100;
|
||||
private int count = 0,maxCount = 100,pathID = -1;
|
||||
|
||||
public PlayArea(double xToRight,double heightOfGameScreen,double widthOfGameScreen, int sizeOctagon) {
|
||||
super();
|
||||
@@ -99,11 +99,14 @@ public class PlayArea {
|
||||
g2.drawImage(background, 0, 0, 1280, 1024, null);
|
||||
if(hit){
|
||||
g2.setColor(hitAreaColor);
|
||||
g2.fill(hitArea);
|
||||
}
|
||||
|
||||
if(count == maxCount){
|
||||
hit = false;
|
||||
g2.fill(hitArea);
|
||||
if(count == maxCount){
|
||||
hit = false;
|
||||
}
|
||||
}
|
||||
if(pathID >= 0 && pathColor != null){
|
||||
g2.setColor(pathColor);
|
||||
g2.draw(paths.get(pathID));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,4 +139,9 @@ public class PlayArea {
|
||||
hitAreaColor = new Color(hitAreaColor.getRed(),hitAreaColor.getGreen(),hitAreaColor.getBlue(),255-(255*count)/maxCount);
|
||||
}
|
||||
}
|
||||
|
||||
public void pathPainted(int pathID,Color pathColor){
|
||||
this.pathID = pathID;
|
||||
this.pathColor = pathColor;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user