1 Star 0 Fork 78

太玄归一/asteroids

forked from 吕焱飞/asteroids 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
ScoreBoard.java 1.27 KB
一键复制 编辑 原始数据 按行查看 历史
luyanfei78 提交于 2020-04-15 10:17 . asteroids initialized.
import greenfoot.*;
/**
* The ScoreBoard is used to display results on the screen. It can display some
* text and a score.
*
* @author M Kölling
* @version 1.1
*/
public class ScoreBoard extends Actor
{
public static final float FONT_SIZE = 48.0f;
public static final int WIDTH = 400;
public static final int HEIGHT = 300;
/**
* Create a score board with dummy result for testing.
*/
public ScoreBoard()
{
this(100);
}
/**
* Create a score board for the final result.
*/
public ScoreBoard(int score)
{
makeImage("Game Over", "Score: ", score);
}
/**
* Make the score board image.
*/
private void makeImage(String title, String prefix, int score)
{
GreenfootImage image = new GreenfootImage(WIDTH, HEIGHT);
image.setColor(new Color(255,255,255, 128));
image.fillRect(0, 0, WIDTH, HEIGHT);
image.setColor(new Color(0, 0, 0, 128));
image.fillRect(5, 5, WIDTH-10, HEIGHT-10);
Font font = image.getFont();
font = font.deriveFont(FONT_SIZE);
image.setFont(font);
image.setColor(Color.WHITE);
image.drawString(title, 60, 100);
image.drawString(prefix + score, 60, 200);
setImage(image);
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/peng_chen_bo/asteroids.git
git@gitee.com:peng_chen_bo/asteroids.git
peng_chen_bo
asteroids
asteroids
master

搜索帮助