C源码分享网站 分享源码的网站

大家好,今天给各位分享C源码分享网站的一些知识,其中也会对分享源码的网站进行解释,文章篇幅可能偏长,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在就马上开始吧!

超级玛丽菜单模块设计,switch使用,最终样式

超级玛丽菜单模块设计,动态效果

本文相应视频教程

C语言视频,C语言零基础打造动态菜单,C语言实现超级玛丽菜单

源码分享

加载资源函数

include<stdio.h>

#include<conio.h>

IMAGEbeginImg;

IMAGEmenuBackground;

IMAGEmenuBlack;

IMAGEgameOver;

IMAGEbeginGame;

intwidth;

intheight;

intcountMenu=1;

voidloadResourse()

{

loadimage(&beginImg,”beginImg.jpg”);

width=beginImg.getwidth();

height=beginImg.getheight();

loadimage(&menuBackground,”menubackgroud.jpg”,30,30);

loadimage(&menuBlack,”menuBlack.jpg”,30,30);

loadimage(&gameOver,”gameOver.jpg”,width,height);

loadimage(&beginGame,”beginGameImg.jpg”,width,height);

}

初始化界面

voidgameBeginUI()

{

putimage(0,0,&beginImg);

//测试位置

putimage(170,270,&menuBlack,SRCAND);

putimage(170,270,&menuBackground,SRCPAINT);

//putimage(170,312,&menuBlack,SRCAND);

//putimage(170,312,&menuBackground,SRCPAINT);

}

用户选择

voiduserChoice()

{

////方向键:上:72下:80左:75右:77

intchoice=_getch();

switch(choice)

{

//上

case72:

case80:

if(countMenu==1)

{

putimage(0,0,&beginImg);

putimage(170,312,&menuBlack,SRCAND);

putimage(170,312,&menuBackground,SRCPAINT);

countMenu=2;

}

else

{

putimage(0,0,&beginImg);

putimage(170,270,&menuBlack,SRCAND);

putimage(170,270,&menuBackground,SRCPAINT);

countMenu=1;

}

break;

case13:

if(countMenu==1)

{

putimage(0,0,&beginGame);

Sleep(3000);

exit(0);

}

else

{

putimage(0,0,&gameOver);

Sleep(3000);

exit(0);

}

break;

}

}

主函数

intmain()

{

loadResourse();

initgraph(width,height);

gameBeginUI();

while(1)

{

userChoice();

}

getchar();

closegraph();

return0;

}

好了今天的分享就到这里结束了,谢谢大家。

更多精彩:

C语言学习,C语言可视化编程,C语言一周速成,C语言开发拼图游戏

C语言学习,C语言可视化编程,C语言一周速成,C语言开发拼图游戏

关于本次C源码分享网站和分享源码的网站的问题分享到这里就结束了,如果解决了您的问题,我们非常高兴。

Published by

风君子

独自遨游何稽首 揭天掀地慰生平