/*STGの作り方 完成ソース*/

/*目次へ戻る*/ #include "DxLib.h" #include <time.h> #include <math.h> #define LEFT_LIMIT -320 #define RIGHT_LIMIT 320 #define TOP_LIMIT 240 #define BOTTOM_LIMIT -240 #define PLAYER_SHOT_MAX 20 #define DISP_ENEMY_MAX 20 #define STAGE_ENEMY_MAX 82 #define ENEMY_DATA_MAX 10 #define DISP_BOSS_MAX 5 #define STAGE_BOSS_MAX 5 #define BOSS_DATA_MAX 11 #define STAGE_MAX 3 void my_init_back_img(void); void my_init_img(void); void my_init_sound(void); void my_init_variable(void); void my_init_variable2(void); void my_init_player(void); void my_init_player2(void); void my_init_player_shot(void); void my_init_player_shot2(void); void my_init_enemy(void); void my_init_enemy2(void); void my_init_enemy_shot(void); void my_init_enemy_shot2(void); void my_init_boss(void); void my_init_boss2(void); void my_init_boss_shot(void); void my_init_boss_shot2(void); void my_init_exp_effect(void); void my_init_exp_effect2(void); void my_init_item(void); void my_init_item2(void); void my_init_barrier(void); void my_init_barrier2(void); void my_init_bomb(void); void my_init_bomb2(void); void my_set_player_shot(int ); void my_set_enemy(void); void my_set_enemy_shot(double,double,int,int); void my_set_boss(void); void my_set_boss_shot(double,double,int,int); void my_set_exp_effect(double,double,int); void my_set_item(double,double); void my_set_barrier(void); void my_set_bomb(void); void my_move_back(void); void my_move_player(void); void my_move_player_shot(void); void my_move_enemy(void); void my_move_enemy_shot(void); void my_move_boss(void); void my_move_boss_shot(void); void my_move_exp_effect(void); void my_move_item(void); void my_move_barrier(void); void my_move_bomb(void); int my_pythago_theorem(double,double,double,double,double,double); void my_collision_detection(void); void my_to_center(void); void my_calc_img(void); void my_draw_op(void); void my_draw_ed(void); void my_draw_stage_no(void); void my_draw_back(void); void my_draw_player(void); void my_draw_player_shot(void); void my_draw_enemy(void); void my_draw_enemy_shot(void); void my_draw_boss(void); void my_draw_boss_shot(void); void my_draw_exp_effect(void); void my_draw_item(void); void my_draw_barrier(void); void my_draw_bomb(void); void my_draw_variable(void); void my_draw_start(void); void my_draw_clear(void); void my_draw_gameover(void); void my_play_se_sound(int); void my_search_bgm_sound(void); void my_play_bgm_sound(int); void my_stop_bgm_sound(void); void my_gameover(void); void my_timer(void); int my_get_key(void); struct PLAYER{ double x, y; double draw_x, draw_y; int speed; int shot_type; int power; int life; double range; int bomb; }; struct PLAYER p1; struct PLAYER_SHOT{ double x[5]; double y[5]; double draw_x[5]; double draw_y[5]; int init_flag; int move_flag; int move_type; int flag[5]; double angle[5]; int max_bullet; int gamecount_point; double range; }; struct PLAYER_SHOT ps1[PLAYER_SHOT_MAX]; struct ENEMY{ int serial_no; int appear_point; double first_x, first_y; double x, y; double draw_x, draw_y; int init_flag; int move_flag; double angle; int move_type; int shot_type; int pattern; double var[5]; int gamecount_point; int power; double range; int item_flag; int img; }; struct ENEMY enemy[DISP_ENEMY_MAX]; struct ENEMY_SHOT{ double first_x; double first_y; double x[10]; double y[10]; double draw_x[10]; double draw_y[10]; double angle[10]; int init_flag; int move_flag; int move_type; int max_bullet; int gamecount_point[5]; double range; int enemy_no; }; struct ENEMY_SHOT enemy_shot[DISP_ENEMY_MAX * 2]; struct BOSS{ int serial_no; int appear_point; double first_x, first_y; double x, y; double draw_x, draw_y; int init_flag; int move_flag; double angle; int move_type; int shot_type; double var[5]; int gamecount_point[5]; int power; double range; int item_flag; int end_flag; int img; }; struct BOSS boss[DISP_BOSS_MAX]; struct BOSS_SHOT{ double first_x; double first_y; double x[300]; double y[300]; double draw_x[300]; double draw_y[300]; double angle[100]; double angle2[100]; int init_flag; int move_flag; int move_type; int max_bullet; int gamecount_point[5]; double range; int boss_no; }; struct BOSS_SHOT boss_shot[DISP_BOSS_MAX * 2]; struct EXP_EFFECT{ double first_x; double first_y; double x; double y; double draw_x; double draw_y; int init_flag; int move_flag; int move_type; int gamecount_point; }; struct EXP_EFFECT exp_effect[DISP_ENEMY_MAX]; struct ITEM{ double first_x; double first_y; double x; double y; double draw_x; double draw_y; int init_flag; int move_flag; int move_type; int gamecount_point; double range; }; struct ITEM item[DISP_ENEMY_MAX]; struct BARRIER{ double x, y; double draw_x, draw_y; int init_flag; int move_flag; double angle; int power; double range; }; struct BARRIER b1; struct BOMB{ int init_flag; int move_flag; int count; int flag; }; struct BOMB bo1; int ary_enemy_data[STAGE_MAX][STAGE_ENEMY_MAX * ENEMY_DATA_MAX] = { { 0,100,150,260,6,0,1,10,0,0, 1,120,150,260,6,0,1,10,0,0, 2,140,150,260,6,0,1,10,0,0, 3,160,150,260,6,0,1,10,0,0, 4,180,150,260,6,0,1,10,0,0, 5,200,150,260,6,0,1,10,0,0, 6,220,150,260,6,0,1,10,0,0, 7,240,150,260,6,0,1,10,0,0, 8,600,-150,260,6,0,1,10,0,0, 9,620,-150,260,6,0,1,10,0,0, 10,640,-150,260,6,0,1,10,0,0, 11,660,-150,260,6,0,1,10,0,0, 12,680,-150,260,6,0,1,10,0,0, 13,700,-150,260,6,0,1,10,0,0, 14,720,-150,260,6,0,1,10,0,0, 15,740,-150,260,6,0,1,10,0,0, 16,1100,150,260,6,0,1,10,0,0, 17,1120,150,260,6,0,1,10,0,0, 18,1140,150,260,6,0,1,10,0,0, 19,1160,150,260,6,0,1,10,0,0, 20,1180,150,260,6,0,1,10,0,0, 21,1200,150,260,6,0,1,10,0,0, 22,1220,150,260,6,0,1,10,0,0, 23,1240,150,260,6,0,1,10,1,0, 24,1600,0,260,7,2,1,10,0,1, 25,1700,0,260,7,2,1,10,0,1, 26,1800,0,260,7,2,1,10,0,1, 27,1900,0,260,7,2,1,10,0,1, 28,2000,0,260,7,2,1,10,0,1, 29,2100,0,260,7,2,1,10,0,1, 30,2200,0,260,7,2,1,10,0,1, 31,2300,0,260,7,2,1,10,0,1, 32,2400,-300,260,8,2,10,10,0,2, 33,2450,250,260,8,2,10,10,0,2, 34,2500,-200,260,8,2,10,10,0,2, 35,2550,-100,260,8,2,10,10,0,2, 36,2600,100,260,8,2,10,10,0,2, 37,2650,300,260,8,2,10,10,0,2, 38,2700,-150,260,8,2,10,10,0,2, 39,2750,150,260,8,2,10,10,0,2, 40,3300,150,260,6,0,1,10,0,0, 41,3320,150,260,6,0,1,10,0,0, 42,3340,150,260,6,0,1,10,0,0, 43,3360,150,260,6,0,1,10,0,0, 44,3380,150,260,6,0,1,10,0,0, 45,3400,150,260,6,0,1,10,0,0, 46,3420,150,260,6,0,1,10,0,0, 47,3440,150,260,6,0,1,10,0,0, 48,3800,-150,260,6,0,1,10,0,0, 49,3820,-150,260,6,0,1,10,0,0, 50,3840,-150,260,6,0,1,10,0,0, 51,3860,-150,260,6,0,1,10,0,0, 52,3880,-150,260,6,0,1,10,0,0, 53,3900,-150,260,6,0,1,10,0,0, 54,3920,-150,260,6,0,1,10,0,0, 55,3940,-150,260,6,0,1,10,1,0, 56,6600,-320,-260,9,2,1,10,0,3, 57,6650,320,-260,13,2,1,10,0,3, 58,6700,-320,-260,9,2,1,10,0,3, 59,6750,320,-260,13,2,1,10,0,3, 60,6800,-320,-260,9,2,1,10,0,3, 61,6850,320,-260,13,2,1,10,0,3, 62,6900,-320,-260,9,2,1,10,0,3, 63,6950,320,-260,13,2,1,10,0,3, 64,7100,-340,200,10,0,20,10,0,4, 65,7150,-150,260,10,0,20,10,0,4, 66,7200,0,260,10,0,20,10,0,4, 67,7250,100,260,10,0,20,10,0,4, 68,7300,340,200,10,0,20,10,0,4, 69,7350,150,260,10,0,20,10,0,4, 70,7400,0,260,10,0,20,10,0,4, 71,7450,-100,260,10,0,20,10,0,4, 72,8000,-300,260,11,2,10,10,0,5, 73,8050,300,260,11,2,10,10,0,5, 74,8100,-100,260,11,2,10,10,0,5, 75,8150,200,260,11,2,10,10,0,5, 76,8200,150,260,11,2,10,10,0,5, 77,8250,-150,260,11,2,10,10,0,5, 78,8300,0,260,11,2,10,10,0,5, 79,8350,100,260,11,2,10,10,1,5, 80,9500,0,260,3,3,10,10,0,6, 81,9500,0,260,12,3,10,10,0,6 }, { 0,100,150,260,6,0,1,10,0,0, 1,120,150,260,6,0,1,10,0,0, 2,140,150,260,6,0,1,10,0,0, 3,160,150,260,6,0,1,10,0,0, 4,180,150,260,6,0,1,10,0,0, 5,200,150,260,6,0,1,10,0,0, 6,220,150,260,6,0,1,10,0,0, 7,240,150,260,6,0,1,10,0,0, 8,600,-150,260,6,0,1,10,0,0, 9,620,-150,260,6,0,1,10,0,0, 10,640,-150,260,6,0,1,10,0,0, 11,660,-150,260,6,0,1,10,0,0, 12,680,-150,260,6,0,1,10,0,0, 13,700,-150,260,6,0,1,10,0,0, 14,720,-150,260,6,0,1,10,0,0, 15,740,-150,260,6,0,1,10,0,0, 16,1100,150,260,6,0,1,10,0,0, 17,1120,150,260,6,0,1,10,0,0, 18,1140,150,260,6,0,1,10,0,0, 19,1160,150,260,6,0,1,10,0,0, 20,1180,150,260,6,0,1,10,0,0, 21,1200,150,260,6,0,1,10,0,0, 22,1220,150,260,6,0,1,10,0,0, 23,1240,150,260,6,0,1,10,1,0, 24,1600,0,260,7,2,1,10,0,1, 25,1700,0,260,7,2,1,10,0,1, 26,1800,0,260,7,2,1,10,0,1, 27,1900,0,260,7,2,1,10,0,1, 28,2000,0,260,7,2,1,10,0,1, 29,2100,0,260,7,2,1,10,0,1, 30,2200,0,260,7,2,1,10,0,1, 31,2300,0,260,7,2,1,10,0,1, 32,2400,-300,260,8,2,10,10,0,2, 33,2450,250,260,8,2,10,10,0,2, 34,2500,-200,260,8,2,10,10,0,2, 35,2550,-100,260,8,2,10,10,0,2, 36,2600,100,260,8,2,10,10,0,2, 37,2650,300,260,8,2,10,10,0,2, 38,2700,-150,260,8,2,10,10,0,2, 39,2750,150,260,8,2,10,10,0,2, 40,3300,150,260,6,0,1,10,0,0, 41,3320,150,260,6,0,1,10,0,0, 42,3340,150,260,6,0,1,10,0,0, 43,3360,150,260,6,0,1,10,0,0, 44,3380,150,260,6,0,1,10,0,0, 45,3400,150,260,6,0,1,10,0,0, 46,3420,150,260,6,0,1,10,0,0, 47,3440,150,260,6,0,1,10,0,0, 48,3800,-150,260,6,0,1,10,0,0, 49,3820,-150,260,6,0,1,10,0,0, 50,3840,-150,260,6,0,1,10,0,0, 51,3860,-150,260,6,0,1,10,0,0, 52,3880,-150,260,6,0,1,10,0,0, 53,3900,-150,260,6,0,1,10,0,0, 54,3920,-150,260,6,0,1,10,0,0, 55,3940,-150,260,6,0,1,10,1,0, 56,6600,-320,-260,9,2,1,10,0,3, 57,6650,320,-260,13,2,1,10,0,3, 58,6700,-320,-260,9,2,1,10,0,3, 59,6750,320,-260,13,2,1,10,0,3, 60,6800,-320,-260,9,2,1,10,0,3, 61,6850,320,-260,13,2,1,10,0,3, 62,6900,-320,-260,9,2,1,10,0,3, 63,6950,320,-260,13,2,1,10,0,3, 64,7100,-340,200,10,0,20,10,0,4, 65,7150,-150,260,10,0,20,10,0,4, 66,7200,0,260,10,0,20,10,0,4, 67,7250,100,260,10,0,20,10,0,4, 68,7300,340,200,10,0,20,10,0,4, 69,7350,150,260,10,0,20,10,0,4, 70,7400,0,260,10,0,20,10,0,4, 71,7450,-100,260,10,0,20,10,0,4, 72,8000,-300,260,11,2,10,10,0,5, 73,8050,300,260,11,2,10,10,0,5, 74,8100,-100,260,11,2,10,10,0,5, 75,8150,200,260,11,2,10,10,0,5, 76,8200,150,260,11,2,10,10,0,5, 77,8250,-150,260,11,2,10,10,0,5, 78,8300,0,260,11,2,10,10,0,5, 79,8350,100,260,11,2,10,10,1,5, 80,9500,0,260,3,3,10,10,0,6, 81,9500,0,260,12,3,10,10,0,6 }, { 0,100,150,260,6,0,1,10,0,0, 1,120,150,260,6,0,1,10,0,0, 2,140,150,260,6,0,1,10,0,0, 3,160,150,260,6,0,1,10,0,0, 4,180,150,260,6,0,1,10,0,0, 5,200,150,260,6,0,1,10,0,0, 6,220,150,260,6,0,1,10,0,0, 7,240,150,260,6,0,1,10,0,0, 8,600,-150,260,6,0,1,10,0,0, 9,620,-150,260,6,0,1,10,0,0, 10,640,-150,260,6,0,1,10,0,0, 11,660,-150,260,6,0,1,10,0,0, 12,680,-150,260,6,0,1,10,0,0, 13,700,-150,260,6,0,1,10,0,0, 14,720,-150,260,6,0,1,10,0,0, 15,740,-150,260,6,0,1,10,0,0, 16,1100,150,260,6,0,1,10,0,0, 17,1120,150,260,6,0,1,10,0,0, 18,1140,150,260,6,0,1,10,0,0, 19,1160,150,260,6,0,1,10,0,0, 20,1180,150,260,6,0,1,10,0,0, 21,1200,150,260,6,0,1,10,0,0, 22,1220,150,260,6,0,1,10,0,0, 23,1240,150,260,6,0,1,10,1,0, 24,1600,0,260,7,2,1,10,0,1, 25,1700,0,260,7,2,1,10,0,1, 26,1800,0,260,7,2,1,10,0,1, 27,1900,0,260,7,2,1,10,0,1, 28,2000,0,260,7,2,1,10,0,1, 29,2100,0,260,7,2,1,10,0,1, 30,2200,0,260,7,2,1,10,0,1, 31,2300,0,260,7,2,1,10,0,1, 32,2400,-300,260,8,2,10,10,0,2, 33,2450,250,260,8,2,10,10,0,2, 34,2500,-200,260,8,2,10,10,0,2, 35,2550,-100,260,8,2,10,10,0,2, 36,2600,100,260,8,2,10,10,0,2, 37,2650,300,260,8,2,10,10,0,2, 38,2700,-150,260,8,2,10,10,0,2, 39,2750,150,260,8,2,10,10,0,2, 40,3300,150,260,6,0,1,10,0,0, 41,3320,150,260,6,0,1,10,0,0, 42,3340,150,260,6,0,1,10,0,0, 43,3360,150,260,6,0,1,10,0,0, 44,3380,150,260,6,0,1,10,0,0, 45,3400,150,260,6,0,1,10,0,0, 46,3420,150,260,6,0,1,10,0,0, 47,3440,150,260,6,0,1,10,0,0, 48,3800,-150,260,6,0,1,10,0,0, 49,3820,-150,260,6,0,1,10,0,0, 50,3840,-150,260,6,0,1,10,0,0, 51,3860,-150,260,6,0,1,10,0,0, 52,3880,-150,260,6,0,1,10,0,0, 53,3900,-150,260,6,0,1,10,0,0, 54,3920,-150,260,6,0,1,10,0,0, 55,3940,-150,260,6,0,1,10,1,0, 56,6600,-320,-260,9,2,1,10,0,3, 57,6650,320,-260,13,2,1,10,0,3, 58,6700,-320,-260,9,2,1,10,0,3, 59,6750,320,-260,13,2,1,10,0,3, 60,6800,-320,-260,9,2,1,10,0,3, 61,6850,320,-260,13,2,1,10,0,3, 62,6900,-320,-260,9,2,1,10,0,3, 63,6950,320,-260,13,2,1,10,0,3, 64,7100,-340,200,10,0,20,10,0,4, 65,7150,-150,260,10,0,20,10,0,4, 66,7200,0,260,10,0,20,10,0,4, 67,7250,100,260,10,0,20,10,0,4, 68,7300,340,200,10,0,20,10,0,4, 69,7350,150,260,10,0,20,10,0,4, 70,7400,0,260,10,0,20,10,0,4, 71,7450,-100,260,10,0,20,10,0,4, 72,8000,-300,260,11,2,10,10,0,5, 73,8050,300,260,11,2,10,10,0,5, 74,8100,-100,260,11,2,10,10,0,5, 75,8150,200,260,11,2,10,10,0,5, 76,8200,150,260,11,2,10,10,0,5, 77,8250,-150,260,11,2,10,10,0,5, 78,8300,0,260,11,2,10,10,0,5, 79,8350,100,260,11,2,10,10,1,5, 80,9500,0,260,3,3,10,10,0,6, 81,9500,0,260,12,3,10,10,0,6 } }; int ary_boss_data[STAGE_MAX][STAGE_BOSS_MAX * BOSS_DATA_MAX] = { { 1,4100,0,260,0,0,50,30,0,0,0, 2,4100,0,260,2,2,50,10,0,0,1, 3,10000,0,260,3,1,100,80,0,1,2, 4,10000,-20,280,3,2,100,10,0,0,1, 5,10000,20,280,3,2,100,10,0,0,1 }, { 1,4100,0,260,0,0,50,30,0,0,0, 2,4100,0,260,2,2,50,10,0,0,1, 3,10000,0,260,3,1,100,80,0,1,2, 4,10000,-20,280,3,2,100,10,0,0,1, 5,10000,20,280,3,2,100,10,0,0,1 }, { 1,4100,0,260,0,0,50,30,0,0,0, 2,4100,0,260,2,2,50,10,0,0,1, 3,10000,0,260,3,1,100,80,0,1,2, 4,10000,-20,280,3,2,100,10,0,0,1, 5,10000,20,280,3,2,100,10,0,0,1 } }; int key[256]; double back_img_x; double back_img_y; double back_img_speed; int back_img; int back_img2; int gamecount; int gamecount2; int gamecount3; int gamecount4; int gamecount5; int game_state; int stage_no; int gameover_flag; int gameclear_flag; int score; int Color_White; int Color_Red; int Color_Green; int op_img; int player_img_count; int player_chip[12]; int player_shot_img; int enemy_img_count; int enemy_chip[14]; int enemy_shot_img; int exp_effect_img_count; int exp_effect_chip[2]; int item_img; int boss_img_count; int boss_chip[6]; int boss_shot_img; int barrier_img; int se1; int se2; int se3; int se4; int se5; int se6; int bgm1; int bgm2; int bgm3; int bgm4; int bgm5; int bgm6; int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int){ ChangeWindowMode(TRUE); DxLib_Init(); SetDrawScreen(DX_SCREEN_BACK); my_init_back_img(); my_init_img(); my_init_sound(); my_init_variable(); my_init_player(); my_init_player_shot(); my_init_enemy(); my_init_enemy_shot(); my_init_boss(); my_init_boss_shot(); my_init_exp_effect(); my_init_item(); my_init_barrier(); my_init_bomb(); while (ScreenFlip()==0 && ProcessMessage()==0 && ClearDrawScreen()==0 && my_get_key()==0){ switch(game_state){ case 0: my_search_bgm_sound(); my_draw_op(); my_timer(); if(gamecount % 100 == 1){ gamecount2++; } if (key[KEY_INPUT_RETURN] == 1){ my_play_se_sound(0); gamecount = 0; gamecount2 = 0; game_state = 5; } break; case 5: my_search_bgm_sound(); my_init_variable2(); my_init_player2(); my_init_player_shot2(); my_init_enemy2(); my_init_enemy_shot2(); my_init_boss2(); my_init_boss_shot2(); my_init_exp_effect2(); my_init_item2(); my_init_barrier2(); my_init_bomb2(); game_state = 10; break; case 10: my_search_bgm_sound(); my_draw_stage_no(); if(gamecount == 300){ gamecount = 0; game_state = 15; } else{ my_timer(); } break; case 15: my_search_bgm_sound(); my_move_back(); my_move_barrier(); my_to_center(); my_calc_img(); my_draw_back(); my_draw_player(); my_draw_barrier(); if(gamecount2 % 2 == 1){ my_draw_start(); } my_timer(); if(gamecount == 200){ gamecount = 0; gamecount2 = 0; game_state = 20; } else{ if (gamecount % 10 == 1){ back_img_speed *= 0.9f; gamecount2++; } p1.y++; } break; case 20: my_search_bgm_sound(); my_set_enemy(); my_set_boss(); my_move_back(); my_move_player(); my_move_player_shot(); my_move_enemy(); my_move_enemy_shot(); my_move_boss(); my_move_boss_shot(); my_move_exp_effect(); my_move_item(); my_move_barrier(); my_move_bomb(); my_collision_detection(); my_to_center(); my_calc_img(); my_draw_back(); my_draw_player(); my_draw_player_shot(); my_draw_enemy(); my_draw_enemy_shot(); my_draw_boss(); my_draw_boss_shot(); my_draw_exp_effect(); my_draw_item(); my_draw_barrier(); my_draw_bomb(); my_draw_variable(); my_draw_gameover(); my_gameover(); my_timer(); break; case 25: my_search_bgm_sound(); my_move_back(); my_move_barrier(); my_to_center(); my_calc_img(); my_draw_back(); my_draw_player(); my_draw_barrier(); if(gamecount2 % 2 == 1){ my_draw_clear(); } my_timer(); if(gamecount == 500){ if(stage_no == STAGE_MAX){ gamecount = 0; gamecount2 = 0; game_state = 30; } else{ gamecount = 0; gamecount2 = 0; game_state = 5; } } else{ if (gamecount % 10 == 1){ back_img_speed *= 1.1f; gamecount2++; } p1.y++; } break; case 30: my_search_bgm_sound(); my_draw_ed(); my_timer(); break; default: break; } } DxLib_End(); return 0; } void my_init_back_img(){ back_img = LoadGraph("../back_img.png"); } void my_init_img(){ op_img = LoadGraph("../op_img.jpg"); LoadDivGraph("../player_chip.png",12,4,3,70,70,player_chip); player_shot_img = LoadGraph("../player_shot_img.png"); LoadDivGraph("../enemy_chip.png",14,2,7,70,70,enemy_chip); enemy_shot_img = LoadGraph("../enemy_shot_img.png"); LoadDivGraph("../exp_effect_chip.png",2,2,1,70,70,exp_effect_chip); LoadDivGraph("../boss_chip.png",6,2,3,300,300,boss_chip); item_img = LoadGraph("../item_img.png"); boss_shot_img = LoadGraph("../boss_shot_img.png"); barrier_img = LoadGraph("../barrier_img.png"); back_img2 = LoadGraph("../back_img2.jpg"); } void my_init_sound(){ se1 = LoadSoundMem("../se1.ogg"); se2 = LoadSoundMem("../se2.ogg"); se3 = LoadSoundMem("../se3.ogg"); se4 = LoadSoundMem("../se4.ogg"); se5 = LoadSoundMem("../se5.ogg"); se6 = LoadSoundMem("../se6.ogg"); bgm1 = LoadSoundMem("../bgm1.ogg"); bgm2 = LoadSoundMem("../bgm2.ogg"); bgm3 = LoadSoundMem("../bgm3.ogg"); bgm4 = LoadSoundMem("../bgm4.ogg"); bgm5 = LoadSoundMem("../bgm5.ogg"); bgm6 = LoadSoundMem("../bgm6.ogg"); } void my_init_variable(){ gamecount = 0; gamecount2 = 0; gamecount3 = 0; game_state = 0; stage_no = 0; gameover_flag = 0; gameclear_flag = 0; score = 0; Color_White = GetColor(255, 255, 255); Color_Red = GetColor(255, 0, 0); Color_Green = GetColor(0, 255, 0); back_img_x = -320; back_img_y = 0; back_img_speed = 8; player_img_count = 0; enemy_img_count = 0; boss_img_count = 0; exp_effect_img_count = 0; gamecount4 = 0; gamecount5 = 0; } void my_init_variable2(){ gamecount = 0; gamecount2 = 0; gamecount3 = 0; gameover_flag = 0; gameclear_flag = 0; back_img_x = -320; back_img_y = 0; back_img_speed = 8; srand((unsigned)time(NULL)); } void my_init_player(){ p1.x = 0; p1.y = -300; p1.draw_x = 0; p1.draw_y = 0; p1.speed = 4; p1.shot_type = 0; p1.power = 100; p1.life = 3; p1.range = 10; p1.bomb = 3; } void my_init_player2(){ p1.x = 0; p1.y = -300; p1.power = 100; p1.bomb = 3; } void my_init_player_shot(){ for(int i = 0;i < PLAYER_SHOT_MAX;i++){ ps1[i].init_flag = 0; ps1[i].move_flag = 0; ps1[i].move_type = 0; ps1[i].max_bullet = 0; ps1[i].gamecount_point = 0; ps1[i].range = 10; for(int j = 0;j < 5;j++){ ps1[i].x[j] = 0; ps1[i].y[j] = 0; ps1[i].draw_x[j] = 0; ps1[i].draw_y[j] = 0; ps1[i].flag[j] = 0; ps1[i].angle[j] = 0; } } } void my_init_player_shot2(){ for(int i = 0;i < PLAYER_SHOT_MAX;i++){ ps1[i].init_flag = 0; ps1[i].move_flag = 0; } } void my_init_enemy(){ for (int i = 0; i < DISP_ENEMY_MAX; i++){ enemy[i].serial_no = 0; enemy[i].appear_point = 0; enemy[i].first_x = 0; enemy[i].first_y = 0; enemy[i].x = 0; enemy[i].y = 0; enemy[i].draw_x = 0; enemy[i].draw_y = 0; enemy[i].init_flag = 0; enemy[i].move_flag = 0; enemy[i].angle = 0; enemy[i].move_type = 0; enemy[i].shot_type = 0; enemy[i].pattern = 0; enemy[i].gamecount_point = 0; enemy[i].power = 0; enemy[i].range = 0; enemy[i].item_flag = 0; for(int j = 0;j < 5;j++){ enemy[i].var[j] = 0; } } } void my_init_enemy2(){ for (int i = 0; i < DISP_ENEMY_MAX; i++){ enemy[i].init_flag = 0; enemy[i].move_flag = 0; } } void my_init_enemy_shot(){ for (int i = 0; i < DISP_ENEMY_MAX * 2; i++){ enemy_shot[i].first_x = 0; enemy_shot[i].first_y = 0; enemy_shot[i].init_flag = 0; enemy_shot[i].move_flag = 0; enemy_shot[i].move_type = 0; enemy_shot[i].max_bullet = 0; enemy_shot[i].range = 10; enemy_shot[i].enemy_no = 0; for(int j = 0;j < 10;j++){ enemy_shot[i].x[j] = 0; enemy_shot[i].y[j] = 0; enemy_shot[i].draw_x[j] = 0; enemy_shot[i].draw_y[j] = 0; enemy_shot[i].angle[j] = 0; } for(int j = 0;j < 5;j++){ enemy_shot[i].gamecount_point[j] = 0; } } } void my_init_enemy_shot2(){ for (int i = 0; i < DISP_ENEMY_MAX * 2; i++){ enemy_shot[i].init_flag = 0; enemy_shot[i].move_flag = 0; } } void my_init_boss(){ for (int i = 0; i < DISP_BOSS_MAX; i++){ boss[i].serial_no = 0; boss[i].appear_point = 0; boss[i].first_x = 0; boss[i].first_y = 0; boss[i].x = 0; boss[i].y = 0; boss[i].draw_x = 0; boss[i].draw_y = 0; boss[i].init_flag = 0; boss[i].move_flag = 0; boss[i].angle = 0; boss[i].move_type = 0; boss[i].shot_type = 0; boss[i].power = 0; boss[i].range = 0; boss[i].item_flag = 0; boss[i].end_flag = 0; for(int j = 0;j < 5;j++){ boss[i].gamecount_point[j] = 0; } } } void my_init_boss2(){ for (int i = 0; i < DISP_BOSS_MAX; i++){ boss[i].init_flag = 0; boss[i].move_flag = 0; } } void my_init_boss_shot(){ for (int i = 0; i < DISP_BOSS_MAX * 2; i++){ boss_shot[i].first_x = 0; boss_shot[i].first_y = 0; boss_shot[i].init_flag = 0; boss_shot[i].move_flag = 0; boss_shot[i].move_type = 0; boss_shot[i].max_bullet = 0; boss_shot[i].range = 10; boss_shot[i].boss_no = 0; for(int j = 0;j < 300;j++){ boss_shot[i].x[j] = 0; boss_shot[i].y[j] = 0; boss_shot[i].draw_x[j] = 0; boss_shot[i].draw_y[j] = 0; } for(int j = 0;j < 100;j++){ boss_shot[i].angle[j] = 0; boss_shot[i].angle2[j] = 0; } for(int j = 0;j < 5;j++){ boss_shot[i].gamecount_point[j] = 0; } } } void my_init_boss_shot2(){ for (int i = 0; i < DISP_BOSS_MAX * 2; i++){ boss_shot[i].init_flag = 0; boss_shot[i].move_flag = 0; } } void my_init_exp_effect(){ for (int i = 0; i < DISP_ENEMY_MAX; i++){ exp_effect[i].first_x = 0; exp_effect[i].first_y = 0; exp_effect[i].x = 0; exp_effect[i].y = 0; exp_effect[i].draw_x = 0; exp_effect[i].draw_y = 0; exp_effect[i].init_flag = 0; exp_effect[i].move_flag = 0; exp_effect[i].move_type = 0; exp_effect[i].gamecount_point = 0; } } void my_init_exp_effect2(){ for (int i = 0; i < DISP_ENEMY_MAX; i++){ exp_effect[i].init_flag = 0; exp_effect[i].move_flag = 0; } } void my_init_item(){ for (int i = 0; i < DISP_ENEMY_MAX; i++){ item[i].first_x = 0; item[i].first_y = 0; item[i].x = 0; item[i].y = 0; item[i].draw_x = 0; item[i].draw_y = 0; item[i].init_flag = 0; item[i].move_flag = 0; item[i].move_type = 0; item[i].range = 10; item[i].gamecount_point = 0; } } void my_init_item2(){ for (int i = 0; i < DISP_ENEMY_MAX; i++){ item[i].init_flag = 0; item[i].move_flag = 0; } } void my_init_barrier(){ b1.x = 0; b1.y = 0; b1.draw_x = 0; b1.draw_y = 0; b1.init_flag = 0; b1.move_flag = 0; b1.angle = 0; b1.power = 30; b1.range = 10; } void my_init_barrier2(){ b1.power = 30; } void my_init_bomb(){ bo1.init_flag = 0; bo1.move_flag = 0; bo1.count = 0; bo1.flag = 0; } void my_init_bomb2(){ bo1.init_flag = 0; bo1.move_flag = 0; } void my_move_back(){ if (key[KEY_INPUT_RIGHT] >= 1 && p1.x < RIGHT_LIMIT && game_state == 20){ back_img_x -= 0.5f; } if (key[KEY_INPUT_LEFT] >= 1 && p1.x > LEFT_LIMIT && game_state == 20){ back_img_x += 0.5f; } back_img_y += back_img_speed; if (back_img_y > 480){ back_img_y = 0; } } void my_move_player(){ if(p1.power > 0){ if (key[KEY_INPUT_RIGHT] >= 1 && p1.x < RIGHT_LIMIT){ p1.x += p1.speed; } if (key[KEY_INPUT_DOWN] >= 1 && p1.y > BOTTOM_LIMIT){ p1.y -= p1.speed; } if (key[KEY_INPUT_LEFT] >= 1 && p1.x > LEFT_LIMIT){ p1.x -= p1.speed; } if (key[KEY_INPUT_UP] >= 1 && p1.y < TOP_LIMIT){ p1.y += p1.speed; } if (key[KEY_INPUT_Z] % 8 == 1){ my_set_player_shot(p1.shot_type); my_play_se_sound(1); } if (key[KEY_INPUT_X] == 1 && p1.bomb > 0){ my_set_bomb(); my_play_se_sound(5); } } } void my_set_player_shot(int shot_type){ for(int i = 0;i < PLAYER_SHOT_MAX;i++){ if(ps1[i].move_flag == 0){ ps1[i].move_type = shot_type; ps1[i].move_flag = 1; break; } } } void my_move_player_shot(){ for(int i = 0;i < PLAYER_SHOT_MAX;i++){ if(ps1[i].move_flag == 1){ switch(ps1[i].move_type){ case 0: if(ps1[i].init_flag == 0){ ps1[i].max_bullet = 1; for(int j = 0;j < ps1[i].max_bullet;j++){ ps1[i].x[j] = p1.x; ps1[i].y[j] = p1.y; ps1[i].flag[j] = 1; } ps1[i].gamecount_point = gamecount; ps1[i].init_flag = 1; } else{ if(gamecount < ps1[i].gamecount_point + 100){ for(int j = 0;j < ps1[i].max_bullet;j++){ ps1[i].y[j] += 8; } } else{ ps1[i].move_flag = 0; ps1[i].init_flag = 0; } } break; case 1: if(ps1[i].init_flag == 0){ ps1[i].max_bullet = 2; for(int j = 0;j < ps1[i].max_bullet;j++){ ps1[i].x[j] = p1.x; ps1[i].y[j] = p1.y; ps1[i].flag[j] = 1; } ps1[i].x[0] += 10; ps1[i].x[1] -= 10; ps1[i].gamecount_point = gamecount; ps1[i].init_flag = 1; } else{ if(gamecount < ps1[i].gamecount_point + 100){ for(int j = 0;j < ps1[i].max_bullet;j++){ ps1[i].y[j] += 8; } } else{ ps1[i].move_flag = 0; ps1[i].init_flag = 0; } } break; case 2: if(ps1[i].init_flag == 0){ ps1[i].max_bullet = 5; for(int j = 0;j < ps1[i].max_bullet;j++){ ps1[i].x[j] = p1.x; ps1[i].y[j] = p1.y; ps1[i].flag[j] = 1; } ps1[i].angle[0] = 90 * (DX_PI / 180); ps1[i].angle[1] = 135 * (DX_PI / 180); ps1[i].angle[2] = 225 * (DX_PI / 180); ps1[i].angle[3] = 315 * (DX_PI / 180); ps1[i].angle[4] = 45 * (DX_PI / 180); ps1[i].gamecount_point = gamecount; ps1[i].init_flag = 1; } else{ if(gamecount < ps1[i].gamecount_point + 100){ for(int j = 0;j < ps1[i].max_bullet;j++){ ps1[i].x[j] += cos(ps1[i].angle[j]) * 8; ps1[i].y[j] += sin(ps1[i].angle[j]) * 8; } } else{ ps1[i].move_flag = 0; ps1[i].init_flag = 0; } } break; default: break; } } } } void my_set_enemy(){ for (int i = 0; i < STAGE_ENEMY_MAX; i++){ if (ary_enemy_data[stage_no][(i * ENEMY_DATA_MAX) + 1] == gamecount){ for (int j = 0; j < DISP_ENEMY_MAX; j++){ if (enemy[j].move_flag == 0){ enemy[j].move_flag = 1; enemy[j].serial_no = ary_enemy_data[stage_no][i * ENEMY_DATA_MAX]; enemy[j].appear_point = ary_enemy_data[stage_no][(i * ENEMY_DATA_MAX) + 1]; enemy[j].first_x = ary_enemy_data[stage_no][(i * ENEMY_DATA_MAX) + 2]; enemy[j].first_y = ary_enemy_data[stage_no][(i * ENEMY_DATA_MAX) + 3]; enemy[j].move_type = ary_enemy_data[stage_no][(i * ENEMY_DATA_MAX) + 4]; enemy[j].shot_type = ary_enemy_data[stage_no][(i * ENEMY_DATA_MAX) + 5]; enemy[j].power = ary_enemy_data[stage_no][(i * ENEMY_DATA_MAX) + 6]; enemy[j].range = ary_enemy_data[stage_no][(i * ENEMY_DATA_MAX) + 7]; enemy[j].item_flag = ary_enemy_data[stage_no][(i * ENEMY_DATA_MAX) + 8]; enemy[j].img = ary_enemy_data[stage_no][(i * ENEMY_DATA_MAX) + 9]; break; } } } } } void my_move_enemy(){ for (int i = 0; i < DISP_ENEMY_MAX; i++){ if (enemy[i].move_flag == 1){ switch (enemy[i].move_type){ case 0: if (enemy[i].init_flag == 0){ enemy[i].x = enemy[i].first_x; enemy[i].y = 260; enemy[i].gamecount_point = gamecount; enemy[i].init_flag = 1; } else{ if (gamecount < enemy[i].gamecount_point + 500){ if (gamecount < enemy[i].gamecount_point + 220){ enemy[i].y--; } if (gamecount == enemy[i].gamecount_point + 240){ my_set_enemy_shot(enemy[i].x,enemy[i].y,enemy[i].shot_type,i); } if (gamecount > enemy[i].gamecount_point + 260){ enemy[i].y++; } } else{ enemy[i].move_flag = 0; enemy[i].init_flag = 0; } } break; case 1: if (enemy[i].init_flag == 0){ enemy[i].x = 0; enemy[i].y = 260; enemy[i].gamecount_point = gamecount; enemy[i].init_flag = 1; } else{ if (gamecount < enemy[i].gamecount_point + 600){ if (gamecount < enemy[i].gamecount_point + 260){ enemy[i].y--; } if (gamecount == enemy[i].gamecount_point + 280){ my_set_enemy_shot(enemy[i].x,enemy[i].y,enemy[i].shot_type,i); } if (gamecount > enemy[i].gamecount_point + 300){ enemy[i].x++; enemy[i].y = 1 * enemy[i].x; } } else{ enemy[i].move_flag = 0; enemy[i].init_flag = 0; } } break; case 2: if (enemy[i].init_flag == 0){ enemy[i].x = 100; enemy[i].y = 260; enemy[i].gamecount_point = gamecount; enemy[i].init_flag = 1; } else{ if (gamecount < enemy[i].gamecount_point + 500){ if (gamecount < enemy[i].gamecount_point + 260){ enemy[i].y--; } if (gamecount == enemy[i].gamecount_point + 270){ my_set_enemy_shot(enemy[i].x,enemy[i].y,enemy[i].shot_type,i); } if (gamecount > enemy[i].gamecount_point + 280){ enemy[i].x++; enemy[i].y = (2 * enemy[i].x) - 200; } } else{ enemy[i].move_flag = 0; enemy[i].init_flag = 0; } } break; case 3: if (enemy[i].init_flag == 0){ enemy[i].x = 0; enemy[i].y = 260; enemy[i].gamecount_point = gamecount; enemy[i].init_flag = 1; } else{ if (gamecount < enemy[i].gamecount_point + 500){ if (gamecount < enemy[i].gamecount_point + 100){ enemy[i].x = enemy[i].x + 2; enemy[i].y = 6000 / enemy[i].x; } if (gamecount == enemy[i].gamecount_point + 110){ my_set_enemy_shot(enemy[i].x,enemy[i].y,enemy[i].shot_type,i); } if (gamecount > enemy[i].gamecount_point + 160){ enemy[i].x = enemy[i].x + 2; enemy[i].y = 6000 / enemy[i].x; } } else{ enemy[i].move_flag = 0; enemy[i].init_flag = 0; } } break; case 4: if (enemy[i].init_flag == 0){ enemy[i].x = -155; enemy[i].y = 260; enemy[i].gamecount_point = gamecount; enemy[i].init_flag = 1; } else{ if (gamecount < enemy[i].gamecount_point + 500){ if (gamecount < enemy[i].gamecount_point + 90){ enemy[i].x++; enemy[i].y = 0.01 * (enemy[i].x * enemy[i].x); } if (gamecount == enemy[i].gamecount_point + 100){ my_set_enemy_shot(enemy[i].x,enemy[i].y,enemy[i].shot_type,i); } if (gamecount > enemy[i].gamecount_point + 200){ enemy[i].x++; enemy[i].y = 0.01 * (enemy[i].x * enemy[i].x); } } else{ enemy[i].move_flag = 0; enemy[i].init_flag = 0; } } break; case 5: if (enemy[i].init_flag == 0){ enemy[i].x = enemy[i].first_x; enemy[i].y = 260; enemy[i].gamecount_point = gamecount; enemy[i].init_flag = 1; } else{ if (gamecount < enemy[i].gamecount_point + 600){ if (key[KEY_INPUT_RIGHT] >= 1 && p1.x < RIGHT_LIMIT){ enemy[i].x -= 0.5f; } if (key[KEY_INPUT_LEFT] >= 1 && p1.x > LEFT_LIMIT){ enemy[i].x += 0.5f; } enemy[i].y -= back_img_speed; if (gamecount % 200 == 1){ my_set_enemy_shot(enemy[i].x,enemy[i].y,enemy[i].shot_type,i); } } else{ enemy[i].move_flag = 0; enemy[i].init_flag = 0; } } break; case 6: if (enemy[i].init_flag == 0){ enemy[i].x = enemy[i].first_x; enemy[i].y = 260; enemy[i].angle = 0; enemy[i].gamecount_point = gamecount; enemy[i].init_flag = 1; } else{ if (gamecount < enemy[i].gamecount_point + 600){ if (gamecount < enemy[i].gamecount_point + 450){ enemy[i].angle += 2; enemy[i].x = (sin(enemy[i].angle * (DX_PI / 180)) * 100) + enemy[i].first_x; enemy[i].y -= 0.5f; } if (gamecount > enemy[i].gamecount_point + 450){ enemy[i].y += 4; } } else{ enemy[i].move_flag = 0; enemy[i].init_flag = 0; } } break; case 7: if (enemy[i].init_flag == 0){ enemy[i].x = -320; enemy[i].y = 260; enemy[i].var[0] = rand() % 400; enemy[i].var[1] = rand() % 50; enemy[i].gamecount_point = gamecount; enemy[i].init_flag = 1; } else{ if (gamecount < enemy[i].gamecount_point + 400){ enemy[i].x += 2; enemy[i].y = 0.02 * ((enemy[i].x + (200 - enemy[i].var[0])) * (enemy[i].x + (200 - enemy[i].var[0]))) - enemy[i].var[1]; if (enemy[i].x == (((int)(-(200 - enemy[i].var[0])) / 2)) * 2){ my_set_enemy_shot(enemy[i].x, enemy[i].y, enemy[i].shot_type,i); } } else{ enemy[i].move_flag = 0; enemy[i].init_flag = 0; } } break; case 8: if (enemy[i].init_flag == 0){ enemy[i].x = enemy[i].first_x; enemy[i].y = 260; enemy[i].pattern = (rand() % 4) * 2; enemy[i].gamecount_point = gamecount; enemy[i].init_flag = 1; } else{ if (gamecount < enemy[i].gamecount_point + 1200){ switch (enemy[i].pattern % 8){ case 0: enemy[i].x += 2; break; case 1: enemy[i].x -= 2; break; case 2: enemy[i].y += 2; break; case 3: enemy[i].y -= 2; break; case 4: enemy[i].x -= 2; break; case 5: enemy[i].x += 2; break; case 6: enemy[i].y -= 2; break; case 7: enemy[i].y += 2; break; default: break; } enemy[i].y -= 0.5f; if(gamecount % 20 == 1){ enemy[i].pattern++; } if ((gamecount - enemy[i].gamecount_point) % 200 == 1){ my_set_enemy_shot(enemy[i].x,enemy[i].y,enemy[i].shot_type,i); } } else{ enemy[i].move_flag = 0; enemy[i].init_flag = 0; } } break; case 9: if (enemy[i].init_flag == 0){ enemy[i].x = -320; enemy[i].y = -260; enemy[i].angle = atan2(p1.y - enemy[i].y, p1.x - enemy[i].x); enemy[i].pattern = 0; enemy[i].gamecount_point = gamecount; enemy[i].init_flag = 1; } else{ if (gamecount < enemy[i].gamecount_point + 800){ if (gamecount < enemy[i].gamecount_point + 50){ enemy[i].x++; enemy[i].y = 0.1 * ((enemy[i].x + 320) * (enemy[i].x + 320)) - 240; } if (gamecount > enemy[i].gamecount_point + 50 && gamecount < enemy[i].gamecount_point + 500){ switch (enemy[i].pattern % 2){ case 0: enemy[i].x += cos(enemy[i].angle) * 2; enemy[i].y += sin(enemy[i].angle) * 2; break; case 1: break; default: break; } if (gamecount % 12 == 0){ enemy[i].pattern++; enemy[i].angle = atan2(p1.y - enemy[i].y, p1.x - enemy[i].x); } if ((gamecount - enemy[i].gamecount_point) % 200 == 1){ my_set_enemy_shot(enemy[i].x,enemy[i].y,enemy[i].shot_type,i); } } if (gamecount > enemy[i].gamecount_point + 500){ enemy[i].y += 4; } } else{ enemy[i].move_flag = 0; enemy[i].init_flag = 0; } } break; case 10: if (enemy[i].init_flag == 0){ enemy[i].x = enemy[i].first_x; enemy[i].y = enemy[i].first_y; enemy[i].angle = atan2(p1.y - enemy[i].y, p1.x - enemy[i].x); enemy[i].gamecount_point = gamecount; enemy[i].init_flag = 1; } else{ if (gamecount < enemy[i].gamecount_point + 2000){ enemy[i].x += cos(enemy[i].angle) * 0.5f; enemy[i].y += sin(enemy[i].angle) * 0.5f; if (gamecount % 12 == 0){ enemy[i].angle = atan2(p1.y - enemy[i].y, p1.x - enemy[i].x); } if (gamecount > enemy[i].gamecount_point + 1000){ enemy[i].y--; } } else{ enemy[i].move_flag = 0; enemy[i].init_flag = 0; } } break; case 11: if (enemy[i].init_flag == 0){ enemy[i].var[0] = enemy[i].first_x; enemy[i].var[1] = 260; enemy[i].x = enemy[i].var[0]; enemy[i].y = enemy[i].var[1]; enemy[i].pattern = rand() % 4; enemy[i].var[2] = 0; enemy[i].gamecount_point = gamecount; enemy[i].init_flag = 1; } else{ if (gamecount < enemy[i].gamecount_point + 1500){ switch (enemy[i].pattern % 4){ case 0: enemy[i].x = enemy[i].var[0] + ((sin(DX_PI / 60 * enemy[i].var[2] - (DX_PI * 0.5f)) + 1) / 2) * 100; enemy[i].y = enemy[i].var[1] + ((sin(DX_PI / 60 * enemy[i].var[2] - (DX_PI * 0.5f)) + 1) / 2) * 100; break; case 1: enemy[i].x = (enemy[i].var[0] + 100) - ((sin(DX_PI / 60 * enemy[i].var[2] - (DX_PI * 0.5f)) + 1) / 2) * 100; enemy[i].y = (enemy[i].var[1] + 100) + ((sin(DX_PI / 60 * enemy[i].var[2] - (DX_PI * 0.5f)) + 1) / 2) * 100; break; case 2: enemy[i].x = enemy[i].var[0] - ((sin(DX_PI / 60 * enemy[i].var[2] - (DX_PI * 0.5f)) + 1) / 2) * 100; enemy[i].y = (enemy[i].var[1] + 200) - ((sin(DX_PI / 60 * enemy[i].var[2] - (DX_PI * 0.5f)) + 1) / 2) * 100; break; case 3: enemy[i].x = (enemy[i].var[0] - 100) + ((sin(DX_PI / 60 * enemy[i].var[2] - (DX_PI * 0.5f)) + 1) / 2) * 100; enemy[i].y = (enemy[i].var[1] + 100) - ((sin(DX_PI / 60 * enemy[i].var[2] - (DX_PI * 0.5f)) + 1) / 2) * 100; break; default: break; } if (enemy[i].var[2] < 60){ enemy[i].var[2]++; } else{ enemy[i].var[2] = 0; enemy[i].pattern++; } enemy[i].var[1] -= 0.5f; if ((gamecount - enemy[i].gamecount_point) % 200 == 1){ my_set_enemy_shot(enemy[i].x,enemy[i].y,enemy[i].shot_type,i); } } else{ enemy[i].move_flag = 0; enemy[i].init_flag = 0; } } break; case 12: if (enemy[i].init_flag == 0){ enemy[i].x = 0; enemy[i].y = 240; enemy[i].gamecount_point = gamecount; enemy[i].init_flag = 1; } else{ if (gamecount < enemy[i].gamecount_point + 500){ if (gamecount < enemy[i].gamecount_point + 100){ enemy[i].x = enemy[i].x - 2; enemy[i].y = -6000 / enemy[i].x; } if (gamecount == enemy[i].gamecount_point + 110){ my_set_enemy_shot(enemy[i].x,enemy[i].y,enemy[i].shot_type,i); } if (gamecount > enemy[i].gamecount_point + 160){ enemy[i].x = enemy[i].x - 2; enemy[i].y = -6000 / enemy[i].x; } } else{ enemy[i].move_flag = 0; enemy[i].init_flag = 0; } } break; case 13: if (enemy[i].init_flag == 0){ enemy[i].x = 320; enemy[i].y = -260; enemy[i].angle = atan2(p1.y - enemy[i].y, p1.x - enemy[i].x); enemy[i].pattern = 0; enemy[i].gamecount_point = gamecount; enemy[i].init_flag = 1; } else{ if (gamecount < enemy[i].gamecount_point + 800){ if (gamecount < enemy[i].gamecount_point + 50){ enemy[i].x--; enemy[i].y = 0.1 * ((enemy[i].x - 320) * (enemy[i].x - 320)) - 240; } if (gamecount > enemy[i].gamecount_point + 50 && gamecount < enemy[i].gamecount_point + 500){ switch (enemy[i].pattern % 2){ case 0: enemy[i].x += cos(enemy[i].angle) * 2; enemy[i].y += sin(enemy[i].angle) * 2; break; case 1: break; default: break; } if (gamecount % 12 == 0){ enemy[i].pattern++; enemy[i].angle = atan2(p1.y - enemy[i].y, p1.x - enemy[i].x); } if ((gamecount - enemy[i].gamecount_point) % 200 == 1){ my_set_enemy_shot(enemy[i].x,enemy[i].y,enemy[i].shot_type,i); } } if (gamecount > enemy[i].gamecount_point + 500){ enemy[i].y += 4; } } else{ enemy[i].move_flag = 0; enemy[i].init_flag = 0; } } break; default: break; } } } } void my_set_enemy_shot(double x,double y,int shot_type,int enemy_no){ for(int i = 0;i < DISP_ENEMY_MAX * 2;i++){ if(enemy_shot[i].move_flag == 0){ enemy_shot[i].move_flag = 1; enemy_shot[i].first_x = x; enemy_shot[i].first_y = y; enemy_shot[i].move_type = shot_type; enemy_shot[i].enemy_no = enemy_no; break; } } } void my_move_enemy_shot(){ for(int i = 0;i < DISP_ENEMY_MAX * 2;i++){ if(enemy_shot[i].move_flag == 1){ switch(enemy_shot[i].move_type){ case 0: if (enemy_shot[i].init_flag == 0){ enemy_shot[i].x[0] = enemy_shot[i].first_x; enemy_shot[i].y[0] = enemy_shot[i].first_y; enemy_shot[i].max_bullet = 1; enemy_shot[i].gamecount_point[0] = gamecount; enemy_shot[i].init_flag = 1; } else{ if (gamecount < enemy_shot[i].gamecount_point[0] + 300){ enemy_shot[i].y[0] -= 2; } else{ enemy_shot[i].move_flag = 0; enemy_shot[i].init_flag = 0; } } break; case 1: if (enemy_shot[i].init_flag == 0){ enemy_shot[i].gamecount_point[0] = gamecount; enemy_shot[i].gamecount_point[1] = gamecount; enemy_shot[i].max_bullet = 1; for (int j = 0; j < 5; j++){ enemy_shot[i].x[j] = enemy_shot[i].first_x; enemy_shot[i].y[j] = enemy_shot[i].first_y; } enemy_shot[i].init_flag = 1; } else{ if (gamecount < enemy_shot[i].gamecount_point[0] + 500){ for (int j = 0; j < enemy_shot[i].max_bullet; j++){ enemy_shot[i].y[j] = enemy_shot[i].y[j] - 2; } if (enemy_shot[i].max_bullet < 5){ if (gamecount == enemy_shot[i].gamecount_point[1] + 5){ enemy_shot[i].max_bullet++; enemy_shot[i].gamecount_point[1] += 5; } } } else{ enemy_shot[i].move_flag = 0; enemy_shot[i].init_flag = 0; } } break; case 2: if (enemy_shot[i].init_flag == 0){ enemy_shot[i].gamecount_point[0] = gamecount; enemy_shot[i].max_bullet = 1; enemy_shot[i].x[0] = enemy_shot[i].first_x; enemy_shot[i].y[0] = enemy_shot[i].first_y; enemy_shot[i].angle[0] = atan2(p1.y - enemy_shot[i].first_y, p1.x - enemy_shot[i].first_x); enemy_shot[i].init_flag = 1; } else{ if (gamecount < enemy_shot[i].gamecount_point[0] + 400){ enemy_shot[i].x[0] += cos(enemy_shot[i].angle[0]) * 2; enemy_shot[i].y[0] += sin(enemy_shot[i].angle[0]) * 2; } else{ enemy_shot[i].move_flag = 0; enemy_shot[i].init_flag = 0; } } break; case 3: if (enemy_shot[i].init_flag == 0){ enemy_shot[i].gamecount_point[0] = gamecount; enemy_shot[i].gamecount_point[1] = gamecount; enemy_shot[i].max_bullet = 1; for (int j = 0; j < 10; j++){ enemy_shot[i].x[j] = enemy_shot[i].first_x; enemy_shot[i].y[j] = enemy_shot[i].first_y; } enemy_shot[i].angle[0] = atan2(p1.y - enemy_shot[i].first_y, p1.x - enemy_shot[i].first_x); enemy_shot[i].init_flag = 1; } else{ if (gamecount < enemy_shot[i].gamecount_point[0] + 500){ for (int j = 0; j < enemy_shot[i].max_bullet; j++){ enemy_shot[i].x[j] += cos(enemy_shot[i].angle[0]) * 4; enemy_shot[i].y[j] += sin(enemy_shot[i].angle[0]) * 4; } if (enemy_shot[i].max_bullet < 10){ if (gamecount == enemy_shot[i].gamecount_point[1] + 5 && enemy[enemy_shot[i].enemy_no].move_flag == 1){ enemy_shot[i].max_bullet++; enemy_shot[i].gamecount_point[1] += 5; } } } else{ enemy_shot[i].move_flag = 0; enemy_shot[i].init_flag = 0; } } break; case 4: if (enemy_shot[i].init_flag == 0){ enemy_shot[i].gamecount_point[0] = gamecount; enemy_shot[i].gamecount_point[1] = gamecount; enemy_shot[i].max_bullet = 1; for (int j = 0; j < 10; j++){ enemy_shot[i].x[j] = enemy_shot[i].first_x; enemy_shot[i].y[j] = enemy_shot[i].first_y; } enemy_shot[i].angle[0] = atan2(p1.y - enemy_shot[i].first_y, p1.x - enemy_shot[i].first_x); enemy_shot[i].init_flag = 1; } else{ if (gamecount < enemy_shot[i].gamecount_point[0] + 500){ for (int j = 0; j < enemy_shot[i].max_bullet; j++){ enemy_shot[i].x[j] += cos(enemy_shot[i].angle[j]) * 4; enemy_shot[i].y[j] += sin(enemy_shot[i].angle[j]) * 4; } if (enemy_shot[i].max_bullet < 10){ if (gamecount == enemy_shot[i].gamecount_point[1] + 10 && enemy[enemy_shot[i].enemy_no].move_flag == 1){ enemy_shot[i].angle[enemy_shot[i].max_bullet] = atan2(p1.y - enemy_shot[i].first_y,p1.x - enemy_shot[i].first_x); enemy_shot[i].max_bullet++; enemy_shot[i].gamecount_point[1] += 10; } } } else{ enemy_shot[i].move_flag = 0; enemy_shot[i].init_flag = 0; } } break; default: break; } } } } void my_set_boss(){ for (int i = 0; i < STAGE_BOSS_MAX; i++){ if (ary_boss_data[stage_no][(i * BOSS_DATA_MAX) + 1] == gamecount){ for (int j = 0; j < DISP_BOSS_MAX; j++){ if (boss[j].move_flag == 0){ boss[j].move_flag = 1; boss[j].serial_no = ary_boss_data[stage_no][i * BOSS_DATA_MAX]; boss[j].appear_point = ary_boss_data[stage_no][(i * BOSS_DATA_MAX) + 1]; boss[j].first_x = ary_boss_data[stage_no][(i * BOSS_DATA_MAX) + 2]; boss[j].first_y = ary_boss_data[stage_no][(i * BOSS_DATA_MAX) + 3]; boss[j].move_type = ary_boss_data[stage_no][(i * BOSS_DATA_MAX) + 4]; boss[j].shot_type = ary_boss_data[stage_no][(i * BOSS_DATA_MAX) + 5]; boss[j].power = ary_boss_data[stage_no][(i * BOSS_DATA_MAX) + 6]; boss[j].range = ary_boss_data[stage_no][(i * BOSS_DATA_MAX) + 7]; boss[j].item_flag = ary_boss_data[stage_no][(i * BOSS_DATA_MAX) + 8]; boss[j].end_flag = ary_boss_data[stage_no][(i * BOSS_DATA_MAX) + 9]; boss[j].img = ary_boss_data[stage_no][(i * BOSS_DATA_MAX) + 10]; break; } } } } } void my_move_boss(){ for (int i = 0; i < DISP_BOSS_MAX; i++){ if (boss[i].move_flag == 1){ switch (boss[i].move_type){ case 0: if (boss[i].init_flag == 0){ boss[i].x = boss[i].first_x; boss[i].y = 260; boss[i].gamecount_point[0] = gamecount; boss[i].init_flag = 1; } else{ if (gamecount < boss[i].gamecount_point[0] + 2500){ if(boss[i].power > 0){ if (gamecount < boss[i].gamecount_point[0] + 260){ boss[i].y--; } if (gamecount >= boss[i].gamecount_point[0] + 280 && gamecount < boss[i].gamecount_point[0] + 2080){ if((gamecount - (boss[i].gamecount_point[0] + 280)) % 900 == 0){ my_set_boss_shot(boss[i].x,boss[i].y,boss[i].shot_type,i); } } if(boss[i].power > 0){ if (gamecount > boss[i].gamecount_point[0] + 2080){ boss[i].y++; } } } } else{ boss[i].move_flag = 0; boss[i].init_flag = 0; } } break; case 1: if (boss[i].init_flag == 0){ boss[i].x = boss[i].first_x; boss[i].y = 260; boss[i].gamecount_point[0] = gamecount; boss[i].init_flag = 1; } else{ if(boss[i].power > 0){ if (gamecount < boss[i].gamecount_point[0] + 260){ boss[i].y--; } if (gamecount >= boss[i].gamecount_point[0] + 280){ if((gamecount - (boss[i].gamecount_point[0] + 280)) % 900 == 0){ my_set_boss_shot(boss[i].x,boss[i].y,boss[i].shot_type,i); } } } } break; case 2: if (boss[i].init_flag == 0){ boss[i].var[0] = boss[i].first_x; boss[i].var[1] = 260; boss[i].x = boss[i].var[0] + cos(((DX_PI * 2) / 360) * gamecount) * 100; boss[i].y = boss[i].var[1] + sin(((DX_PI * 2) / 360) * gamecount) * 100; boss[i].gamecount_point[0] = gamecount; boss[i].init_flag = 1; } else{ if (gamecount < boss[i].gamecount_point[0] + 2500){ if(boss[i].power > 0){ if (gamecount < boss[i].gamecount_point[0] + 260){ boss[i].var[1]--; } if (gamecount >= boss[i].gamecount_point[0] + 260 && gamecount < boss[i].gamecount_point[0] + 2080){ if (gamecount % 400 == 1){ my_set_boss_shot(boss[i].x,boss[i].y,boss[i].shot_type,i); } } if (gamecount > boss[i].gamecount_point[0] + 2080){ boss[i].var[1]++; } boss[i].x = boss[i].var[0] + cos(((DX_PI * 2) / 360) * gamecount) * 100; boss[i].y = boss[i].var[1] + sin(((DX_PI * 2) / 360) * gamecount) * 100; } } else{ boss[i].move_flag = 0; boss[i].init_flag = 0; } } break; case 3: if (boss[i].init_flag == 0){ boss[i].x = boss[i].first_x; boss[i].y = boss[i].first_y; boss[i].angle = 0; boss[i].gamecount_point[0] = gamecount; boss[i].gamecount_point[1] = gamecount + 260; boss[i].init_flag = 1; } else{ if(boss[i].power > 0){ if (gamecount < boss[i].gamecount_point[0] + 260){ boss[i].y--; } if (gamecount == boss[i].gamecount_point[1] + 10){ my_set_boss_shot(boss[i].x,boss[i].y,boss[i].shot_type,i); } if (gamecount == boss[i].gamecount_point[1] + 550){ boss[i].angle = atan2(p1.y, p1.x); } if (gamecount > boss[i].gamecount_point[1] + 550 && gamecount < boss[i].gamecount_point[1] + 600){ boss[i].x += cos(boss[i].angle) * 4; boss[i].y += sin(boss[i].angle) * 4; } if (gamecount > boss[i].gamecount_point[1] + 600 && gamecount < boss[i].gamecount_point[1] + 700){ boss[i].x -= cos(boss[i].angle) * 2; boss[i].y -= sin(boss[i].angle) * 2; } if (gamecount == boss[i].gamecount_point[1] + 700){ boss[i].x = boss[i].first_x; boss[i].y = boss[i].first_y - 260; } if (gamecount == boss[i].gamecount_point[1] + 900){ boss[i].gamecount_point[1] += 900; } } } break; default: break; } } } } void my_set_boss_shot(double x,double y,int shot_type,int boss_no){ for(int i = 0;i < DISP_BOSS_MAX * 2;i++){ if(boss_shot[i].move_flag == 0){ boss_shot[i].move_flag = 1; boss_shot[i].first_x = x; boss_shot[i].first_y = y; boss_shot[i].move_type = shot_type; boss_shot[i].boss_no = boss_no; break; } } } void my_move_boss_shot(){ for(int i = 0;i < DISP_BOSS_MAX * 2;i++){ if(boss_shot[i].move_flag == 1){ switch(boss_shot[i].move_type){ case 0: if (boss_shot[i].init_flag == 0){ boss_shot[i].gamecount_point[0] = gamecount; boss_shot[i].gamecount_point[1] = gamecount; boss_shot[i].max_bullet = 40; for (int j = 0; j < 20; j++){ boss_shot[i].angle[j] = (18 * j) * DX_PI / 180; boss_shot[i].angle[j + 20] = (18 * j) * DX_PI / 180; boss_shot[i].angle2[j] = ((18 * j) + 4) * DX_PI / 180; boss_shot[i].angle2[j + 20] = ((18 * j) - 4) * DX_PI / 180; } for (int j = 0; j < 300; j++){ boss_shot[i].x[j] = 0; boss_shot[i].y[j] = 0; } boss_shot[i].init_flag = 1; } else{ if (gamecount < boss_shot[i].gamecount_point[0] + 900){ for (int j = 0; j < boss_shot[i].max_bullet; j++){ if (boss_shot[i].x[j] < 80 && boss_shot[i].x[j] > -80 && boss_shot[i].y[j] < 80 && boss_shot[i].y[j] > -80){ boss_shot[i].x[j] += cos(boss_shot[i].angle[j % 40]) * 1; boss_shot[i].y[j] += sin(boss_shot[i].angle[j % 40]) * 1; } else{ boss_shot[i].x[j] += cos(boss_shot[i].angle2[j % 40]) * 1; boss_shot[i].y[j] += sin(boss_shot[i].angle2[j % 40]) * 1; } } if (gamecount == boss_shot[i].gamecount_point[1] + 80 && boss[boss_shot[i].boss_no].move_flag == 1){ if (boss_shot[i].max_bullet < 280){ boss_shot[i].max_bullet += 40; boss_shot[i].gamecount_point[1] += 80; } } } else{ boss_shot[i].move_flag = 0; boss_shot[i].init_flag = 0; } } break; case 1: if (boss_shot[i].init_flag == 0){ boss_shot[i].gamecount_point[0] = gamecount; boss_shot[i].gamecount_point[1] = gamecount; boss_shot[i].max_bullet = 12; int angle[12] = {270,240,300,210,330,180,0,150,30,120,60,90}; for (int j = 0; j < 12; j++){ boss_shot[i].angle[j] = angle[j] * (DX_PI / 180); } for (int k = 0; k < 12; k++){ for (int j = 0; j < 12; j++){ boss_shot[i].x[j + (k * 12)] = cos(boss_shot[i].angle[k]) * 150; boss_shot[i].y[j + (k * 12)] = sin(boss_shot[i].angle[k]) * 150; } } boss_shot[i].init_flag = 1; } else{ if (gamecount < boss_shot[i].gamecount_point[0] + 800){ for (int j = 0; j < boss_shot[i].max_bullet; j++){ boss_shot[i].x[j] += cos(boss_shot[i].angle[j % 12]) * 1; boss_shot[i].y[j] += sin(boss_shot[i].angle[j % 12]) * 1; } if (gamecount == boss_shot[i].gamecount_point[1] + 50 && boss[boss_shot[i].boss_no].move_flag == 1){ if (boss_shot[i].max_bullet < 132){ boss_shot[i].max_bullet += 24; boss_shot[i].gamecount_point[1] += 50; } else if (boss_shot[i].max_bullet == 132){ boss_shot[i].max_bullet += 12; } } } else{ boss_shot[i].move_flag = 0; boss_shot[i].init_flag = 0; } } break; case 2: if (boss_shot[i].init_flag == 0){ boss_shot[i].gamecount_point[0] = gamecount; boss_shot[i].gamecount_point[1] = gamecount; boss_shot[i].max_bullet = 1; for (int j = 0; j < 5; j++){ boss_shot[i].x[j] = boss_shot[i].first_x; boss_shot[i].y[j] = boss_shot[i].first_y; } boss_shot[i].angle[0] = atan2(p1.y - boss_shot[i].first_y, p1.x - boss_shot[i].first_x); boss_shot[i].init_flag = 1; } else{ if (gamecount < boss_shot[i].gamecount_point[0] + 500){ for (int j = 0; j < boss_shot[i].max_bullet; j++){ boss_shot[i].x[j] += cos(boss_shot[i].angle[0]) * 4; boss_shot[i].y[j] += sin(boss_shot[i].angle[0]) * 4; } if (boss_shot[i].max_bullet < 5){ if (gamecount == boss_shot[i].gamecount_point[1] + 5 && boss[boss_shot[i].boss_no].move_flag == 1){ boss_shot[i].max_bullet++; boss_shot[i].gamecount_point[1] += 5; } } } else{ boss_shot[i].move_flag = 0; boss_shot[i].init_flag = 0; } } break; default: break; } } } } void my_set_exp_effect(double x,double y,int exp_type){ for(int i = 0;i < DISP_ENEMY_MAX;i++){ if(exp_effect[i].move_flag == 0){ exp_effect[i].move_flag = 1; exp_effect[i].first_x = x; exp_effect[i].first_y = y; exp_effect[i].move_type = exp_type; break; } } } void my_move_exp_effect(){ for(int i = 0;i < DISP_ENEMY_MAX;i++){ if(exp_effect[i].move_flag == 1){ switch(exp_effect[i].move_type){ case 0: if (exp_effect[i].init_flag == 0){ exp_effect[i].x = exp_effect[i].first_x; exp_effect[i].y = exp_effect[i].first_y; exp_effect[i].gamecount_point = gamecount; exp_effect[i].init_flag = 1; } else{ if (gamecount < exp_effect[i].gamecount_point + 30){ } else{ exp_effect[i].move_flag = 0; exp_effect[i].init_flag = 0; } } break; case 1: if (exp_effect[i].init_flag == 0){ exp_effect[i].x = exp_effect[i].first_x; exp_effect[i].y = exp_effect[i].first_y; exp_effect[i].gamecount_point = gamecount; exp_effect[i].init_flag = 1; } else{ if (gamecount < exp_effect[i].gamecount_point + 200){ if(gamecount % 10 == 1){ int ran = (rand() % 5); int ran2 = (rand() % 5); int ary[5] = {-50,-25,0,25,50}; exp_effect[i].x = exp_effect[i].first_x + ary[ran]; exp_effect[i].y = exp_effect[i].first_y + ary[ran2]; } } else{ exp_effect[i].move_flag = 0; exp_effect[i].init_flag = 0; } } break; default: break; } } } } void my_set_item(double x,double y){ for(int i = 0;i < DISP_ENEMY_MAX;i++){ if(item[i].move_flag == 0){ item[i].move_flag = 1; item[i].first_x = x; item[i].first_y = y; break; } } } void my_move_item(){ for(int i = 0;i < DISP_ENEMY_MAX;i++){ if(item[i].move_flag == 1){ switch(item[i].move_type){ case 0: if (item[i].init_flag == 0){ item[i].x = item[i].first_x; item[i].y = item[i].first_y; item[i].gamecount_point = gamecount; item[i].init_flag = 1; } else{ if (gamecount < item[i].gamecount_point + 240){ item[i].y -= 2; } else{ item[i].move_flag = 0; item[i].init_flag = 0; } } break; default: break; } } } } void my_set_barrier(){ b1.move_flag = 1; b1.power = 30; } void my_move_barrier(){ if(b1.move_flag == 1){ if (b1.init_flag == 0){ b1.x = p1.x + cos(((DX_PI * 2) / 10) * gamecount) * 20; b1.y = p1.y + sin(((DX_PI * 2) / 10) * gamecount) * 20; b1.init_flag = 1; } else{ b1.x = p1.x + cos(((DX_PI * 2) / 10) * gamecount) * 20; b1.y = p1.y + sin(((DX_PI * 2) / 10) * gamecount) * 20; } } } void my_set_bomb(){ if(bo1.move_flag == 0){ bo1.move_flag = 1; p1.bomb--; } } void my_move_bomb(){ if(bo1.move_flag == 1){ if(bo1.init_flag == 0){ bo1.count = 0; bo1.flag = 0; bo1.init_flag = 1; } else{ if(bo1.count < 10){ bo1.count++; if(bo1.count % 2 == 0){ bo1.flag = 1; } else{ bo1.flag = 0; } } else{ bo1.move_flag = 0; bo1.init_flag = 0; } } } } int my_pythago_theorem(double x,double x2,double y,double y2,double range,double range2){ double x3 = x - x2; double y3 = y - y2; double range3 = range + range2; if (x3 * x3 + y3 * y3 < range3 * range3){ return 1; } else{ return 0; } } void my_collision_detection(){ for(int i = 0;i < DISP_ENEMY_MAX;i++){ if(enemy[i].move_flag == 1 && enemy[i].init_flag == 1){ if(my_pythago_theorem(p1.x,enemy[i].x, p1.y,enemy[i].y,p1.range,enemy[i].range)){ if(p1.power > 0 && b1.move_flag == 0){ p1.power--; } enemy[i].power--; } if(b1.move_flag == 1 && b1.init_flag == 1){ if(my_pythago_theorem(b1.x,enemy[i].x, b1.y,enemy[i].y,b1.range,enemy[i].range)){ if(b1.power > 0){ b1.power--; } enemy[i].power--; } } for(int j = 0;j < PLAYER_SHOT_MAX;j++){ if(ps1[j].move_flag == 1 && ps1[j].init_flag == 1){ for(int k = 0;k < ps1[j].max_bullet;k++){ if(ps1[j].flag[k] == 1){ if(my_pythago_theorem(enemy[i].x,ps1[j].x[k], enemy[i].y,ps1[j].y[k],enemy[i].range,ps1[j].range)){ enemy[i].power--; if(enemy[i].power > 0){ my_play_se_sound(4); } ps1[j].flag[k] = 0; } } } } } if(bo1.move_flag == 1 && bo1.init_flag == 1){ if(bo1.flag == 1){ enemy[i].power--; } } if(enemy[i].power <= 0){ my_set_exp_effect(enemy[i].x,enemy[i].y,0); my_play_se_sound(2); if(enemy[i].item_flag == 1){ my_set_item(enemy[i].x,enemy[i].y); } enemy[i].move_flag = 0; enemy[i].init_flag = 0; score++; } } if(item[i].move_flag == 1 && item[i].init_flag == 1){ if(my_pythago_theorem(p1.x,item[i].x, p1.y,item[i].y,p1.range,item[i].range)){ if(p1.shot_type == 2){ my_set_barrier(); } if(p1.shot_type < 2){ p1.shot_type++; } my_play_se_sound(3); item[i].move_flag = 0; item[i].init_flag = 0; } } } for(int i = 0;i < DISP_ENEMY_MAX * 2;i++){ if(enemy_shot[i].move_flag == 1 && enemy_shot[i].init_flag == 1){ for(int j = 0;j < enemy_shot[i].max_bullet;j++){ if(my_pythago_theorem(p1.x,enemy_shot[i].x[j], p1.y,enemy_shot[i].y[j],p1.range,enemy_shot[i].range)){ if(p1.power > 0 && b1.move_flag == 0){ p1.power--; } } if(b1.move_flag == 1 && b1.init_flag == 1){ if(my_pythago_theorem(b1.x,enemy_shot[i].x[j], b1.y,enemy_shot[i].y[j],b1.range,enemy_shot[i].range)){ if(b1.power > 0){ b1.power--; } } } if(bo1.move_flag == 1 && bo1.init_flag == 1){ if(bo1.flag == 1){ enemy_shot[i].move_flag = 0; enemy_shot[i].init_flag = 0; } } } } } for(int i = 0;i < DISP_BOSS_MAX;i++){ if(boss[i].move_flag == 1 && boss[i].init_flag == 1){ if(my_pythago_theorem(p1.x,boss[i].x, p1.y,boss[i].y,p1.range,boss[i].range)){ if(p1.power > 0 && b1.move_flag == 0){ p1.power--; } boss[i].power--; } if(b1.move_flag == 1 && b1.init_flag == 1){ if(my_pythago_theorem(b1.x,boss[i].x, b1.y,boss[i].y,b1.range,boss[i].range)){ if(b1.power > 0){ b1.power--; } boss[i].power--; } } for(int j = 0;j < PLAYER_SHOT_MAX;j++){ if(ps1[j].move_flag == 1 && ps1[j].init_flag == 1){ for(int k = 0;k < ps1[j].max_bullet;k++){ if(ps1[j].flag[k] == 1){ if(my_pythago_theorem(boss[i].x,ps1[j].x[k], boss[i].y,ps1[j].y[k],boss[i].range,ps1[j].range)){ boss[i].power--; if(boss[i].power > 0){ my_play_se_sound(4); } ps1[j].flag[k] = 0; } } } } } if(bo1.move_flag == 1 && bo1.init_flag == 1){ if(bo1.flag == 1){ boss[i].power--; } } if(boss[i].power <= 0){ gamecount2++; if(gamecount2 == 1){ my_set_exp_effect(boss[i].x,boss[i].y,1); } else if(gamecount2 < 200){ if(gamecount2 % 10 == 1){ my_play_se_sound(2); } } else if(gamecount2 == 200){ if(boss[i].end_flag == 1 && p1.power > 0){ gameclear_flag = 1; } gamecount2 = 0; boss[i].move_flag = 0; boss[i].init_flag = 0; score++; } } } } for(int i = 0;i < DISP_BOSS_MAX * 2;i++){ if(boss_shot[i].move_flag == 1 && boss_shot[i].init_flag == 1){ for(int j = 0;j < boss_shot[i].max_bullet;j++){ if(my_pythago_theorem(p1.x,boss_shot[i].x[j], p1.y,boss_shot[i].y[j],p1.range,boss_shot[i].range)){ if(p1.power > 0 && b1.move_flag == 0){ p1.power--; } } if(b1.move_flag == 1 && b1.init_flag == 1){ if(my_pythago_theorem(b1.x,boss_shot[i].x[j], b1.y,boss_shot[i].y[j],b1.range,boss_shot[i].range)){ if(b1.power > 0){ b1.power--; } } } } } } if(p1.power <= 0 && gameover_flag == 0){ my_set_exp_effect(p1.x,p1.y,0); my_play_se_sound(2); gameover_flag = 1; } if(b1.power <= 0){ b1.move_flag = 0; b1.init_flag = 0; } } void my_to_center(){ p1.draw_x = p1.x + 320; p1.draw_y = ((-1) * p1.y) + 240; for(int i = 0;i < PLAYER_SHOT_MAX;i++){ if(ps1[i].move_flag == 1 && ps1[i].init_flag == 1){ for(int j = 0;j < ps1[i].max_bullet;j++){ ps1[i].draw_x[j] = ps1[i].x[j] + 320; ps1[i].draw_y[j] = ((-1) * ps1[i].y[j]) + 240; } } } for (int i = 0; i < DISP_ENEMY_MAX; i++){ if (enemy[i].move_flag == 1 && enemy[i].init_flag == 1){ enemy[i].draw_x = enemy[i].x + 320; enemy[i].draw_y = ((-1) * enemy[i].y) + 240; } } for(int i = 0;i < DISP_ENEMY_MAX * 2;i++){ if(enemy_shot[i].move_flag == 1 && enemy_shot[i].init_flag == 1){ for(int j = 0;j < enemy_shot[i].max_bullet;j++){ enemy_shot[i].draw_x[j] = enemy_shot[i].x[j] + 320; enemy_shot[i].draw_y[j] = ((-1) * enemy_shot[i].y[j]) + 240; } } } for (int i = 0; i < DISP_BOSS_MAX; i++){ if (boss[i].move_flag == 1 && boss[i].init_flag == 1){ boss[i].draw_x = boss[i].x + 320; boss[i].draw_y = ((-1) * boss[i].y) + 240; } } for(int i = 0;i < DISP_BOSS_MAX * 2;i++){ if(boss_shot[i].move_flag == 1 && boss_shot[i].init_flag == 1){ for(int j = 0;j < boss_shot[i].max_bullet;j++){ boss_shot[i].draw_x[j] = boss_shot[i].x[j] + 320; boss_shot[i].draw_y[j] = ((-1) * boss_shot[i].y[j]) + 240; } } } for (int i = 0;i < DISP_ENEMY_MAX;i++){ if (exp_effect[i].move_flag == 1 && exp_effect[i].init_flag == 1){ exp_effect[i].draw_x = exp_effect[i].x + 320; exp_effect[i].draw_y = ((-1) * exp_effect[i].y) + 240; } } for (int i = 0;i < DISP_ENEMY_MAX;i++){ if (item[i].move_flag == 1 && item[i].init_flag == 1){ item[i].draw_x = item[i].x + 320; item[i].draw_y = ((-1) * item[i].y) + 240; } } if(b1.move_flag == 1 && b1.init_flag == 1){ b1.draw_x = b1.x + 320; b1.draw_y = ((-1) * b1.y) + 240; } } void my_calc_img(){ switch(game_state){ case 15: player_img_count = gamecount % 4; break; case 20: if (key[KEY_INPUT_LEFT] >= 1){ player_img_count = gamecount % 4 + 4; } else if (key[KEY_INPUT_RIGHT] >= 1){ player_img_count = gamecount % 4 + 8; } else{ player_img_count = gamecount % 4; } if(gamecount % 50 == 1){ gamecount4++; } if(gamecount % 2 == 1){ gamecount5++; } enemy_img_count = gamecount4 % 2; boss_img_count = gamecount5 % 2; exp_effect_img_count = gamecount % 2; break; case 25: player_img_count = gamecount % 4; break; default: break; } } void my_draw_op(){ DrawGraph(0, 0, op_img, TRUE); DrawFormatString(400, 220, Color_White, "C言語入門"); DrawFormatString(380, 240, Color_White, "STGの作り方"); if(gamecount2 % 2 == 1){ DrawFormatString(360, 280, Color_White, "press enter to start"); } DrawFormatString(100, 460, Color_White, "操作方法 移動:矢印キー ショット:Zキー ボム:Xキー"); } void my_draw_ed(){ DrawFormatString(280, 220, Color_White, "おしまい"); DrawFormatString(180, 240, Color_White, "ウィンドウを閉じて終了してください"); } void my_draw_stage_no(){ DrawFormatString(200, 220, Color_White, "STAGE %d START",stage_no + 1); DrawFormatString(230, 240, Color_White, "PLAYER × %d",p1.life); } void my_draw_back(){ DrawGraph(0, 0, back_img2, TRUE); DrawGraph(back_img_x, back_img_y, back_img, TRUE); DrawGraph(back_img_x + 640, back_img_y, back_img, TRUE); DrawGraph(back_img_x, back_img_y - 480, back_img, TRUE); DrawGraph(back_img_x + 640, back_img_y - 480, back_img, TRUE); } void my_draw_player(){ if(p1.power > 0){ DrawRotaGraph(p1.draw_x, p1.draw_y,1.0,0.0, player_chip[player_img_count], TRUE); } } void my_draw_player_shot(){ for(int i = 0;i < PLAYER_SHOT_MAX;i++){ if(ps1[i].move_flag == 1 && ps1[i].init_flag == 1){ for(int j = 0;j < ps1[i].max_bullet;j++){ if(ps1[i].flag[j] == 1){ DrawRotaGraph(ps1[i].draw_x[j], ps1[i].draw_y[j],1.0,0.0, player_shot_img, TRUE); } } } } } void my_draw_enemy(){ for (int i = 0; i < DISP_ENEMY_MAX; i++){ if (enemy[i].move_flag == 1 && enemy[i].init_flag == 1){ DrawRotaGraph(enemy[i].draw_x, enemy[i].draw_y,1.0,0.0, enemy_chip[enemy_img_count + enemy[i].img * 2], TRUE); } } } void my_draw_enemy_shot(){ for(int i = 0;i < DISP_ENEMY_MAX * 2;i++){ if(enemy_shot[i].move_flag == 1 && enemy_shot[i].init_flag == 1){ for(int j = 0;j < enemy_shot[i].max_bullet;j++){ DrawRotaGraph(enemy_shot[i].draw_x[j], enemy_shot[i].draw_y[j],1.0,0.0, enemy_shot_img, TRUE); } } } } void my_draw_boss(){ for (int i = 0; i < DISP_BOSS_MAX; i++){ if (boss[i].move_flag == 1 && boss[i].init_flag == 1){ DrawRotaGraph(boss[i].draw_x, boss[i].draw_y,1.0,0.0, boss_chip[boss_img_count + boss[i].img * 2], TRUE); } } } void my_draw_boss_shot(){ for(int i = 0;i < DISP_BOSS_MAX * 2;i++){ if(boss_shot[i].move_flag == 1 && boss_shot[i].init_flag == 1){ for(int j = 0;j < boss_shot[i].max_bullet;j++){ DrawRotaGraph(boss_shot[i].draw_x[j], boss_shot[i].draw_y[j],1.0,0.0, boss_shot_img, TRUE); } } } } void my_draw_exp_effect(){ for (int i = 0;i < DISP_ENEMY_MAX;i++){ if (exp_effect[i].move_flag == 1 && exp_effect[i].init_flag == 1){ DrawRotaGraph(exp_effect[i].draw_x, exp_effect[i].draw_y,1.0,0.0, exp_effect_chip[exp_effect_img_count], TRUE); } } } void my_draw_item(){ for (int i = 0;i < DISP_ENEMY_MAX;i++){ if (item[i].move_flag == 1 && item[i].init_flag == 1){ DrawRotaGraph(item[i].draw_x, item[i].draw_y,1.0,0.0, item_img, TRUE); } } } void my_draw_barrier(){ if(b1.move_flag == 1 && b1.init_flag == 1){ DrawRotaGraph(b1.draw_x, b1.draw_y,1.0,0.0, barrier_img, TRUE); } } void my_draw_bomb(){ if(bo1.move_flag == 1 && bo1.init_flag == 1){ if(bo1.flag == 1){ DrawBox(0,0,640,480,Color_White,true); } } } void my_draw_variable(){ DrawFormatString(40, 0, Color_White, "STAGE %d", stage_no + 1); DrawFormatString(200, 0, Color_White, "SCORE"); DrawFormatString(320, 0, Color_White, "%d",score * 100); if(b1.move_flag == 0){ DrawFormatString(400, 0, Color_White, "Pl=%d:Pw=%d:Bo=%d", p1.life,p1.power,p1.bomb); } else{ DrawFormatString(400, 0, Color_White, "Pl=%d:Pw=%d:Bo=%d:Ba=%d", p1.life,p1.power,p1.bomb,b1.power); } } void my_draw_start(){ DrawFormatString(230,160, Color_White, "STAGE START"); } void my_draw_clear(){ DrawFormatString(230,160, Color_White, "STAGE CLEAR"); DrawFormatString(230,180, Color_White, "TOTAL SCORE"); DrawFormatString(300,200, Color_White, "%d",score * 100); } void my_draw_gameover(){ if(gameover_flag == 1 && p1.life == 1){ DrawFormatString(245,220, Color_White, "GAME OVER"); } } void my_play_se_sound(int se_no){ switch(se_no){ case 0: PlaySoundMem(se1, DX_PLAYTYPE_BACK); break; case 1: PlaySoundMem(se2, DX_PLAYTYPE_BACK); break; case 2: PlaySoundMem(se3, DX_PLAYTYPE_BACK); break; case 3: PlaySoundMem(se4, DX_PLAYTYPE_BACK); break; case 4: PlaySoundMem(se5, DX_PLAYTYPE_BACK); break; case 5: PlaySoundMem(se6, DX_PLAYTYPE_BACK); break; default: break; } } void my_search_bgm_sound(){ int boss_move_flag = 0; switch(game_state){ case 0: if(gamecount == 1){ my_stop_bgm_sound(); } if(gamecount == 2){ my_play_bgm_sound(0); } break; case 5: my_stop_bgm_sound(); break; case 10: my_stop_bgm_sound(); break; case 15: if(gamecount == 1){ my_stop_bgm_sound(); } if(gamecount == 2){ my_play_bgm_sound(1); } break; case 20: if(gamecount == 1){ my_stop_bgm_sound(); } if(gamecount > 2){ for (int i = 0; i < DISP_BOSS_MAX; i++){ if (boss[i].move_flag == 1 && boss[i].init_flag == 1){ boss_move_flag = 1; break; } } if(boss_move_flag == 1){ if(!CheckSoundMem(bgm4)){ my_stop_bgm_sound(); my_play_bgm_sound(3); } } else{ if(!CheckSoundMem(bgm3)){ my_stop_bgm_sound(); my_play_bgm_sound(2); } } } break; case 25: if(gamecount == 1){ my_stop_bgm_sound(); } if(gamecount == 2){ my_play_bgm_sound(4); } break; case 30: if(gamecount == 1){ my_stop_bgm_sound(); } if(gamecount == 2){ my_play_bgm_sound(5); } break; default: break; } } void my_play_bgm_sound(int bgm_no){ switch(bgm_no){ case 0: PlaySoundMem(bgm1, DX_PLAYTYPE_LOOP); break; case 1: PlaySoundMem(bgm2, DX_PLAYTYPE_LOOP); break; case 2: PlaySoundMem(bgm3, DX_PLAYTYPE_LOOP); break; case 3: PlaySoundMem(bgm4, DX_PLAYTYPE_LOOP); break; case 4: PlaySoundMem(bgm5, DX_PLAYTYPE_LOOP); break; case 5: PlaySoundMem(bgm6, DX_PLAYTYPE_LOOP); break; default: break; } } void my_stop_bgm_sound(){ StopSoundMem(bgm1); StopSoundMem(bgm2); StopSoundMem(bgm3); StopSoundMem(bgm4); StopSoundMem(bgm5); StopSoundMem(bgm6); } void my_gameover(){ if(gameover_flag == 1){ gamecount3++; if(gamecount3 == 200){ if(p1.life == 1){ stage_no = 0; p1.life = 3; p1.shot_type = 0; b1.move_flag = 0; score = 0; gamecount = 0; game_state = 0; } else{ p1.life--; p1.shot_type = 0; b1.move_flag = 0; gamecount = 0; game_state = 5; } } } if(gameclear_flag == 1){ stage_no++; gamecount = 0; game_state = 25; } } void my_timer(){ gamecount++; } int my_get_key(){ char keys[256]; GetHitKeyStateAll(keys); for (int i = 0; i < 256; i++){ if (keys[i] != 0){ key[i]++; } else{ key[i] = 0; } } return 0; } /*ページの先頭へ*/ /*目次へ戻る*/ /*HOME*/