Mercurial > hg > Members > tkaito > dandy
comparison mydandy.cc @ 5:57af5c610b34
iroiro add
author | tkaito |
---|---|
date | Mon, 07 Jun 2010 02:16:02 +0900 |
parents | dca6d5d2ef46 |
children | 581fa1888e2e |
comparison
equal
deleted
inserted
replaced
4:e089ac9ea221 | 5:57af5c610b34 |
---|---|
1 #include "game_scene01.h" | 1 #include "game_scene01.h" |
2 | 2 |
3 void def_angle(SceneGraphPtr node, void *sgroot_, int w, int h); | 3 void change_angle(SceneGraphPtr node); |
4 void left_angle(SceneGraphPtr node, void *sgroot_, int w, int h); | 4 void collision_obj(SceneGraphIteratorPtr it,SceneGraphPtr node ,int w, int h, void *sgroot); |
5 void right_angle(SceneGraphPtr node, void *sgroot_, int w, int h); | |
6 | 5 |
7 void | 6 void |
8 dandy_move(SceneGraphPtr node, void *sgroot_, int w, int h) | 7 mydandy_move(SceneGraphPtr node, void *sgroot_, int w, int h) |
9 { | 8 { |
10 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; | 9 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; |
11 Pad *pad = sgroot->getController(); | 10 Pad *pad = sgroot->getController(); |
12 | 11 |
13 /* 左右の移動 */ | |
14 if (pad->right.isPush() && w > node->xyz[0]) { | |
15 right_angle(node, sgroot, w, h); | |
16 } else if (pad->left.isPush() && 0 < node->xyz[0]) { | |
17 left_angle(node, sgroot, w, h); | |
18 } else { | |
19 //def_angle(node, sgroot, w, h); | |
20 } | |
21 if (pad->right.isHold() && w > node->xyz[0]) { | 12 if (pad->right.isHold() && w > node->xyz[0]) { |
13 node->xyz[2] = 100000.0f; | |
22 node->xyz[0] += 10.0f; | 14 node->xyz[0] += 10.0f; |
23 } else if (pad->left.isHold() && 0 < node->xyz[0]) { | 15 } else if (pad->left.isHold() && 0 < node->xyz[0]) { |
16 node->xyz[2] = 100000.0f; | |
24 node->xyz[0] -= 10.0f; | 17 node->xyz[0] -= 10.0f; |
25 } | 18 } |
26 if (pad->right.isRelease()) { | |
27 | |
28 } else if(pad->left.isRelease()) { | |
29 | |
30 } | |
31 /* 上下の移動 */ | |
32 if (pad->up.isHold() && 0 < node->xyz[1]) { | 19 if (pad->up.isHold() && 0 < node->xyz[1]) { |
33 node->xyz[1] -= 10.0f; | 20 node->xyz[1] -= 10.0f; |
34 //def_angle(node, sgroot, w, h); | |
35 } else if (pad->down.isHold() && h > node->xyz[1]) { | 21 } else if (pad->down.isHold() && h > node->xyz[1]) { |
36 node->xyz[1] += 10.0f; | 22 node->xyz[1] += 10.0f; |
37 } | 23 } |
38 | 24 |
39 } | 25 } |
40 | 26 |
41 void | 27 void |
42 dandy_collision(SceneGraphPtr node, void *sgroot_, int w, int h,SceneGraphPtr tree) | 28 ltdandy_move(SceneGraphPtr node, void *sgroot_, int w, int h) |
43 { | 29 { |
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 } | |
44 | |
45 } | |
46 void | |
47 rtdandy_move(SceneGraphPtr node, void *sgroot_, int w, int h) | |
48 { | |
49 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; | |
50 Pad *pad = sgroot->getController(); | |
51 | |
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 } | |
44 | 64 |
45 } | 65 } |
46 | 66 |
47 /* 時機や敵機のオブジェクトや何やらを作成してsetSceneDataまで */ | 67 void |
68 ldandy_move(SceneGraphPtr node, void *sgroot_, int w, int h){} | |
69 void | |
70 rdandy_move(SceneGraphPtr node, void *sgroot_, int w, int h){} | |
48 | 71 |
49 void | 72 void |
50 def_angle(SceneGraphPtr node, void *sgroot_, int w, int h) | 73 mydandy_coll(SceneGraphPtr node, void *sgroot_, int w, int h,SceneGraphPtr tree) |
51 { | 74 { |
52 | 75 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; |
53 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; | 76 SceneGraphIteratorPtr it = sgroot->getIterator(tree); |
54 SceneGraphPtr dandy = sgroot->createSceneGraph("mydandy"); | 77 collision_obj(it, node, w, h, sgroot); |
55 SceneGraphPtr back = sgroot->createSceneGraph(); | |
56 | |
57 dandy->xyz[0] = node->xyz[0]; | |
58 dandy->xyz[1] = node->xyz[1]; | |
59 | |
60 dandy->set_move_collision(dandy_move, dandy_collision); | |
61 | |
62 back->addChild(dandy); | |
63 sgroot->setSceneData(back); | |
64 } | 78 } |
65 | 79 |
66 void | 80 void |
67 right_angle(SceneGraphPtr node, void *sgroot_, int w, int h) | 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_) | |
68 { | 85 { |
69 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; | 86 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; |
70 SceneGraphPtr rtdandy; | 87 float dx, dy,ddx,ddy; |
71 SceneGraphPtr back = sgroot->createSceneGraph(); | 88 int g_clab = sgroot->getSgid("green_clab"); |
72 | 89 |
73 rtdandy = sgroot->createSceneGraph("rt-dandy"); | 90 for (; it->hasNext(g_clab);) { |
91 it->next(g_clab); | |
92 SceneGraphPtr obj = it->get(); | |
74 | 93 |
75 rtdandy->xyz[0] = node->xyz[0]; | 94 dx = node->xyz[0] - obj->xyz[0]; |
76 rtdandy->xyz[1] = node->xyz[1]; | 95 dy = node->xyz[1] - obj->xyz[1]; |
77 | 96 ddx = dx*dx; |
78 rtdandy->set_move_collision(dandy_move, dandy_collision); | 97 ddy = dy*dy; |
79 back->addChild(rtdandy); | 98 |
80 | 99 if(sqrt(ddx) < 10 && sqrt(ddy) < 10) { |
81 sgroot->setSceneData(back); | 100 gameover_scene(sgroot, w, h); |
82 rtdandy->xyz[0] += 1.0f; | 101 node->remove(); |
102 break; | |
103 } | |
104 } | |
83 } | 105 } |
84 void | |
85 left_angle(SceneGraphPtr node, void *sgroot_, int w, int h) | |
86 { | |
87 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_; | |
88 SceneGraphPtr ltdandy; | |
89 SceneGraphPtr back = sgroot->createSceneGraph(); | |
90 | |
91 ltdandy = sgroot->createSceneGraph("lt-dandy"); | |
92 | |
93 ltdandy->xyz[0] = node->xyz[0]; | |
94 ltdandy->xyz[1] = node->xyz[1]; | |
95 | |
96 ltdandy->set_move_collision(dandy_move, dandy_collision); | |
97 back->addChild(ltdandy); | |
98 | |
99 sgroot->setSceneData(back); | |
100 ltdandy->xyz[0] -= 1.0f; | |
101 } |