/*STGの作り方 中間ソース11*/

/*目次へ戻る*/ #include "DxLib.h" #include <time.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 5 #define STAGE_ENEMY_MAX 10 #define ENEMY_DATA_MAX 9 #define DISP_BOSS_MAX 2 #define STAGE_BOSS_MAX 2 #define BOSS_DATA_MAX 10 void my_init_back_img(void); void my_init_variable(void); void my_init_player(void); void my_init_player_shot(void); void my_init_enemy(void); void my_init_enemy_shot(void); void my_init_boss(void); void my_init_exp_effect(void); void my_init_item(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_exp_effect(double,double,int); void my_set_item(double,double); 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_exp_effect(void); void my_move_item(void); int my_pythago_theorem(double,double,double,double,double,double); void my_collision_detection(void); void my_to_center(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_exp_effect(void); void my_draw_item(void); void my_draw_variable(void); void my_draw_enemy_power(void); void my_draw_boss_power(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; }; 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; }; 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; int move_type; int shot_type; int gamecount_point[5]; int power; double range; int item_flag; int end_flag; }; struct BOSS boss[DISP_BOSS_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[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]; int ary_enemy_data[STAGE_ENEMY_MAX * ENEMY_DATA_MAX] = { 0,100,-250,260,0,0,1,10,1, 1,300,-200,260,0,0,1,10,0, 2,500,-150,260,0,0,1,10,1, 3,700,-100,260,0,0,1,10,0, 4,900,-50,260,0,0,1,10,1, 5,1800,50,260,0,0,1,10,0, 6,2000,100,260,0,0,1,10,1, 7,2200,150,260,0,0,1,10,0, 8,2400,200,260,0,0,1,10,1, 9,2600,250,260,0,0,1,10,0 }; int ary_boss_data[STAGE_BOSS_MAX * BOSS_DATA_MAX] = { 100,1100,0,260,1,0,30,10,0,0, 101,2800,0,260,1,0,30,10,0,1 }; int key[256]; double back_img_y; int back_img; int gamecount; int gamecount2; int Color_White; int Color_Red; int Color_Green; int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int){ ChangeWindowMode(TRUE); DxLib_Init(); SetDrawScreen(DX_SCREEN_BACK); my_init_back_img(); my_init_variable(); my_init_player(); my_init_player_shot(); my_init_enemy(); my_init_enemy_shot(); my_init_boss(); my_init_exp_effect(); my_init_item(); while (ScreenFlip()==0 && ProcessMessage()==0 && ClearDrawScreen()==0 && my_get_key()==0){ 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_exp_effect(); my_move_item(); 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_boss(); my_draw_exp_effect(); my_draw_item(); my_draw_variable(); my_draw_enemy_power(); my_draw_boss_power(); my_timer(); } DxLib_End(); return 0; } void my_init_back_img(){ back_img = LoadGraph("../back_img.jpg"); } void my_init_variable(){ gamecount = 0; gamecount2 = 0; Color_White = GetColor(255, 255, 255); Color_Red = GetColor(255, 0, 0); Color_Green = GetColor(0, 255, 0); back_img_y = 0; srand((unsigned)time(NULL)); } void my_init_player(){ p1.x = 0; p1.y = -200; p1.draw_x = 0; p1.draw_y = 0; p1.speed = 4; p1.shot_type = 0; p1.power = 100; p1.life = 3; p1.range = 10; } 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_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_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_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].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_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_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_move_back(){ back_img_y++; if (back_img_y > 480){ back_img_y = 0; } } void my_move_player(){ 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); } } 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; default: break; } } } } void my_set_enemy(){ for (int i = 0; i < STAGE_ENEMY_MAX; i++){ if (ary_enemy_data[(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[i * ENEMY_DATA_MAX]; enemy[j].appear_point = ary_enemy_data[(i * ENEMY_DATA_MAX) + 1]; enemy[j].first_x = ary_enemy_data[(i * ENEMY_DATA_MAX) + 2]; enemy[j].first_y = ary_enemy_data[(i * ENEMY_DATA_MAX) + 3]; enemy[j].move_type = ary_enemy_data[(i * ENEMY_DATA_MAX) + 4]; enemy[j].shot_type = ary_enemy_data[(i * ENEMY_DATA_MAX) + 5]; enemy[j].power = ary_enemy_data[(i * ENEMY_DATA_MAX) + 6]; enemy[j].range = ary_enemy_data[(i * ENEMY_DATA_MAX) + 7]; enemy[j].item_flag = ary_enemy_data[(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; 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; default: break; } } } } void my_set_boss(){ for (int i = 0; i < STAGE_BOSS_MAX; i++){ if (ary_boss_data[(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[i * BOSS_DATA_MAX]; boss[j].appear_point = ary_boss_data[(i * BOSS_DATA_MAX) + 1]; boss[j].first_x = ary_boss_data[(i * BOSS_DATA_MAX) + 2]; boss[j].first_y = ary_boss_data[(i * BOSS_DATA_MAX) + 3]; boss[j].move_type = ary_boss_data[(i * BOSS_DATA_MAX) + 4]; boss[j].shot_type = ary_boss_data[(i * BOSS_DATA_MAX) + 5]; boss[j].power = ary_boss_data[(i * BOSS_DATA_MAX) + 6]; boss[j].range = ary_boss_data[(i * BOSS_DATA_MAX) + 7]; boss[j].item_flag = ary_boss_data[(i * BOSS_DATA_MAX) + 8]; boss[j].end_flag = ary_boss_data[(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].gamecount_point[0] = gamecount; boss[i].init_flag = 1; } else{ if (gamecount < boss[i].gamecount_point[0] + 1000){ if(boss[i].power > 0){ if (gamecount < boss[i].gamecount_point[0] + 220){ boss[i].y--; } if (gamecount > boss[i].gamecount_point[0] + 240 && gamecount < boss[i].gamecount_point[0] + 520){ if(gamecount % 100 == 1){ my_set_enemy_shot(boss[i].x,boss[i].y,boss[i].shot_type,i); } } if (gamecount > boss[i].gamecount_point[0] + 520){ 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] + 220){ boss[i].y--; } 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; 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] = {-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){ 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; } } } } 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)){ p1.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--; ps1[j].flag[k] = 0; } } } } } if(enemy[i].power <= 0){ my_set_exp_effect(enemy[i].x,enemy[i].y,0); 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; } } 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)){ 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)){ p1.power--; } } } } 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)){ p1.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--; ps1[j].flag[k] = 0; } } } } } 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(boss[i].end_flag == 1){ WaitKey(); } gamecount2 = 0; boss[i].move_flag = 0; boss[i].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_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; } } } void my_draw_back(){ DrawGraph(0, back_img_y, back_img, TRUE); DrawGraph(0, back_img_y - 480, back_img, TRUE); DrawLine(0, 240, 640, 240, Color_White); DrawLine(320, 0, 320, 480, Color_White); DrawFormatString(320, 240, Color_White, "(0,0)"); DrawFormatString(100, 0, Color_White, "操作方法 移動:矢印キー ショット:Zキー"); } void my_draw_player(){ 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_no); } } } 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++){ DrawFormatString(enemy_shot[i].draw_x[j],enemy_shot[i].draw_y[j],Color_Red, "弾"); } } } } 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){ DrawFormatString(exp_effect[i].draw_x, exp_effect[i].draw_y, Color_Red, "*"); } } } void my_draw_item(){ for (int i = 0;i < DISP_ENEMY_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_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_no); } } } void my_draw_variable(){ DrawFormatString(440, 440, Color_White, "gamecount = %d", gamecount); DrawFormatString(440, 460, Color_White, "p1.power = %d", p1.power); } void my_draw_enemy_power(){ int y_point = 420; for (int i = DISP_ENEMY_MAX;i >= 0; i--){ if (enemy[i].move_flag == 1){ DrawFormatString(440, y_point, Color_White, "enemy[%d].power = %d", enemy[i].serial_no, enemy[i].power); y_point = y_point - 20; } } } void my_draw_boss_power(){ int y_point = 20; for (int i = DISP_BOSS_MAX;i >= 0; i--){ if (boss[i].move_flag == 1 && boss[i].power > 0){ DrawFormatString(440, y_point, Color_White, "boss[%d].power = %d", boss[i].serial_no, boss[i].power); y_point = y_point + 20; } } } 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*/