代码拉取完成,页面将自动刷新
同步操作将从 吕焱飞/WDC 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* The bloodstream is the setting for our White Blood Cell scenario.
* It's a place where blood cells, bacteria and viruses float around.
*
* @author Michael Kölling
* @version 0.1
*/
public class Bloodstream extends World
{
/**
* Constructor: Set up the starting objects.
*/
public Bloodstream()
{
super(780, 360, 1);
showText("Score:0000", 65, 20);
showText("Time:2000", 720, 20);
prepare();
setPaintOrder(Border.class);
}
/**
* Create new floating objects at irregular intervals.
*/
public void act()
{
if (Greenfoot.getRandomNumber(100) < 1)
{
addObject(new Virus(), 779, Greenfoot.getRandomNumber(360));
}
if (Greenfoot.getRandomNumber(100) < 3)
{
addObject(new Bacteria(), 779, Greenfoot.getRandomNumber(360));
}
if (Greenfoot.getRandomNumber(100) < 5)
{
addObject(new RedCell(), 779, Greenfoot.getRandomNumber(360));
}
}
/**
* Prepare the world for the start of the program. In this case: Create
* a white blood cell and the lining at the edge of the blood stream.
*/
private void prepare()
{
WhiteCell whitecell = new WhiteCell();
addObject(whitecell, 83, 179);
Lining lining = new Lining();
addObject(lining, 126, 1);
Lining lining2 = new Lining();
addObject(lining2, 342, 5);
Lining lining3 = new Lining();
addObject(lining3, 589, 2);
Lining lining4 = new Lining();
addObject(lining4, 695, 5);
Lining lining5 = new Lining();
addObject(lining5, 114, 359);
Lining lining6 = new Lining();
addObject(lining6, 295, 353);
Lining lining7 = new Lining();
addObject(lining7, 480, 358);
Lining lining8 = new Lining();
addObject(lining8, 596, 359);
Lining lining9 = new Lining();
addObject(lining9, 740, 354);
Border borderLeft = new Border();
addObject(borderLeft, 0, 180);
Border borderRight= new Border();
addObject(borderRight, 780, 180);
}
public void showScore(int score)
{
if(score < 0){
showText("Score:" + score, 65, 20);
showText("YOU LOSE", 400, 180);
}
else if(score < 10){
showText("Score:000" + score, 65, 20);
}
else if(score < 100){
showText("Score:00" + score, 65, 20);
}
else if(score < 1000){
showText("Score:0" + score, 65, 20);
}
else {
showText("Score:" + score, 65, 20);
}
}
public void showTime(int time)
{
if(time == 0){
showText("Time:0000", 720, 20);
Greenfoot.playSound("slurp.wav");
showText("YOU WIN", 400, 180);
}
else if(time < 10){
showText("Time:000" + time, 720, 20);
}
else if(time < 100){
showText("Time:00" + time, 720, 20);
}
else if(time < 1000){
showText("Time:0" + time, 720, 20);
}
else {
showText("Time:" + time, 720, 20);
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。