1 Star 0 Fork 0

OOSAD-软工21009-21010/杨卓熙坦克大战

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Missile1-5.java 1.71 KB
一键复制 编辑 原始数据 按行查看 历史
杨卓熙 提交于 2023-05-06 15:19 . 坦克大战代码
package v1_5;
import java.awt.*;
public class Missile {
public static final int XSPEED = 10;
public static final int YSPEED = 10;
public static final int WIDTH = 10;
public static final int HEIGHT = 10;
Missile m = null;
Tank myTank = null;
private boolean live = true;
public boolean isLive() {
return live;
}
public void setLive(boolean live) {
this.live = live;
}
private int x, y;
Tank.Direction dir;
public Missile(int x, int y, Tank.Direction dir) {
this.x = x;
this.y = y;
this.dir = dir;
}
public void draw(Graphics g) {
Color c = g.getColor();
g.setColor(Color.BLACK);
g.fillOval(x, y, 10, 10);
g.setColor(c);
move();
}
private void move() {
switch (dir) {
case L:
x -= XSPEED;
break;
case LU:
x -= XSPEED;
y -= YSPEED;
break;
case U:
y -= YSPEED;
break;
case RU:
x += XSPEED;
y -= YSPEED;
break;
case R:
x += XSPEED;
break;
case RD:
x += XSPEED;
y += YSPEED;
break;
case D:
y += YSPEED;
break;
case LD:
x -= XSPEED;
y += YSPEED;
break;
}
}
public void paint(Graphics g) {
myTank.draw(g);
if (m != null) {
m.draw(g);
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/oosad-soft-work-21009-21010/yang-zhuoxis-tank-battle.git
git@gitee.com:oosad-soft-work-21009-21010/yang-zhuoxis-tank-battle.git
oosad-soft-work-21009-21010
yang-zhuoxis-tank-battle
杨卓熙坦克大战
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385