Mercurial > hg > Members > tkaito > task_dandy
diff 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 |
line wrap: on
line diff
--- a/main.cc Tue Oct 26 17:28:56 2010 +0900 +++ b/main.cc Wed Nov 24 19:24:04 2010 +0900 @@ -1,7 +1,7 @@ #include "dandy.h" #define ENEMY_STATUS(charano,score,hardness) {charano,score,hardness} -const state status[50] = ENEMY_STATUS_TABLE; +const state enemy_status[ENEMY_NUM] = ENEMY_STATUS_TABLE; extern void task_init(void); @@ -12,6 +12,52 @@ -length Number of data (default DATA_NUM (Func.h))\n\ -count Number of task (default 1)\n"; +HTaskPtr +pad_alloc(Viewer *sgroot) +{ + HTaskPtr task = sgroot->tmanager->create_task(PAD_ALLOCATE); + void *pad = (void*)sgroottmp->getController(); + int size = sizeof(Pad); + + task->set_param(0, PAD_INPUT); + task->set_param(1, size); + task->add_inData(pad, size); + task->set_cpu(SPE_ANY); + task->spawn(); + + return task; +} + +HTaskPtr +pad_update(Viewer *sgroot) +{ + HTaskPtr task = sgroot->tmanager->create_task(PAD_UPDATE); + void *pad = (void*)sgroottmp->getController(); + int size = sizeof(Pad); + + task->set_param(0, PAD_INPUT); + task->set_param(1, size); + task->add_inData(pad, size); + task->set_cpu(SPE_ANY); + task->spawn(); + + return task; +} + +HTaskPtr +pad_free(Viewer *sgroot) +{ + HTaskPtr task = sgroot->tmanager->create_task(PAD_FREE); + void *pad = (void*)sgroottmp->getController(); + int size = sizeof(Pad); + + task->set_param(0, PAD_INPUT); + task->set_cpu(SPE_ANY); + task->spawn(); + + return task; +} + int init(int argc, char **argv) { @@ -26,8 +72,24 @@ return 0; } +//旧APIとの互換関数 void -init_charactor(Viewer *sgroot, int w, int h) +PutSprite(float x, float y, int number) +{ + char* name = charactor[number].name; + SceneGraphPtr object = sgroot->createSceneGraph(name); + + title->xyz[0] = x; + title->xyz[1] = y; + + charactor[number].x = x; + charactor[number].y = y; + charactor[number].flag = 0; + charactor[number].root = (void*)object; +} + +void +create_sg(Viewer *sgroot, int w, int h) { sgroot->createFromXMLfile("xml/mydandy.xml"); sgroot->createFromXMLfile("xml/greencrab.xml"); @@ -36,20 +98,172 @@ sgroot->createFromXMLfile("xml/bluebullet.xml"); sgroot->createFromXMLfile("xml/redbullet.xml"); sgroot->createFromXMLfile("xml/title2.xml"); +} + +void +def_charactor(int number, char *name, float w, float h) +{ + charactor[number].chara_id = number; + charactor[number].name = name; + charactor[number].width = w; + charactor[number].height = h; + charactor[number].mid_w = w / 2; + charactor[number].mid_h = h / 2; +} + +void +set_parameter() +{ + /** + * 1引数:キャラクターID; + * 2引数:キャラクター名; + * 3引数:幅 + * 4引数:高さ + */ + + def_charactor(PLAYER_IDLE, "player_idle", 128, 128); + def_charactor(PLAYER_LEFTMOVE, "player_leftmove", 128, 128); + def_charactor(PLAYER_TURNTOLEFT, "player_turntoleft", 128, 128); + def_charactor(PLAYER_TURNTORIGHT, "player_turntoright", 128, 128); + def_charactor(PLAYER_RIGHTMOVE, "player_rightmove", 128, 128); + def_charactor(BLUEBULLET_LEFT, "bulebullet_left", 45, 128); + def_charactor(BLUEBULLET_RIGHT, "blebullet_right", 38, 128); + def_charactor(REDBULLET, "redbullet", 128, 256); + def_charactor(LONGLASER, "longlaser", 64, 256); + def_charactor(GAUGE_PANEL, "gauge_panel", 128, 512); + def_charactor(OFFENSIVEPOWER_GAUGE, "offensivepower_gauge", 27, 220); + def_charactor(BURNER, "burner", 63, 122); + def_charactor(LOCKON_SIGHT, "lockon_sight", 64, 64); + //def_charactor(SPECIAL_LASERGAUGE, "special_lasergauge", 0, 0); + def_charactor(DIFFENSIVEPOWER_GAUGE, "diffensivepower_gauge", 20, 215); + def_charactor(GREENBULLET, "greenbullet", 128, 128); + def_charactor(BULEBARRIER, "bulebarrier", 128, 128); + //def_charactor(FONT_PLAYER_1, "font_player1", 128, 32); + //def_charactor(FONT_GAMEOVER, "font_gameover", 256, 32); + def_charactor(FONT_0, "font_0", 32, 32); + def_charactor(FONT_1, "font_1", 32, 32); + def_charactor(FONT_2, "font_2", 32, 32); + def_charactor(FONT_3, "font_3", 32, 32); + def_charactor(FONT_4, "font_4", 32, 32); + def_charactor(FONT_5, "font_5", 32, 32); + def_charactor(FONT_6, "font_6", 32, 32); + def_charactor(FONT_7, "font_7", 32, 32); + def_charactor(FONT_8, "font_8", 32, 32); + def_charactor(FONT_9, "font_9", 32, 32); + def_charactor(REDBOMB_ANIM_0, "redbomb_anim_0", 64, 64); + def_charactor(REDBOMB_ANIM_1, "redbomb_anim_1", 64, 64); + def_charactor(REDBOMB_ANIM_2, "redbomb_anim_2", 64, 64); + def_charactor(REDBOMB_ANIM_3, "redbomb_anim_3", 64, 64); + def_charactor(REDBOMB_ANIM_4, "redbomb_anim_4", 64, 64); + def_charactor(REDBOMB_ANIM_5, "redbomb_anim_5", 64, 64); + def_charactor(REDBOMB_ANIM_6, "redbomb_anim_6", 64, 64); + def_charactor(REDBOMB_ANIM_7, "redbomb_anim_7", 64, 64); + def_charactor(FONT_HIGE, "font_hige", 128, 32); + def_charactor(GREENBOMB_ANIM_0, "greenbomb_anim_0", 64, 64); + def_charactor(GREENBOMB_ANIM_1, "greenbomb_anim_1", 64, 64); + def_charactor(GREENBOMB_ANIM_2, "greenbomb_anim_2", 64, 64); + //def_charactor(GREENBOMB_ANIM_3, "greenbomb_anim_3", 64, 64); + def_charactor(GREENBOMB_ANIM_4, "greenbomb_anim_4", 64, 64); + def_charactor(GREENBOMB_ANIM_5, "greenbomb_anim_5", 64, 64); + def_charactor(GREENBOMB_ANIM_6, "greenbomb_anim_6", 64, 64); + def_charactor(GREENBOMB_ANIM_7, "greenbomb_anim_7", 64, 64); + def_charactor(INFLATION_GAUGE, "inflation_gauge", 64, 512); + def_charactor(INFLATION_METER, "inflation_meter", 32, 512); + def_charactor(ENEMY_GREENCRAB, "enemy_greenclab", 128, 128); + def_charactor(ENEMY_PLANE, "enemy_plane", 128, 128); + def_charactor(ENEMY_REDBULLET, "enemy_redbullet", 32, 32); + def_charactor(FONT_PUSHSTART, "font_pushstart", 512, 32); + def_charactor(BOSS1_ORGAN, "boss1_organ", 128, 256); + def_charactor(ENEMY_LASER, "enemy_laser", 64, 251); + def_charactor(ENEMY_BLUEBULLET, "enemy_bluebullet", 36, 28); + def_charactor(ENEMY_LIGHTNING, "enemy_lightning", 64, 252); + def_charactor(ENEMY_LASERSPLOSH_0, "enemy_lasersplosh_0", 126, 127); + def_charactor(ENEMY_LASERSPLOSH_1, "enemy_lasersplosh_1", 124, 119); + def_charactor(ENEMY_LASERSPLOSH_2, "enemy_lasersplosh_2", 126, 127); + def_charactor(ENEMY_LASERSPLOSH_3, "enemy_lasersplosh_3", 112, 102); + def_charactor(ASTEROID, "meteo", 128, 128); //inseki + def_charactor(ORBITMACHINE, "orbitmachine", 128, 64); //inseki no shita maruiyatsu + def_charactor(BOSS2_BODY, "boss2_body", 512, 512); + def_charactor(BOSS2_RIGHTSHOULDER, "boss2_rightshoulder", 256, 256); + def_charactor(BOSS2_LEFTSHOULDER, "boss2_leftshoulder", 256, 256); + def_charactor(BOSS2_RIGHTARM, "boss2_rightarm", 128, 256); + def_charactor(BOSS2_LEFTARM, "boss2_leftarm", 128, 256); + def_charactor(BOSS2_BATTERY, "boss2_battery", 128, 128); + def_charactor(BOSS2_OPENBATTERY, "boss2_openbattery", 256, 128); + def_charactor(BOSS2_BROKENHATCH, "boss2_brokenhatch", 128, 64); + def_charactor(BOSS2_DUMMY, "boss2_dummy", 128, 64); + def_charactor(BOSS2_RIGHTSHOULDERUP, "boss2_r_shoulderup", 256, 128); + def_charactor(BOSS2_LEFTSHOULDERUP, "boss2_left_s_up", 256, 128); + def_charactor(BOSS2_LEFTSHOULDERGIRD, "boss2_left_s_gird", 256, 256); + def_charactor(BOSS2_RIGHTARMBATTERY, "boss2_rightarm_b", 64, 64); + def_charactor(BOSS2_LEFTARMBATTERY, "boss2_leftarmbattery", 64, 64); + def_charactor(BOSS2_RIGHTHAND, "boss2_righthand", 64, 64); + def_charactor(BOSS2_RIGHTPALM, "boss2_rightpalm", 64, 64); + def_charactor(BOSS2_LEFTHAND, "boss2_lefthand", 64, 64); + def_charactor(BOSS2_LEFTPALM, "boss2_leftpalm", 64, 64); + def_charactor(PLAYER_LASERSPLOSH_0, "player_lasersplosh_0", 115, 91); + def_charactor(PLAYER_LASERSPLOSH_1, "player_lasersplosh_1", 133, 121); + def_charactor(PLAYER_LASERSPLOSH_2, "player_lasersplosh_2", 135, 119); + def_charactor(PLAYER_LASERSPLOSH_3, "player_lasersplosh_3", 131, 120); + def_charactor(BOSS_POWERGAUGE, "boss_powergauge", 69, 762); + def_charactor(BLACKHOLE, "blackhole", 128, 128); + def_charactor(FONT_DOYOUCONTINUE, "font_doyoucontinue", 512, 32); + def_charactor(FONT_ALLSTAGECLEAR, "font_allstageclear", 512, 32); + def_charactor(FONT_REST, "font_rest", 128, 32); + def_charactor(FONT_STAGE, "font_stage", 256, 32); + def_charactor(FONT_LINEOFZERO_000000, "font_000000", 256, 32); + def_charactor(FONT_LINEOFZERO_0000000, "font_0000000", 256, 32); + def_charactor(FONT_THANKYOU, "font_thankyou", 512, 32); + def_charactor(FONT_NYSOFT, "font_nysoft", 512, 32); + def_charactor(FONT_1997YGGDRASIL, "font_1997yggdrasil", 512, 32); + def_charactor(FONT_SUPERDANDY, "font_superdandy", 256, 64); + def_charactor(FONT_1997YAS_K, "font_1997yas_k", 512, 32); + def_charactor(GUNBATTERY, "gunbattery", 128, 128); + def_charactor(PURPLECORE, "purplecore", 128, 128); + def_charactor(SPACEFISH, "spacefish", 128, 128); + def_charactor(MISSILE, "missile", 64, 128); + def_charactor(BOSS3_BODY, "boss3_body", 256, 256); + def_charactor(BODD4_BODY, "boss_4", 256, 256); + def_charactor(TITLEFONT_SUPER, "titlefont_super", 256, 256); + def_charactor(TITLEFONT_BATTLE, "titlefont_battle", 256, 256); + def_charactor(TITLEFONT_EMPEROR, "titlefont_emperor", 256, 256); + def_charactor(GREENBARRIER, "greenbarrier", 130, 133); + def_charactor(REMAINDER, "remainder", 126, 34); + def_charactor(EARTH, "earth", 256, 256); + def_charactor(BOSS_CORPSE, "boss_corpse", 64, 256); + def_charactor(211, "rank_c_mins", 64, 32); + def_charactor(210, "rank_c", 64, 32); + def_charactor(209, "rank_c_pla", 64, 32); + def_charactor(208, "rank_b_mins", 64, 32); + def_charactor(207, "rank_b", 64, 32); + def_charactor(206, "rank_b_pla", 64, 32); + def_charactor(205, "rank_a_mins", 64, 32); + def_charactor(204, "rank_a", 64, 32); + def_charactor(203, "rank_a_pla", 64, 32); + def_charactor(202, "rank_s", 64, 32); +} + +void +init_charactor(Viewer *sgroot, int w, int h) +{ + create_sg(sgroot, w, h); + set_parameter(); for (int i = 0; i < ENEMY_NUM; i++) { - charactor[i].root = (void*)sgroot->createSceneGraph(status[i].charano); - charactor[i].score = status[i].score; - charactor[i].vital = status[i].vital; + int char_id = enemy_status[i].char_id; + + charactor[char_id].score = enemy_status[i].score; + charactor[char_id].vital = enemy_status[i].vital; } - create_title_back(sgroot, w, h); } MainLoopPtr Dandy::init(Viewer *sgroot, int w, int h) { - charactor = (ObjPropertyPtr)sgroot->manager->allocate(sizeof(ObjProperty)*ENEMY_NUM); + charactor = (ObjPropertyPtr)sgroot->manager->allocate(sizeof(ObjProperty)*CHAR_NUM); init_charactor(sgroot, w, h); + init_game(sgroot, w, h); + return sgroot; } @@ -65,22 +279,10 @@ int TMmain(TaskManager *manager,int argc, char *argv[]) { - /* - if (init(argc, argv) < 0) { - return -1; - } - */ - // Task Register - // ppe/task_init.cc task_init(); - /* - for (int i = 0; i < task; ++i) { - twice_init(manager); - } - */ - //create_title(sgroot, w, h); task_initialize(); manager->set_TMend(TMend); + return init(manager,argc, argv); }