⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 一个恶搞类的小游戏,从大家熟悉的小玛丽恶搞而来
💻 CPP
📖 第 1 页 / 共 5 页
字号:
#include "DxLib.h"
#include <stdio.h>
#include <math.h>

void loadg();

//String 使用
#include <string>
using namespace std;


//プログラム中
//main-10
//タイトル-100
int main=100,maintm=0;

//ステージ
int stagecolor=0;
int sta=1,stb=4,stc=0;

//クイック
int fast=1;

//トラップ表示
int trap=1;

//中間ゲート
int tyuukan=0;


//スタッフロール
int ending=0;


//ステージ読み込みループ(いじらない)
int stagerr,stagepoint;
//オーバーフローさせる
int over=0;

//ステージスイッチ
int stageonoff=0;


//メインプログラム
void Mainprogram();
void rpaint();
int maint;


//サブクラス
//(ウエイト系
void wait(int interval);
void wait2(long stime, long etime,int FLAME_TIME);
int rand(int Rand);
void end();

//描画
int color;
void setfont(int a);
void setcolor(int red, int green, int blue);
void setc0();
void setc1();
void drawpixel(int a,int b);
void drawline(int a,int b,int c,int d);
void drawrect(int a,int b,int c,int d);
void fillrect(int a,int b,int c,int d);
void drawarc(int a,int b,int c,int d);
void fillarc(int a,int b,int c,int d);
int grap[161][8],mgrap[51];
int loadimage(string b);
int loadimage(int a,int x,int y,int r,int z);
int mirror;
void drawimage(int mx,int a,int b);
void drawimage(int mx,int a,int b,int c,int d,int e,int f);
void setre();
void setre2();
void setno();
int oto[151];
void ot(int x);void bgmchange(int x);

//文字
void str(string c,int a,int b);


//)

void stagecls();
void stage();
void stagep();





//1-ステージ
//10-ステージ前
//



//ループ
int t,tt,t1,t2,t3,t4;


//初期化
int zxon,zzxon;

//キーコンフィグ
int key,keytm;

//三角関数
double pai=3.1415926535;


//地面
#define smax 31
int sx,sco;
int sa[smax],sb[smax],sc[smax],sd[smax],stype[smax],sxtype[smax],sr[smax];
int sgtype[smax];



//プレイヤー
int mainmsgtype;
int ma,mb,mnobia,mnobib,mhp;
int mc,md,macttype,atkon,atktm,mactsok,msstar,nokori=2,mactp,mact;

int mtype,mxtype,mtm,mzz;
int mzimen,mrzimen,mkasok,mmuki,mmukitm,mjumptm,mkeytm,mcleartm;
int mmutekitm,mmutekion;
int mztm,mztype;
int actaon[7];
//メッセージ
int mmsgtm,mmsgtype;

int mascrollmax=21000;//9000




//ブロック
void tyobi(int x,int y,int type);
void brockbreak(int t);
#define tmax 641
int tco;
int ta[tmax],tb[tmax],tc[tmax],td[tmax],thp[tmax],ttype[tmax];
int titem[tmax],txtype[tmax];

//メッセージブロック
int tmsgtm,tmsgtype,tmsgx,tmsgy,tmsgnobix,tmsgnobiy,tmsg;
void ttmsg();void txmsg(string x,int a);
void setfont(int x,int y);

//効果を持たないグラ
void eyobi(int xa,int xb,int xc,int xd,int xe,int xf,int xnobia,int xnobib,int xgtype,int xtm);
#define emax 201
int eco;
int ea[emax],eb[emax],enobia[emax],enobib[emax],ec[emax],ed[emax];
int ee[emax],ef[emax],etm[emax];
int egtype[emax];



//敵キャラ
void ayobi(int xa,int xb,int xc,int xd,int xnotm,int xtype,int xxtype);
void tekizimen();
#define amax 24
int aco;
int aa[amax],ab[amax],anobia[amax],anobib[amax],ac[amax],ad[amax];
int ae[amax],af[amax],abrocktm[amax];
int aacta[amax],aactb[amax],azimentype[amax],axzimen[amax];
int atype[amax],axtype[amax],amuki[amax],ahp[amax];
int anotm[amax],anx[160],any[160];
int atm[amax],a2tm[amax];
int amsgtm[amax],amsgtype[amax];

//敵出現
#define bmax 81
int bco;
int ba[bmax],bb[bmax],btm[bmax];
int btype[bmax],bxtype[bmax],bz[bmax];


//背景
#define nmax 41
int nxxmax,nco;
int na[nmax],nb[nmax],nc[nmax],nd[nmax],ntype[nmax];
int ne[nmax],nf[nmax],ng[nmax],nx[nmax];


//リフト
#define srmax 21
int srco;
int sra[srmax],srb[srmax],src[srmax],srd[srmax],sre[srmax],srf[srmax];
int srtype[srmax],srgtype[srmax],sracttype[srmax],srsp[srmax];
int srmuki[srmax],sron[srmax],sree[srmax];
int srsok[srmax],srmovep[srmax],srmove[srmax];





//スクロール範囲
int fx=0,fy=0,fzx,fzy,scrollx,scrolly;
//全体のポイント
int fma=0,fmb=0;
//強制スクロール
int kscroll=0;
//画面サイズ(ファミコンサイズ×2)(256-224)
int fxmax=48000,fymax=42000;



//ステージ
byte stagedate[17][2001];

//画面黒
int blacktm=1,blackx=0;



//自由な値
int xx[91];
double xd[11];
string xs[31];


//タイマー測定
long stime;



// プログラムは WinMain から始まります
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow ){

//画面サイズ設定
SetGraphMode( fxmax/100 , fymax/100 , 16 ) ;
//
SetWindowIconID(127);
//最大化の防止
ChangeWindowMode(TRUE ) ;
//タイトルの変更
SetMainWindowText( "しょぼんのアクション" ) ;
//applog無効
SetOutApplicationLogValidFlag(false);


// DXライブラリ初期化処理(エラーが起きたら直ちに終了)
if( DxLib_Init() == -1 )return -1 ;

// 点を打つ
//DrawPixel( 320 , 240 , 0xffff ) ;

// キー入力待ち
//WaitKey();


//全ロード
loadg();

//フォント
SetFontSize(16) ;
SetFontThickness(4) ;

//ループ
//for (maint=0;maint<=2;maint++){
while( ProcessMessage() == 0 && CheckHitKey( KEY_INPUT_ESCAPE ) == 0){

maint=0;Mainprogram();
if (maint==3)break;
}



//DXライブラリ使用の終了処理
DxLib_End() ;				

// ソフトの終了 
return 0 ;				
}



//メイン描画
void rpaint(){

//ダブルバッファリング
SetDrawScreen(DX_SCREEN_BACK);

ClearDrawScreen();

setcolor(0,0,0);
//if (stagecolor==1)setcolor(170,170,255);
if (stagecolor==1)setcolor(160,180,250);
if (stagecolor==2)setcolor(10,10,10);
if (stagecolor==3)setcolor(160,180,250);
if (stagecolor==4)setcolor(10,10,10);
fillrect(0,0,fxmax,fymax);


/*
//文字を書く
setcolor(0,0,120);

xs[1]="";
char num_str[255];
sprintf_s(num_str, sizeof(num_str),"%d",mjumptm);

xs[3]=xs[1]+num_str;
str(xs[3],10,10);
*/


if (main==1 && zxon>=1){


//背景
for (t=0;t<nmax;t++){
xx[0]=na[t]-fx;xx[1]=nb[t]-fy;
xx[2]=ne[ntype[t]]*100;xx[3]=nf[ntype[t]]*100;
xx[2]=16000;xx[3]=16000;

if (xx[0]+xx[2]>=-10 && xx[0]<=fxmax && xx[1]+xx[3]>=-10 && xx[3]<=fymax){

if (ntype[t]!=3)
drawimage(grap[ntype[t]][4],xx[0]/100,xx[1]/100);

if (ntype[t]==3)
drawimage(grap[ntype[t]][4],xx[0]/100-5,xx[1]/100);

//51
if (ntype[t]==100){
DrawFormatString(xx[0]/100+fma,xx[1]/100+fmb,GetColor(255,255,255),"51");
}

if (ntype[t]==101)
DrawFormatString(xx[0]/100+fma,xx[1]/100+fmb,GetColor(255,255,255),"ゲームクリアー");
if (ntype[t]==102)
DrawFormatString(xx[0]/100+fma,xx[1]/100+fmb,GetColor(255,255,255),"プレイしてくれてありがとー");

}}//t



//グラ
for (t=0;t<emax;t++){
xx[0]=ea[t]-fx;xx[1]=eb[t]-fy;
xx[2]=enobia[t]/100;xx[3]=enobib[t]/100;
if (xx[0]+xx[2]*100>=-10 && xx[1]<=fxmax && xx[1]+xx[3]*100>=-10-8000 && xx[3]<=fymax){

//コイン
if (egtype[t]==0)
drawimage(grap[0][2],xx[0]/100,xx[1]/100);

//ブロックの破片
if (egtype[t]==1){
if (stagecolor<=1 || stagecolor==3)setcolor(9*16,6*16,3*16);
if (stagecolor==2)setcolor(0,120,160);
if (stagecolor==4)setcolor(192,192,192);

fillarc(xx[0]/100,xx[1]/100,7,7);
setcolor(0,0,0);
drawarc(xx[0]/100,xx[1]/100,7,7);
}

//リフトの破片
if (egtype[t]==2 || egtype[t]==3){
if (egtype[t]==3)mirror=1;
drawimage(grap[0][5],xx[0]/100,xx[1]/100);
mirror=0;
}

//ポール
if (egtype[t]==4){
setc1();
fillrect((xx[0])/100+10,(xx[1])/100, 10, xx[3]);
setc0();
drawrect((xx[0])/100+10,(xx[1])/100, 10, xx[3]);
setcolor(250,250,0);
fillarc((xx[0])/100+15-1,(xx[1])/100,10,10);
setc0();
drawarc((xx[0])/100+15-1,(xx[1])/100,10,10);
}//4

//if (egtype[t]==1){
//drawimage(image[0],xx[0]/100+fma+5,xx[1]/100+fmb+5,0,0,10,10);
//おもしろ
//drawimage(image[2],xx[0]/100+fma,xx[1]/100+fmb,0,0,20,20);
//}
//if (egtype[t]==2)
//drawimage(image[11],xx[0]/100+fma,xx[1]/100+fmb,0,0,25,16);


}
/*
//
if (egtype[t]==100){
for (t3=0;t3<=2;t3++){ 
setcolor(60,60,60);
if (t3==2)setcolor(250,250,250);
t2=t3*2;if (t2==4)t2=1;
//str("ステージ  クリアー",xx[0]/100+t2+fx/100,xx[1]/100+t2+fy/100);
str("ステージ  クリアー",60+t2,90+t2);
}
}//100
*/
}






//リフト
for (t=0;t<srmax;t++){
xx[0]=sra[t]-fx;xx[1]=srb[t]-fy;
if (xx[0]+src[t]>=-10 && xx[1]<=fxmax+12100 && src[t]/100>=1){
xx[2]=14;if (srsp[t]==1){xx[2]=12;}

if (srsp[t]<=9 || srsp[t]>=20){
setcolor(220,220,0);
if (srsp[t]==2){setcolor(0,220,0);}
if (srsp[t]==21){setcolor(180,180,180);}
fillrect((sra[t]-fx)/100,(srb[t]-fy)/100,src[t]/100,xx[2]);

setcolor(180,180,0);
if (srsp[t]==2){setcolor(0,180,0);}
if (srsp[t]==21){setcolor(150,150,150);}
drawrect((sra[t]-fx)/100,(srb[t]-fy)/100,src[t]/100,xx[2]);
}
else if (srsp[t]<=14){
if (src[t]>=5000){
setcolor(0,200,0);
fillrect((sra[t]-fx)/100,(srb[t]-fy)/100,src[t]/100,30);
setcolor(0,160,0);
drawrect((sra[t]-fx)/100,(srb[t]-fy)/100,src[t]/100,30);

setcolor(180,120,60);
fillrect((sra[t]-fx)/100+20,(srb[t]-fy)/100+30,src[t]/100-40,480);
setcolor(100,80,20);
drawrect((sra[t]-fx)/100+20,(srb[t]-fy)/100+30,src[t]/100-40,480);

}}
if (srsp[t]==15){
for (t2=0;t2<=2;t2++){
xx[6]=1+0;drawimage(grap[xx[6]][1],(sra[t]-fx)/100+t2*29,(srb[t]-fy)/100);
}
}//15



/*
if (srtype[t]==0){
setc1();
if (srgtype[t]==0){setcolor(200,120,0);}
if (srgtype[t]==1){setcolor(40,40,240);}
if (srgtype[t]>=2 && srgtype[t]<=6)setcolor(240,240,40);
if (srgtype[t]==7)setcolor(0,240,0);
fillrect(xx[0]/100+fma,xx[1]/100+fmb, src[t]/100, srd[t]/100);
setc0();
if (srgtype[t]==0){setcolor(160,80,0);}
if (srgtype[t]==1){setcolor(0,0,200);}
if (srgtype[t]>=2 && srgtype[t]<=6)setcolor(200,200,0);
if (srgtype[t]==7)setcolor(0,210,0);
drawrect(xx[0]/100+fma,xx[1]/100+0+fmb, src[t]/100, srd[t]/100);
}}

//(トゲ)
if (srtype[t]==1 || srtype[t]==2){
if (srtype[t]==2)setre2();
//drawimage(image[6],xx[0]/100+fma,xx[1]/100+fmb,0,0,src[t]/100, srd[t]/100+2);

xx[20]=2000;
for (tt=0;tt<=src[t]/xx[20];tt++){
xx[6]=xx[20]/100;xx[7]=xx[20]/100;if (src[t]/xx[20]==tt){xx[7]=(src[t]%xx[20])/100;}
if (xx[6]<=0)xx[6]=1;if (xx[7]<=0)xx[7]=1;
//drawimage(im[0],xx[0]/100+fma+tt*(xx[6]),xx[1]/100+fmb,5,0,xx[7],10);
drawimage(image[6],xx[0]/100+fma+tt*(xx[6]),xx[1]/100+fmb,0,0,xx[7], srd[t]/100+2);
}

*/
}
//t=xx[21];//if (xx[22]>spmax)t=spmax+1;

//setno();
}//t












//プレイヤー描画
setcolor(0,0,255);
//mirror=1;

if (mactp>=2000){mactp-=2000;if (mact==0){mact=1;}else{mact=0;}}
if (mmuki==0)mirror=1;

if (mtype!=200 && mtype!=1){
if (mzimen==1){
// 読みこんだグラフィックを拡大描画
//DrawExtendGraph(ma/100,mb/100,ma/100+100,mb/100+100,grap[0][0], TRUE ) ;
if (mact==0)drawimage(grap[0][0],ma/100,mb/100);
if (mact==1)drawimage(grap[1][0],ma/100,mb/100);
}
if (mzimen==0){
drawimage(grap[2][0],ma/100,mb/100);
}
}
//巨大化
else if (mtype==1){
drawimage(grap[41][0],ma/100,mb/100);
}

else if (mtype==200){
drawimage(grap[3][0],ma/100,mb/100);
}

mirror=0;

//drawrect(ma/100,mb/100,30,36);


//g.setFlipMode(Graphics.FLIP_NONE);
//}//muteki




//for (t=0;t<bmax;t++){DrawFormatString((ba[t]-fx)/100+40,(bb[t]-fy)/100,GetColor(250,250,250),"%d",t);}

//敵キャラ
for (t=0;t<amax;t++){

xx[0]=aa[t]-fx;xx[1]=ab[t]-fy;
xx[2]=anobia[t]/100;xx[3]=anobib[t]/100;xx[14]=3000;xx[16]=0;
if (xx[0]+xx[2]*100>=-10-xx[14] && xx[1]<=fxmax+xx[14] && xx[1]+xx[3]*100>=-10 && xx[3]<=fymax){
//if (atype[t]>=100)amuki[t]=0;
if (amuki[t]==1){mirror=1;}
if (atype[t]==3 && axtype[t]==1){DrawRotaGraph(xx[0]/100+13,xx[1]/100+15, 1.0f ,pai/ 1 , grap[atype[t]][3], TRUE ) ;xx[16]=1;}
if (atype[t]==9 && ad[t]>=1){DrawRotaGraph(xx[0]/100+13,xx[1]/100+15, 1.0f ,pai/ 1 , grap[atype[t]][3], TRUE ) ;xx[16]=1;}
if (atype[t]>=100 && amuki[t]==1)mirror=0;

//tekikaki(atype[t]);

//if (atype[t]>=100)
//drawrect(xx[0]/100,xx[1]/100,30,30);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -