#include #include #include using namespace std; void gotoxy(int x, int y); void setcolor(WORD color); void setForeGroundAndBackGroundColor(int ForeGroundColor,int BackGroundColor); void clearscreen(); void drawpixel( unsigned char x, unsigned char y, unsigned char Color); void drawpixel2( unsigned char x, unsigned char y, unsigned char Color, char character); void drawcircle(int x, int y, int a, int b, int color); void drawline(int x0, int y0, int x1, int y1, int color); void drawfilledrectangle(unsigned char x1,unsigned char y1,unsigned char x2,unsigned char y2,unsigned char bkcol); void drawframe(unsigned x,unsigned y,unsigned sx,unsigned sy,unsigned char col,unsigned char col2,char text_[]); void drawwindow(unsigned x,unsigned y,unsigned sx,unsigned sy,unsigned char col,unsigned char col2,unsigned char bkcol,char text_[]); int main() { gotoxy(1,23); setcolor(7); clearscreen(); cout<<"click anywhere in console window to write - hello world -\n\n\n\n\n\n\n\n\n\n\n\n\n" "Press Ctrl+C to Exit"; HANDLE hout= GetStdHandle(STD_OUTPUT_HANDLE); HANDLE hin = GetStdHandle(STD_INPUT_HANDLE); INPUT_RECORD InputRecord; DWORD Events; COORD coord; CONSOLE_CURSOR_INFO cci; cci.dwSize = 25; cci.bVisible = FALSE; SetConsoleCursorInfo(hout, &cci); SetConsoleMode(hin, ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT); bool EXITGAME = false; int buttonX=1, buttonY=1; drawpixel(buttonX,buttonY ,1); gotoxy(buttonX+2,buttonY); setcolor(3); cout<<"<----- a button \n"; while( !EXITGAME ) { ReadConsoleInput(hin, &InputRecord, 1, &Events); switch ( InputRecord.EventType ){ case KEY_EVENT: // keyboard input switch (InputRecord.Event.KeyEvent.wVirtualKeyCode) { case VK_ESCAPE: EXITGAME = TRUE; break; case VK_SPACE: break; case VK_RETURN: break; case VK_LEFT: // left key move player left cout<<"VK_LEFT = "<= 0) { ya -= asq * 2; thresh -= ya; wy--; } xa += bsq * 2; wx++; if (xa >= ya) break; drawpixel(x+wx, y-wy, color); drawpixel(x-wx, y-wy, color); drawpixel(x+wx, y+wy, color); drawpixel(x-wx, y+wy, color); } drawpixel(x+a, y, color); drawpixel(x-a, y, color); wx = a; wy = 0; xa = bsq * 2 * a; ya = 0; thresh = bsq / 4 - bsq * a; for (;;) { thresh += ya + asq; if (thresh >= 0) { xa -= bsq * 2; thresh = thresh - xa; wx--; } ya += asq * 2; wy++; if (ya > xa) break; drawpixel(x+wx, y-wy, color); drawpixel(x-wx, y-wy, color); drawpixel(x+wx, y+wy, color); drawpixel(x-wx, y+wy, color); } } //***************************************************************************** void drawline(int x0, int y0, int x1, int y1, int color){ int pix = color; int dy = y1 - y0; int dx = x1 - x0; int stepx, stepy; if (dy < 0) { dy = -dy; stepy = -1; } else { stepy = 1; } if (dx < 0) { dx = -dx; stepx = -1; } else { stepx = 1; } dy <<= 1; // dy is now 2*dy dx <<= 1; // dx is now 2*dx drawpixel( x0, y0,pix); if (dx > dy) { int fraction = dy - (dx >> 1); // same as 2*dy - dx while (x0 != x1) { if (fraction >= 0) { y0 += stepy; fraction -= dx; // same as fraction -= 2*dx } x0 += stepx; fraction += dy; // same as fraction -= 2*dy drawpixel( x0, y0,pix); } } else { int fraction = dx - (dy >> 1); while (y0 != y1) { if (fraction >= 0) { x0 += stepx; fraction -= dy; } y0 += stepy; fraction += dx; drawpixel( x0, y0,pix); } } } //***************************************************************************** void drawframe(unsigned x,unsigned y,unsigned sx,unsigned sy,unsigned char col,unsigned char col2,char text_[]){ unsigned i,j,m;{ m=(sx-x); //differential j=m/8; //adjust j=j-1; //more adjustment gotoxy(x,y);printf("É"); //Top left corner of drawframe gotoxy(sx,y);printf("»"); //Top right corner of drawframe gotoxy(x,sy);printf("È"); //Bottom left corner of drawframe gotoxy(sx,sy);printf("¼"); //Bottom right corner of drawframe for (i=x+1;i