<span style="font-size:18px;">
#include "stdio.h"
#include "conio.h"
#include "bios.h"
#define UP 18432
#define DOWN 20480
#define LEFT 19200
#define RIGHT 19712
#define ESC 283
struct move_point{
int x,y; /*该点的位置*/
int xv, yv; /*该点在x轴,y轴的速度*/
}man;
int main(void)
{
long key,i;
man.x = man.y = 1;
man.xv = man.yv = 1;
clrscr();
gotoxy(man.x, man.y);
printf("%c\b", 2);
while(bioskey(1) == 0){ //等待按键
key = bioskey(0); //接收按键的键盘码
clrscr();
switch(key){
case DOWN:
if(man.y == 25);
else
man.y += man.yv;
break;
case UP:
if(man.y == 1);
else
man.y -= man.yv;
break;
case RIGHT:
if(man.x == 75);
else
man.x += man.xv;
break;
case LEFT:
if(man.x == 1);
else
man.x -= man.xv;
break;
case ESC:
return 0;
default:
break;
}
gotoxy(man.x, man.y);
printf("%c\b", 2);
}
getch();
return 0;
}
</span>
用键盘移动笑脸
最新推荐文章于 2021-06-04 04:25:19 发布