?? play.c
字號:
#include "MAGIC.h"
#include "stdio.h"
#include "stdlib.h"
#include "conio.h"
#include "graphics.h"
#include "time.h"
#include "string.h"
void Gameplay(void)
{
int QuesNum=1,RightCount=0,WrongCount=0,Score=0;
char temp[6];
setcolor(YELLOW);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
outtextxy(180,350,ntostr(RightCount,temp));
outtextxy(180,380,ntostr(WrongCount,temp));
outtextxy(180,410,ntostr(Score,temp));
while(1)
{
setfillstyle(1,BLUE);
bar(180,320,220,340);
outtextxy(180,320,ntostr(QuesNum,temp));
if(Play())
{
RightCount++;
Score+=10;
}
else
{
WrongCount++;
}
setfillstyle(1,BLUE);
bar(180,320,220,430);
setcolor(YELLOW);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
outtextxy(180,320,ntostr(QuesNum,temp));
outtextxy(180,350,ntostr(RightCount,temp));
outtextxy(180,380,ntostr(WrongCount,temp));
outtextxy(180,410,ntostr(Score,temp));
getch();
QuesNum++;
}
}
int Play(void)
{
int AnsFlag;
int a,b,c,d;
char Str[50]="*";
char *Ans[100];
NewQues(&a,&b,&c,&d);
Magic(a,b,c,d,Ans);
AnsFlag=strcmp(Ans[0],"No Answer!");
setfillstyle(1,BLUE);
bar(173,262,600,290);
GetText(173,262,Str);
if((Str[0]=='0'&&Str[1]=='\0'&&AnsFlag==0)||(CalcForm(Str)==24&&AnsFlag&&Justify(a,b,c,d,Str)))
{
Right();
return 1;
}
else
{
Wrong();
setfillstyle(1,BLUE);
bar(311,301,633,439);
settextjustify(CENTER_TEXT,CENTER_TEXT);
setcolor(LIGHTGREEN);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
outtextxy(465,330,"Correct Answer");
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
setcolor(WHITE);
outtextxy(465,380,Ans[0]);
settextjustify(LEFT_TEXT,TOP_TEXT);
return 0;
}
}
void Right(void) /*如果正確*/
{
int i,timer;
char *Tip[6]={" Wow! You are Right!"," Correct! This seems too easy for you."," Oh,maybe Einstein cannot do it quicker. ",
" How can you make it? I wanna know."," You must be a genius!"," Have you got a super brain?"};
int t1,t2;
srand(time(NULL));
t1=rand()%3;
srand(time(NULL));
t2=rand()%3+3;
setfillstyle(1,BLUE);
bar(311,301,633,439);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
setcolor(LIGHTGREEN);
outtextxy(315,340,Tip[t1]);
outtextxy(315,355,Tip[t2]);
setcolor(YELLOW);
outtextxy(315,420," Press Any Key to Next Question...");
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
for(i=0;i<4;i++)
{
setfillstyle(1,BLACK);
bar(6,441,633,456);
setcolor(YELLOW);
outtextxy(190,445,"Correct answer! Congratulations!");
timer=clock();
while(((clock()-timer)<2));
setfillstyle(1,LIGHTGREEN);
bar(6,441,633,456);
setcolor(BLUE);
outtextxy(190,445,"Correct answer! Congratulations!");
timer=clock();
while(((clock()-timer)<2));
}
}
void Wrong(void) /*如果錯誤*/
{
int i,timer;
setcolor(YELLOW);
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
for(i=0;i<4;i++)
{
setfillstyle(1,BLUE);
bar(6,441,633,456);
outtextxy(190,445,"Wrong! NOT the Correct Answer!");
timer=clock();
while(((clock()-timer)<2));
setfillstyle(1,RED);
bar(6,441,633,456);
outtextxy(190,445,"Wrong! NOT the Correct Answer!");
timer=clock();
while(((clock()-timer)<2));
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -