1 Star 0 Fork 1

曹俊涛/little-crab-initial

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Crab.java 809 Bytes
一键复制 编辑 原始数据 按行查看 历史
曹俊涛 提交于 2020-03-18 22:25 . update Crab.java.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class crab here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class crab extends Actor
{
/**
* Act - do whatever the crab wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
move(3);
turnAtEdge();
control();
}
public void turnAtEdge()
{
if(isAtEdge())
{
turn(5);
}
}
public void control(){
if(Greenfoot.isKeyDown("left"))
{
turn(-10);
}
if(Greenfoot.isKeyDown("right"))
{
turn(10);
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/cao_jun_tao/little-crab-initial.git
git@gitee.com:cao_jun_tao/little-crab-initial.git
cao_jun_tao
little-crab-initial
little-crab-initial
master

搜索帮助