Hỏi đáp
Chia sẻ kiến thức, cùng nhau phát triển
Mình không thể lấy dữ kiện từ bàn phím mỗi lần nhập là nó mất màn hình đồ họa
#include <iostream>
// tu vien toan hoc
#include <cmath>
// thu vien do hoa
#include <graphics.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int vuong(int x, int y, int w, int h)
{
w += x;
h += y;
line(x,y,w,y);
line(x,y,x,h);
line(w,y,w,h);
line(x,h,w,h);
}
int main(int argc, char** argv) {
// int gd = DETECT, gm;
// initgraph(&gd,&gm,"c:\\tc\\bgi");
char a;
initwindow(1366,786,"my game", 0, 0);
setcolor(15);
outtextxy(1,1,"my game");
outtextxy(2,20,"Would you like a cup of coffee?");
outtextxy(20,40,"yes");
vuong(15,40,35,20);
outtextxy(60,40,"no");
vuong(55,40,35,20);
do{
a = getch();
if (a==75){
setcolor(5);
vuong(15,40,35,20);
} else if(a == 77){
setcolor(5);
vuong(55,40,35,20);
}
}while(a == 75 || a == 77);
getch();
closegraph();
return 0;
}
get