comparison mydandy.cc @ 2:69b4108bf4e8

refact few
author tkaito
date Sun, 06 Jun 2010 03:22:11 +0900
parents
children dca6d5d2ef46
comparison
equal deleted inserted replaced
1:5a888b557a41 2:69b4108bf4e8
1 #include "SceneGraphRoot.h"
2 #include "dandy.h"
3
4 SceneGraphPtr *dandys;
5
6 void def_angle(SceneGraphPtr node, void *sgroot_, int w, int h);
7 void left_angle(SceneGraphPtr node, void *sgroot_, int w, int h);
8 void right_angle(SceneGraphPtr node, void *sgroot_, int w, int h);
9
10 void
11 dandy_move(SceneGraphPtr node, void *sgroot_, int w, int h)
12 {
13 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
14 Pad *pad = sgroot->getController();
15
16 /* 左右の移動 */
17 if (pad->right.isPush() && w > node->xyz[0]) {
18 right_angle(node, sgroot, w, h);
19 } else if (pad->left.isPush() && 0 < node->xyz[0]) {
20 left_angle(node, sgroot, w, h);
21 } else {
22 //def_angle(node, sgroot, w, h);
23 }
24 if (pad->right.isHold() && w > node->xyz[0]) {
25 node->xyz[0] += 10.0f;
26 } else if (pad->left.isHold() && 0 < node->xyz[0]) {
27 node->xyz[0] -= 10.0f;
28 }
29 if (pad->right.isRelease()) {
30
31 } else if(pad->left.isRelease()) {
32
33 }
34 /* 上下の移動 */
35 if (pad->up.isHold() && 0 < node->xyz[1]) {
36 node->xyz[1] -= 10.0f;
37 //def_angle(node, sgroot, w, h);
38 } else if (pad->down.isHold() && h > node->xyz[1]) {
39 node->xyz[1] += 10.0f;
40 }
41 }
42
43 void
44 dandy_collision(SceneGraphPtr node, void *sgroot_, int w, int h,SceneGraphPtr tree)
45 {
46
47 }
48
49 /* 時機や敵機のオブジェクトや何やらを作成してsetSceneDataまで */
50 void
51 create_object(void *sgroot_, int w, int h)
52 {
53 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
54 SceneGraphPtr dandy, rdandy, rtdandy, ldandy, ltdandy;
55 //SceneGraphPtr tmp[5] = {ldandy, ltdandy, dandy, rtdandy, rtdandy};
56 //dandys = tmp;
57
58 SceneGraphPtr back = sgroot->createSceneGraph();
59
60 dandy = sgroot->createSceneGraph("mydandy");
61 ldandy = sgroot->createSceneGraph("l-dandy");
62 ltdandy = sgroot->createSceneGraph("lt-dandy");
63 rdandy = sgroot->createSceneGraph("r-dandy");
64 rtdandy = sgroot->createSceneGraph("rt-dandy");
65
66 dandy->xyz[0] = w/2;
67 dandy->xyz[1] = h*0.9;
68
69 dandy->set_move_collision(dandy_move, dandy_collision);
70 //ldandy->set_move_collision(dandy_move, dandy_collision);
71 ltdandy->set_move_collision(dandy_move, dandy_collision);
72 rdandy->set_move_collision(dandy_move, dandy_collision);
73 rtdandy->set_move_collision(dandy_move, dandy_collision);
74
75 back->addChild(dandy);
76 sgroot->setSceneData(back);
77 }
78
79 void
80 def_angle(SceneGraphPtr node, void *sgroot_, int w, int h)
81 {
82
83 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
84 SceneGraphPtr dandy = sgroot->createSceneGraph("mydandy");
85 SceneGraphPtr back = sgroot->createSceneGraph();
86
87 dandy->xyz[0] = node->xyz[0];
88 dandy->xyz[1] = node->xyz[1];
89
90 dandy->set_move_collision(dandy_move, dandy_collision);
91
92 back->addChild(dandy);
93 sgroot->setSceneData(back);
94 }
95
96 void
97 right_angle(SceneGraphPtr node, void *sgroot_, int w, int h)
98 {
99 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
100 SceneGraphPtr rtdandy;
101 SceneGraphPtr back = sgroot->createSceneGraph();
102
103 rtdandy = sgroot->createSceneGraph("rt-dandy");
104
105 rtdandy->xyz[0] = node->xyz[0];
106 rtdandy->xyz[1] = node->xyz[1];
107
108 rtdandy->set_move_collision(dandy_move, dandy_collision);
109 back->addChild(rtdandy);
110
111 sgroot->setSceneData(back);
112 rtdandy->xyz[0] += 1.0f;
113 }
114 void
115 left_angle(SceneGraphPtr node, void *sgroot_, int w, int h)
116 {
117 SceneGraphRoot *sgroot = (SceneGraphRoot *)sgroot_;
118 SceneGraphPtr ltdandy;
119 SceneGraphPtr back = sgroot->createSceneGraph();
120
121 ltdandy = sgroot->createSceneGraph("lt-dandy");
122
123 ltdandy->xyz[0] = node->xyz[0];
124 ltdandy->xyz[1] = node->xyz[1];
125
126 ltdandy->set_move_collision(dandy_move, dandy_collision);
127 back->addChild(ltdandy);
128
129 sgroot->setSceneData(back);
130 ltdandy->xyz[0] -= 1.0f;
131 }