エラーもなく実行できるのですがスコアが表示されません。
なぜスコアが表示されないのでしょうかおねがいします。
main.cpp
#include"control.h"
int WINAPI WinMain(HINSTANCE h1, HINSTANCE hP, LPSTR lpC, int nC) {
//ウインドウモードにする
ChangeWindowMode(TRUE);
//画面モードの設定
SetGraphMode(WINDOW_WIDTH, WINDOW_HEIGHT, 16);
//DXライブラリ初期化
if (DxLib_Init() == -1)return -1;
//グラフィックの描画先を裏画面にセット
SetDrawScreen(DX_SCREEN_BACK);
CONTROL *pCControl;
pCControl = new CONTROL;
while (ScreenFlip() == 0 && ProcessMessage() == 0 && ClearDrawScreen() == 0)
{
// 画面初期化
ClearDrawScreen();
pCControl->All();
//ESCキーで終了
if (CheckHitKey(KEY_INPUT_ESCAPE) == 1) break;
/* int Cr = GetColor(255, 255, 255);
DrawFormatString(0, 0, Cr, "てすと");*/
}
DxLib_End();
return 0;
}
define.h
#pragma once
#include<DxLib.h>
#define KEY_NUM 256
#define WINDOW_WIDTH 600
#define WINDOW_HEIGHT 900
#define PLAYER_SPEED 10
#define PLAYER_HP 100
#define PLAYER_LIFE 5
#define PLAYER_ATK 10
#define PLAYER_DIF 10
#define ENEMY_NUMBERS 15
#define ENEMY_SPEED 7
#define ENEMY_SHOT_SPEED 50
#define ENEMY_SHOT_NUMBERS 50
struct SHOT {
bool bSflag;//弾が発射中かどうか
int iSx;//x座標
int iSy;//y座標
int iSgh;//グラフィックハンドル
int iSw, iSh;//画像の幅と高さ
double rad;//角度
int iType;//弾の種類(0なら通常、1なら追跡弾)
};
#define PLAYER_SHOT_NUMBERS 30
#define PLAYER_SHOT_SPEED 15
struct E_SHOT {
bool bSflag;//弾が発射中かどうか
double x;//x座標
double y;//y座標
double rad;//角度(ラジアン)
int gh;//グラフィックハンドル
int width, height;//画像の幅と高さ
int pattern;//ショットパターン
int speed;//弾スピード
int type;
};
//敵のショット数
#define ENEMY_SNUM 50
player.h
#pragma once
#include"define.h"
class PLAYER {
private:
int iX; //x座標
int iY; //y座標
int iHp; //体力
int iLife; //残機
int iAtk; //攻撃力
int iDif; //守備力
int iSpeed; //移動速度
bool bDamageflag; //ダメージフラグ
bool bLive; //生きているか
bool bRflag; //右に進んでいるか
bool bLflag; //左に進んでいるか
int iGh; //グラヒックハンドル格納
int iRgh; //右グラヒックハンドル格納
int iLgh; //左グラヒックハンドル格納
int iDgh; //ダメージグラヒックハンドル格納
int iW; //画像の横幅
int iH; //画像の高さ
SHOT CPshot[PLAYER_SHOT_NUMBERS];
bool bSpaceflag;
int i;
int count = 0;//tesutoyou
void Move();
void Draw();
void Shot();
public:
PLAYER();
void All();
int Get_hp();
int Get_life();
int Get_atk();
int Get_dif();
int Get_speed();
};
player.cpp
#pragma once
#include"player.h"
PLAYER::PLAYER(){
iHp = PLAYER_HP;
iGh= LoadGraph("media\\a-ulinn.png");//画像読み込み
iDgh = LoadGraph("media\\a-ulinndamage.png");
iRgh = LoadGraph("media\\a-ulinnr.jpg");
iLgh = LoadGraph("media\\a-ulinnl.jpg");
GetGraphSize(iGh, &iW, &iH);
iX = (WINDOW_WIDTH / 2 - iW / 2);//自機x座標初期化
iY = (WINDOW_HEIGHT / 2 - iH / 2);//自機y座標初期化
iLife = PLAYER_LIFE;//残機初期化
iAtk = PLAYER_ATK;//攻撃力初期化
iDif = PLAYER_DIF;//守備力初期化
iSpeed = PLAYER_SPEED;//スピード初期化
bDamageflag = false;
bLive = true;
bRflag = false;
bLflag = false;
memset(CPshot, 0, sizeof(CPshot));
int temp = LoadGraph("media\\biimu.png");
int w, h;
GetGraphSize(temp, &w, &h);
for (int i = 0; i<PLAYER_SHOT_NUMBERS; ++i) {
CPshot[i].bSflag = false;
CPshot[i].iSgh = temp;
CPshot[i].iSw = w;
CPshot[i].iSh = h;
}
count = 0;
}
void PLAYER::Move() {
iY += 2;//下がり続ける
if (CheckHitKey(KEY_INPUT_UP) == 1 || CheckHitKey(KEY_INPUT_W) == 1)iY -= iSpeed;
if (CheckHitKey(KEY_INPUT_LEFT) == 1 || CheckHitKey(KEY_INPUT_A) == 1) {
iX -= (iSpeed/1.5);
bLflag = true;
}
if (CheckHitKey(KEY_INPUT_RIGHT) == 1 || CheckHitKey(KEY_INPUT_D) == 1) {
iX += (iSpeed/1.5);
bRflag = true;
}
//自機が画面外にいかない
if (iX > WINDOW_WIDTH - iW)iX = WINDOW_WIDTH - iW;
if (iX < 0)iX = 0;
if (iY > WINDOW_HEIGHT - iH)iY = WINDOW_HEIGHT - iH;
if (iY < 0)iY = 0;
}
void PLAYER::Draw() {
if (bLive) {
if (bDamageflag)DrawGraph(iX, iY, iDgh, TRUE);
else if (bRflag) {
DrawGraph(iX, iY, iRgh, TRUE);
bRflag = false;
}
else if (bLflag) {
DrawGraph(iX, iY, iLgh, TRUE);
bLflag = false;
}
else DrawGraph(iX, iY, iGh, TRUE);
}
for (i = 0; i < PLAYER_SHOT_NUMBERS; i++) {
if (CPshot[i].bSflag == true) {
CPshot[i].iSy -= PLAYER_SHOT_SPEED;
if (CPshot[i].iSy < 0 - CPshot[i].iSh) {
CPshot[i].bSflag = false;
}
DrawGraph(CPshot[i].iSx, CPshot[i].iSy, CPshot[i].iSgh, TRUE);
}
}
}
void PLAYER::Shot() {
if (CheckHitKey(KEY_INPUT_SPACE)) {
if (bSpaceflag == false) {
for (i = 0; i < PLAYER_SHOT_NUMBERS; i++) {
if (CPshot[i].bSflag == false) {
CPshot[i].iSx = (iW - CPshot[i].iSw) / 2 + iX;
CPshot[i].iSy = (iH - CPshot[i].iSh) / 2 + iY;
CPshot[i].bSflag = true;
// PlaySoundMem(shotsound, DX_PLAYTYPE_BACK);
break;
}
}
}
bSpaceflag = true;
}
else { bSpaceflag = false; }
}
void PLAYER::All() {
Move();
Shot();
Draw();
count++;
if (!(40 % count))iAtk += 10;
if (!(80 % count))iDif += 20;
if (!(160 % count))iHp += 30;
}
int PLAYER::Get_hp() {
return iHp;
}
int PLAYER::Get_life() {
return iLife;
}
int PLAYER::Get_atk() {
return iAtk;
}
int PLAYER::Get_dif() {
return iDif;
}
int PLAYER::Get_speed() {
return iSpeed;
}
control.h
#pragma once
#include"define.h"
#include"player.h"
#include"enemy.h"
#include"score.h"
class CONTROL {
private:
PLAYER *pCPlayer;
SCORE *pCScore;
//ENEMY *enemy[ENEMY_NUMBERS];
public:
CONTROL();
~CONTROL();
void All();
};
control.cpp
#include"control.h"
CONTROL::CONTROL() {
pCPlayer = new PLAYER();
//ppCPlayer = &pCPlayer;
//pCScore = new SCORE(ppCPlayer);
pCScore = new SCORE(pCPlayer);
}
void CONTROL::All(){
pCPlayer->All();
pCScore->All();
}
CONTROL::~CONTROL() {
delete pCPlayer;
//delete pCScore;
}
score.h
#pragma once
#include"define.h"
#include"player.h"
class SCORE {
private:
int iHp;//プレイヤーのHP
int iLife;//プレイヤーの残機
int iScore ;//スコア
int iAtk ;//プレイヤーの攻撃力
int iDif;//プレイヤーの守備力
int iSpeed;//プレイヤーのスピード
int iCr ;//文字色
void Get_sta();
void Draw();
PLAYER** p;
public:
SCORE(PLAYER *);
void All();
};
score.cpp
#include"score.h"
SCORE::SCORE(PLAYER *inp) {
iHp = PLAYER_HP;
iLife = PLAYER_LIFE;
iScore = 0;
iAtk = PLAYER_ATK;
iDif = PLAYER_DIF;
iSpeed = PLAYER_SPEED;
iCr = GetColor(255, 255, 255);
p = &inp;
}
void SCORE::Draw() {
DrawFormatString(50, 0, iCr, "HP %d/100", iHp);
DrawFormatString(50, 30, iCr, "残機 %d", iLife);
DrawFormatString(50, 60, iCr, "攻撃力 %d", iAtk);
DrawFormatString(50, 90, iCr, "守備力 %d", iDif);
DrawFormatString(50, 120, iCr, "スピード %d", iSpeed);
DrawFormatString(50, 150, iCr, "SCORE %d", iScore);
}
void SCORE::Get_sta() {
iHp = (*p)->Get_hp();
iLife = (*p)->Get_life();
iAtk = (*p)->Get_atk();
iDif = (*p)->Get_dif();
iSpeed = (*p)->Get_speed();
}
void SCORE::All() {
void Get_sta();
void Draw();
}