码迷,mamicode.com
首页 > 其他好文 > 详细

坦克大战

时间:2015-01-17 18:09:29      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:

自己练手的一个小项目,还有少量bug,路过的看一看瞧一瞧,请大家指教=.=

[1].[代码] [Java]代码 跳至 [1]

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
protected void onDraw(Canvas canvas) {
        for (int i = 0; i < mybulletlist.size(); i++) {
            if (mybulletlist.get(i).getX() > 380
                    || mybulletlist.get(i).getX() < 0
                    || mybulletlist.get(i).getY() > 700
                    || mybulletlist.get(i).getY() < 0) {
                mybulletlist.remove(i);
            }
        }
        for (int i = 0; i < bulletlist.size(); i++) {
            if (bulletlist.get(i).getX() > 380 || bulletlist.get(i).getX() < 0
                    || bulletlist.get(i).getY() > 700
                    || bulletlist.get(i).getY() < 0) {
                bulletlist.remove(i);
            }
        }
 
        if (!bulletlist.isEmpty() && !mybulletlist.isEmpty()) {
            mytank_die(bulletlist);
            tank_die(mybulletlist, tanklist);
        }
        if (mytank == null) {
 
        } else {
            if (mytank.getZ() == 1) {
                turn_right(canvas, mytank.getX(), mytank.getY());
            } else if (mytank.getZ() == 2) {
                turn_down(canvas, mytank.getX(), mytank.getY());
            } else if (mytank.getZ() == 3) {
                turn_left(canvas, mytank.getX(), mytank.getY());
            } else if (mytank.getZ() == 4) {
                turn_up(canvas, mytank.getX(), mytank.getY());
            }
        }
        if (tanklist.isEmpty()) {
 
        } else {
 
            tank_turn(canvas);
        }
        if (bulletlist.isEmpty()) {
 
        } else {
            bullet_turn(canvas);
        }
        if (mybulletlist.isEmpty()) {
 
        } else {
            mybullet_turn(canvas);
        }
 
    }

坦克大战

标签:

原文地址:http://blog.csdn.net/u014311037/article/details/42805369

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!