九洲方除百尺冰,映秀又遭蛮牛耕。汽笛嘶鸣国旗半,哀伤尽处是重生。 -老K
治国就是治吏。礼义廉耻,国之四维。四维不张,国之不国。 -毛泽东
#include <stdio.h> #include <graphics.h>
#define UP 18432 #define DOWN 20480 #define ENTER 7181
int barcolor[4]={WHITE,BLUE,BLUE,BLUE}; char bartext[4][6]={"HEART","COUNT","UFO","EXIT"}; int barstate=0;
void show_heart(); void show_count(); void show_ufo();
void in_graphics(); void out_graphics(); void press_control(); void show_menu_bar(); void clear_screen();
void main(){ in_graphics(); clear_screen(); show_menu_bar(); press_control(); out_graphics(); }
void in_graphics(){ int gd=DETECT,gm; initgraph(&gd,&gm,""); cleardevice(); }
void out_graphics(){ closegraph(); }
void clear_screen(){ setfillstyle(1,BLUE); bar(100-20,200-20,500+20,400+20); setfillstyle(1,7); bar(100-6,200-6,500-6,400-6); setcolor(WHITE); rectangle(100-1,200-1,500+1,400+1); setfillstyle(1,0); bar(100,200,500,400); }
void show_heart(){ int i; char heart[9][26]={ " * * * * ", " * * * * ", " * * * * ", " * * * ", " * * ", " * * ", " * * ", " * * ", " * * "}; clear_screen(); for(i=0;i<9;i++) outtextxy(200,210+i*20,heart[i]); } void show_count(){ char str[7]; int i; clear_screen(); setfillstyle(1,7); bar(200-4,250-4,400-4,300-4); setfillstyle(1,WHITE); bar(200,250,400,300); for(i=1500;i>=0;i--){ bar(220+65,260,260+65,268); itoa(i,str,10); setcolor(RED); outtextxy(220+65,260,str); setcolor(i/100); outtextxy(220+50,280,"quickly!"); } setfillstyle(1,WHITE); bar(220,280,350,300); setcolor(RED); outtextxy(220,280,"YOU DEATH! GAME OVER!"); } void show_ufo(){ clear_screen(); /*这里,你自己画个UFO吧,我不可能什么都帮你做完*/ /*你只能在(100,200)-(500,400)的区域范围内画,否则会超出边框*/ }
void show_menu_bar(){ int i; setcolor(0); for(i=0;i<4;i++){ setfillstyle(1,barcolor[i]); bar(10,i*20,100,20+i*20); outtextxy(10+10,i*20+8,bartext[i]); } }
void press_control(){ int key,i;
while(1){ key=bioskey(0); if(key==UP){ if(barstate==0) barstate=3; else barstate--; } else if(key==DOWN){ if(barstate==3) barstate=0; else barstate++; } else if(key==ENTER){ switch(barstate){ case 0: show_heart();break; case 1: show_count();break; case 2: show_ufo();break; case 3: exit(0); } continue; } else continue; for(i=0;i<4;i++) barcolor[i]=BLUE; barcolor[barstate]=WHITE; show_menu_bar(); } } 死KNOCKER还不是你害的,我必须要向我朋友保证以后不许帮女孩子回答问题。