1 Star 0 Fork 114

gcaog/little-crab-initial

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
CrabWorld.java 1.27 KB
一键复制 编辑 原始数据 按行查看 历史
gcaog 提交于 2021-04-23 18:22 . update CrabWorld.java.
import greenfoot.*; // (Actor, World, Greenfoot, GreenfootImage)
public class CrabWorld extends World
{
/**
* Create the crab world (the beach). Our world has a size
* of 560x560 cells, where every cell is just 1 pixel.
*/
public CrabWorld()
{
super(560, 560, 1);
Crab c=new Crab();
addObject( c, 360,360);
for(int i=0;i<=10;i++){
for(int j=0;j<=10;j++){
Worm w=new Worm();
addObject(w,30+j*50,30+i*50);
}
for(int j=1;j<=3;j++){
Lobster l= new Lobster();
addObject( l, 100,100+j*50);
}
}
}
public void drawNum(int num){
GreenfootImage image = getBackground();
Color color = new Color(255,0,0);
image.setColor(color);
image.drawString("吃虫数:"+num,400,50);
Font font = new Font(40);
image.setFont(font);
}
public void abc1(int num){
if(num==4){
Greenfoot.stop();
GreenfootImage image = getBackground();
image.drawString("成功", 260, 280);
}
}
public void abc2(int num){
if(num==0){
Greenfoot.stop();
GreenfootImage image = getBackground();
image.drawString("失败", 260, 280);
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/gtx123456789/little-crab-initial.git
[email protected]:gtx123456789/little-crab-initial.git
gtx123456789
little-crab-initial
little-crab-initial
master

搜索帮助