Permalink
Browse files

Add background image to high score list

  • Loading branch information...
1 parent 550fc9f commit 0f2f759dd33c5f4573b995874f6aa41ff4b4b930 @aardvarrk aardvarrk committed Jan 23, 2013
Showing with 16 additions and 9 deletions.
  1. +12 −5 HighScoreWorld.java
  2. BIN images/highScores.png
  3. +4 −4 project.greenfoot
View
@@ -1,4 +1,6 @@
import greenfoot.*;
+import java.awt.Color;
+import java.awt.Font;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -7,7 +9,7 @@
private Game game;
public HighScoreWorld(Game game) {
- super(600, 400, 1);
+ super(700, 500, 1);
this.game = game;
List<HighScore> highScores;
@@ -17,13 +19,18 @@ public HighScoreWorld(Game game) {
highScores = new ArrayList<HighScore>();
}
- String highScoresString = "High Scores\n";
+ GreenfootImage textImage = new GreenfootImage("images/highScores.png");
+ textImage.setColor(Color.WHITE);
+ textImage.setFont(new Font("Arial", Font.PLAIN, 20));
+
+ int i = 0;
for (HighScore highScore : highScores) {
- highScoresString += highScore.getName() + ": " + highScore.getScore() + "\n";
+ ++i;
+ textImage.drawString("#" + i, 25, 200 + i * 25);
+ textImage.drawString(highScore.getName(), 210, 200 + i * 25);
+ textImage.drawString("" + highScore.getScore(), 590, 200 + i * 25);
}
- GreenfootImage textImage = new GreenfootImage(600, 400);
- textImage.drawString(highScoresString, 10, 20);
setBackground(textImage);
}
}
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -181,13 +181,13 @@ dependency9.from=FloodWorld
dependency9.to=Counter
dependency9.type=UsesDependency
mainWindow.height=774
-mainWindow.width=1280
-mainWindow.x=0
+mainWindow.width=1023
+mainWindow.x=105
mainWindow.y=22
package.numDependencies=46
package.numTargets=26
project.charset=UTF-8
-simulation.speed=36
+simulation.speed=100
target1.editor.height=700
target1.editor.width=900
target1.editor.x=40
@@ -298,7 +298,7 @@ target17.x=150
target17.y=550
target18.editor.height=700
target18.editor.width=900
-target18.editor.x=0
+target18.editor.x=442
target18.editor.y=22
target18.height=50
target18.name=HighScoreWorld

0 comments on commit 0f2f759

Please sign in to comment.