- infopanel laat nu een tijdje je 'score change' zien, die na een bepaalde tijd vervaagd

- verbeteringen
This commit is contained in:
Bilel Bghiel
2015-06-19 22:42:00 +02:00
parent bfc62c2b62
commit 412ed60dfe
4 changed files with 84 additions and 78 deletions
+22 -14
View File
@@ -2,12 +2,7 @@ package model.objects;
import image.Images;
import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Transparency;
import java.awt.*;
import java.awt.image.VolatileImage;
import model.SongHandler;
@@ -22,8 +17,10 @@ public class InfoPanel {
private SongHandler sh;
private String time;
private CoinAnimation coinAnimation = new CoinAnimation(125, 300);
private int tempComboScore;
private CoinAnimation coinAnimation = new CoinAnimation(125, 300);
public InfoPanel(int x, int y, SongHandler sh){
this.x = x;
@@ -58,33 +55,44 @@ public class InfoPanel {
g2.setRenderingHints(rh);
g2.setColor(Color.BLACK);
// g2.setColor(Color.GRAY);
GradientPaint gp = new GradientPaint(0, 0, new Color(245,245,245), 256, 1024, Color.WHITE);
g2.setPaint(gp);
g2.fillRect(x, y, 256, 1024);
// Score balk
g2.setColor(Color.BLACK);
g2.drawRect(x, y, 255, 1023);
Font scoreFont = new Font("OCR A Extended", Font.BOLD, 30);
g2.setFont(scoreFont);
g2.setColor(Color.GREEN);
g2.fillRect(25, 100, (int)(2 * PlayState.lifePoints), 30);
// Laatste punten in-/decrease tonen.
if (PlayState.sinceScoreChanged < 75 && PlayState.sinceScoreChanged != 0) {
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float)(1 - (PlayState.sinceScoreChanged * 0.01))));
g2.setColor(Color.RED);
g2.drawString("+" + PlayState.lastScoreChange, 205, 40);
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f));
}
g2.setColor(Color.ORANGE);
g2.drawString("Score: " + totalHighscore, 25, 75);
// BALK
g2.drawRect(25, 100, 200, 30);
g2.drawRect(25, 300, 200, 700);
g2.drawString(sh.getCurrentSong().getTitle(), 25, 200);
g2.drawString(sh.getCurrentSongInstance().getDifficulty(), 25, 230);
g2.drawString(sh.getCurrentSong().getAuthor(), 25, 260);
g2.drawString(time, 25, 290);
// Controlen of coin animatie nodig is
if (!coinAnimation.areWeDoneYet()) {
coinAnimation.draw(g2);
// Score pas updaten wanneer coin klaar is met afspelen
// Score pas updaten wanneer coin in zijn laatste draw loop zit
if (coinAnimation.isLastLoop())
tempComboScore = PlayState.comboScore;
} else
@@ -101,7 +109,7 @@ public class InfoPanel {
}
public void throwACoin() {
coinAnimation.start(); // Teller weer op 0 zetten
coinAnimation.start(); // Teller weer op 1 zetten
}
public void draw(Graphics2D g2){
+37 -32
View File
@@ -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);