📄 train.c
字号:
/* file: train.c
*/
#include <stdio.h>
#include <conio.h>
#include <bios.h>
#include "run.h"
#include "track.h"
/* 已有轨道的转折点列表 */
static const POINT point0[]=
{
{202,36},{585,36},{602,53},{602,425},
{585,442},{215,442},{196,423},{196,43}
};
static const POINT point1[]=
{
{399,51},{427,52},{463,57},{488,57},{513,66},{536,78},
{558,92},{573,112},{587,133},{600,156},{602,181},{602,207},
{602,234},{602,261},{602,288},{601,312},{593,338},{579,358},
{558,374},{536,387},{513,398},{490,408},{468,418},{444,422},
{417,422},{389,422},{363,417},{334,413},{310,405},{288,391},
{271,373},{257,352},{245,329},{236,305},{229,281},{222,257},
{221,232},{222,207},{230,181},{240,157},{254,134},{270,115},
{289,100},{308,84},{327,68}
};
static const POINT point2[]=
{
{299,144},{515,144},{542,144},{567,138},{585,118},{594,95},
{597,70},{585,48},{564,36},{538,36},{511,53},{500,79},
{497,114},{498,345},{500,369},{503,393},{518,412},{536,428},
{561,425},{583,413},{599,393},{599,368},{587,347},{568,331},
{546,321},{520,320},{289,320},{264,320},{230,329},{211,344},
{205,369},{211,410},{243,427},{288,424},{310,396},{319,358},
{320,92},{319,68},{309,46},{286,36},{260,37},{237,49},
{222,68},{219,93},{226,116},{246,131},{268,142}
};
/* 自定义轨道的转折点列表 */
static POINT pointbuf[1024];
/* 已有的三个轨道 */
static const TRACK Track[]=
{
{sizeof(point0)/sizeof(POINT),point0},
{sizeof(point1)/sizeof(POINT),point1},
{sizeof(point2)/sizeof(POINT),point2}
};
/* 自定义轨道 */
static TRACK CusTrack={0,pointbuf};
int main(void)
{
int gmode;
int gdriver=DETECT;
BOOL bSelect;
registerbgidriver(EGAVGA_driver);
initgraph(&gdriver,&gmode,"");
nWidth=getmaxx();
nHeight=getmaxy();
nMidWid=nWidth>>1;
nMidHei=nHeight>>1;
for(;;)
{
cleardevice();
setbkcolor(BLACK);
setcolor(GREEN);
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
outtextxy(nMidWid-136,80,"The Running Train");
outtextxy(nMidWid-200,180,"1 : Select a track and run");
outtextxy(nMidWid-200,230,"2 : Customize your track");
outtextxy(nMidWid-200,280,"Esc: Quit");
do {
switch((char)(getch()))
{
case '1':/* select a track*/
{
bSelect=TRUE;
Run(Select(Track,sizeof(Track)/sizeof(TRACK)));
}break;
case '2':/* customize your track */
{
bSelect=TRUE;
Run(Customize(&CusTrack));
CusTrack.size=0;
}break;
case 27:/* quit */
{
return;
}break;
default:{
bSelect=FALSE;
}break;
}/*end switch*/
}while(!bSelect);
}/*end loop*/
closegraph();
return 0;
}/*end main*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -