Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _WIN32_WINNT 0x0601
- #ifndef UNICODE
- #define UNICODE
- #define UNICODE_WAS_UNDEFINED
- #endif
- #include <Windows.h>
- #ifdef UNICODE_WAS_UNDEFINED
- #undef UNICODE
- #endif
- #define WHITE_SPACE 9608
- typedef struct _CONSOLE_FONT_INFOEX
- {
- ULONG cbSize;
- DWORD nFont;
- COORD dwFontSize;
- UINT FontFamily;
- UINT FontWeight;
- WCHAR FaceName[LF_FACESIZE];
- }CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX;
- //the function declaration begins
- #ifdef __cplusplus
- extern "C" {
- #endif
- BOOL WINAPI SetCurrentConsoleFontEx(HANDLE hConsoleOutput,
- BOOL bMaximumWindow,
- PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx);
- #ifdef __cplusplus
- }
- #endif
- //the function declaration ends
- void setFontSize(int w, int h)
- {
- CONSOLE_FONT_INFOEX fontStructure={0};
- fontStructure.cbSize=sizeof(fontStructure);
- fontStructure.dwFontSize.X=w;
- fontStructure.dwFontSize.Y=h;
- HANDLE hConsole=GetStdHandle(STD_OUTPUT_HANDLE);
- SetCurrentConsoleFontEx(hConsole, true, &fontStructure);
- }
- const int nScreenWidth = 100, nScreenHeight = 20;
- int columns, rows;
- class Pile
- {
- };
- int main()
- {
- //setting correct window size
- setFontSize(10, 20);
- HWND hwnd = GetConsoleWindow();
- MoveWindow(hwnd, 0, 0, nScreenWidth*10.4, nScreenHeight*22, TRUE);
- //initialising variables
- //miscellaneous
- POINT mouse;
- CONSOLE_SCREEN_BUFFER_INFO csbi;
- //console dimensions
- RECT r;
- GetWindowRect(hwnd, &r);
- //PCONSOLE_FONT_INFO lpConsoleCurrentFont = new CONSOLE_FONT_INFO;
- GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
- columns = csbi.srWindow.Right - csbi.srWindow.Left + 1;
- rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
- //window output set up
- wchar_t *screen = new wchar_t[nScreenWidth*nScreenHeight];
- HANDLE hConsole = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
- SetConsoleActiveScreenBuffer(hConsole);
- DWORD dwBytesWritten = 0;
- while(1)
- {
- //clear screen
- int ii=-1;
- while(ii<nScreenHeight*nScreenWidth)//replace later
- {
- screen[++ii]=' ';
- }
- //find out over which cell the mouse hovers
- GetCursorPos(&mouse);
- GetWindowRect(hwnd, &r);
- int mi = (mouse.y - r.top - 30)/20 ;
- int mj = (mouse.x - r.left - 8) / 10;
- if(mouse.x > 0 && mouse.x < 1010 && mouse.y > 0 && mouse.y < 436)
- {
- //mouse stuff
- screen[ mi * nScreenWidth + mj ] = WHITE_SPACE;//optional
- }
- //optional {
- screen[2] = mi%10 + '0';
- screen[1] = mi%100/10 + '0';
- screen[0] = mi%1000/100 + '0';
- screen[6] = mj%10 + '0';
- screen[5] = mj%100/10 + '0';
- screen[4] = mj%1000/100 + '0';
- screen[100]='+';
- screen[nScreenHeight*nScreenWidth] = WHITE_SPACE;
- // }
- //game stuff
- //display
- screen[nScreenWidth * nScreenHeight - 1] = WHITE_SPACE;
- WriteConsoleOutputCharacter(hConsole, screen, nScreenHeight * nScreenWidth, { 0,0 }, &dwBytesWritten);
- Sleep(0);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement