画像のアニメーション
Posted: 2014年9月07日(日) 09:25
#include "DxLib.h"
#include <math.h>
#define PI (3.14159269)
#define SCREEN_WIDTH (640) // 画面の横幅
#define SCREEN_HEIGHT (480) // 画面の縦幅
#define CHIP_SIZE (32) // 一つのチップのサイズ
#define MAP_WIDTH (120) // マップの横幅
#define MAP_HEIGHT (20) // マップの縦幅
#define CHAR_SIZE (30)
#define G (0.3F) // キャラに掛かる重力加速度
#define speed (1.0F)
#define p_jump (10.0F) //キャラのジャンプ力
#define h_speed (1.0F) //背景のスピード
int sousasetumei;
int h_color=(255,0,0),st=(255,255,222);//カラー変数
int color=GetColor(255,255,255);
int mode=0;//シーン用の変数
int t_back,t_mask,t_over,t_count=0,t_moji;
int tai_sound,st_call,st_oto,st_BGM;//タイトル用変数
int title_Bright=0;
int misail,mx,my,m1_count=0,m2_count=0;//弾用変数
int mw,mh;
bool pm_flag=false;
bool key_flag=false;
float px=30.0F,py=420.0F;//キャラ用変数
int pr[6],xcount,kaiten_count=0;
float Movex=0.0F,Movey=0.0F;//移動量
int ph,pw;//キャラ画像の高さと幅
int at_count,reitai=0;
int muki=3,i,j;
float p_downsp=4.0F;
int input=0,keep_input=0;
bool p_flag=false;
int r_flag=0;
int hp_x=374;//HP変数
int sp=360;//sp変数
char Key[256];
int goki,g_Handle,ex=608,ey=366,ey_prev,ey_tmp,e_junp=0;//敵(死神)用変数
int et_count=0;
int ew,eh;//敵画像の高さと幅
bool ep_flag=false;//敵のジャンプフラグ
bool e_flag=true;//敵の存在有無
int g_hp=70;
int zonbi[6],zx=608,zy=450,zx_count,z_junp=0;//敵(ゾンビ)用
int zw,zh;
bool z_flag=false;//ゾンビの存在有無
bool zp_flag=false;//ジャンプしてるかどうか
int z_anime,zr_flag=32;
int z_hp=30;
int yurei[4],yu_x=2900,yu_y=272,RL_flag,y_muki=0;//幽霊用変数
int yu_count;
int yu_movex=1;
int yu_hp=40;
int torinn[2],tori_x=2679,tori_y=336,tori_count;//とりんドル用変数
int tori_hp=10;
int tow,toh;
int jiga,jigax=2341,jigay=480;//自画用変数
int ji_flag=true;
int j_hp=950;
int jw,jh;
int count=0;
int haikei,stage_haikei;
float sh_x=0.0F,sh_y=0.0F,stage_haikei2,sh2_x=0;//ステージ用変数
int tera,tx=3700,ty=330;
int torii,tr_x=32,tr_y=194;
int ido,id_x=3304,id_y=194,idw,idh;
int dao,dao_x=3310,dao_y=480,dao_dy=10,dh,dw;//井戸文字
int jam_dao;//音声変数
int kage,kx=0,ky=384;
int DrawBaseX,DrawBaseY;
int orbu_r,orbu_rx,orbu_ry,orbu_b,orbu_bx=60,orbu_by=367;//アイテム(オーブ)
int oh,ow;
int ob_flag=false;
int wall,wx,wy;
//マップとの当たり判定(戻り値0当たらなかった 1:左辺に当たった 2:右辺に当たった
// 3:上辺に当たった 4:下辺に当たった
//MoveXとMoveY,どっちか片方が0じゃないと動作しない
int GetChipParam(float x,float y);
int CharMove(float *cx,float *cy,float DownSP,float Movex,float Movey,float size,float *p_flag);
int MapHitCheck(float x,float y,float *Move_shx,float *Move_shy);
char hantei[MAP_HEIGHT][MAP_WIDTH] ={
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,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,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,
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,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,0,0,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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,0,0,0, 0,0,1,0,0, 0,0,0,0,1, 0,0,0,0,0, 0,1,1,1,1, 1,1,1,1,0, 4,0,0,0,0, 0,0,0,0,0, 0,0,0,0,2,
1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1 ,1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1, 1,1,1,0,0, 0,0,0,1,1, 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,0, 0,6,0,0,0, 0,1,1,1,1, 1,1,1,1,1,
} ;
// キャラクタをマップとの当たり判定を考慮しながら移動する
int CharMove(float *x,float *y,float *DownSP,float Movex,float Movey,float size,bool *p_flag){
float Dummy = 0.0F ;
float hsize ;
// キャラクタの左上、右上、左下、右下部分が当たり判定のある
// マップに衝突しているか調べ、衝突していたら補正する
// 半分のサイズを算出
hsize=size*0.5F ;
// 先ず上下移動成分だけでチェック
{
// 左下のチェック、もしブロックの上にキャラがいたら落下停止
if( MapHitCheck(*x-hsize,*y+hsize,&Dummy,&Movey)==3){
*DownSP=0.0F;
}
if(MapHitCheck(*x+hsize,*y+hsize,&Dummy,&Movey)==3){
*DownSP=0.0F;
}
if( MapHitCheck(*x-hsize,*y-hsize,&Dummy,&Movey)==4){
*DownSP=-1.0F;
}
if(MapHitCheck(*x+hsize,*y-hsize,&Dummy,&Movey)== 4){
*DownSP=-1.0F;
}
// 上下移動成分を加算
*y+=Movey;
}
// 後に左右移動成分だけでチェック
{
// 左下のチェック
MapHitCheck(*x-hsize,*y+hsize,&Movex,&Dummy);
MapHitCheck(*x+hsize,*y+hsize,&Movex,&Dummy);
MapHitCheck(*x-hsize,*y-hsize,&Movex,&Dummy);
MapHitCheck(*x+hsize,*y-hsize,&Movex,&Dummy);
// 左右移動成分を加算
*x+=Movex;
}
// 接地判定
{
// キャラクタの左下と右下の下に床があるかどうか
if(GetChipParam(*x-size*0.5F,*y+size*0.5F+1.0F)==0 && GetChipParam(*x+size*0.5F,*y+size*0.5F+1.0F)==0){
// 床が無かったらジャンプ中にする
*p_flag=true;
}
else{
*p_flag=false;
}
}
return 4;
}
int MapHitCheck(float x,float y,float *Movex,float *Movey){
float afX,afY;
// 移動量を足す
afX=x+*Movex;
afY=y+*Movey;
// 当たり判定のあるブロックに当たっているかチェック
if(GetChipParam(afX,afY)==1){
float blx,bty,brx,bby;
// 当たっていたら壁から離す処理を行う
// ブロックの上下左右の座標を算出
blx=(float)((int)afX/CHIP_SIZE)*CHIP_SIZE;
brx=(float)((int)afX/CHIP_SIZE+1)*CHIP_SIZE;
bty=(float)((int)afY/CHIP_SIZE)*CHIP_SIZE;
bby=(float)((int)afY/CHIP_SIZE+1)*CHIP_SIZE;
// 上辺に当たっていた場合
if(*Movey>0.0F){
// 移動量を補正する
*Movey=bty-y-1.0F ;
// 上辺に当たったと返す
return 3;
}
// 下辺に当たっていた場合
if(*Movey<0.0F){
// 移動量を補正する
*Movey=bby-y+1.0F;
// 下辺に当たったと返す
return 4;
}
// 左辺に当たっていた場合
if(*Movex>0.0F){
// 移動量を補正する
*Movex=blx-x-1.0F;
// 左辺に当たったと返す
return 1;
}
// 右辺に当たっていた場合
if(*Movex<0.0F){
// 移動量を補正する
*Movex=brx-x+1.0F;
// 右辺に当たったと返す
return 2;
}
// ここに来たら適当な値を返す
return 4;
}
// どこにも当たらなかったと返す
return 0;
}
int GetChipParam(float x,float y){
int cx,cy;
cx=(int)x/CHIP_SIZE;
cy=(int)y/CHIP_SIZE;
if(cx>=SCREEN_WIDTH || cy>=SCREEN_HEIGHT || cx<0 || cy<0){
return 0;
}
return hantei[cy][cx];
}
//自画の上下移動
void jiga_move(){
if(j_hp>0 && ji_flag==true){
if(jigay>380){
jigay--;
if(jigay<=380){
jigay=450;
}
}
//ダメージ回復
if(jigay==450 && j_hp<=950){
j_hp++;
}
//弾との当たり判定
if(((mx>jigax&&mx<jigax+jw) || (jigax>mx&&jigax<mx+mw))&&((my>jigay&&my<jigay+jh) || (jigay>my&&jigay<my+mh))){//判定処理
j_hp--;
reitai++;
}
DrawGraph(jigax-DrawBaseX,jigay-DrawBaseY,jiga,TRUE);
DrawFormatString(jigax+35,jigay-43,GetColor(255,0,255),"HP:%d",j_hp);
}else{
ji_flag=false;
//DeleteGraph(jiga);
}
}
//井戸・文字の上運動
void dao_move(){
if(((px>id_x&&px<id_x+idw) || (id_x>px&&id_x<px+pw))&&((py>id_y&&py<id_y+idh) || (id_y>py&&id_y<py+ph))){//判定処理
dao_y-=20;
}
if(dao_y-=20){
PlaySoundMem(jam_dao,DX_PLAYTYPE_BACK);
}
}
void reibai(){
DrawString(px/2,240,"霊払成功!!",GetColor(255,255,255));
}
int updatekey(){
char tKey[256];
GetHitKeyStateAll(tKey);
for(int tk=0;tk<256;tk++){
if(tKey[tk]!=0){
Key[tk]++;
}else {
Key[tk]=0;
}
}return 0;
}
//画像消去
void menu_delete(){
DeleteGraph(t_back);
DeleteGraph(t_mask);
DeleteGraph(t_over);
}
//タイトル回転数計算
void menu_calc(){
t_count++;
}
//ゲームオーバー
void gameover(){
LoadGraphScreen(0,0,"アクション画像/Gameover.png",FALSE);
}
//タイトル
void title(){
//照明
title_Bright++;
if(title_Bright>=255){
title_Bright=255;
}
SetDrawBright(title_Bright,title_Bright,title_Bright);
DrawGraph(0,0,haikei,FALSE);
//点滅処理
count=(count+1)%20;
if(count<2){
WaitTimer(500);
DrawGraph(-30,100,t_moji,TRUE);
}
if(Key[KEY_INPUT_G]==1/* && title_Bright==255*/){
PlaySoundMem(st_oto,DX_PLAYTYPE_BACK);
PlaySoundMem(st_call,DX_PLAYTYPE_BACK);
WaitTimer(3000);
mode=1;
}
}
//操作説明
void setumei(){
DrawGraph(0,0,sousasetumei,TRUE);
DrawString(320,230,"↑",st);
DrawString(310,240,"←",st);
DrawString(330,240,"→",st);
DrawString(305,200,"ジャンプ",st);
DrawString(250,240,"左移動",st);
DrawString(360,240,"右移動",st);
if(Key[KEY_INPUT_G]==1) mode=1;
if(Key[KEY_INPUT_M]==1) mode=0;
}
void kabe(){
{
DrawBaseX=px-SCREEN_WIDTH/3;
DrawBaseY=py-SCREEN_HEIGHT;
if(DrawBaseX<0){
DrawBaseX=0;
}
if(DrawBaseX+SCREEN_WIDTH>MAP_WIDTH*CHIP_SIZE){
DrawBaseX=MAP_WIDTH*CHIP_SIZE-SCREEN_WIDTH;
}
if(DrawBaseY<0){
DrawBaseY=0;
}
if(DrawBaseY+SCREEN_HEIGHT>MAP_HEIGHT*CHIP_SIZE){
DrawBaseY=MAP_HEIGHT*CHIP_SIZE-SCREEN_HEIGHT;
}
}
//描画するマップチップの数をセット
// マップを描く
for(i=0;i<MAP_HEIGHT;i++){
for(j=0;j<MAP_WIDTH;j++){
// マップデータが1だったら四角を描画する
if(hantei[i][j]==1){
DrawGraph((int)(j*CHIP_SIZE-DrawBaseX),(int)(i*CHIP_SIZE-DrawBaseY),wall,FALSE);
}
if(hantei[i][j]==2){
DrawGraph(tx-DrawBaseX,ty-DrawBaseY,tera,TRUE);
}
if(hantei[i][j]==3){
DrawGraph(tr_x-DrawBaseX,tr_y-DrawBaseY,torii,TRUE);
}
if(hantei[i][j]==4){
DrawGraph(id_x-DrawBaseX,id_y-DrawBaseY,ido,TRUE);
}
/* if(hantei[i][j]==5){
DrawGraph(jigax-DrawBaseX,jigay-DrawBaseY,jiga,TRUE);
}*/
if(hantei[i][j]==6){
DrawGraph(dao_x-DrawBaseX,dao_y-DrawBaseY,dao,TRUE);
}
}
}
DrawFormatString(3,80,GetColor(255,255,255),"自画の座標は:%d",jigay);
}
//弾の関数
void mr_flag(int mx,int m1_flag,int muki){
if(muki==1){
if(m1_count<=640){
mx+=10;
m1_count++;
}
}
}
void pmove(){
if(hp_x>310){
{
//左キーが押されたとき
if(Key[KEY_INPUT_LEFT]==1){
muki=1;
key_flag=true;
r_flag=1;
Movex-=speed;
if(Movex<-3){
Movex=-3;
}
}
//右キーが押されたとき
if(Key[KEY_INPUT_RIGHT]==1){
muki=3;
key_flag=true;
r_flag=3;
Movex+=speed;
if(Movex>3){
Movex=3;
}
}
//上キーが押されたとき
if(Key[KEY_INPUT_UP]==1 && p_flag==false){
muki=4;
p_downsp=-p_jump;
p_flag=true;
}
p_downsp+=G;
Movey=p_downsp;
//下キーを押すと、落下速度がつく
if(Key[KEY_INPUT_DOWN]==1){
p_downsp=10.0;
}
//主人公のアニメーション
if(Key[KEY_INPUT_LEFT]==1){
xcount++;
if(xcount>=6){
xcount=3;
}
}
if(Key[KEY_INPUT_RIGHT]==1){
xcount++;
if(xcount>=3){
xcount=0;
}
}
CharMove(&px,&py,&p_downsp,Movex,Movey,CHAR_SIZE,&p_flag);
}
//プレイヤー弾発射
if(sp>=310){
if(Key[KEY_INPUT_Z]==1 && pm_flag==false){
mx=px;
my=py-20;
pm_flag=true;
}
}
//弾の移動処理
if(pm_flag==true){
if(muki==3 && m2_count==0){//右を向いていて、mxの減算処理が終了していたら
mx+=10;
m1_count++;
if(mx>=660){
pm_flag=false;
m1_count=0;//初期化する
}
}
}
/* if(muki==1 && m1_count==0){//左を向いて、mxの加算処理が終了していたえら
mx-=10;
m2_count--;
if(mx<=-70){
pm_flag=false;
m2_count=0;//初期化する
}
}
if(((mx>ex&&mx<ex+ew) || (ex>mx&&ex<mx+mw))&&((my>ey&&my<ey+eh) || (ey>my&&ey<my+mh)) && e_flag==true){//判定処理
reitai++;
if(((mx>zx&&mx<zx+zw) || (zx>mx&&zx<mx+mw))&&((my>zy&&my<zy+zh) || (zy>my&&zy<my+mh)) && z_flag==true){
reitai++;//除霊作業量
}
}
DrawGraph(mx,my,misail,TRUE);
}*/
//弾を撃った時のSPの消耗処理
/* if(Key[KEY_INPUT_Z]==1){
if(sp>=310){
sp-=5;
}
}*/
//アイテム出現
if(e_flag==false){
if(((orbu_bx>px&&orbu_bx<px+pw) || (px>orbu_bx&&px<orbu_bx+ow))&&((orbu_by>py&&orbu_by<py+ph) || (py>orbu_by&&py<orbu_by+oh))){
DeleteGraph(orbu_b);
if(sp<=370){
sp++;
}
}
}
//死神との当たり判定
if(((ex>px&&ex<px+pw) || (px>ex&&px<ex+ew))&&((ey>py&&ey<py+ph) || (py>ey&&py<ey+eh))){
if(g_hp>0){
if(hp_x>=310){
hp_x=310;
DeleteGraph(pr[xcount]);
PlaySoundMem(st_BGM,DX_PLAYTYPE_BACK);
}
}
}
//ゾンビとの当たり判定
if(((zx>px&&zx<px+pw) || (px>zx&&px<zx+zw))&&((zy>py&&zy<py+ph) || (py>zy&&py<zy+zh))){
if(z_hp>0){
if(hp_x>=310){
hp_x--;
}else if(hp_x<0){
DeleteGraph(pr[xcount]);
PlaySoundMem(st_BGM,DX_PLAYTYPE_BACK);
}
}
}
//とりんドルとの当たり判定
if(((tori_x>px&&tori_x<px+pw) || (px>tori_x&&px<tori_x+tow))&&((tori_y>py&&zy<py+ph) || (py>tori_y&&py<tori_y+toh))){
if(tori_hp>0){
DrawRotaGraph(px,py,PI/4,10.0,pr[xcount],TRUE);
kaiten_count++;
hp_x--;
if(hp_x<0){
DeleteGraph(pr[xcount]);
PlaySoundMem(st_BGM,DX_PLAYTYPE_BACK);
}
}
}
//井戸文字あたり判定
if(((dao_x>px&&dao_x<px+pw) || (px>dao_x&&px<dao_x+dw))&&((dao_y>py&&dao_y<py+ph) || (py>dao_y&&py<dao_y+dh))){
if(hp_x>310){
hp_x--;
}
}
//jigaとの当たり判定
if(((jigax>px&&jigax<px+pw) || (px>jigax&&px<jigax+jw))&&((jigay>py&&jigay<py+ph) || (py>jigay&&py<jigay+jh))){
Movex=0;
p_flag=false;
}
//mapchipが6の部分で下を押すと、別ステージへ行く
if(px>=id_x && px<=id_x+128 && py<=id_y-96){
if(Key[KEY_INPUT_DOWN]==1){
py--;
}
}
//寺の前でUPキーを押すと、クリアー
if(px>=3660 && px>=3690 && py<=450 && py>=416){
if(Key[KEY_INPUT_UP]==1){
if(reitai>=800){
DeleteGraph(pr[xcount]);
reibai();
}
}
}
//キャラクタの移動制御
if(py<=0+32){
py=0+32;
}else if(py>=480){
mode=2;
}
if(px<=0){
px=0;
}else if(px>=3810){
px=3810;
}
}
DrawGraph(sh_x,sh_y,stage_haikei,TRUE);
kabe();
jiga_move();
dao_move();
DrawString(500,3,"M:メニュー画面",GetColor(255,0,0));
DrawGraph((int)(px-CHAR_SIZE*0.5F-DrawBaseX),(int)(py-CHAR_SIZE*0.5F-DrawBaseY),pr[xcount],TRUE);
DrawBox(310,7,hp_x,16,GetColor(255,0,0),TRUE);
DrawBox(310,30,sp,38,GetColor(240,0,255),TRUE);
DrawGraph(mx,my,misail,TRUE);
DrawGraph(orbu_bx,orbu_by,orbu_b,TRUE);
DrawGraph(kx-DrawBaseX,ky-DrawBaseY,kage,TRUE);
DrawString(270,3,"精力",GetColor(255,255,255),TRUE);
DrawString(285,25,"気",GetColor(255,255,255),TRUE);
DrawFormatString(266,48,GetColor(255,255,255),"駆除数%d",reitai);
DrawFormatString(3,3,GetColor(255,255,255),"キャラのX座標:%f",px);
DrawFormatString(3,24,GetColor(255,255,255),"キャラのy座標:%f",py);
DrawFormatString(3,45,GetColor(255,255,255),"弾の座標は:%d",mx);
DrawFormatString(3,64,GetColor(255,255,255),"井戸文字の座標は:%d",dao_y);
DrawFormatString(3,100,GetColor(255,255,255),"アイテムx軸:%d",orbu_bx);
DrawFormatString(3,123,GetColor(255,255,255),"アイテムy軸:%d",orbu_by);
DrawFormatString(3,146,GetColor(255,255,255),"xcount:%d",xcount);
//メニュー画面
if(Key[KEY_INPUT_M]==1){
mode=0;
}
//操作説明画面
if(Key[KEY_INPUT_S]==1){
setumei();
}
//ステージ移動
if(sh_x<=-3200+32&&px>=640-32){
mode=2;
}
//ステージ先でのプレイヤーの初期値
if(mode==2){
px=0;
py=420;
}
}
void enemy(){
//死神
if(g_hp>0){
ey-=e_junp;
e_junp-=1;
if(e_flag==true){
if(ey>=366){
ey=366;
e_junp=0;
ep_flag=false;
}
if(p_flag==true && ep_flag==false){
ep_flag=true;
e_junp=22;
}
}
//敵と弾の当たり判定
if(pm_flag==true || e_flag==true){
if(((mx>ex&&mx<ex+ew) || (ex>mx&&ex<mx+mw))&&((my>ey&&my<ey+eh) || (ey>my&&ey<my+mh))){//判定処理
g_hp--;
}
}
//敵移動制御
if(px<=ex){
ex--;
}else if(px>=ex){
ex++;
}
DrawGraph(ex-DrawBaseX,ey-DrawBaseX,goki,TRUE);
DrawFormatString(ex+35,ey+35,GetColor(255,0,255),"HP:%d",g_hp);
}else{
e_flag=false;
}
//ゾンビ
if(z_hp>0 && e_flag==false){
z_flag=true;
if(z_flag==true){
zy-=z_junp;
z_junp-=1;
if(z_flag==true){
if(zy>=386){
zy=386;
z_junp=0;
zp_flag=false;
}
if(p_flag==true && zp_flag==false){
zp_flag=true;
z_junp=3;
}
}
}
if(((mx>zx&&mx<zx+mw) || (zx>mx&&zx<mx+mw))&&((my>zy&&my<zy+mh) || (zy>my&&zy<my+mh))){//判定処理
z_hp--;
}
if(px<=zx){
zx--;
zx_count++;
if(zx_count>=2){
zx_count=0;
}
}else if(px>=zx){
zx++;
zx_count++;
if(zx_count>=5){
zx_count=4;
}
}
DrawGraph(zx,zy,zonbi[zx_count],TRUE);
DrawFormatString(zx+35,zy-1,GetColor(255,0,255),"HP:%d",z_hp);
}else{
z_flag=false;
}
//幽霊
if(yu_hp>0){
if(yu_x<=2679){
RL_flag=0;
}
if(yu_x>=2900){
RL_flag=1;
}
if(RL_flag==0){
yu_x++;
yu_count++;
if(yu_count>=5){
yu_count=2;
}
}
if(RL_flag==1){
yu_x--;
yu_count++;
if(yu_count>=2){
yu_count=0;
}
}
DrawGraph(yu_x,yu_y,yurei[yu_count],TRUE);
DrawFormatString(yu_x+35,yu_y-1,GetColor(255,0,255),"HP:%d",yu_hp);
}
//とりんドル
if(tori_hp>0){
tori_count++;
if(tori_count==2){
tori_count=0;
}
DrawGraph(tori_x-DrawBaseX,tori_y-DrawBaseY,torinn[tori_count],TRUE);
DrawFormatString(tori_x,tori_y,GetColor(255,0,255),"HP:%d",tori_hp);
}
DrawFormatString(3,160,GetColor(255,255,255),"幽霊のX座標:%d",yu_x);
DrawFormatString(3,180,GetColor(255,255,255),"幽霊のy座標:%d",yu_y);
}
void stage(){
pmove();
enemy();
}
void stage2(){
if(Key[KEY_INPUT_LEFT]==1){
muki=1;
}
}
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow ){
ChangeWindowMode(TRUE);
SetMainWindowText("maze a point");
if( DxLib_Init() == -1 ){
return -1;
}
t_moji=LoadGraph("アクション画像/スタート1.png");
haikei=LoadGraph("アクション画像/メニュー背景1.png");
tai_sound=LoadSoundMem("アクション音声/1up.wav");
st_call=LoadSoundMem("アクション音声/スタートコール.wav");
st_oto=LoadSoundMem("アクション音声/スタート音.wav");
st_BGM=LoadSoundMem("アクション音声/ステージBGM.wav");
jam_dao=LoadSoundMem("アクション音声/だお.wav");
LoadDivGraph("アクション画像/幽霊.png",4,2,2,44,64,yurei);
LoadDivGraph("アクション画像/ゾンビ.png",6,3,2,30,60,zonbi);
LoadDivGraph("アクション画像/tekiat.png",8,3,3,30,30,pr);
LoadDivGraph("アクション画像/とりんドル.png",2,2,1,150,120,torinn);
wall=LoadGraph("アクション画像/teki.png");
goki=LoadGraph("アクション画像/キャラクタ01.png");
misail=LoadGraph("アクション画像/弾00.png");
orbu_r=LoadGraph("アクション画像/オーブ 赤.png");
orbu_b=LoadGraph("アクション画像/オーブ 紫.png");
stage_haikei=LoadGraph("アクション画像/ステージ背景.png");
tera=LoadGraph("アクション画像/お寺.png");
torii=LoadGraph("アクション画像/鳥居.png");
ido=LoadGraph("アクション画像/井戸.png");
dao=LoadGraph("アクション画像/井戸・文字.png");
jiga=LoadGraph("アクション画像/自画.png");
kage=LoadGraph("アクション画像/影.png");
sousasetumei=LoadGraph("アクション画像/操作説明.png");
//グラフィックの縦、横の幅を得る
GetGraphSize(misail,&mw,&mh);
GetGraphSize(pr[xcount],&pw,&ph);
GetGraphSize(goki,&ew,&eh);
GetGraphSize(zonbi[zx_count],&zw,&zh);
GetGraphSize(jiga,&jw,&jh);
GetGraphSize(torinn[tori_count],&tow,&toh);
GetGraphSize(dao,&dw,&dh);
GetGraphSize(ido,&idw,&idh);
GetGraphSize(orbu_b,&ow,&oh);
SetDrawScreen( DX_SCREEN_BACK );
while(1){
ClearDrawScreen();
GetHitKeyStateAll(Key);
switch(mode){
case 0:
title();
break;
case 1:
stage();
break;
case 2:
stage2();
break;
case 5:
gameover();
break;
default:
DxLib_End();
return 0;
break;
}
if(Key[KEY_INPUT_ESCAPE]==1){
break;
}
if(ProcessMessage()==-1){
break;
}
ScreenFlip();
}
DxLib_End();
return 0;
}