再掲します。
main.cpp
#include <DxLib.h>
#include"typedef_characters.h"
#include"Player_Enemy.h"
// プログラムは WinMain から始まります
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
Player_Enemy PE;
if (DxLib_Init() == -1) // DXライブラリ初期化処理
{
return -1; // エラーが起きたら直ちに終了
}
ChangeWindowMode(TRUE);
char tmpkey[256];
char key[256];
GetHitKeyStateAll(tmpkey);
for (int i = 0; i < 256; i++) {
if (tmpkey[i] != 0) {
key[i]++;
}
else {
key[i] = 0;
}
}
PE.LoadGraphs();
while (ProcessMessage() == 0 && ClearDrawScreen() == 0 && key[KEY_INPUT_ESCAPE] == 0) {
PE.PlayerMove();
PE.EnemyMove();
PE.EnemyInit();
PE.EnemyProgress();
ScreenFlip();
}
DxLib_End(); // DXライブラリ使用の終了処理
return 0; // ソフトの終了
}
typedef_characters.h
#pragma once
#define shot 12
#define shot1 100
typedef struct Player
{
float x = 10;
float y = 200;
int chara_hp;
int g_graph;
bool flag = false;
};
typedef struct Enemy
{
float x;
float y;
bool flag = true;
bool flag_1 = true;
bool flag_2 = true;
int E_hp;
int Eg_graph;
int count = 0;
};
typedef struct Bullet
{
float x;
float y;
int count = 15;
bool flag = true;
int Bg_graph;
int angle[shot] = { 360,330,300,270,240,210,180,150,120,90,60,30 };
};
typedef struct BulletMAX
{
float x[shot];
float y[shot];
bool flag = true;
int Bg_graph[shot];
int angle[shot1];
};
Player_Enemy.cpp
#include "Player_Enemy.h"
#include<DxLib.h>
#include"typedef_characters.h"
#include<math.h>
#include"KindsBullets.h"
Player player;
Enemy enemy;
Bullet *bullet = new Bullet[shot];
BULLET_KINDS BKinds;
BulletMAX* bulletmax = new BulletMAX[shot];
void Player_Enemy::LoadGraphs()
{
player.g_graph = LoadGraph("E:\\Aseprite\\chara0001.png");
enemy.Eg_graph = LoadGraph("E:\\Aseprite\\chara0002.png");
for (int i = 0; i < shot; i++) bullet[i].Bg_graph = LoadGraph("E:\\Aseprite\\bulletskincolor.png");
for (int i = 0; i < shot; i++) bulletmax[i].Bg_graph[i] = LoadGraph("E:\\Aseprite\\bulletskincolor.png");
}
void Player_Enemy::PlayerMove()
{
char tmpkey[256];
char key[256];
GetHitKeyStateAll(tmpkey);
for (int i = 0; i < 256; i++) {
if (tmpkey[i] != 0) {
key[i]++;
}
else {
key[i] = 0;
}
}
//移動処理
if (key[KEY_INPUT_W]) {
player.y -= 5.0f;
}
if (key[KEY_INPUT_S]) {
player.y += 5.0f;
}
if (key[KEY_INPUT_D]) {
player.x += 5.0f;
}
if (key[KEY_INPUT_A]) {
player.x -= 5.0f;
}
//範囲指定
if (player.y > 400) {
player.y == 400;
}
if (player.y < 0) {
player.y == 0;
}
if (player.x > 500) {
player.x == 500;
}
if (player.x < 0) {
player.x == 0;
}
//描画処理
DrawGraph(player.x, player.y, player.g_graph, true);
}
void Player_Enemy::EnemyMove()
{
if (enemy.y < 100) {
enemy.y += 10.0f;
}
if (enemy.y>100) {
enemy.y += 0;
}
if (enemy.count > 100) {
enemy.x += 10;
enemy.y -= 10;
}
DrawGraph(enemy.x, enemy.y, enemy.Eg_graph, true);
enemy.count++;
}
void Player_Enemy::EnemyInit()
{
int blsizex;
int blsizey;
int ensizex, ensizey;
//弾生成
if (bullet->flag==true&&bullet->count%60==0)
{
GetGraphSize(bullet->Bg_graph, &blsizex, &blsizey);
GetGraphSize(enemy.Eg_graph, &ensizex, &ensizey);
//for (int i = 0; i < shot; ++i) {
//
// bullet[i].x = cos(bullet[i].angle[i]) * 30 + enemy.x + (ensizex - blsizex) / 2;
// bullet[i].y = sin(bullet[i].angle[i]) * 30 + enemy.y + (ensizey - blsizey) / 2;
//
//}
for (int i = 0; i < 10; i++) {
for (int j = 0; j < shot; j++) {
bulletmax[i].x[j] = cos(bullet[i].angle[j]) * 30+enemy.x;
bulletmax[i].y[j] = sin(bullet[i].angle[j]) * 30+enemy.y;
bulletmax[i].Bg_graph[j] = enemy.Eg_graph;
}
}
}
bullet->count++;
}
void Player_Enemy::EnemyDrawshooting()
{
for (int j = 0; j < 5; ++j) {
for (int i = 0; i < shot; ++i) {
}
}
}
void Player_Enemy::EnemyProgress()
{
if (bullet->flag) {
//for (int j = 0; j < 10; ++j) {
// for (int i = 0; i < shot; ++i) {
// bullet[i].x += cos(bullet[i].angle[i]) * 2;
// bullet[i].y += sin(bullet[i].angle[i]) * 2;
//
// DrawGraph(bullet[i].x, bullet[i].y, bullet[i].Bg_graph, true);
// }
//}
for (int i = 0; i < 10; i++) {
for (int j = 0; j < shot; j++) {
bulletmax[i].x[j] += cos(bullet[i].angle[j]) * 5;
bulletmax[i].y[j] += sin(bullet[i].angle[j]) * 5;
DrawGraph(bulletmax[i].x[j], bulletmax[i].y[j], bulletmax[i].Bg_graph[j], true);
}
}
}
}
Player_Enemy.h
#pragma once
class Player_Enemy
{
public:
void LoadGraphs();
void PlayerMove();
void PlayerShooting();
void EnemyMove();
void EnemyDrawshooting();
void EnemyInit();
void EnemyProgress();
};
KindsBullets.h
#pragma once
#include"typedef_characters.h"
#define shots 12
Enemy En;
Bullet* bullet = new Bullet[shot];
enum {
BULLET_1,
BULLET_2,
BULLET_3,
BULLET_MAX
};
typedef struct {
int x;
int y;
int flag;
int count;
int kinds_graph;
int angle[shots];
}BULLET_KINDS;
BULLET_KINDS Bullet_Kinds[BULLET_MAX] = {
{
En.x,
En.y,
En.flag,
En.count,
bullet->Bg_graph,
{ 360,330,300,270,240,210,180,150,120,90,60,30 }
},
{
En.x ,
En.y ,
En.flag_1,
En.count,
bullet->Bg_graph,
{ 360,330,300,270,240,210,180,150,120,90,60,30 }
},
{
En.x ,
En.y,
En.flag_2,
En.count,
En.Eg_graph,
{ 360,330,300,270,240,210,180,150,120,90,60,30 }
},
};
以上となります。
長々とすみません。
これですべてです。
申し訳ございません。全部出す必要がありましたね…因みにコンパイルエラーとかはありません。