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

📄 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);


// 俢倃儔僀僽儔儕弶婜壔張棟(僄儔乕偑婲偒偨傜捈偪偵廔椆)
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;
}



//俢倃儔僀僽儔儕巊梡偺廔椆張棟
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 + -