加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
WhiteCell.java 785 Bytes
一键复制 编辑 原始数据 按行查看 历史
luyanfei78 提交于 2020-04-08 12:09 . add initial project.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* This is a white blood cell. This kind of cell has the job to catch
* bacteria and remove them from the blood.
*
* @author Michael Kölling
* @version 0.1
*/
public class WhiteCell extends Actor
{
/**
* Act: move up and down when cursor keys are pressed.
*/
public void act()
{
checkKeyPress();
}
/**
* Check whether a keyboard key has been pressed and react if it has.
*/
private void checkKeyPress()
{
if (Greenfoot.isKeyDown("up"))
{
setLocation(getX(), getY()-4);
}
if (Greenfoot.isKeyDown("down"))
{
setLocation(getX(), getY()+4);
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化