213
|
1 #include "SceneGraphRoot.h"
|
|
2 #include "bullet_action.h"
|
|
3 #include "SGList.h"
|
|
4
|
|
5 #define MOVE_SPEED 5.00
|
|
6
|
|
7
|
|
8 void
|
|
9 player_move_right(SceneGraphPtr node, int screen_w, int screen_h)
|
|
10 {
|
|
11 if(node->xyz[0]<screen_w/2)
|
|
12 {
|
|
13 node->xyz[0] += MOVE_SPEED;
|
|
14 }
|
|
15 if(node->angle[1]<=20)
|
|
16 {
|
|
17 node->angle[1]+=1.0;
|
|
18 }
|
|
19 if(node->angle[2]>=-45)
|
|
20 {
|
|
21 node->angle[2]-=1.0;
|
|
22 }
|
|
23 }
|
|
24
|
|
25 void
|
|
26 player_move_left(SceneGraphPtr node, int screen_w, int screen_h)
|
|
27 {
|
|
28 if(node->xyz[0]> -screen_w/2)
|
|
29 {
|
|
30 node->xyz[0] -= MOVE_SPEED;
|
|
31 }
|
|
32 if(node->angle[1]>=-20)
|
|
33 {
|
|
34 node->angle[1]-=1.0;
|
|
35 }
|
|
36 if(node->angle[2]<=45)
|
|
37 {
|
|
38 node->angle[2]+=1.0;
|
|
39 }
|
|
40 }
|
|
41
|
|
42 void
|
|
43 player_move_up(SceneGraphPtr node, int screen_w, int screen_h)
|
|
44 {
|
|
45 if(node->xyz[2]<screen_h/2 + 100)
|
|
46 {
|
|
47 node->xyz[2] += MOVE_SPEED;
|
|
48 }
|
|
49 if(node->angle[0]<45)
|
|
50 {
|
|
51 node->angle[0] += 2.0;
|
|
52 }
|
|
53 }
|
|
54
|
|
55 void
|
|
56 player_move_down(SceneGraphPtr node, int screen_w, int screen_h)
|
|
57 {
|
|
58 if(node->xyz[2]> -screen_h/2)
|
|
59 {
|
|
60 node->xyz[2] -= MOVE_SPEED;
|
|
61 }
|
|
62 if(node->angle[0]>-45)
|
|
63 {
|
|
64 node->angle[0] -= 2.0;
|
|
65 }
|
|
66 }
|
|
67
|
|
68 void
|
|
69 player_move_idle(SceneGraphPtr node)
|
|
70 {
|
|
71 if (node->angle[1]>0)
|
|
72 {
|
|
73 node->angle[1]-=1.0;
|
|
74 }
|
|
75 else if(node->angle[1]<0)
|
|
76 {
|
|
77 node->angle[1]+=1.0;
|
|
78 }
|
|
79
|
|
80 if(node->angle[2]<0)
|
|
81 {
|
|
82 node->angle[2]+=0.5;
|
|
83 }
|
|
84 else if(node->angle[2]>0)
|
|
85 {
|
|
86 node->angle[2]-=0.5;
|
|
87 }
|
|
88
|
|
89 if(node->angle[0]<0)
|
|
90 {
|
|
91 node->angle[0]+=1.0;
|
|
92 }
|
|
93 else if(node->angle[0]>0)
|
|
94 {
|
|
95 node->angle[0]-=1.0;
|
|
96 }
|
|
97 }
|
|
98
|
|
99 void
|
|
100 player_move_all(SceneGraphPtr node, int screen_w, int screen_h)
|
|
101 {
|
|
102 Pad *pad = sgroot->getController();
|
|
103
|
|
104 if (pad->right.isHold() || pad->left.isHold() ||
|
|
105 pad->up.isHold() || pad->down.isHold()) {
|
|
106 if (pad->right.isHold()) {
|
|
107 player_move_right(node, screen_w, screen_h);
|
|
108 } else if (pad->left.isHold()) {
|
|
109 player_move_left(node, screen_w, screen_h);
|
|
110 }
|
|
111
|
|
112 if (pad->down.isHold()) {
|
|
113 player_move_up(node, screen_w, screen_h);
|
|
114 } else if(pad->up.isHold()) {
|
|
115 player_move_down(node, screen_w, screen_h);
|
|
116 }
|
|
117 } else {
|
|
118 player_move_idle(node);
|
|
119 }
|
|
120
|
|
121 if (pad->r2.isHold()) {
|
|
122 node->xyz[2] -= 10.0f;
|
|
123 }
|
|
124
|
|
125 if (pad->circle.isPush()) {
|
|
126 SceneGraphPtr bullet = sgroot->createSceneGraph(BULEBULLET);
|
|
127 bullet->set_move_collision(bluebullet_move, bullet_collision);
|
|
128 bullet_init(bullet, node);
|
|
129 node->addBrother(bullet);
|
|
130 }
|
|
131 }
|
|
132
|
|
133 void
|
|
134 player_collision(SceneGraphPtr node, int screen_w, int screen_h,
|
|
135 SceneGraphPtr tree)
|
|
136 {
|
|
137 #if 0
|
|
138 int judge = square_judge(node, BULEBULLET, scene_graph);
|
|
139
|
|
140 if (judge == HIT)
|
|
141 {
|
|
142 node->set_move_collision(player_move_all,player_collision);
|
|
143 }
|
|
144 #endif
|
|
145 }
|
|
146
|