annotate mydandy.cc @ 5:57af5c610b34

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