- infopanel laat nu een tijdje je 'score change' zien, die na een bepaalde tijd vervaagd
- verbeteringen
This commit is contained in:
+37
-32
@@ -22,21 +22,23 @@ import model.gameState.PlayState;
|
||||
|
||||
public class PlayArea {
|
||||
|
||||
public List<Path> paths;
|
||||
public List<Path> paths;
|
||||
private Polygon innerHitAreaBorder,outsideHitAreaBorder;
|
||||
private GeneralPath hitArea;
|
||||
private Color hitAreaColor,pathColor = null;
|
||||
private VolatileImage background;
|
||||
private boolean hit = false;
|
||||
private int count = 0,maxCount = 100,pathID = -1, oldPathId = pathID;
|
||||
private int count = 0,
|
||||
maxCount = 100,
|
||||
pathID = -1,
|
||||
oldPathId = pathID;
|
||||
private Stroke stroke = new BasicStroke(5);
|
||||
|
||||
private Rectangle2D backgroundPlay = new Rectangle2D.Double(256, 0, 1024, 1024);
|
||||
|
||||
|
||||
|
||||
public PlayArea(double xToRight,double heightOfGameScreen,double widthOfGameScreen, int sizeOctagon) {
|
||||
super();
|
||||
paths = new ArrayList<Path>();
|
||||
paths = new ArrayList<>();
|
||||
setHitAreaColor(Color.WHITE);
|
||||
//make the polygons
|
||||
int amountOfAngles = 8;
|
||||
@@ -62,30 +64,35 @@ public class PlayArea {
|
||||
hitArea = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
|
||||
|
||||
hitArea.moveTo(innerHitAreaBorder.xpoints[0], innerHitAreaBorder.ypoints[0]);
|
||||
for(int i = 1; i < innerHitAreaBorder.npoints;i++){
|
||||
for(int i = 1; i < innerHitAreaBorder.npoints;i++)
|
||||
hitArea.lineTo(innerHitAreaBorder.xpoints[i], innerHitAreaBorder.ypoints[i]);
|
||||
}
|
||||
|
||||
hitArea.moveTo(outsideHitAreaBorder.xpoints[0], outsideHitAreaBorder.ypoints[0]);
|
||||
for(int i = 1; i < innerHitAreaBorder.npoints;i++){
|
||||
for(int i = 1; i < innerHitAreaBorder.npoints;i++)
|
||||
hitArea.lineTo(outsideHitAreaBorder.xpoints[i], outsideHitAreaBorder.ypoints[i]);
|
||||
}
|
||||
|
||||
//make the paths
|
||||
double angleX,angleY;
|
||||
angleX = (Math.cos(Math.toRadians(45)))*Enemy.distanceToOctagon;
|
||||
angleY = (Math.sin(Math.toRadians(45)))*Enemy.distanceToOctagon;
|
||||
|
||||
paths.add(new Path(outsideHitAreaBorder.xpoints[6],outsideHitAreaBorder.ypoints[6]-Enemy.distanceToOctagon ,outsideHitAreaBorder.xpoints[6],outsideHitAreaBorder.ypoints[6]));//top
|
||||
paths.add(new Path(outsideHitAreaBorder.xpoints[7] + angleX,outsideHitAreaBorder.ypoints[7] - angleY ,outsideHitAreaBorder.xpoints[7],outsideHitAreaBorder.ypoints[7]));//right -top
|
||||
paths.add(new Path(outsideHitAreaBorder.xpoints[0]+Enemy.distanceToOctagon,outsideHitAreaBorder.ypoints[0] ,outsideHitAreaBorder.xpoints[0],outsideHitAreaBorder.ypoints[0]));//right
|
||||
paths.add(new Path(outsideHitAreaBorder.xpoints[1]+angleX,outsideHitAreaBorder.ypoints[1]+angleY ,outsideHitAreaBorder.xpoints[1],outsideHitAreaBorder.ypoints[1]));//right -down
|
||||
paths.add(new Path(outsideHitAreaBorder.xpoints[2],outsideHitAreaBorder.ypoints[2]+Enemy.distanceToOctagon ,outsideHitAreaBorder.xpoints[2],outsideHitAreaBorder.ypoints[2]));//down
|
||||
paths.add(new Path(outsideHitAreaBorder.xpoints[3] - angleX,outsideHitAreaBorder.ypoints[3] + angleY ,outsideHitAreaBorder.xpoints[3],outsideHitAreaBorder.ypoints[3]));//left -down
|
||||
paths.add(new Path(outsideHitAreaBorder.xpoints[4] - Enemy.distanceToOctagon,outsideHitAreaBorder.ypoints[4] ,outsideHitAreaBorder.xpoints[4],outsideHitAreaBorder.ypoints[4]));//left
|
||||
paths.add(new Path(outsideHitAreaBorder.xpoints[5] - angleX,outsideHitAreaBorder.ypoints[5] - angleY ,outsideHitAreaBorder.xpoints[5],outsideHitAreaBorder.ypoints[5]));//left -top
|
||||
|
||||
|
||||
paths.add(new Path(outsideHitAreaBorder.xpoints[6],outsideHitAreaBorder.ypoints[6]-Enemy.distanceToOctagon,
|
||||
outsideHitAreaBorder.xpoints[6],outsideHitAreaBorder.ypoints[6]));//top
|
||||
paths.add(new Path(outsideHitAreaBorder.xpoints[7] + angleX,outsideHitAreaBorder.ypoints[7] - angleY,
|
||||
outsideHitAreaBorder.xpoints[7],outsideHitAreaBorder.ypoints[7]));//right -top
|
||||
paths.add(new Path(outsideHitAreaBorder.xpoints[0]+Enemy.distanceToOctagon,outsideHitAreaBorder.ypoints[0],
|
||||
outsideHitAreaBorder.xpoints[0],outsideHitAreaBorder.ypoints[0]));//right
|
||||
paths.add(new Path(outsideHitAreaBorder.xpoints[1]+angleX,outsideHitAreaBorder.ypoints[1]+angleY,
|
||||
outsideHitAreaBorder.xpoints[1],outsideHitAreaBorder.ypoints[1]));//right -down
|
||||
paths.add(new Path(outsideHitAreaBorder.xpoints[2],outsideHitAreaBorder.ypoints[2]+Enemy.distanceToOctagon,
|
||||
outsideHitAreaBorder.xpoints[2],outsideHitAreaBorder.ypoints[2]));//down
|
||||
paths.add(new Path(outsideHitAreaBorder.xpoints[3] - angleX,outsideHitAreaBorder.ypoints[3] + angleY,
|
||||
outsideHitAreaBorder.xpoints[3],outsideHitAreaBorder.ypoints[3]));//left -down
|
||||
paths.add(new Path(outsideHitAreaBorder.xpoints[4] - Enemy.distanceToOctagon,outsideHitAreaBorder.ypoints[4],
|
||||
outsideHitAreaBorder.xpoints[4],outsideHitAreaBorder.ypoints[4]));//left
|
||||
paths.add(new Path(outsideHitAreaBorder.xpoints[5] - angleX,outsideHitAreaBorder.ypoints[5] - angleY,
|
||||
outsideHitAreaBorder.xpoints[5],outsideHitAreaBorder.ypoints[5]));//left -top
|
||||
|
||||
generateBackground();
|
||||
}
|
||||
|
||||
@@ -94,23 +101,22 @@ public class PlayArea {
|
||||
if(hit){
|
||||
g2.setColor(hitAreaColor);
|
||||
g2.fill(hitArea);
|
||||
if(count == maxCount){
|
||||
|
||||
if(count == maxCount)
|
||||
hit = false;
|
||||
}
|
||||
}
|
||||
if( oldPathId != pathID){
|
||||
if (oldPathId != pathID){
|
||||
generateBackground();
|
||||
oldPathId = pathID;
|
||||
}
|
||||
}
|
||||
|
||||
public Line2D getLine(int index){
|
||||
if(index < 0){
|
||||
if(index < 0)
|
||||
index = 0;
|
||||
}
|
||||
if(index >= 8 ){
|
||||
else if(index >= 8)
|
||||
index = 7;
|
||||
}
|
||||
|
||||
return paths.get(index);
|
||||
}
|
||||
|
||||
@@ -127,9 +133,8 @@ public class PlayArea {
|
||||
public void count(){
|
||||
if(hit){
|
||||
count += 3;
|
||||
if(count > maxCount){
|
||||
if(count > maxCount)
|
||||
count = maxCount;
|
||||
}
|
||||
hitAreaColor = new Color(hitAreaColor.getRed(),hitAreaColor.getGreen(),hitAreaColor.getBlue(),255-(255*count)/maxCount);
|
||||
}
|
||||
}
|
||||
@@ -149,10 +154,10 @@ public class PlayArea {
|
||||
Line2D current;
|
||||
g2.setColor(Color.BLACK);
|
||||
g2.setStroke(stroke);
|
||||
for(int i = 0; i < paths.size(); i++){
|
||||
current = paths.get(i);
|
||||
g2.draw(current);
|
||||
}
|
||||
|
||||
paths.forEach(path -> {
|
||||
g2.draw(path);
|
||||
});
|
||||
g2.draw(innerHitAreaBorder);
|
||||
g2.draw(outsideHitAreaBorder);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user