/*
1.显示背景
2.显示静止的马里奥
3.移动的马里奥
4.让背景随马里奥的移动而移动
5.显示障碍物
6.增加马里奥d与障碍物的判断
7.增加野怪
8.增加背景音乐
9.完善代码
*/
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <windows.h>
#include<graphics.h>
#include <math.h>
#pragma comment(lib,"Winmm.lib")
#define High 504 // 游戏画面尺寸
#define Width 1024
#define rwHigh 131
#define rwWidth 134 //人物像素
#define gsHigh 128
#define gsWidth 128 //怪兽尺寸
int i;
int ksjm;//
float bj_x; //
IMAGE img_ks;//
IMAGE img_bk,img_human1,img_human2; //定义背景,人物
float human_x,human_y; //定义人物的坐标
float x,y;//
float jiao_y;//定义脚的坐标
int left_i,right_i; //定义左右移动动画序号
int picture_x,picture_y; //绘制图像的位置
int sfkt;//
int sfkz;//
int ydfx; //
int sfkcz;//
IMAGE img_pd1,img_pd2; //
struct ptzgt //
{
float pt_x,pt_y;
float pd_x,pd_y;
};
ptzgt zpt[3]; //
float ptzjbl[3]; //
float G; //定义重力
float tgz,pdtg,tgjl; //跳高值,判断跳高,跳高纪录
struct gs
{
float gs_x,gs_y; //怪兽坐标
float gssj_x,gssj_y; //怪兽的实际坐标
int gspicture_x,gspicture_y; //绘制怪兽图像的位置
};
gs num[5]; //怪兽数目
int gsleft_i,gsright_i; //定义怪兽左右移动的序号
int gsydfw; //怪兽移动范围
int gsydfx; //怪兽移动方向
int gsydjl; //怪兽移动纪录
IMAGE img_gs1,img_gs2; //怪兽图像
float t[5]; //
int number[5]; //
float time;//时间
float sjc;//
float sjjg;//
float score;//实际分数
struct kd //空地
{
float qs_x,zd_x;
};
kd n[9];
struct zc //
{
float qs_x,zd_x;
float high;//
};
zc pt[3]; //
zc zk[4]; //
zc mk[3]; //
zc sk[9]; //
zc xsg[3]; //
int zkc;//
struct zaw
{
float z_x,y_x; //
float high;//
};
zaw za[13];
struct ftqy //
{
float qs_x,zd_x;//
float high;//
float xlhigh;//
int zjcs;//
};
ftqy fmk[4];
ftqy fzk[4];
int gameStatus = 0; //
void startMenu();
void show();
void startup();
void updateWithoutInput();
void updateWithInput();
void startMenu() //
{
putimage(0,0,&img_ks); //
setbkmode(TRANSPARENT);
settextcolor(BLACK);
settextstyle(50,0, _T("∫⁄ÃÂ"));
outtextxy(Width*0.3, High*0.2, "1 –¬”Œœ∑");
outtextxy(Width*0.3, High*0.3, "2 Ω· ¯”Œœ∑");
settextcolor(RED);
settextstyle(30,0, _T(""));
outtextxy(Width*0.25, High*0.6, "");
outtextxy(Width*0.25, High*0.65, "");
outtextxy(Width*0.25, High*0.7, "");
FlushBatchDraw();
Sleep(2);
char input;
if(kbhit()) //
{
input = getch(); //
if (input == '1')
gameStatus = 1;
else if (input == '2')
{
//readRecordFile();
gameStatus = 2;
exit(0);
}
}
}
void startup() //数据初始化
{
sfkcz=1;
sjjg=0.02;
human_x=0;
human_y=0;
x=human_x;
y=human_y;
jiao_y=y+rwHigh/2;
left_i=0;
right_i=0;
bj_x=0;
picture_x=0;
picture_y=0;
//
zpt[0].pt_x=815;
zpt[0].pt_y=360;
zpt[0].pd_x=zpt[0].pt_x;
zpt[0].pd_y=zpt[0].pt_y;
ptzjbl[0]=0;
zpt[1].pt_x=1200;
zpt[1].pt_y=255;
zpt[1].pd_x=1024;
zpt[1].pd_y=zpt[1].pt_y;
ptzjbl[1]=zpt[1].pt_x-1024;
zpt[2].pt_x=5905;
zpt[2].pt_y=360;
zpt[2].pd_x=1024;
zpt[2].pd_y=zpt[2].pt_y;
ptzjbl[2]=zpt[2].pt_x-1024;
time = 300;
score=0;
G=7;
tgz=200;
pdtg=0;
tgjl=0;
sfkt=0;
zkc=50;
num[0].gs_y=319; //
num[0].gs_x=444;
num[0].gspicture_x=0;
num[0].gspicture_y=128;
num[0].gssj_x=num[0].gs_x;
num[0].gssj_y=num[0].gs_y;
num[1].gs_y=319;
num[1].gs_x=1024;
num[1].gspicture_x=0;
num[1].gspicture_y=128;
num[1].gssj_x=2000;
num[1].gssj_y=num[0].gs_y;
num[2].gs_y=319;
num[2].gs_x=1024;
num[2].gspicture_x=0;
num[2].gspicture_y=128;
num[2].gssj_x=3000;
num[2].gssj_y=num[0].gs_y;
num[3].gs_y=177;
num[3].gs_x=1024;
num[3].gspicture_x=0;
num[3].gspicture_y=128;
num[3].gssj_x=3200;
num[3].gssj_y=162;
num[4].gs_y=319;
num[4].gs_x=1024;
num[4].gspicture_x=0;
num[4].gspicture_y=128;
num[4].gssj_x=5200;
num[4].gssj_y=num[0].gs_y;
t[0]=0;
t[1]=num[1].gssj_x-1024;;//
t[2]=num[2].gssj_x-1024-80;
t[3]=num[3].gssj_x-1024+200;
t[4]=num[4].gssj_x-1024;
for(int i=1;i<=4;i++)
number[i]=0;
gsleft_i=0; //
gsright_i=0;
gsydfw=200; //
gsydfx=0;
gsydjl=0;
//
n[0].qs_x=2158;
n[0].zd_x=2257;
n[1].qs_x=2630;
n[1].zd_x=2689;
n[2].qs_x=2775;
n[2].zd_x=2784;
n[3].qs_x=6220;
n[3].zd_x=6240;
n[4].qs_x=6845;
n[4].zd_x=6865;
n[5].qs_x=8238;
n[5].zd_x=8258;
n[6].qs_x=8476;
n[6].zd_x=8553;
n[7].qs_x=9053;
n[7].zd_x=9215;
n[8].qs_x=9484;
n[8].zd_x=9852;
//
pt[0].qs_x=786;
pt[0].zd_x=pt[0].qs_x+50;
pt[0].high=289;
pt[1].qs_x=1060;
pt[1].zd_x=pt[1].qs_x+50;
pt[1].high=329;
pt[2].qs_x=1200;
pt[2].zd_x=pt[2].qs_x+50;
pt[2].high=252;
//
zk[0].qs_x=975;
zk[0].zd_x=zk[0].qs_x+zkc;
zk[0].high=330;
zk[1].qs_x=1390;
zk[1].zd_x=zk[1].qs_x+zkc*3;
zk[1].high=330;
zk[2].qs_x=5900;
zk[2].zd_x=zk[2].qs_x+zkc*9;
zk[2].high=290;
zk[3].qs_x=8110;
zk[3].zd_x=zk[3].qs_x+zkc*7;
zk[3].high=290;
//
mk[0].qs_x=2880;
mk[0].zd_x=mk[0].qs_x+zkc*10;
mk[0].high=145;
mk[1].qs_x=3260;
mk[1].zd_x=mk[1].qs_x+zkc*8;
mk[1].high=290;
mk[2].qs_x=6815;
mk[2].zd_x=mk[2].qs_x+zkc;
mk[2].high=360;
//
sk[0].qs_x=3020;
sk[0].zd_x=sk[0].qs_x+zkc;
sk[0].high=325;
sk[1].qs_x=3645;
sk[1].zd_x=sk[1].qs_x+zkc;
sk[1].high=250;
sk[2].qs_x=7485;
sk[2].zd_x=sk[2].qs_x+zkc*13;
sk[2].high=325;
sk[3].qs_x=8975;
sk[3].zd_x=sk[3].qs_x+zkc+10;
sk[3].high=290;
sk[4].qs_x=9120;
sk[4].zd_x=sk[4].qs_x+zkc;
sk[4].high=250;
sk[5].qs_x=9310;
sk[5].zd_x=sk[5].qs_x+zkc;
sk[5].high=250;
sk[6].qs_x=9410;
sk[6].zd_x=sk[6].qs_x+zkc;
sk[6].high=395;
sk[7].qs_x=9455;
sk[7].zd_x=sk[7].qs_x+zkc*2;
sk[7].high=145;
sk[8].qs_x=9885;
sk[8].zd_x=sk[8].qs_x+zkc;
sk[8].high=395;
//
xsg[0].qs_x=5615;
xsg[0].zd_x=5710;
xsg[0].high=250;
xsg[1].qs_x=8255;
xsg[1].zd_x=8445;
xsg[1].high=436;
xsg[2].qs_x=8590;
xsg[2].zd_x=8690;
xsg[2].high=360;
//
za[0].z_x=820;
za[0].y_x=860;
za[0].high=290;
za[1].z_x=1060;
za[1].y_x=1100;
za[1].high=330;
za[2].z_x=1200;
za[2].y_x=1245;
za[2].high=260;
za[3].z_x=3020;
za[3].y_x=3070;
za[3].high=325;
za[4].z_x=3645;
za[4].y_x=3695;
za[4].high=255;
za[5].z_x=5620;
za[5].y_x=5710;
za[5].high=250;
za[6].z_x=8110;
za[6].y_x=8110;
za[6].high=290;
za[7].z_x=8635;
za[7].y_x=8685;
za[7].high=360;
za[8].z_x=5900;
za[8].y_x=6040;
za[8].high=360;
za[9].z_x=6285;
za[9].y_x=6335
超级马里奥(待完善)
最新推荐文章于 2024-06-18 18:30:19 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)