加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
lobster.java 773 Bytes
一键复制 编辑 原始数据 按行查看 历史
baikun 提交于 2020-03-20 14:03 . tijiao
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()
{
// Add your action code here
move(3);
turnAtEdge();
control();
}
public void turnAtEdge(){
if(isAtEdge()){
turn(20);
}
}
public void control(){
if(Greenfoot.isKeyDown("up")){
turn(15);
}
if(Greenfoot.isKeyDown("down")){
turn(-15);
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化