/*広告*/
/*STGの作り方 おまけソース1(ファイル読み込み)*/
#include "DxLib.h" #include <time.h> #include <math.h> #define LEFT_LIMIT -220 #define RIGHT_LIMIT 220 #define TOP_LIMIT 240 #define BOTTOM_LIMIT -240 #define PLAYER_SHOT_MAX 30 #define DISP_ENEMY_MAX 30 #define STAGE_ENEMY_MAX 85 #define ENEMY_DATA_MAX 9 #define ENEMY_SHOT_MAX 30 #define DISP_BOSS_MAX 6 #define STAGE_BOSS_MAX 6 #define BOSS_DATA_MAX 10 #define BOSS_SHOT_MAX 20 #define EXP_EFFECT_MAX 20 #define ITEM_MAX 10 #define STAGE_MAX 3 void my_init_back_img(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_load_enemy_data(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,int); 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_collision_player_enemy(void); void my_collision_player_shot_enemy(void); void my_collision_player_enemy_shot(void); void my_collision_player_boss(void); void my_collision_player_shot_boss(void); void my_collision_player_boss_shot(void); void my_collision_player_item(void); void my_collision_barrier_enemy(void); void my_collision_barrier_enemy_shot(void); void my_collision_barrier_boss(void); void my_collision_barrier_boss_shot(void); void my_collision_bomb_enemy(void); void my_collision_bomb_enemy_shot(void); void my_check_player_power(void); void my_check_enemy_power(void); void my_check_boss_power(void); void my_check_barrier_power(void); void my_change_state(void); void my_to_center(void); void my_draw_op(void); void my_draw_ed(void); void my_draw_stage_num(void); void my_draw_start(void); void my_draw_clear(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_enemy_power(void); void my_draw_boss(void); void my_draw_boss_shot(void); void my_draw_boss_power(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_score_board(void); void my_draw_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 bomb; int power; int life; double range; }; 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_num; int appear_point; double first_x, first_y; double x, y; double draw_x, draw_y; double m_x,m_y; double a_x,a_y; double f_x,f_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; }; 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_num; }; struct ENEMY_SHOT enemy_shot[ENEMY_SHOT_MAX]; struct BOSS{ int serial_num; int appear_point; double first_x, first_y; double x, y; double draw_x, draw_y; double angle; int init_flag; int move_flag; int damage_flag; int move_type; int shot_type; double var[5]; int gamecount_point[5]; int power; double range; int item_flag; int end_flag; }; 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[300]; double angle2[300]; double var[300]; int init_flag; int move_flag; int move_type; int max_bullet; int gamecount_point[5]; double range; int boss_num; }; struct BOSS_SHOT boss_shot[BOSS_SHOT_MAX]; 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[EXP_EFFECT_MAX]; struct ITEM{ double first_x; double first_y; double x; double y; double draw_x; double draw_y; double m_x,m_y; double a_x,a_y; double f_x,f_y; int init_flag; int move_flag; int move_type; int gamecount_point; double range; }; struct ITEM item[ITEM_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 barrier1; struct BOMB{ int init_flag; int move_flag; int count; int flag; }; struct BOMB bomb1; int ary_enemy_data[STAGE_MAX][STAGE_ENEMY_MAX * ENEMY_DATA_MAX]; int ary_boss_data[STAGE_MAX][STAGE_BOSS_MAX * BOSS_DATA_MAX] = { { 0,4100,0,260,2,0,100,10,0,0, 1,7900,0,260,2,1,120,10,0,1, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0 }, { 0,3000,0,260,2,0,100,10,0,0, 1,7900,0,260,2,2,120,10,0,1, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0 }, { 0,5300,0,260,2,1,120,10,0,0, 1,5300,0,260,3,3,30,10,0,0, 2,9000,0,260,4,2,120,10,0,1, 3,9000,-20,280,4,3,30,10,0,0, 4,9000,20,280,4,3,30,10,0,0, 0,0,0,0,0,0,0,0,0,0 } }; int key[256]; double back_img_x; double back_img_y; double back_img_speed; int back_img; int gamecount; int gamecount2; int gamecount3; int game_state; int stage_num; int gameover_flag; int gameclear_flag; int score; int Color_White; int Color_Gray; int Color_Red; int Color_Green; int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int){ ChangeWindowMode(TRUE); DxLib_Init(); SetDrawScreen(DX_SCREEN_BACK); while (ScreenFlip()==0 && ProcessMessage()==0 && ClearDrawScreen()==0 && my_get_key()==0){ switch(game_state){ case 0: my_init_back_img(); game_state = 2; break; case 2: 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(); game_state = 4; break; case 4: my_draw_op(); if (key[KEY_INPUT_RETURN] == 1){ game_state = 5; } break; case 5: 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(); my_load_enemy_data(); game_state = 10; break; case 10: my_draw_stage_num(); if(gamecount == 300){ gamecount = 0; game_state = 15; } else{ my_timer(); } break; case 15: my_move_back(); my_move_barrier(); my_to_center(); my_draw_back(); my_draw_player(); my_draw_barrier(); my_draw_score_board(); if(gamecount2 % 2 == 1){ my_draw_start(); } if(gamecount == 200){ gamecount = 0; gamecount2 = 0; game_state = 20; } else{ if (gamecount % 10 == 1){ back_img_speed *= 0.9f; gamecount2++; } p1.y++; my_timer(); } break; case 20: 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_draw_back(); my_draw_player(); my_draw_player_shot(); my_draw_enemy(); my_draw_enemy_shot(); my_draw_enemy_power(); my_draw_boss(); my_draw_boss_shot(); my_draw_boss_power(); my_draw_exp_effect(); my_draw_item(); my_draw_barrier(); my_draw_bomb(); my_draw_score_board(); my_draw_gameover(); my_change_state(); my_timer(); break; case 25: my_move_back(); my_move_barrier(); my_to_center(); my_draw_back(); my_draw_player(); my_draw_barrier(); my_draw_score_board(); if(gamecount2 % 2 == 1){ my_draw_clear(); } if(gamecount == 500){ if(stage_num == STAGE_MAX){ game_state = 30; } else{ game_state = 5; } } else{ if (gamecount % 10 == 1){ back_img_speed *= 1.1f; gamecount2++; } p1.y++; my_timer(); } break; case 30: my_draw_ed(); break; default: break; } } DxLib_End(); return 0; } void my_init_back_img(){ back_img = LoadGraph("../back_img.jpg"); } void my_init_variable(){ gamecount = 0; gamecount2 = 0; gamecount3 = 0; game_state = 0; stage_num = 0; gameover_flag = 0; gameclear_flag = 0; score = 0; Color_White = GetColor(255, 255, 255); Color_Gray = GetColor(100, 100, 100); Color_Red = GetColor(255, 0, 0); Color_Green = GetColor(0, 255, 0); back_img_x = -220; back_img_y = 0; back_img_speed = 8; SetFontSize(16); } void my_init_variable2(){ gamecount = 0; gamecount2 = 0; gamecount3 = 0; gameover_flag = 0; gameclear_flag = 0; back_img_x = -220; 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.bomb = 1; p1.power = 1; p1.life = 3; p1.range = 10; } void my_init_player2(){ p1.x = 0; p1.y = -300; p1.bomb = 1; p1.power = 1; } 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_num = 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].m_x = 0; enemy[i].m_y = 0; enemy[i].a_x = 0; enemy[i].a_y = 0; enemy[i].f_x = 0; enemy[i].f_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 < ENEMY_SHOT_MAX; 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_num = 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 < ENEMY_SHOT_MAX; 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_num = 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].angle = 0; boss[i].init_flag = 0; boss[i].move_flag = 0; boss[i].damage_flag = 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].var[j] = 0; 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 < BOSS_SHOT_MAX; 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_num = 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; boss_shot[i].angle[j] = 0; boss_shot[i].angle2[j] = 0; boss_shot[i].var[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 < BOSS_SHOT_MAX; i++){ boss_shot[i].init_flag = 0; boss_shot[i].move_flag = 0; } } void my_init_exp_effect(){ for (int i = 0; i < EXP_EFFECT_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 < EXP_EFFECT_MAX; i++){ exp_effect[i].init_flag = 0; exp_effect[i].move_flag = 0; } } void my_init_item(){ for (int i = 0; i < ITEM_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].m_x = 0; item[i].m_y = 0; item[i].a_x = 0; item[i].a_y = 0; item[i].f_x = 0; item[i].f_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 < ITEM_MAX; i++){ item[i].init_flag = 0; item[i].move_flag = 0; } } void my_init_barrier(){ barrier1.x = 0; barrier1.y = 0; barrier1.draw_x = 0; barrier1.draw_y = 0; barrier1.init_flag = 0; barrier1.move_flag = 0; barrier1.angle = 0; barrier1.power = 30; barrier1.range = 5; } void my_init_barrier2(){ barrier1.power = 30; } void my_init_bomb(){ bomb1.init_flag = 0; bomb1.move_flag = 0; bomb1.count = 0; bomb1.flag = 0; } void my_init_bomb2(){ bomb1.init_flag = 0; bomb1.move_flag = 0; } void my_load_enemy_data(){ int fp; char c; char str[64]; int str_count = 0; int ary_enemy_data_count = 0; switch(stage_num){ case 0: fp = FileRead_open("../enemy_data1.csv"); break; case 1: fp = FileRead_open("../enemy_data2.csv"); break; case 2: fp = FileRead_open("../enemy_data3.csv"); break; default: break; } if(fp == NULL){ printfDx("ファイル読み込みエラー\n"); return; } while (FileRead_getc(fp) != '\n'); while(1){ c = FileRead_getc(fp); str[str_count] = c; if(str[str_count] == ',' || str[str_count] == '\n' || str[str_count] == EOF){ str[str_count] = '\0'; ary_enemy_data[stage_num][ary_enemy_data_count] = atoi(str); str_count = -1; ary_enemy_data_count++; } if (c == EOF || ary_enemy_data_count == STAGE_ENEMY_MAX * ENEMY_DATA_MAX)break; str_count++; } FileRead_close(fp); } 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] % 5 == 1){ my_set_player_shot(p1.shot_type); } if (key[KEY_INPUT_X] == 1 && p1.bomb > 0){ my_set_bomb(); } } } 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_num][(i * ENEMY_DATA_MAX) + 1] == gamecount && gamecount > 0){ for (int j = 0; j < DISP_ENEMY_MAX; j++){ if (enemy[j].move_flag == 0){ enemy[j].move_flag = 1; enemy[j].serial_num = ary_enemy_data[stage_num][i * ENEMY_DATA_MAX]; enemy[j].appear_point = ary_enemy_data[stage_num][(i * ENEMY_DATA_MAX) + 1]; enemy[j].first_x = ary_enemy_data[stage_num][(i * ENEMY_DATA_MAX) + 2]; enemy[j].first_y = ary_enemy_data[stage_num][(i * ENEMY_DATA_MAX) + 3]; enemy[j].move_type = ary_enemy_data[stage_num][(i * ENEMY_DATA_MAX) + 4]; enemy[j].shot_type = ary_enemy_data[stage_num][(i * ENEMY_DATA_MAX) + 5]; enemy[j].power = ary_enemy_data[stage_num][(i * ENEMY_DATA_MAX) + 6]; enemy[j].range = ary_enemy_data[stage_num][(i * ENEMY_DATA_MAX) + 7]; enemy[j].item_flag = ary_enemy_data[stage_num][(i * ENEMY_DATA_MAX) + 8]; 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 = 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 3: 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 4: 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 5: 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 + 50){ enemy[i].x = enemy[i].x + 2; enemy[i].y = 6000 / enemy[i].x; } if (gamecount == enemy[i].gamecount_point + 60){ my_set_enemy_shot(enemy[i].x,enemy[i].y,enemy[i].shot_type,i); } if (gamecount > enemy[i].gamecount_point + 110){ 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 6: 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 + 50){ enemy[i].x = enemy[i].x - 2; enemy[i].y = -6000 / enemy[i].x; } if (gamecount == enemy[i].gamecount_point + 60){ my_set_enemy_shot(enemy[i].x,enemy[i].y,enemy[i].shot_type,i); } if (gamecount > enemy[i].gamecount_point + 110){ 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 7: 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 8: 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 9: if (enemy[i].init_flag == 0){ enemy[i].x = enemy[i].first_x; enemy[i].y = enemy[i].first_y; enemy[i].gamecount_point = gamecount; enemy[i].init_flag = 1; } else{ if (gamecount < enemy[i].gamecount_point + 800){ 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 10: 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 11: if (enemy[i].init_flag == 0){ enemy[i].x = -220; 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 12: if (enemy[i].init_flag == 0){ enemy[i].x = 220; 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 13: 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 14: if (enemy[i].init_flag == 0){ enemy[i].x = -220; 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 + 220) * (enemy[i].x + 220)) - 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 15: if (enemy[i].init_flag == 0){ enemy[i].x = 220; 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 - 220) * (enemy[i].x - 220)) - 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 % 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 16: 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 17: if (enemy[i].init_flag == 0){ enemy[i].x = enemy[i].first_x; enemy[i].y = 280; enemy[i].var[0] = 0; enemy[i].gamecount_point = gamecount; enemy[i].init_flag = 1; } else{ if (gamecount < enemy[i].gamecount_point + 3000){ if (gamecount < enemy[i].gamecount_point + 100){ enemy[i].y = 280 - (sin(DX_PI / 100 * enemy[i].var[0] - (DX_PI * 0.5f)) + 1) / 2 * 220; enemy[i].var[0]++; } if (gamecount > enemy[i].gamecount_point + 100 && gamecount < enemy[i].gamecount_point + 2900){ if (gamecount % 100 == 1){ enemy[i].var[0] = 0; enemy[i].var[1] = enemy[i].x; enemy[i].var[2] = enemy[i].y; enemy[i].pattern = (rand() % 8); if (enemy[i].x < -220){ enemy[i].pattern = 4; } else if (enemy[i].x > 220){ enemy[i].pattern = 5; } else if (enemy[i].y < -240){ enemy[i].pattern = 6; } else if (enemy[i].y > 240){ enemy[i].pattern = 7; } enemy[i].var[3] = 1; } if (enemy[i].var[3] == 1){ switch(enemy[i].pattern){ case 0: enemy[i].x = enemy[i].var[1] + ((sin(DX_PI / 50 * enemy[i].var[0] - (DX_PI * 0.5f)) + 1) / 2 * 80); enemy[i].y = enemy[i].var[2] + ((sin(DX_PI / 50 * enemy[i].var[0] - (DX_PI * 0.5f)) + 1) / 2 * 80); break; case 1: enemy[i].x = enemy[i].var[1] - ((sin(DX_PI / 50 * enemy[i].var[0] - (DX_PI * 0.5f)) + 1) / 2 * 80); enemy[i].y = enemy[i].var[2] + ((sin(DX_PI / 50 * enemy[i].var[0] - (DX_PI * 0.5f)) + 1) / 2 * 80); break; case 2: enemy[i].x = enemy[i].var[1] + ((sin(DX_PI / 50 * enemy[i].var[0] - (DX_PI * 0.5f)) + 1) / 2 * 80); enemy[i].y = enemy[i].var[2] - ((sin(DX_PI / 50 * enemy[i].var[0] - (DX_PI * 0.5f)) + 1) / 2 * 80); break; case 3: enemy[i].x = enemy[i].var[1] - ((sin(DX_PI / 50 * enemy[i].var[0] - (DX_PI * 0.5f)) + 1) / 2 * 80); enemy[i].y = enemy[i].var[2] - ((sin(DX_PI / 50 * enemy[i].var[0] - (DX_PI * 0.5f)) + 1) / 2 * 80); break; case 4: enemy[i].x = enemy[i].var[1] + ((sin(DX_PI / 50 * enemy[i].var[0] - (DX_PI * 0.5f)) + 1) / 2 * 80); break; case 5: enemy[i].x = enemy[i].var[1] - ((sin(DX_PI / 50 * enemy[i].var[0] - (DX_PI * 0.5f)) + 1) / 2 * 80); break; case 6: enemy[i].y = enemy[i].var[2] + ((sin(DX_PI / 50 * enemy[i].var[0] - (DX_PI * 0.5f)) + 1) / 2 * 80); break; case 7: enemy[i].y = enemy[i].var[2] - ((sin(DX_PI / 50 * enemy[i].var[0] - (DX_PI * 0.5f)) + 1) / 2 * 80); break; default: break; } enemy[i].var[0]++; if (enemy[i].var[0] == 50){ my_set_enemy_shot(enemy[i].x,enemy[i].y,enemy[i].shot_type,i); enemy[i].var[3] = 0; } } } if (gamecount > enemy[i].gamecount_point + 2900){ enemy[i].y += 5; } } else{ enemy[i].move_flag = 0; enemy[i].init_flag = 0; } } break; case 18: if (enemy[i].init_flag == 0){ enemy[i].x = enemy[i].first_x; enemy[i].y = enemy[i].first_y; enemy[i].m_y = -5; enemy[i].f_y = 0.9; enemy[i].gamecount_point = gamecount; enemy[i].init_flag = 1; } else{ if (gamecount < enemy[i].gamecount_point + 1000){ if (gamecount < enemy[i].gamecount_point + 30){ enemy[i].y += enemy[i].m_y; } if (gamecount > enemy[i].gamecount_point + 30 && gamecount < enemy[i].gamecount_point + 60){ enemy[i].y += enemy[i].m_y; enemy[i].m_y *= enemy[i].f_y; } if (gamecount == enemy[i].gamecount_point + 60){ my_set_enemy_shot(enemy[i].x, enemy[i].y, enemy[i].shot_type, i); enemy[i].a_y = 0.1; } if (gamecount > enemy[i].gamecount_point + 80){ enemy[i].y += enemy[i].m_y; enemy[i].m_y += enemy[i].a_y; } } else{ enemy[i].move_flag = 0; enemy[i].init_flag = 0; } } break; case 19: if (enemy[i].init_flag == 0){ enemy[i].x = 0; enemy[i].y = 260; enemy[i].m_x = 0; enemy[i].m_y = -5; enemy[i].gamecount_point = gamecount; enemy[i].init_flag = 1; } else{ if (gamecount < enemy[i].gamecount_point + 100){ if (gamecount < enemy[i].gamecount_point + 10){ enemy[i].x += enemy[i].m_x; enemy[i].y += enemy[i].m_y; } if (gamecount == enemy[i].gamecount_point + 10){ enemy[i].a_x = 0.1; enemy[i].a_y = 0.05; } if (gamecount > enemy[i].gamecount_point + 10 && gamecount){ enemy[i].x += enemy[i].m_x; enemy[i].y += enemy[i].m_y; enemy[i].m_x += enemy[i].a_x; enemy[i].m_y += enemy[i].a_y; } if (gamecount % 10 == 0){ my_set_enemy_shot(enemy[i].x, enemy[i].y, 2, i); } } else{ enemy[i].move_flag = 0; enemy[i].init_flag = 0; } } break; case 20: if (enemy[i].init_flag == 0){ enemy[i].x = 0; enemy[i].y = 260; enemy[i].m_x = 0; enemy[i].m_y = -5; enemy[i].gamecount_point = gamecount; enemy[i].init_flag = 1; } else{ if (gamecount < enemy[i].gamecount_point + 100){ if (gamecount < enemy[i].gamecount_point + 10){ enemy[i].x += enemy[i].m_x; enemy[i].y += enemy[i].m_y; } if (gamecount == enemy[i].gamecount_point + 10){ enemy[i].a_x = -0.1; enemy[i].a_y = 0.05; } if (gamecount > enemy[i].gamecount_point + 10 && gamecount){ enemy[i].x += enemy[i].m_x; enemy[i].y += enemy[i].m_y; enemy[i].m_x += enemy[i].a_x; enemy[i].m_y += enemy[i].a_y; } if (gamecount % 10 == 0){ my_set_enemy_shot(enemy[i].x, enemy[i].y, 2, i); } } 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_num){ for(int i = 0;i < ENEMY_SHOT_MAX;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_num = enemy_num; break; } } } void my_move_enemy_shot(){ for(int i = 0;i < ENEMY_SHOT_MAX;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_num].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_num].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; case 5: 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; } int tmp = 245; for (int j = 0; j < 5; j++){ enemy_shot[i].angle[j] = tmp * (DX_PI / 180); tmp += 10; } 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]) * 5; enemy_shot[i].y[j] += sin(enemy_shot[i].angle[j]) * 5; } if (enemy_shot[i].max_bullet < 5){ if (gamecount == enemy_shot[i].gamecount_point[1] + 5 && enemy[enemy_shot[i].enemy_num].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; default: break; } } } } void my_set_boss(){ for (int i = 0; i < STAGE_BOSS_MAX; i++){ if (ary_boss_data[stage_num][(i * BOSS_DATA_MAX) + 1] == gamecount && gamecount > 0){ for (int j = 0; j < DISP_BOSS_MAX; j++){ if (boss[j].move_flag == 0){ boss[j].move_flag = 1; boss[j].serial_num = ary_boss_data[stage_num][i * BOSS_DATA_MAX]; boss[j].appear_point = ary_boss_data[stage_num][(i * BOSS_DATA_MAX) + 1]; boss[j].first_x = ary_boss_data[stage_num][(i * BOSS_DATA_MAX) + 2]; boss[j].first_y = ary_boss_data[stage_num][(i * BOSS_DATA_MAX) + 3]; boss[j].move_type = ary_boss_data[stage_num][(i * BOSS_DATA_MAX) + 4]; boss[j].shot_type = ary_boss_data[stage_num][(i * BOSS_DATA_MAX) + 5]; boss[j].power = ary_boss_data[stage_num][(i * BOSS_DATA_MAX) + 6]; boss[j].range = ary_boss_data[stage_num][(i * BOSS_DATA_MAX) + 7]; boss[j].item_flag = ary_boss_data[stage_num][(i * BOSS_DATA_MAX) + 8]; boss[j].end_flag = ary_boss_data[stage_num][(i * BOSS_DATA_MAX) + 9]; 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].damage_flag = 0; boss[i].gamecount_point[0] = gamecount; boss[i].init_flag = 1; } else{ if (gamecount < boss[i].gamecount_point[0] + 3000){ if(boss[i].power > 0){ if (gamecount < boss[i].gamecount_point[0] + 260){ boss[i].y--; } if (gamecount == boss[i].gamecount_point[0] + 260){ boss[i].damage_flag = 1; } if(gamecount == boss[i].gamecount_point[0] + 280){ my_set_boss_shot(boss[i].x,boss[i].y,boss[i].shot_type,i); } if (gamecount > boss[i].gamecount_point[0] + 840){ 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].damage_flag = 0; boss[i].gamecount_point[0] = gamecount; boss[i].init_flag = 1; } else{ if(boss[i].power > 0){ if (gamecount < boss[i].gamecount_point[0] + 220){ boss[i].y--; } if (gamecount == boss[i].gamecount_point[0] + 220){ boss[i].damage_flag = 1; } if (gamecount > boss[i].gamecount_point[0] + 240){ if(gamecount % 100 == 1){ my_set_enemy_shot(boss[i].x,boss[i].y,boss[i].shot_type,i); } } } } break; case 2: if (boss[i].init_flag == 0){ boss[i].x = 0; boss[i].y = 260; boss[i].var[0] = 0; boss[i].damage_flag = 0; 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] + 260){ boss[i].damage_flag = 1; } if (gamecount > boss[i].gamecount_point[0] + 260){ boss[i].y = sin(boss[i].var[0] * (DX_PI / 180)) * 10; boss[i].var[0] += 2; if (gamecount >= boss[i].gamecount_point[0] + 360){ if((gamecount - (boss[i].gamecount_point[0] + 360)) % 900 == 0){ my_set_boss_shot(boss[i].x,boss[i].y,boss[i].shot_type,i); } } } } } break; case 3: if (boss[i].init_flag == 0){ boss[i].var[0] = boss[i].first_x; boss[i].var[1] = 260; boss[i].var[2] = 90; boss[i].x = boss[i].var[0] + cos(((DX_PI * 2) / 360) * boss[i].var[2]) * 100; boss[i].y = boss[i].var[1] + sin(((DX_PI * 2) / 360) * boss[i].var[2]) * 100; boss[i].damage_flag = 0; 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].var[1]--; } if (gamecount == boss[i].gamecount_point[0] + 260){ boss[i].damage_flag = 1; } if (gamecount > boss[i].gamecount_point[0] + 260){ if (gamecount % 400 == 1){ my_set_boss_shot(boss[i].x,boss[i].y,boss[i].shot_type,i); } } boss[i].x = boss[i].var[0] + cos(((DX_PI * 2) / 360) * boss[i].var[2]) * 100; boss[i].y = boss[i].var[1] + sin(((DX_PI * 2) / 360) * boss[i].var[2]) * 100; boss[i].var[2]++; } } break; case 4: 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].var[0] = 0; boss[i].var[1] = boss[i].first_y; boss[i].damage_flag = 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--; boss[i].var[1]--; } if (gamecount == boss[i].gamecount_point[0] + 260){ boss[i].damage_flag = 1; } if (gamecount > boss[i].gamecount_point[1] && gamecount < boss[i].gamecount_point[1] + 550){ boss[i].y = boss[i].var[1] + sin(boss[i].var[0] * (DX_PI / 180)) * 10; boss[i].var[0] += 2; } 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; boss[i].var[0] = 0; } if (gamecount > boss[i].gamecount_point[1] + 700 && gamecount < boss[i].gamecount_point[1] + 900){ boss[i].y = boss[i].var[1] + sin(boss[i].var[0] * (DX_PI / 180)) * 10; boss[i].var[0] += 2; } 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_num){ for(int i = 0;i < BOSS_SHOT_MAX;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_num = boss_num; break; } } } void my_move_boss_shot(){ for(int i = 0;i < BOSS_SHOT_MAX;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 = 1; for (int j = 0; j < 200; j++){ boss_shot[i].x[j] = boss_shot[i].first_x; boss_shot[i].y[j] = boss_shot[i].first_y; } for (int j = 0; j < 200; j++){ boss_shot[i].angle[j] = ((rand() % 360) * (DX_PI / 180)); } for (int j = 0; j < 200; j++){ boss_shot[i].var[j] = (rand() % 5) + 1; } 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]) * boss_shot[i].var[j]; boss_shot[i].y[j] += sin(boss_shot[i].angle[j]) * boss_shot[i].var[j]; } if (gamecount == boss_shot[i].gamecount_point[1] + 2 && boss[boss_shot[i].boss_num].move_flag == 1){ if (boss_shot[i].max_bullet < 200){ boss_shot[i].max_bullet++; boss_shot[i].gamecount_point[1] += 2; } } } 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 = 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_num].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 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 = 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_num].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 3: 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_num].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 < EXP_EFFECT_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 < EXP_EFFECT_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 + 2){ } 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 + 30){ } else{ exp_effect[i].move_flag = 0; exp_effect[i].init_flag = 0; } } break; case 2: 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] = {-20,-10,0,10,20}; 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,int item_type){ for(int i = 0;i < ITEM_MAX;i++){ if(item[i].move_flag == 0){ item[i].move_flag = 1; item[i].first_x = x; item[i].first_y = y; item[i].move_type = item_type; break; } } } void my_move_item(){ for(int i = 0;i < ITEM_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; case 1: if (item[i].init_flag == 0){ item[i].x = item[i].first_x; item[i].y = item[i].first_y; item[i].m_y = 5; item[i].a_y = -0.15; item[i].gamecount_point = gamecount; item[i].init_flag = 1; } else{ if (gamecount < item[i].gamecount_point + 240){ item[i].y += item[i].m_y; item[i].m_y += item[i].a_y; } else{ item[i].move_flag = 0; item[i].init_flag = 0; } } break; default: break; } } } } void my_set_barrier(){ barrier1.move_flag = 1; barrier1.power = 30; } void my_move_barrier(){ if(barrier1.move_flag == 1){ if (barrier1.init_flag == 0){ barrier1.x = p1.x + cos(((DX_PI * 2) / 10) * gamecount) * 20; barrier1.y = p1.y + sin(((DX_PI * 2) / 10) * gamecount) * 20; barrier1.init_flag = 1; } else{ barrier1.x = p1.x + cos(((DX_PI * 2) / 10) * gamecount) * 20; barrier1.y = p1.y + sin(((DX_PI * 2) / 10) * gamecount) * 20; } } } void my_set_bomb(){ if(bomb1.move_flag == 0){ bomb1.move_flag = 1; p1.bomb--; } } void my_move_bomb(){ if(bomb1.move_flag == 1){ if(bomb1.init_flag == 0){ bomb1.count = 0; bomb1.flag = 0; bomb1.init_flag = 1; } else{ if(bomb1.count < 10){ bomb1.count++; if(bomb1.count % 2 == 0){ bomb1.flag = 1; } else{ bomb1.flag = 0; } } else{ bomb1.move_flag = 0; bomb1.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(){ my_collision_player_enemy(); my_collision_player_shot_enemy(); my_collision_player_enemy_shot(); my_collision_player_boss(); my_collision_player_shot_boss(); my_collision_player_boss_shot(); my_collision_player_item(); my_collision_barrier_enemy(); my_collision_barrier_enemy_shot(); my_collision_barrier_boss(); my_collision_barrier_boss_shot(); my_collision_bomb_enemy(); my_collision_bomb_enemy_shot(); my_check_player_power(); my_check_enemy_power(); my_check_boss_power(); my_check_barrier_power(); } void my_collision_player_enemy(){ for(int i = 0;i < DISP_ENEMY_MAX;i++){ if(enemy[i].move_flag == 1 && enemy[i].init_flag == 1 && p1.power > 0 && barrier1.move_flag == 0){ if(my_pythago_theorem(p1.x,enemy[i].x, p1.y,enemy[i].y,p1.range,enemy[i].range)){ p1.power--; enemy[i].power--; my_set_exp_effect(enemy[i].x,enemy[i].y,0); } } } } void my_collision_player_shot_enemy(){ for(int i = 0;i < DISP_ENEMY_MAX;i++){ if(enemy[i].move_flag == 1 && enemy[i].init_flag == 1){ 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 && ps1[j].x[k] > LEFT_LIMIT && ps1[j].x[k] < RIGHT_LIMIT && ps1[j].y[k] > BOTTOM_LIMIT && ps1[j].y[k] < TOP_LIMIT){ 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--; ps1[j].flag[k] = 0; my_set_exp_effect(enemy[i].x,enemy[i].y,0); } } } } } } } } void my_collision_player_enemy_shot(){ for(int i = 0;i < ENEMY_SHOT_MAX;i++){ if(enemy_shot[i].move_flag == 1 && enemy_shot[i].init_flag == 1 && p1.power > 0 && barrier1.move_flag == 0){ 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)){ p1.power--; my_set_exp_effect(p1.x,p1.y,0); } } } } } void my_collision_player_boss(){ for(int i = 0;i < DISP_BOSS_MAX;i++){ if(boss[i].move_flag == 1 && boss[i].init_flag == 1 && p1.power > 0 && barrier1.move_flag == 0){ if(my_pythago_theorem(p1.x,boss[i].x, p1.y,boss[i].y,p1.range,boss[i].range)){ p1.power--; if(boss[i].damage_flag == 1){ boss[i].power--; } my_set_exp_effect(boss[i].x,boss[i].y,0); } } } } void my_collision_player_shot_boss(){ for(int i = 0;i < DISP_BOSS_MAX;i++){ if(boss[i].move_flag == 1 && boss[i].init_flag == 1){ 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 && ps1[j].x[k] > LEFT_LIMIT && ps1[j].x[k] < RIGHT_LIMIT && ps1[j].y[k] > BOTTOM_LIMIT && ps1[j].y[k] < TOP_LIMIT){ if(my_pythago_theorem(boss[i].x,ps1[j].x[k], boss[i].y,ps1[j].y[k],boss[i].range,ps1[j].range)){ if(boss[i].damage_flag == 1){ boss[i].power--; } ps1[j].flag[k] = 0; my_set_exp_effect(boss[i].x,boss[i].y,0); } } } } } } } } void my_collision_player_boss_shot(){ for(int i = 0;i < BOSS_SHOT_MAX;i++){ if(boss_shot[i].move_flag == 1 && boss_shot[i].init_flag == 1 && p1.power > 0 && barrier1.move_flag == 0){ 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)){ p1.power--; my_set_exp_effect(p1.x,p1.y,0); } } } } } void my_collision_player_item(){ for(int i = 0;i < ITEM_MAX;i++){ if(item[i].move_flag == 1 && item[i].init_flag == 1 && p1.power > 0){ if(my_pythago_theorem(p1.x,item[i].x, p1.y,item[i].y,p1.range,item[i].range)){ item[i].move_flag = 0; item[i].init_flag = 0; if(p1.shot_type < 2){ p1.shot_type++; } else if(p1.shot_type == 2){ my_set_barrier(); } } } } } void my_collision_barrier_enemy(){ for(int i = 0;i < DISP_ENEMY_MAX;i++){ if(enemy[i].move_flag == 1 && enemy[i].init_flag == 1 && barrier1.power > 0){ if(barrier1.move_flag == 1 && barrier1.init_flag == 1){ if(my_pythago_theorem(barrier1.x,enemy[i].x, barrier1.y,enemy[i].y,barrier1.range,enemy[i].range)){ barrier1.power--; enemy[i].power--; } } } } } void my_collision_barrier_enemy_shot(){ for(int i = 0;i < ENEMY_SHOT_MAX;i++){ if(enemy_shot[i].move_flag == 1 && enemy_shot[i].init_flag == 1 && barrier1.power > 0){ for(int j = 0;j < enemy_shot[i].max_bullet;j++){ if(barrier1.move_flag == 1 && barrier1.init_flag == 1){ if(my_pythago_theorem(barrier1.x,enemy_shot[i].x[j], barrier1.y,enemy_shot[i].y[j],barrier1.range,enemy_shot[i].range)){ barrier1.power--; } } } } } } void my_collision_barrier_boss(){ for(int i = 0;i < DISP_BOSS_MAX;i++){ if(boss[i].move_flag == 1 && boss[i].init_flag == 1 && barrier1.power > 0){ if(barrier1.move_flag == 1 && barrier1.init_flag == 1){ if(my_pythago_theorem(barrier1.x,boss[i].x, barrier1.y,boss[i].y,barrier1.range,boss[i].range)){ barrier1.power--; if(boss[i].damage_flag == 1){ boss[i].power--; } } } } } } void my_collision_barrier_boss_shot(){ for(int i = 0;i < BOSS_SHOT_MAX;i++){ if(boss_shot[i].move_flag == 1 && boss_shot[i].init_flag == 1 && barrier1.power > 0){ for(int j = 0;j < boss_shot[i].max_bullet;j++){ if(barrier1.move_flag == 1 && barrier1.init_flag == 1){ if(my_pythago_theorem(barrier1.x,boss_shot[i].x[j], barrier1.y,boss_shot[i].y[j],barrier1.range,boss_shot[i].range)){ barrier1.power--; } } } } } } void my_collision_bomb_enemy(){ for(int i = 0;i < DISP_ENEMY_MAX;i++){ if(enemy[i].move_flag == 1 && enemy[i].init_flag == 1){ if(bomb1.move_flag == 1 && bomb1.init_flag == 1){ if(bomb1.flag == 1){ enemy[i].power--; } } } } } void my_collision_bomb_enemy_shot(){ for(int i = 0;i < ENEMY_SHOT_MAX;i++){ if(enemy_shot[i].move_flag == 1 && enemy_shot[i].init_flag == 1){ if(bomb1.move_flag == 1 && bomb1.init_flag == 1){ if(bomb1.flag == 1){ enemy_shot[i].move_flag = 0; enemy_shot[i].init_flag = 0; } } } } } void my_check_player_power(){ if(p1.power <= 0 && gameover_flag == 0){ my_set_exp_effect(p1.x,p1.y,1); gameover_flag = 1; } } void my_check_enemy_power(){ for(int i = 0;i < DISP_ENEMY_MAX;i++){ if(enemy[i].move_flag == 1 && enemy[i].init_flag == 1){ if(enemy[i].power <= 0){ enemy[i].move_flag = 0; enemy[i].init_flag = 0; my_set_exp_effect(enemy[i].x,enemy[i].y,1); if(enemy[i].item_flag == 1){ my_set_item(enemy[i].x,enemy[i].y,1); } score += 10; } } } } void my_check_boss_power(){ for(int i = 0;i < DISP_BOSS_MAX;i++){ if(boss[i].move_flag == 1 && boss[i].init_flag == 1){ if(boss[i].power <= 0){ gamecount2++; if(gamecount2 == 1){ my_set_exp_effect(boss[i].x,boss[i].y,2); } else if(gamecount2 == 200){ boss[i].move_flag = 0; boss[i].init_flag = 0; if(boss[i].end_flag == 1){ gameclear_flag = 1; } gamecount2 = 0; score += 1000; } } } } } void my_check_barrier_power(){ if(barrier1.power <= 0){ barrier1.move_flag = 0; barrier1.init_flag = 0; } } void my_change_state(){ if(gameover_flag == 1){ gamecount3++; if(gamecount3 == 200){ if(p1.life == 1){ game_state = 2; } else{ p1.life--; p1.shot_type = 0; game_state = 5; } } } else if(gameclear_flag == 1){ stage_num++; gamecount = 0; game_state = 25; } } void my_to_center(){ p1.draw_x = p1.x + 220; 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] + 220; 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 + 220; enemy[i].draw_y = ((-1) * enemy[i].y) + 240; } } for(int i = 0;i < ENEMY_SHOT_MAX;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] + 220; 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 + 220; boss[i].draw_y = ((-1) * boss[i].y) + 240; } } for(int i = 0;i < BOSS_SHOT_MAX;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] + 220; boss_shot[i].draw_y[j] = ((-1) * boss_shot[i].y[j]) + 240; } } } for (int i = 0;i < EXP_EFFECT_MAX;i++){ if (exp_effect[i].move_flag == 1 && exp_effect[i].init_flag == 1){ exp_effect[i].draw_x = exp_effect[i].x + 220; exp_effect[i].draw_y = ((-1) * exp_effect[i].y) + 240; } } for (int i = 0;i < ITEM_MAX;i++){ if (item[i].move_flag == 1 && item[i].init_flag == 1){ item[i].draw_x = item[i].x + 220; item[i].draw_y = ((-1) * item[i].y) + 240; } } if(barrier1.move_flag == 1 && barrier1.init_flag == 1){ barrier1.draw_x = barrier1.x + 220; barrier1.draw_y = ((-1) * barrier1.y) + 240; } } void my_draw_op(){ DrawFormatString(320 - (GetDrawFormatStringWidth("オープニング ENTERでスタート") / 2), 240, Color_White, "オープニング ENTERでスタート"); } void my_draw_ed(){ DrawFormatString(320 - (GetDrawFormatStringWidth("エンディング") / 2), 240, Color_White, "エンディング"); } void my_draw_stage_num(){ DrawFormatString(320 - (GetDrawFormatStringWidth("STAGE %d START",stage_num + 1) / 2), 220, Color_White, "STAGE %d START",stage_num + 1); DrawFormatString(320 - (GetDrawFormatStringWidth("PLAYER × %d",p1.life) / 2), 240, Color_White, "PLAYER × %d",p1.life); } void my_draw_start(){ DrawFormatString(220 - (GetDrawFormatStringWidth("STAGE START") / 2),160, Color_White, "STAGE START"); } void my_draw_clear(){ DrawFormatString(220 - (GetDrawFormatStringWidth("STAGE CLEAR") / 2),160, Color_White, "STAGE CLEAR"); DrawFormatString(220 - (GetDrawFormatStringWidth("TOTAL SCORE") / 2),180, Color_White, "TOTAL SCORE"); DrawFormatString(220 - (GetDrawFormatStringWidth("%d",score) / 2),200, Color_White, "%d",score); } void my_draw_gameover(){ if(gameover_flag == 1 && p1.life == 1){ DrawFormatString(220 - (GetDrawFormatStringWidth("GAME OVER") / 2),220, Color_White, "GAME OVER"); } } void my_draw_back(){ DrawGraph(back_img_x, back_img_y, back_img, TRUE); DrawGraph(back_img_x + 440, back_img_y, back_img, TRUE); DrawGraph(back_img_x, back_img_y - 480, back_img, TRUE); DrawGraph(back_img_x + 440, back_img_y - 480, back_img, TRUE); DrawLine(0, 240, 440, 240, Color_White); DrawLine(220, 0, 220, 480, Color_White); DrawFormatString(220, 240, Color_White, "(0,0)"); } void my_draw_player(){ if(p1.power > 0){ DrawFormatString(p1.draw_x, p1.draw_y, Color_White, "P"); } } 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){ DrawFormatString(ps1[i].draw_x[j],ps1[i].draw_y[j],Color_White, "弾"); } } } } } void my_draw_enemy(){ for (int i = 0; i < DISP_ENEMY_MAX; i++){ if (enemy[i].move_flag == 1 && enemy[i].init_flag == 1){ DrawFormatString(enemy[i].draw_x, enemy[i].draw_y, Color_Red, "e[%d]", enemy[i].serial_num); } } } void my_draw_enemy_shot(){ for(int i = 0;i < ENEMY_SHOT_MAX;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++){ DrawFormatString(enemy_shot[i].draw_x[j],enemy_shot[i].draw_y[j],Color_Red, "弾"); } } } } void my_draw_enemy_power(){ SetFontSize(7); for (int i = 0; i < DISP_ENEMY_MAX; i++){ if (enemy[i].move_flag == 1 && enemy[i].init_flag == 1){ int x_point = 0; for (int j = 0; j < enemy[i].power; j++){ DrawFormatString(enemy[i].draw_x + x_point, enemy[i].draw_y - 7, Color_White, "|"); x_point += 1; } } } SetFontSize(16); } void my_draw_boss(){ for (int i = 0; i < DISP_BOSS_MAX; i++){ if (boss[i].move_flag == 1 && boss[i].init_flag == 1){ DrawFormatString(boss[i].draw_x, boss[i].draw_y, Color_Red, "BOSS[%d]", boss[i].serial_num); } } } void my_draw_boss_shot(){ for(int i = 0;i < BOSS_SHOT_MAX;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++){ DrawFormatString(boss_shot[i].draw_x[j],boss_shot[i].draw_y[j],Color_Red, "弾"); } } } } void my_draw_boss_power(){ SetFontSize(7); for (int i = 0; i < DISP_BOSS_MAX; i++){ if (boss[i].move_flag == 1 && boss[i].init_flag == 1){ int x_point = 0; for (int j = 0; j < boss[i].power; j++){ DrawFormatString(boss[i].draw_x + x_point, boss[i].draw_y - 7, Color_White, "|"); x_point += 1; } } } SetFontSize(16); } void my_draw_exp_effect(){ for (int i = 0;i < EXP_EFFECT_MAX;i++){ if (exp_effect[i].move_flag == 1 && exp_effect[i].init_flag == 1){ DrawFormatString(exp_effect[i].draw_x, exp_effect[i].draw_y, Color_Red, "*"); } } } void my_draw_item(){ for (int i = 0;i < ITEM_MAX;i++){ if (item[i].move_flag == 1 && item[i].init_flag == 1){ DrawFormatString(item[i].draw_x, item[i].draw_y, Color_Green, "item"); } } } void my_draw_barrier(){ if(barrier1.move_flag == 1 && barrier1.init_flag == 1){ DrawFormatString(barrier1.draw_x, barrier1.draw_y, Color_White, "防"); } } void my_draw_bomb(){ if(bomb1.move_flag == 1 && bomb1.init_flag == 1){ if(bomb1.flag == 1){ DrawBox(0,0,440,480,Color_White,true); } } } void my_draw_score_board(){ DrawBox(440,0,640,480,Color_Gray,true); DrawFormatString(460, 20, Color_White, "gamecount = %d", gamecount); DrawFormatString(460, 40, Color_White, "p1.power = %d", p1.power); DrawFormatString(460, 60, Color_White, "p1.life = %d", p1.life); DrawFormatString(460, 80, Color_White, "p1.bomb = %d", p1.bomb); DrawFormatString(460, 100, Color_White, "barrier1.power = %d",barrier1.move_flag? barrier1.power:0); DrawFormatString(460, 360, Color_White, "score = %d", score); DrawFormatString(460, 380, Color_White, "操作方法"); DrawFormatString(460, 400, Color_White, "移動:矢印キー"); DrawFormatString(460, 420, Color_White, "ショット:Zキー"); DrawFormatString(460, 440, Color_White, "ボム:Xキー"); } 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; }/*Copyright 2016 K.N/petitetech.com*/
/*広告*/