3
|
1 #include "game_scene01.h"
|
2
|
2
|
5
|
3 void change_angle(SceneGraphPtr node);
|
|
4 void collision_obj(SceneGraphIteratorPtr it,SceneGraphPtr node ,int w, int h, void *sgroot);
|
2
|
5
|
|
6 void
|
5
|
7 mydandy_move(SceneGraphPtr node, void *sgroot_, int w, int h)
|
2
|
8 {
|
|
9 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
|
|
10 Pad *pad = sgroot->getController();
|
|
11
|
|
12 if (pad->right.isHold() && w > node->xyz[0]) {
|
5
|
13 node->xyz[2] = 100000.0f;
|
2
|
14 node->xyz[0] += 10.0f;
|
|
15 } else if (pad->left.isHold() && 0 < node->xyz[0]) {
|
5
|
16 node->xyz[2] = 100000.0f;
|
2
|
17 node->xyz[0] -= 10.0f;
|
|
18 }
|
|
19 if (pad->up.isHold() && 0 < node->xyz[1]) {
|
|
20 node->xyz[1] -= 10.0f;
|
|
21 } else if (pad->down.isHold() && h > node->xyz[1]) {
|
|
22 node->xyz[1] += 10.0f;
|
|
23 }
|
3
|
24
|
2
|
25 }
|
|
26
|
|
27 void
|
5
|
28 ltdandy_move(SceneGraphPtr node, void *sgroot_, int w, int h)
|
2
|
29 {
|
5
|
30 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
|
|
31 Pad *pad = sgroot->getController();
|
|
32 if (pad->right.isHold() && w > node->xyz[0]) {
|
|
33 node->xyz[2] = 100000.0f;
|
|
34 node->xyz[0] += 10.0f;
|
|
35 } else if (pad->left.isHold() && 0 < node->xyz[0]) {
|
|
36 node->xyz[2] = 0.0f;
|
|
37 node->xyz[0] -= 10.0f;
|
|
38 }
|
|
39 if (pad->up.isHold() && 0 < node->xyz[1]) {
|
|
40 node->xyz[1] -= 10.0f;
|
|
41 } else if (pad->down.isHold() && h > node->xyz[1]) {
|
|
42 node->xyz[1] += 10.0f;
|
|
43 }
|
2
|
44
|
|
45 }
|
|
46 void
|
5
|
47 rtdandy_move(SceneGraphPtr node, void *sgroot_, int w, int h)
|
2
|
48 {
|
5
|
49 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
|
|
50 Pad *pad = sgroot->getController();
|
2
|
51
|
5
|
52 if (pad->right.isHold() && w > node->xyz[0]) {
|
|
53 node->xyz[2] = 0.0f;
|
|
54 node->xyz[0] += 10.0f;
|
|
55 } else if (pad->left.isHold() && 0 < node->xyz[0]) {
|
|
56 node->xyz[2] = 100000.0f;
|
|
57 node->xyz[0] -= 10.0f;
|
|
58 }
|
|
59 if (pad->up.isHold() && 0 < node->xyz[1]) {
|
|
60 node->xyz[1] -= 10.0f;
|
|
61 } else if (pad->down.isHold() && h > node->xyz[1]) {
|
|
62 node->xyz[1] += 10.0f;
|
|
63 }
|
|
64
|
2
|
65 }
|
|
66
|
|
67 void
|
5
|
68 ldandy_move(SceneGraphPtr node, void *sgroot_, int w, int h){}
|
|
69 void
|
|
70 rdandy_move(SceneGraphPtr node, void *sgroot_, int w, int h){}
|
|
71
|
|
72 void
|
|
73 mydandy_coll(SceneGraphPtr node, void *sgroot_, int w, int h,SceneGraphPtr tree)
|
|
74 {
|
|
75 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
|
|
76 SceneGraphIteratorPtr it = sgroot->getIterator(tree);
|
|
77 collision_obj(it, node, w, h, sgroot);
|
|
78 }
|
|
79
|
|
80 void
|
|
81 dandy_coll(SceneGraphPtr node, void *sgroot_, int w, int h,SceneGraphPtr tree){}
|
|
82
|
|
83 void
|
|
84 collision_obj(SceneGraphIteratorPtr it,SceneGraphPtr node ,int w, int h, void *sgroot_)
|
2
|
85 {
|
|
86 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
|
5
|
87 float dx, dy,ddx,ddy;
|
|
88 int g_clab = sgroot->getSgid("green_clab");
|
2
|
89
|
5
|
90 for (; it->hasNext(g_clab);) {
|
|
91 it->next(g_clab);
|
|
92 SceneGraphPtr obj = it->get();
|
2
|
93
|
5
|
94 dx = node->xyz[0] - obj->xyz[0];
|
|
95 dy = node->xyz[1] - obj->xyz[1];
|
|
96 ddx = dx*dx;
|
|
97 ddy = dy*dy;
|
|
98
|
|
99 if(sqrt(ddx) < 10 && sqrt(ddy) < 10) {
|
|
100 gameover_scene(sgroot, w, h);
|
|
101 node->remove();
|
|
102 break;
|
|
103 }
|
|
104 }
|
2
|
105 }
|