1 Star 0 Fork 165

erido-8/little-crab-initial

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
CrabWorld.java 1.16 KB
一键复制 编辑 原始数据 按行查看 历史
erido-8 提交于 2021-04-23 21:24 . 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, 100, 100);
for(int i=0;i<3;i++) {
Lobster l=new Lobster();
addObject(l,200+i*20,200+i*50);
}
for (int i = 0;i <5 ;i ++) {
Worm w =new Worm();
addObject(w, 50 + i * 50, 150 + i * 50);
}
for (int i = 0;i <5 ;i ++) {
Worm w =new Worm();
addObject(w, 50 + i * 100, 100);
}
for (int i = 0;i <5 ;i ++) {
Worm w =new Worm();
addObject(w, 250 + i * 50, 350 - i * 50 );
}
}
public void drawNum(int num){
GreenfootImage image = getBackground();
Color color = new Color(255, 0, 0);
image.setColor(color);
image.drawString("吃虫数:"+ num,200,200);
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/erido-8/little-crab-initial.git
git@gitee.com:erido-8/little-crab-initial.git
erido-8
little-crab-initial
little-crab-initial
master

搜索帮助