加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
runGame.cpp 24.25 KB
一键复制 编辑 原始数据 按行查看 历史
SadLava 提交于 2022-05-21 23:24 . 修复了若干bug
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967
#include "input.cpp"
inline void runAll(role& player) {
char tc[60];
player.move( ::GetAsyncKeyState( VK_LCONTROL ) );
player.getnew();
runBullets();
runStar();
runGrain();
runInfoList();
deleteRoles();
runRoles( player );
if(HCOLL) hColl( player );
drawGame( player );
hSkills(player);
}
int runGame(bool StoryMode=false) {
if(ISDEBUG) DoBeforeRunGame();
if(pBuffs&buffstype::STRONGER) {
SDATA.life[PLAYER]*=STRONGER_SCALE;
SDATA.hurt[PLAYER]*=STRONGER_SCALE;
}
if(pBuffs&buffstype::SHEILD) {
SDATA.pro[PLAYER]*=STRONGER_SCALE;
}
pBuffs=0;
pX = 0;
pY = 0;
pS = 0;
pR = 0;
pF = 0;
bGrade=0;
role player;
string info;
player.type = PLAYER;
player.id=1;
player.life = SDATA.life[PLAYER];
char tc[100];
roles.clear();
stars.clear();
bullets.clear();
grains.clear();
infoList.clear();
if(ISDEBUG) AddRoleForDebug();
begin:
MSYS.playGBgm();
drawBeginningTexts(s_words);
//设置背景色
setbkcolor(bkcolor);
cleardevice();
delay_fps(64);
runBullets();
runStar();
hColl( player );
drawGame( player );
delay_fps( 60 );
cleardevice();
{
/* 倒计时 */
runBullets();
runStar();
drawGame( player );
setcolor( RED );
setfont( -1 * getheight() / 2, 0, "黑体" );
xyprintf( getwidth() / 2 - textwidth( "3" ) / 2, getheight() / 2 - textheight( "3" ) / 2, "3" );
Sleep( 1000 );
cleardevice();
runBullets();
runStar();
hColl( player );
drawGame( player );
setcolor( RED );
setfont( -1 * getheight() / 2, 0, "黑体" );
xyprintf( getwidth() / 2 - textwidth( "3" ) / 2, getheight() / 2 - textheight( "3" ) / 2, "2" );
Sleep( 1000 );
cleardevice();
runBullets();
runStar();
drawGame( player );
setcolor( RED );
setfont( -1 * getheight() / 2, 0, "黑体" );
xyprintf( getwidth() / 2 - textwidth( "3" ) / 2, getheight() / 2 - textheight( "3" ) / 2, "1" );
Sleep( 1000 );
cleardevice();
runBullets();
runStar();
drawGame( player );
setcolor( RED );
setfont( -1 * getheight() / 2, 0, "黑体" );
xyprintf( getwidth() / 2 - textwidth( "Go!" ) / 2, getheight() / 2 - textheight( "Go!" ) / 2, "Go!" );
Sleep( 1000 );
cleardevice();
setcolor( RED );
player.energy = MAXE / 4;
player.protecting = 1;
}
addPlane();
bool win=false;
if(StoryMode) showTarget();
while ( 1 ) {
Game:
MSYS.playGBgm();
//监测故事模式是否胜利
if(StoryMode) {
if(s_target.len<=pS&&s_target.falls<=pF) {
win=true;
for(int i=0; i<END; i++) {
if(s_target.fall[i]>p_target.fall[i]) {
win=false;
}
}
if(win) {
player.death=1;
}
}
}
//最后两个需要自己监测的键
if ( ::GetAsyncKeyState( 'P' ) ) {
setfont( getwidth() / strlen( "已暂停" ), 0, "黑体" );
xyprintf( getwidth() / 2 - textwidth( "已暂停" ) / 2, getheight() / 2 - textheight( "已暂停" ) / 2, "已暂停" );
delay_fps( 60 );
while ( !::GetAsyncKeyState( 'Z' ) )
;
}
if ( ::GetAsyncKeyState( VK_ESCAPE ) ) {
saveUData();
MSYS.playAGBgm();
player.reset();
player.life = SDATA.life[PLAYER];
pX = 0;
pY = 0;
pR = 0;
pF = 0;
pS = 0;
roles.clear();
bullets.clear();
return 0;
}
//按键监测
InputKey(player);
runAll(player);
{
/* 输出数据 */
setfont( 20, 0, "黑体" );
setcolor( WHITE );
info = "生命:";
itoa( player.life, tc, 10 );
info += tc;
info += " 能量:";
itoa( player.energy, tc, 10 );
info += tc;
info += " 飞行距离:";
itoa( pS, tc, 10 );
info += tc;
info += " 飞行速度:";
itoa( player.v, tc, 10 );
info += tc;
info += " 击落敌机数量:";
itoa( pF, tc, 10 );
info += tc;
info += " 子弹容量:";
itoa( player.bulletC / 5, tc, 10 );
info += " buff状态:";
itoa( pBuffs, tc, 2 );
info += tc;
info += " 伤害评级:";
itoa( bGrade, tc, 10 );
info += tc;
info += " fps:";
itoa( getfps(), tc, 10 );
info += tc;
outtextxy( 0, 0, info.c_str() );
}
if ( player.death ) {
if ( player.type == RUINER && guns.size() > 0 ) {
guns.pop_back();
guns.pop_back();
player.death = false;
player.blasting = false;
player.blaststep = 0;
SDATA.maxV[player.type] -= 2;
player.v -= 2;
player.life = SDATA.life[player.type];
player.energy = MAXE;
player.clearing = true;
player.hE = player.energy;
bullets.clear();
goto Game;
}
itoa( (float) pS, tc, 10 );
player.death = 0;
player.life = 99999999;
player.reset();
player.id=1;
int tW = 0;
info.clear();
info = "共飞行了" + (string) tc + "千米,击落敌机";
itoa( (float) pF, tc, 10 );
info += tc;
info += "架,获得积分:";
itoa( (pF * 50 + pS / 80)*s_weight, tc, 10 );
info += tc;
scores += (pF * 50 + pS / 80)*s_weight;
settextjustify(CENTER_TEXT, CENTER_TEXT);
if(win) {
while ( !::GetAsyncKeyState( 'Z' ) ) {
/* 自动移动 */
if ( tW == 0 ) {
if ( random( 100 ) > 50 ) {
tW = 50;
} else tW = -50;
}
if ( tW > 0 ) {
player.turnL();
tW--;
} else {
player.turnR();
tW++;
}
player.move( (random( 2 ) == 0) );
player.getnew();
player.v = SDATA.maxV[PLAYER];
runBullets();
runStar();
runGrain();
runRoles( player );
hColl( player );
drawGame( player );
player.death = 0;
player.life = 99999999;
setfont( getwidth() / strlen( "胜利!" ), 0, "黑体" );
imagefilter_blurring( NULL, 0x01, 0x90, 0, 0, 0, 0 );
setcolor(YELLOW);
outtextxy( getwidth() / 2, getheight() / 2 , "胜利!");
MSYS.playAGBgm();
delay_fps( 60 );
cleardevice();
}
api_sleep(100);
if(s_grade.second<s_maxg) {
s_grade.second++;
}
}
while ( !::GetAsyncKeyState( 'Z' ) ) {
/* 自动移动 */
if ( tW == 0 ) {
if ( random( 100 ) > 50 ) {
tW = 50;
} else tW = -50;
}
if ( tW > 0 ) {
player.turnL();
tW--;
} else {
player.turnR();
tW++;
}
player.move( (random( 2 ) == 0) );
player.getnew();
player.v = SDATA.maxV[PLAYER];
runBullets();
runStar();
runGrain();
runRoles( player );
hColl( player );
drawGame( player );
player.death = 0;
player.life = 99999999;
setfont( getwidth() / strlen( info.c_str() ) * 1.8, 0, "黑体" );
imagefilter_blurring( NULL, 0x01, 0x90, 0, 0, 0, 0 );
outtextxy( getwidth() / 2, getheight() / 2, info.c_str() );
MSYS.playAGBgm();
delay_fps( 60 );
cleardevice();
}
api_sleep(100);
grade g;
g.score = (pF * 50 + pS / 80)*s_weight;
g.falls = pF;
g.lens = pS;
g.role = PLAYER;
tops.push_back( g );
sort( tops.begin(), tops.end(), cmpGrade );
while(tops.size()>10) {
tops.pop_back();
}
saveUData();
player.reset();
player.id=1;
player.death = 0;
//player.life = SDATA.life[PLAYER];
pX = 0;
pY = 0;
pR = 0;
pF = 0;
pS = 0;
roles.clear();
stars.clear();
bullets.clear();
settextjustify(LEFT_TEXT, TOP_TEXT);
while ( !::GetAsyncKeyState( 'Z' ) ) {
/* 自动移动 */
if ( tW == 0 ) {
if ( random( 100 ) > 50 ) {
tW = 50;
} else tW = -50;
}
if ( tW > 0 ) {
player.turnL();
tW--;
} else {
player.turnR();
tW++;
}
runAll(player);
player.v = SDATA.maxV[PLAYER];
player.death = 0;
player.life = 99999999;
hColl( player );
drawGame( player );
/* 显示榜单 */
setfillcolor( EGECOLORA( DARKGRAY, 80 ) );
setfont( getwidth() / strlen( "名次/使用机型/评分/击落敌机数量/飞行距离" ), 0, "黑体" );
ege_fillrect( getwidth() / 4 - 20, getheight() / 18 - 20, textwidth( "名次/使用机型/评分/击落敌机数量/飞行距离" ) * 1.1, getheight() / 18 * (tops.size() + 4) + textheight( "名" ) );
info.clear();
for ( int i = 0; i < tops.size(); i++ ) {
setcolor( WHITE );
outtextxy( getwidth() / 4, getheight() / 18, "名次/使用机型/评分/击落敌机数量/飞行距离" );
if ( tops[i].role == g.role && tops[i].falls == g.falls && tops[i].lens == g.lens && tops[i].score == g.score ) {
setcolor( YELLOW );
} else {
setcolor( WHITE );
}
info.clear();
itoa( i + 1, tc, 10 );
info = tc;
info += "/";
info+=SDATA.i2n[tops[i].role]+"/";
itoa( tops[i].score, tc, 10 );
info += tc;
info += "/";
itoa( tops[i].falls, tc, 10 );
info += tc;
info += "/";
itoa( tops[i].lens, tc, 10 );
info += tc;
xyprintf( getwidth() / 4, getheight() / 18 * (i + 2), info.c_str() );
}
setcolor( YELLOW );
info.clear();
info+=SDATA.i2n[g.role]+"/";
itoa( g.score, tc, 10 );
info += tc;
info += "/";
itoa( g.falls, tc, 10 );
info += tc;
info += "/";
itoa( g.lens, tc, 10 );
info += tc;
xyprintf( getwidth() / 4, getheight() / 18 * (tops.size() + 4), info.c_str() );
MSYS.playAGBgm();
delay_fps( 60 );
cleardevice();
}
roles.clear();
stars.clear();
bullets.clear();
return(1);
}
delay_fps( 60 );
cleardevice();
}
}
void choosePlane(bool StoryMode=false,pair<int,int> Diff=make_pair(0,0),bool show=false) {
//初始化
pX = 0;
pY = 0;
pS = 0;
pR = 0;
pF = 0;
pBuffs=0;
bGrade=0;
//PLAYER = NOYA;
role player;
player.type = PLAYER;
player.id=1;
roles.clear();
stars.clear();
bullets.clear();
grains.clear();
infoList.clear();
//各种缓存
string info;//消息输出
char tc[100];//char缓存
string ts;//string缓存
int ti;//int缓存
player.life=SDATA.life[PLAYER];
SDATA.getImage();
SDATA.initData(StoryMode);
SDATA.getImage();
CPB:
while ( !::GetAsyncKeyState( 'Z' ) ) {
/*选择 */
if ( ::GetAsyncKeyState( VK_UP ) ) {
if ( PLAYER > NOYA ) {
PLAYER--;
} else {
PLAYER = STARD;
}
SDATA.initData(StoryMode);
SDATA.getImage();
player.type = PLAYER;
player.bulletC = 0;
player.life=SDATA.life[PLAYER];
SDATA.maxNum[PLAYER] = 0;
api_sleep( 100 );
}
if ( ::GetAsyncKeyState( VK_DOWN ) ) {
if ( PLAYER < STARD ) {
PLAYER++;
} else {
PLAYER = NOYA;
}
SDATA.initData(StoryMode);
SDATA.getImage();
player.type = PLAYER;
player.bulletC = 0;
player.life=SDATA.life[PLAYER];
SDATA.maxNum[PLAYER] = 0;
api_sleep( 100 );
}
/* 回满能量 */
if ( ::GetAsyncKeyState( 'E' ) ) {
player.energy = MAXE;
api_sleep( 100 );
}
//最后两个需要自己监测的键
if ( ::GetAsyncKeyState( 'P' ) ) {
setfont( getwidth() / strlen( "已暂停" ), 0, "黑体" );
xyprintf( getwidth() / 2 - textwidth( "已暂停" ) / 2, getheight() / 2 - textheight( "已暂停" ) / 2, "已暂停" );
delay_fps( 60 );
while ( !::GetAsyncKeyState( 'Z' ) )
;
}
if ( ::GetAsyncKeyState( VK_ESCAPE ) ) {
saveUData();
player.reset();
player.life = SDATA.life[PLAYER];
pX = 0;
pY = 0;
pR = 0;
pF = 0;
pS = 0;
roles.clear();
bullets.clear();
changePos();
return;
}
//按键监测
InputKey(player);
runAll(player);
setcolor( WHITE );
ti=0;
setfont( 50*getwidth()/1920, 0, "黑体" );
info = "名称:";
ts="名称:";
info+=SDATA.i2n[PLAYER];
ts+=SDATA.i2n[PLAYER];
ti=max(ti,textwidth(ts.c_str()));
ts="生命力:";
info+="\n生命力:";
itoa( SDATA.life[PLAYER], tc, 10 );
info += tc;
ts+=tc;
ti=max(ti,textwidth(ts.c_str()));
ts="极速:" ;
info += "\n极速:";
itoa( SDATA.maxV[PLAYER], tc, 10 );
info += tc;
ts+=tc;
ti=max(ti,textwidth(ts.c_str()));
ts="射速:";
info += "\n射速:";
itoa( SDATA.shootV[PLAYER], tc, 10 );
info += tc;
ts+=tc;
ti=max(ti,textwidth(ts.c_str()));
ts="最低伤害:";
info += "\n最低伤害:";
itoa( SDATA.hurt[PLAYER], tc, 10 );
info += tc;
ts+=tc;
ti=max(ti,textwidth(ts.c_str()));
ts="装甲值:";
info += "\n装甲值:";
itoa( SDATA.pro[PLAYER], tc, 10 );
info += tc;
ts+=tc;
ti=max(ti,textwidth(ts.c_str()));
ts="弹仓容量:";
info += "\n弹舱容量:";
itoa( SDATA.BNum[PLAYER], tc, 10 );
info += tc;
ts+=tc;
ti=max(ti,textwidth(ts.c_str()));
setfillcolor(EGECOLORA(DARKGRAY,127));
ege_fillrect(getwidth()/192, getheight()/192*2,ti+getwidth()/192*2,textheight("字")*7);
outtextrect( getwidth()/192*2, getheight()/192*2, getwidth(), getheight(), info.c_str() );
if(!gPlanes[PLAYER]) {
info="价格:";
itoa( SDATA.pri[PLAYER], tc, 10 );
info+=tc;
info+="G";
setfillcolor(EGECOLORA(EGERGB(255,0,0),127));
} else if(!show) {
info="起航(Z)!";
setfillcolor(EGECOLORA(EGERGB(0,255,0),127));
} else {
info="完成!";
setfillcolor(EGECOLORA(EGERGB(0,255,0),127));
}
setfont( getwidth()/2/strlen(info.c_str()), 0, "微软雅黑" );
ege_fillrect(getwidth()/8*6-getwidth()/192, getheight()/8*5,textwidth(info.c_str())+getwidth()/192*2,textheight(info.c_str()));
xyprintf( getwidth()/8*6, getheight()/8*5,info.c_str() );
delay_fps( 60 );
if ( player.mV || player.clearing )
imagefilter_blurring( NULL, 0xFF, 0x100 );
else
cleardevice();
MSYS.playMBgm();
}
if(show) return;
if(!gPlanes[PLAYER]) {
if(scores<SDATA.pri[PLAYER]) {
MessageBox(getHWnd(),"积分不足!","提示",MB_OK);
} else {
vector<string> infos;
scores-=SDATA.pri[PLAYER];
gPlanes[PLAYER]=1;
saveUData();
infos.push_back("购买成功!");
drawBeginningTexts(infos);
}
goto CPB;
}
if ( PLAYER == RUINER ) {
SDATA.maxV[PLAYER] += 6;
}
if(StoryMode) {
readCheckpoint(Diff.first,Diff.second);
} else {
readCheckpoint(0,Diff.first);
}
changePos();
runGame(StoryMode);
}
//选择难度,因为必定为自由模式所以没有参数
int chooseDiff() {
PIMAGE bkimg = newimage();
getimage( bkimg, "image\\Arrow-3.png" );
const int maxDiff=5;
int choose = 1;
string info;
while(!::GetAsyncKeyState( 'Z' )) {
putimage( 0, 0, getwidth(), getheight(), bkimg, 0, 0, getwidth( bkimg ), getheight( bkimg ) ); /* 绘制放大后的图像 */
if ( ::GetAsyncKeyState( VK_UP ) ) {
if ( choose > 1 ) {
choose--;
} else {
choose = maxDiff;
}
api_sleep( 100 );
}
if ( ::GetAsyncKeyState( VK_DOWN ) ) {
if ( choose < maxDiff ) {
choose++;
} else {
choose = 1;
}
api_sleep( 100 );
}
setfont( (float) 160 / 1920 * getwidth(), 0, "黑体" );
info="自由模式\n难度:";
if(choose!=maxDiff)
info+='E'-choose;
else
info+='S';
setfillcolor(EGECOLORA(DARKGRAY,127));
ege_fillrect(getwidth()/2-textwidth("自由模式")/2-getwidth()/192,getheight()/2-textheight("字")-getwidth()/192,textwidth("字字字字")+getwidth()/192*2,textheight("字")*2+getwidth()/192*2);
outtextrect( getwidth()/2-textwidth("自由模式")/2, getheight()/2-textheight("字"), getwidth(), getheight(), info.c_str() );
delay_fps( 60 );
cleardevice();
MSYS.playMBgm();
}
changePos();
return choose;
}
//选择关卡,因为必定为故事模式所以没有参数
pair<int,int> chooseCP() {
PIMAGE bkimg = newimage();
getimage( bkimg, "image\\Arrow-3.png" );
pair<int,int> choose;
choose.first=1;
choose.second=1;
string info;
readStoryInfo();
readChapter(choose.first);
char tc[100];
while(!::GetAsyncKeyState( 'Z' )) {
putimage( 0, 0, getwidth(), getheight(), bkimg, 0, 0, getwidth( bkimg ), getheight( bkimg ) ); //绘制放大后的图像
if ( ::GetAsyncKeyState( VK_UP ) ) {
if ( choose.second > 1 ) {
choose.second--;
} else {
choose.second = s_grade.second;
}
api_sleep( 100 );
}
if ( ::GetAsyncKeyState( VK_DOWN ) ) {
if ( choose.second < s_grade.second ) {
choose.second++;
} else {
choose.second = 1;
}
api_sleep( 100 );
}
if ( ::GetAsyncKeyState( VK_RIGHT ) ) {
if ( choose.first < s_grade.first ) {
choose.first++;
} else {
choose.first = 1;
}
readChapter(choose.first);
api_sleep( 100 );
}
if ( ::GetAsyncKeyState( VK_LEFT ) ) {
if ( choose.first > 1 ) {
choose.first--;
} else {
choose.first = s_grade.first;
}
readChapter(choose.first);
api_sleep( 100 );
}
setfont( (float) 160 / 1920 * getwidth(), 0, "黑体" );
info=s_namec+"\n";
itoa(choose.second,tc,10);
info+=tc;
setfillcolor(EGECOLORA(DARKGRAY,127));
ege_fillrect(getwidth()/2-textwidth(s_namec.c_str())/2-getwidth()/192,getheight()/2-textheight(s_namec.c_str())-getwidth()/192,textwidth(s_namec.c_str())+getwidth()/192*2,textheight("字")*2+getwidth()/192*2);
outtextrect( getwidth()/2-textwidth(s_namec.c_str())/2, getheight()/2-textheight("字"), getwidth(), getheight(), info.c_str() );
delay_fps( 60 );
cleardevice();
MSYS.playMBgm();
}
changePos();
return choose;
}
void showHelp() {
vector<string> texts;
texts.push_back("简要操作说明(按下\"Z\"键继续)");
texts.push_back("使用↑↓和Z选择并确定选项");
texts.push_back("使用ESC回到上一个场景(通常情况下)");
texts.push_back("在主菜单按下→打开设置");
texts.push_back("WASD进行移动,J进行攻击");
texts.push_back("I+移动键=时停转弯");
texts.push_back("SHIFT快速加速,CTRL快速拐弯");
texts.push_back("有盈余能量时按1键(非小键盘数字键)开启护盾减免伤害");
texts.push_back("能量过半时按2键对大范围内的敌机造成大额伤害");
texts.push_back("能量充满时按F键进行跃迁");
texts.push_back("玩的开心!");
drawBeginningTexts(texts,0,DBT_STRESS|DBT_WAIT);
}
void runSetting(PIMAGE bk) {
int choose=1;
char ct[64];
string st;
int it;
PIMAGE bkimg=glass(bk);
bkimg=glass(bkimg);
bkimg=glass(bkimg);
bkimg=glass(bkimg);
bkimg=glass(bkimg);
const int maxc=6;//最大选项
//这里约定界面占2/3屏幕
int mw=getwidth()/3*2,mh=getheight();
while(!::GetAsyncKeyState( VK_LEFT ) && !::GetAsyncKeyState( VK_ESCAPE )) {
//绘制背景
putimage( 0, 0, getwidth(), getheight(), bkimg, 0, 0, getwidth( bkimg ), getheight( bkimg ) );
//处理选项
if ( ::GetAsyncKeyState( VK_UP ) ) {
if ( choose > 1 ) {
choose--;
} else {
choose = maxc;
}
api_sleep( 100 );
}
if ( ::GetAsyncKeyState( VK_DOWN ) ) {
if ( choose < maxc ) {
choose++;
} else {
choose = 1;
}
api_sleep( 100 );
}
//绘制选项框
setfillcolor(EGECOLORA(WHITE,127));
ege_fillrect(0,0,mw,mh);
setfillcolor(EGECOLORA(BLACK,240));
ege_fillrect(mw/192*2,mw/192*2,mw-mw/192*4,mh-mw/192*4);
//绘制信息
setfont( 8*getwidth()/192, 0, "黑体" );
if(choose==1) setcolor(YELLOW);
else setcolor(WHITE);
xyprintf(mw/192*3,mw/192*2,"用户名:%s",name.c_str());
if(choose==2) setcolor(YELLOW);
else setcolor(WHITE);
xyprintf(mw/192*3,mw/192*2+8*getwidth()/192,"积分:%lldG",scores);
setfont( 4*getwidth()/192, 0, "黑体" );
if(choose==3) setcolor(YELLOW);
else setcolor(WHITE);
xyprintf(mw/192*3,mw/192*2+24*getwidth()/192,"背景音乐音量:%1.0f%%",MSYS.getBV()*100);
if(choose==4) setcolor(YELLOW);
else setcolor(WHITE);
xyprintf(mw/192*3,mw/192*2+28*getwidth()/192,"音效音量:%1.0f%%",MSYS.getSV()*100);
if(choose==5) setcolor(YELLOW);
else setcolor(WHITE);
xyprintf(mw/192*3,mw/192*2+36*getwidth()/192,"查看指引");
if(choose==6) setcolor(YELLOW);
else setcolor(WHITE);
xyprintf(mw/192*3,mw/192*2+44*getwidth()/192,"查看机库");
if ( ::GetAsyncKeyState( 'Z' ) ) {
switch(choose) {
case 1: {
name=inputbox("输入新用户名","",name,getwidth()/4,getheight()/4,1);
break;
}
case 2: {
st=inputbox("抽奖","输入抽奖金额,最高奖项8倍积分(4%)!","100",getwidth()/4,getheight()/4,1);
if(scores>atoi(st.c_str())) {
scores-=atoi(st.c_str());
it=random(24);
if(it==23) {
MessageBox(getHWnd(),"您获得了8倍积分!!!","恭喜!",MB_OK);
scores+=atoi(st.c_str())*8;
} else if(it==22) {
MessageBox(getHWnd(),"您获得了5倍积分!!","恭喜!",MB_OK);
scores+=atoi(st.c_str())*5;
} else if(it==21) {
MessageBox(getHWnd(),"您获得了3倍积分!!","恭喜!",MB_OK);
scores+=atoi(st.c_str())*3;
} else if(it>=19&&it<21) {
MessageBox(getHWnd(),"您获得了2倍积分!!","恭喜!",MB_OK);
scores+=atoi(st.c_str())*2;
} else if(it>=17&&it<19) {
MessageBox(getHWnd(),"您获得了1.5倍积分!!","恭喜!",MB_OK);
scores+=atoi(st.c_str())*1.5;
} else if(it>=7&&it<17) {
MessageBox(getHWnd(),"您失去了一半的积分!","恭喜!",MB_OK);
scores+=atoi(st.c_str())*0.5;
} else if(it>=4&&it<7) {
MessageBox(getHWnd(),"您失去了投入的所有积分!","恭喜!",MB_OK);
scores+=atoi(st.c_str())*0.5;
} else {
MessageBox(getHWnd(),"您没失去一点积分!","恭喜!",MB_OK);
scores+=atoi(st.c_str());
}
} else {
MessageBox(getHWnd(),"积分不足!","糟糕!",MB_OK);
}
break;
}
case 3: {
st=inputbox("输入背景音乐音量","","40%",getwidth()/4,getheight()/4,1);
MSYS.setBV(atoi(st.substr(0,st.length()-1).c_str())/100.0);
break;
}
case 4: {
st=inputbox("输入音效音量","","60%",getwidth()/4,getheight()/4,1);
MSYS.setSV(atoi(st.substr(0,st.length()-1).c_str())/100.0);
break;
}
case 5: {
api_sleep(100);
showHelp();
api_sleep(100);
break;
}
case 6: {
changePos();
choosePlane(false,make_pair(0,0),1);
api_sleep(100);
break;
}
}
api_sleep( 100 );
}
delay_fps(60);
cleardevice();
}
}
void runMenu() {
PIMAGE pt = newimage();
PIMAGE bkimg = newimage();
SDATA.hImg.setFillColor( BLACK );
getimage( bkimg, "image\\Arrow-3.png" );
setcolor( WHITE );
int choose = 1;
char st[64]; /* 数字缓存 */
putimage( 0, 0, getwidth(), getheight(), bkimg, 0, 0, getwidth( bkimg ), getheight( bkimg ) ); /* 绘制放大后的图像 */
string info;
while ( 1 ) {
putimage( 0, 0, getwidth(), getheight(), bkimg, 0, 0, getwidth( bkimg ), getheight( bkimg ) ); /* 绘制放大后的图像 */
imagefilter_blurring( NULL, 0x0F, 0x100 );
if ( ::GetAsyncKeyState( VK_UP ) ) {
if ( choose > 1 ) {
choose--;
} else {
choose = 3;
}
api_sleep( 100 );
}
if ( ::GetAsyncKeyState( VK_DOWN ) ) {
if ( choose < 3 ) {
choose++;
} else {
choose = 1;
}
api_sleep( 100 );
}
/* 绘制选项 */
setfont( (float) 160 / 1920 * getwidth(), 0, "黑体" );
setfillcolor(EGECOLORA(DARKGRAY,127));
ege_fillrect((float)getwidth() / 2 - textwidth( "字字" ) -getwidth()/192, (float) 420 / 1920 * getwidth(),(float)textwidth( "字字字字" ) +getwidth()/192,(float)570 / 1920 * getwidth());
if ( choose == 1 )
setcolor( YELLOW );
else setcolor( WHITE );
xyprintf( getwidth() / 2 - textwidth( "自由模式" ) / 2, (float) 420 / 1920 * getwidth(), "自由模式" );
if ( choose == 2 )
setcolor( YELLOW );
else setcolor( WHITE );
xyprintf( getwidth() / 2 - textwidth( "操作说明" ) / 2, (float) 620 / 1920 * getwidth(), "操作说明" );
if ( choose == 3 )
setcolor( YELLOW );
else setcolor( WHITE );
xyprintf( getwidth() / 2 - textwidth( "退出" ) / 2, (float) 820 / 1920 * getwidth(), "退出" );
if ( ::GetAsyncKeyState( 'Z' ) ) {
switch ( choose ) {
case 1: {
gun g;
guns.clear();
g.id = 1;
guns.push_back( g );
g.id = 4;
guns.push_back( g );
g.id = 0;
guns.push_back( g );
g.id = 5;
guns.push_back( g );
g.id = 2;
guns.push_back( g );
g.id = 3;
guns.push_back( g );
changePos();
int ti=chooseDiff();
choosePlane(0,make_pair(ti,0));
break;
}
case 2: {
//MessageBox(getHWnd(),"功能尚未开发完毕","提示",MB_OK);
showHelp();
/*
gun g;
guns.clear();
g.id = 1;
guns.push_back( g );
g.id = 4;
guns.push_back( g );
g.id = 0;
guns.push_back( g );
g.id = 5;
guns.push_back( g );
g.id = 2;
guns.push_back( g );
g.id = 3;
guns.push_back( g );
changePos();
auto t=chooseCP();
choosePlane(1,t);*/
break;
}
case 3: {
saveUData();
exit( 0 );
break;
}
}
}
if ( ::GetAsyncKeyState( VK_RIGHT ) ) {
getimage(pt,0,0,getwidth(),getheight());
runSetting(pt);
api_sleep( 100 );
}
MSYS.playMBgm();
delay_fps( 15 );
cleardevice();
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化