comparison main.cc @ 24:a131729d6e4d

not working.
author koba <koba@cr.ie.u-ryukyu.ac.jp>
date Wed, 24 Nov 2010 19:24:04 +0900
parents 3fb8a6a34e24
children
comparison
equal deleted inserted replaced
23:3fb8a6a34e24 24:a131729d6e4d
1 #include "dandy.h" 1 #include "dandy.h"
2 2
3 #define ENEMY_STATUS(charano,score,hardness) {charano,score,hardness} 3 #define ENEMY_STATUS(charano,score,hardness) {charano,score,hardness}
4 const state status[50] = ENEMY_STATUS_TABLE; 4 const state enemy_status[ENEMY_NUM] = ENEMY_STATUS_TABLE;
5 5
6 extern void task_init(void); 6 extern void task_init(void);
7 7
8 TaskManager *manager; 8 TaskManager *manager;
9 ObjPropertyPtr charactor; 9 ObjPropertyPtr charactor;
10 10
11 const char *usr_help_str = "Usage: ./twice [-length data_length] [-count task_num]\n\ 11 const char *usr_help_str = "Usage: ./twice [-length data_length] [-count task_num]\n\
12 -length Number of data (default DATA_NUM (Func.h))\n\ 12 -length Number of data (default DATA_NUM (Func.h))\n\
13 -count Number of task (default 1)\n"; 13 -count Number of task (default 1)\n";
14
15 HTaskPtr
16 pad_alloc(Viewer *sgroot)
17 {
18 HTaskPtr task = sgroot->tmanager->create_task(PAD_ALLOCATE);
19 void *pad = (void*)sgroottmp->getController();
20 int size = sizeof(Pad);
21
22 task->set_param(0, PAD_INPUT);
23 task->set_param(1, size);
24 task->add_inData(pad, size);
25 task->set_cpu(SPE_ANY);
26 task->spawn();
27
28 return task;
29 }
30
31 HTaskPtr
32 pad_update(Viewer *sgroot)
33 {
34 HTaskPtr task = sgroot->tmanager->create_task(PAD_UPDATE);
35 void *pad = (void*)sgroottmp->getController();
36 int size = sizeof(Pad);
37
38 task->set_param(0, PAD_INPUT);
39 task->set_param(1, size);
40 task->add_inData(pad, size);
41 task->set_cpu(SPE_ANY);
42 task->spawn();
43
44 return task;
45 }
46
47 HTaskPtr
48 pad_free(Viewer *sgroot)
49 {
50 HTaskPtr task = sgroot->tmanager->create_task(PAD_FREE);
51 void *pad = (void*)sgroottmp->getController();
52 int size = sizeof(Pad);
53
54 task->set_param(0, PAD_INPUT);
55 task->set_cpu(SPE_ANY);
56 task->spawn();
57
58 return task;
59 }
14 60
15 int 61 int
16 init(int argc, char **argv) 62 init(int argc, char **argv)
17 { 63 {
18 for (int i = 1; argv[i]; ++i) { 64 for (int i = 1; argv[i]; ++i) {
24 } 70 }
25 71
26 return 0; 72 return 0;
27 } 73 }
28 74
29 void 75 //旧APIとの互換関数
30 init_charactor(Viewer *sgroot, int w, int h) 76 void
77 PutSprite(float x, float y, int number)
78 {
79 char* name = charactor[number].name;
80 SceneGraphPtr object = sgroot->createSceneGraph(name);
81
82 title->xyz[0] = x;
83 title->xyz[1] = y;
84
85 charactor[number].x = x;
86 charactor[number].y = y;
87 charactor[number].flag = 0;
88 charactor[number].root = (void*)object;
89 }
90
91 void
92 create_sg(Viewer *sgroot, int w, int h)
31 { 93 {
32 sgroot->createFromXMLfile("xml/mydandy.xml"); 94 sgroot->createFromXMLfile("xml/mydandy.xml");
33 sgroot->createFromXMLfile("xml/greencrab.xml"); 95 sgroot->createFromXMLfile("xml/greencrab.xml");
34 sgroot->createFromXMLfile("xml/gameover.xml"); 96 sgroot->createFromXMLfile("xml/gameover.xml");
35 sgroot->createFromXMLfile("xml/greencrab.xml"); 97 sgroot->createFromXMLfile("xml/greencrab.xml");
36 sgroot->createFromXMLfile("xml/bluebullet.xml"); 98 sgroot->createFromXMLfile("xml/bluebullet.xml");
37 sgroot->createFromXMLfile("xml/redbullet.xml"); 99 sgroot->createFromXMLfile("xml/redbullet.xml");
38 sgroot->createFromXMLfile("xml/title2.xml"); 100 sgroot->createFromXMLfile("xml/title2.xml");
101 }
102
103 void
104 def_charactor(int number, char *name, float w, float h)
105 {
106 charactor[number].chara_id = number;
107 charactor[number].name = name;
108 charactor[number].width = w;
109 charactor[number].height = h;
110 charactor[number].mid_w = w / 2;
111 charactor[number].mid_h = h / 2;
112 }
113
114 void
115 set_parameter()
116 {
117 /**
118 * 1引数:キャラクターID;
119 * 2引数:キャラクター名;
120 * 3引数:幅
121 * 4引数:高さ
122 */
123
124 def_charactor(PLAYER_IDLE, "player_idle", 128, 128);
125 def_charactor(PLAYER_LEFTMOVE, "player_leftmove", 128, 128);
126 def_charactor(PLAYER_TURNTOLEFT, "player_turntoleft", 128, 128);
127 def_charactor(PLAYER_TURNTORIGHT, "player_turntoright", 128, 128);
128 def_charactor(PLAYER_RIGHTMOVE, "player_rightmove", 128, 128);
129 def_charactor(BLUEBULLET_LEFT, "bulebullet_left", 45, 128);
130 def_charactor(BLUEBULLET_RIGHT, "blebullet_right", 38, 128);
131 def_charactor(REDBULLET, "redbullet", 128, 256);
132 def_charactor(LONGLASER, "longlaser", 64, 256);
133 def_charactor(GAUGE_PANEL, "gauge_panel", 128, 512);
134 def_charactor(OFFENSIVEPOWER_GAUGE, "offensivepower_gauge", 27, 220);
135 def_charactor(BURNER, "burner", 63, 122);
136 def_charactor(LOCKON_SIGHT, "lockon_sight", 64, 64);
137 //def_charactor(SPECIAL_LASERGAUGE, "special_lasergauge", 0, 0);
138 def_charactor(DIFFENSIVEPOWER_GAUGE, "diffensivepower_gauge", 20, 215);
139 def_charactor(GREENBULLET, "greenbullet", 128, 128);
140 def_charactor(BULEBARRIER, "bulebarrier", 128, 128);
141 //def_charactor(FONT_PLAYER_1, "font_player1", 128, 32);
142 //def_charactor(FONT_GAMEOVER, "font_gameover", 256, 32);
143 def_charactor(FONT_0, "font_0", 32, 32);
144 def_charactor(FONT_1, "font_1", 32, 32);
145 def_charactor(FONT_2, "font_2", 32, 32);
146 def_charactor(FONT_3, "font_3", 32, 32);
147 def_charactor(FONT_4, "font_4", 32, 32);
148 def_charactor(FONT_5, "font_5", 32, 32);
149 def_charactor(FONT_6, "font_6", 32, 32);
150 def_charactor(FONT_7, "font_7", 32, 32);
151 def_charactor(FONT_8, "font_8", 32, 32);
152 def_charactor(FONT_9, "font_9", 32, 32);
153 def_charactor(REDBOMB_ANIM_0, "redbomb_anim_0", 64, 64);
154 def_charactor(REDBOMB_ANIM_1, "redbomb_anim_1", 64, 64);
155 def_charactor(REDBOMB_ANIM_2, "redbomb_anim_2", 64, 64);
156 def_charactor(REDBOMB_ANIM_3, "redbomb_anim_3", 64, 64);
157 def_charactor(REDBOMB_ANIM_4, "redbomb_anim_4", 64, 64);
158 def_charactor(REDBOMB_ANIM_5, "redbomb_anim_5", 64, 64);
159 def_charactor(REDBOMB_ANIM_6, "redbomb_anim_6", 64, 64);
160 def_charactor(REDBOMB_ANIM_7, "redbomb_anim_7", 64, 64);
161 def_charactor(FONT_HIGE, "font_hige", 128, 32);
162 def_charactor(GREENBOMB_ANIM_0, "greenbomb_anim_0", 64, 64);
163 def_charactor(GREENBOMB_ANIM_1, "greenbomb_anim_1", 64, 64);
164 def_charactor(GREENBOMB_ANIM_2, "greenbomb_anim_2", 64, 64);
165 //def_charactor(GREENBOMB_ANIM_3, "greenbomb_anim_3", 64, 64);
166 def_charactor(GREENBOMB_ANIM_4, "greenbomb_anim_4", 64, 64);
167 def_charactor(GREENBOMB_ANIM_5, "greenbomb_anim_5", 64, 64);
168 def_charactor(GREENBOMB_ANIM_6, "greenbomb_anim_6", 64, 64);
169 def_charactor(GREENBOMB_ANIM_7, "greenbomb_anim_7", 64, 64);
170 def_charactor(INFLATION_GAUGE, "inflation_gauge", 64, 512);
171 def_charactor(INFLATION_METER, "inflation_meter", 32, 512);
172 def_charactor(ENEMY_GREENCRAB, "enemy_greenclab", 128, 128);
173 def_charactor(ENEMY_PLANE, "enemy_plane", 128, 128);
174 def_charactor(ENEMY_REDBULLET, "enemy_redbullet", 32, 32);
175 def_charactor(FONT_PUSHSTART, "font_pushstart", 512, 32);
176 def_charactor(BOSS1_ORGAN, "boss1_organ", 128, 256);
177 def_charactor(ENEMY_LASER, "enemy_laser", 64, 251);
178 def_charactor(ENEMY_BLUEBULLET, "enemy_bluebullet", 36, 28);
179 def_charactor(ENEMY_LIGHTNING, "enemy_lightning", 64, 252);
180 def_charactor(ENEMY_LASERSPLOSH_0, "enemy_lasersplosh_0", 126, 127);
181 def_charactor(ENEMY_LASERSPLOSH_1, "enemy_lasersplosh_1", 124, 119);
182 def_charactor(ENEMY_LASERSPLOSH_2, "enemy_lasersplosh_2", 126, 127);
183 def_charactor(ENEMY_LASERSPLOSH_3, "enemy_lasersplosh_3", 112, 102);
184 def_charactor(ASTEROID, "meteo", 128, 128); //inseki
185 def_charactor(ORBITMACHINE, "orbitmachine", 128, 64); //inseki no shita maruiyatsu
186 def_charactor(BOSS2_BODY, "boss2_body", 512, 512);
187 def_charactor(BOSS2_RIGHTSHOULDER, "boss2_rightshoulder", 256, 256);
188 def_charactor(BOSS2_LEFTSHOULDER, "boss2_leftshoulder", 256, 256);
189 def_charactor(BOSS2_RIGHTARM, "boss2_rightarm", 128, 256);
190 def_charactor(BOSS2_LEFTARM, "boss2_leftarm", 128, 256);
191 def_charactor(BOSS2_BATTERY, "boss2_battery", 128, 128);
192 def_charactor(BOSS2_OPENBATTERY, "boss2_openbattery", 256, 128);
193 def_charactor(BOSS2_BROKENHATCH, "boss2_brokenhatch", 128, 64);
194 def_charactor(BOSS2_DUMMY, "boss2_dummy", 128, 64);
195 def_charactor(BOSS2_RIGHTSHOULDERUP, "boss2_r_shoulderup", 256, 128);
196 def_charactor(BOSS2_LEFTSHOULDERUP, "boss2_left_s_up", 256, 128);
197 def_charactor(BOSS2_LEFTSHOULDERGIRD, "boss2_left_s_gird", 256, 256);
198 def_charactor(BOSS2_RIGHTARMBATTERY, "boss2_rightarm_b", 64, 64);
199 def_charactor(BOSS2_LEFTARMBATTERY, "boss2_leftarmbattery", 64, 64);
200 def_charactor(BOSS2_RIGHTHAND, "boss2_righthand", 64, 64);
201 def_charactor(BOSS2_RIGHTPALM, "boss2_rightpalm", 64, 64);
202 def_charactor(BOSS2_LEFTHAND, "boss2_lefthand", 64, 64);
203 def_charactor(BOSS2_LEFTPALM, "boss2_leftpalm", 64, 64);
204 def_charactor(PLAYER_LASERSPLOSH_0, "player_lasersplosh_0", 115, 91);
205 def_charactor(PLAYER_LASERSPLOSH_1, "player_lasersplosh_1", 133, 121);
206 def_charactor(PLAYER_LASERSPLOSH_2, "player_lasersplosh_2", 135, 119);
207 def_charactor(PLAYER_LASERSPLOSH_3, "player_lasersplosh_3", 131, 120);
208 def_charactor(BOSS_POWERGAUGE, "boss_powergauge", 69, 762);
209 def_charactor(BLACKHOLE, "blackhole", 128, 128);
210 def_charactor(FONT_DOYOUCONTINUE, "font_doyoucontinue", 512, 32);
211 def_charactor(FONT_ALLSTAGECLEAR, "font_allstageclear", 512, 32);
212 def_charactor(FONT_REST, "font_rest", 128, 32);
213 def_charactor(FONT_STAGE, "font_stage", 256, 32);
214 def_charactor(FONT_LINEOFZERO_000000, "font_000000", 256, 32);
215 def_charactor(FONT_LINEOFZERO_0000000, "font_0000000", 256, 32);
216 def_charactor(FONT_THANKYOU, "font_thankyou", 512, 32);
217 def_charactor(FONT_NYSOFT, "font_nysoft", 512, 32);
218 def_charactor(FONT_1997YGGDRASIL, "font_1997yggdrasil", 512, 32);
219 def_charactor(FONT_SUPERDANDY, "font_superdandy", 256, 64);
220 def_charactor(FONT_1997YAS_K, "font_1997yas_k", 512, 32);
221 def_charactor(GUNBATTERY, "gunbattery", 128, 128);
222 def_charactor(PURPLECORE, "purplecore", 128, 128);
223 def_charactor(SPACEFISH, "spacefish", 128, 128);
224 def_charactor(MISSILE, "missile", 64, 128);
225 def_charactor(BOSS3_BODY, "boss3_body", 256, 256);
226 def_charactor(BODD4_BODY, "boss_4", 256, 256);
227 def_charactor(TITLEFONT_SUPER, "titlefont_super", 256, 256);
228 def_charactor(TITLEFONT_BATTLE, "titlefont_battle", 256, 256);
229 def_charactor(TITLEFONT_EMPEROR, "titlefont_emperor", 256, 256);
230 def_charactor(GREENBARRIER, "greenbarrier", 130, 133);
231 def_charactor(REMAINDER, "remainder", 126, 34);
232 def_charactor(EARTH, "earth", 256, 256);
233 def_charactor(BOSS_CORPSE, "boss_corpse", 64, 256);
234 def_charactor(211, "rank_c_mins", 64, 32);
235 def_charactor(210, "rank_c", 64, 32);
236 def_charactor(209, "rank_c_pla", 64, 32);
237 def_charactor(208, "rank_b_mins", 64, 32);
238 def_charactor(207, "rank_b", 64, 32);
239 def_charactor(206, "rank_b_pla", 64, 32);
240 def_charactor(205, "rank_a_mins", 64, 32);
241 def_charactor(204, "rank_a", 64, 32);
242 def_charactor(203, "rank_a_pla", 64, 32);
243 def_charactor(202, "rank_s", 64, 32);
244 }
245
246 void
247 init_charactor(Viewer *sgroot, int w, int h)
248 {
249 create_sg(sgroot, w, h);
250 set_parameter();
39 251
40 for (int i = 0; i < ENEMY_NUM; i++) { 252 for (int i = 0; i < ENEMY_NUM; i++) {
41 charactor[i].root = (void*)sgroot->createSceneGraph(status[i].charano); 253 int char_id = enemy_status[i].char_id;
42 charactor[i].score = status[i].score; 254
43 charactor[i].vital = status[i].vital; 255 charactor[char_id].score = enemy_status[i].score;
256 charactor[char_id].vital = enemy_status[i].vital;
44 } 257 }
45 create_title_back(sgroot, w, h);
46 } 258 }
47 259
48 MainLoopPtr 260 MainLoopPtr
49 Dandy::init(Viewer *sgroot, int w, int h) 261 Dandy::init(Viewer *sgroot, int w, int h)
50 { 262 {
51 charactor = (ObjPropertyPtr)sgroot->manager->allocate(sizeof(ObjProperty)*ENEMY_NUM); 263 charactor = (ObjPropertyPtr)sgroot->manager->allocate(sizeof(ObjProperty)*CHAR_NUM);
52 init_charactor(sgroot, w, h); 264 init_charactor(sgroot, w, h);
265 init_game(sgroot, w, h);
266
53 return sgroot; 267 return sgroot;
54 } 268 }
55 269
56 extern Application * 270 extern Application *
57 application() { 271 application() {
63 static void TMend(TaskManager *manager); 277 static void TMend(TaskManager *manager);
64 278
65 int 279 int
66 TMmain(TaskManager *manager,int argc, char *argv[]) 280 TMmain(TaskManager *manager,int argc, char *argv[])
67 { 281 {
68 /*
69 if (init(argc, argv) < 0) {
70 return -1;
71 }
72 */
73 // Task Register
74 // ppe/task_init.cc
75 task_init(); 282 task_init();
76 /*
77 for (int i = 0; i < task; ++i) {
78 twice_init(manager);
79 }
80 */
81 //create_title(sgroot, w, h);
82 task_initialize(); 283 task_initialize();
83 manager->set_TMend(TMend); 284 manager->set_TMend(TMend);
285
84 return init(manager,argc, argv); 286 return init(manager,argc, argv);
85 } 287 }
86 288
87 void 289 void
88 TMend(TaskManager *manager) 290 TMend(TaskManager *manager)