1 Star 0 Fork 79

zhangran/little-crab-initial

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Lobster.java 761 Bytes
一键复制 编辑 原始数据 按行查看 历史
zhangran 提交于 2020-03-30 00:11 . 螃蟹吃虾,虾吃虫子。
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Lobster here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Lobster extends Actor
{
/**
* Act - do whatever the Lobster wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
move(3);
randomTurn();
eat1();
}
public void randomTurn(){
if(Greenfoot.getRandomNumber(100)<30){
turn(Greenfoot.getRandomNumber(60)-30);
}
}
public void eat1(){
if(isTouching(worm.class)){
removeTouching(worm.class);
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/zhang_xiao_ran/little-crab-initial.git
git@gitee.com:zhang_xiao_ran/little-crab-initial.git
zhang_xiao_ran
little-crab-initial
little-crab-initial
master

搜索帮助