Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // unicode needs to be enabled so
- //that WHITESPACE character can be used
- #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
- #include <stdio.h>
- #include <vector>
- //used to resize the console cell
- //important for w10 compatibility
- 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
- //resizes cell
- //important for w10 compatibility
- 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);
- }
- //{ variables
- int screen_width = 80, screen_height = 25;//screen dimensions in columns/rows
- bool running = true;//the boolean used for the game loop
- int turn = 0;//indicated who's player turn is
- int default_turn = 0;//retains the preference of who starts the rounds
- wchar_t player1[11] = L"Mitrutz";//can be modified at runtime
- wchar_t player2[11] = L"Matei";//can be modified at runtime
- wchar_t won[] = L"won";//displayed when the game is won next to the player's name
- bool restart_game = false;//when true, the piles get filled and the game begins again
- wchar_t new_game_wchar[] = L"new game\0";//`new game` button text
- wchar_t unselected_coin_texture[51] = L" ######## ############################## ######## ";
- wchar_t selected_coin_texture[51] = L" ######## ############################## ######## ";
- //selected_coin_texture is painted to white in main (the white character cant be copy-pasted)
- bool updated = false;//indicates if the turn has changed
- int nrCoins[] = {0, 1, 2, 3, 4, 5};//keeps count of the coins (on each column)
- const int cell_count = screen_height * screen_width;//number of total cells on screen
- int cell_size_px_x = 8, cell_size_px_y = 12; //used to calculate over which cell the mouse hovers
- float move_window_x = 10.4f, move_window_y = 14.0;
- COORD zerozero = {0, 0};
- wchar_t options_[] = L"options", game_[] = L"game"
- ,how_to_play_[] = L"how to play ", nullstr[] = L" ", turn_wchr[] = L"Turn:";
- wchar_t *screen = new wchar_t[screen_width*screen_height];//console graphic buffer
- HWND hwnd;//used in console manipulation
- int mi, mj;//the line and column over which the mouse hovers
- wchar_t over_score[9] = {175, 175, 175, 175, 175, 175, 175, 175, 0};
- wchar_t under_score[9] = {L'_', L'_', L'_', L'_', L'_', L'_', L'_', L'_', 0};
- wchar_t horizontal_line[12] = {9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 0};
- int scene = 1;//indicates the current scene(game/options/how_to_play scene)
- wchar_t score_wchr[] = {'S', 'c', 'o', 'r', 'e', ':', 0};
- int score1(0), score2(0);//keep track of score
- bool score_updated = false;//checks if the score has been updated
- wchar_t player_names_wchr[] = L"Player names:";
- HANDLE hConsole;DWORD dwBytesWritten = 0;//miscellaneous
- bool widgets_updated;//makes sure multiple widgets can't be open in the same frame
- //}
- bool testbool = false;
- void updateVersion()
- {
- DWORD dwVersion = 0;
- DWORD dwMinorVersion = 0;
- dwVersion = GetVersion();
- // Get the Windows version.
- dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
- int version = dwMinorVersion;
- if(version == 2)
- {
- //setting correct window size
- setFontSize(12, 20);///win10
- move_window_x = 12.5;///win10 used to be .5
- move_window_y = 22; ///win10
- cell_size_px_x = 10;
- cell_size_px_y = 20;
- }
- MoveWindow(hwnd, 0, 0, screen_width*move_window_x, screen_height*move_window_y, TRUE);
- }
- void optionsScene()
- {
- scene = 2;
- }
- void gameScene()
- {
- scene = 1;
- }
- void howToPlayScene()
- {
- scene = 0;
- }
- size_t wstrlen(wchar_t* n)
- {
- size_t i = 0;
- while(n[i])++i;
- return i;
- }
- int print(int n, int x, int y);
- class Mouse
- {
- public:
- void update()//update the state of the mouse
- {
- if(GetKeyState(VK_LBUTTON) < 0)
- {
- if(held)
- clicked = false;
- else
- clicked = held = true;
- }
- else
- clicked = held = false;
- GetCursorPos(&position);
- GetWindowRect(hwnd, &r);
- position.y = position.y - r.top - 30;//30 is the size of the title bar
- position.x = position.x - r.left - 8;//idk what 8 is it's also for correction
- //find out over which cell the mouse hovers
- mi = (this->pos().y)/cell_size_px_y;
- mj = (this->pos().x)/cell_size_px_x;
- }
- POINT pos()
- {
- return this->position;
- }
- bool isHeld()
- {
- return held;
- }
- bool isClicked()
- {
- return clicked;
- }
- Mouse()
- {
- clicked = false;
- held = false;
- position.x = position.y =0;
- }
- private:
- bool clicked;
- bool held;
- POINT position;
- RECT r;
- }mouse;
- class Keyboard
- {
- public:
- Keyboard()
- {
- key = held = 0;
- }
- void update()
- {
- for (char i = '0'; i <= 'Z'; ++i)
- {
- if(GetKeyState(i) < 0)
- {
- if(held == 0)
- {
- key = held = (wchar_t)i;
- if(key >= 'A' && key <= 'Z' && !(GetKeyState(VK_SHIFT) < 0))key = key + ('a' - 'A');
- }
- else
- {
- key = 0;
- }
- return;
- }
- }
- key = key + ('a' - 'A');
- key = held = 0;
- print(3, 0, 3);
- }
- wchar_t keyPressed()
- {
- return key;
- }
- //private:
- wchar_t key, held;
- }keyboard;
- void setrunningtofalse()//end game loop
- {
- running = false;
- }
- //when start_game is true the piles are filled up again
- void setrestart_gametotrue()
- {
- if(scene==1)restart_game=true;
- }
- short sum();
- void changeTurn()
- {
- if (sum() == 15)
- {
- turn = 1 - turn;
- default_turn = turn;
- }
- }
- //can be clicked and have text
- class Button
- {
- public:
- // position , size , displayed text , function called when pressed
- Button (int i, int j, int isize, int jsize, wchar_t name[], void (*foo)())
- {
- textsize = 0;
- while(name[textsize])
- {
- text[textsize]=name[textsize];
- ++textsize;
- }
- text[textsize] = L'\0';
- func = foo;
- left_margin = i;
- j1 = j;
- right_margin = i + isize;
- j2 = j + jsize;
- }
- void update()
- {
- if(mouse.isClicked() && mi >= left_margin && mi < right_margin && mj >= j1 && mj < j2)
- func();
- }
- void draw()
- {
- int aux = 0;
- for(int i = left_margin; i < right_margin; i++)
- {
- for(int j = j1; j < j2; j++)
- {
- if(aux>=0 && aux < textsize)
- screen[i * screen_width + j] = text[aux++];
- }
- }
- }
- void draw(wchar_t *screen, int screen_width, int i = 0, int j = 0)
- {
- int aux = 0;
- while (text[aux] != 0)
- {
- screen[i * screen_width + j + aux] = text[aux];
- ++aux;
- }
- }
- wchar_t* name()
- {
- return text;
- }
- private:
- wchar_t text[200];
- unsigned short textsize;
- short left_margin, right_margin, j1, j2;
- void (*func)();
- };
- void quit()
- {
- exit(1);
- }
- //used in order to check if an area is hovered/clicked
- class Coin
- {
- public:
- int left_margin, j1, right_margin, j2;
- Coin(int i, int j, int isize, int jsize)
- {
- left_margin = i;
- j1 = j;
- right_margin = i + isize;
- j2 = j + jsize;
- }
- bool hovered(int mi, int mj)
- {
- if(mi >= left_margin && mi < right_margin && mj >= j1 && mj <j2)
- {
- if((mi==left_margin || mi == right_margin-1) && (mj == j1 || mj == j2-1))
- return false;
- return true;
- }
- return false;
- }
- bool _clicked(int mi, int mj)
- {
- if(hovered(mi, mj) && mouse.isClicked())
- return true;
- return false;
- }
- };
- //contains coins. when (almost) all Pile instances
- //are empty the game is won
- //hard coded size of 10 cells
- //useless to declare >5 coins
- class Pile
- {
- public:
- /* position (left side), number of coins it will have*/
- Pile(unsigned short i , unsigned short nrcoins)
- {
- left_margin = i;
- right_margin = left_margin + 10;
- nPileWidth = 10;
- coins.clear();
- for(int ii = 1; ii <= nrcoins; ii++)
- coins.push_back(Coin(screen_height-(ii*5), i, 5, 10));
- }
- //does the same as the constructor
- void reset(unsigned short i , unsigned short nrcoins)
- {
- left_margin = i;
- right_margin = left_margin + 10;
- nPileWidth = 10;
- coins.clear();
- for(int ii = 1; ii <= nrcoins; ii++)
- coins.push_back(Coin(screen_height-(ii*5), i, 5, 10));
- }
- //check if any cell is hovered
- //remove the cells from top if also clicked
- int update(int mi, int mj)
- {
- hovered_cell = 0;
- for(size_t i = 0; i< coins.size(); i++){
- if(coins[i].hovered(mi, mj))
- {
- hovered_cell = i+1;
- i= coins.size();//i goes to end and ends loop
- if(mouse.isClicked())
- {
- while((int)coins.size()>=hovered_cell)
- coins.pop_back();
- updated = true;
- return coins.size();
- }
- }
- }
- return coins.size();
- }
- void draw(wchar_t*& screen)
- {
- int i = -1;
- while(++i<nPileWidth*screen_height)gBuffer[i]=L' ';
- if(hovered_cell)
- {
- for(int i = 0; i<hovered_cell-1; i++)
- {
- for(int j = 0; j<50; j++)
- {
- gBuffer[i*nPileWidth*5 + j] = unselected_coin_texture[j];
- }
- }
- for(unsigned short i = hovered_cell-1; i<coins.size(); i++)
- for(int j = 0; j<50; j++)
- gBuffer[i*nPileWidth*5 + j] = selected_coin_texture[j];
- }
- else
- {
- for(unsigned short i = 0; i<coins.size(); i++)
- for(int j = 0; j<50; j++)
- {
- gBuffer[i*nPileWidth*5 + j] = unselected_coin_texture[j];
- }
- }
- int qq = 0;
- bool done = false;
- int gb = screen_height*nPileWidth-1;
- while(!done && qq < screen_height)
- {
- for(int ww = 0; ww < nPileWidth; ww++)
- {
- if(gb)
- {
- int aux = qq*screen_width+ww+left_margin;
- if(aux < cell_count) screen[aux] = gBuffer[gb--];
- }
- else done=true;//*/
- }
- qq++;
- }//*/
- }
- private:
- int left_margin, right_margin, hovered_cell;
- std::vector<Coin>coins;
- unsigned short nPileWidth;
- wchar_t gBuffer[25*50];
- };
- short sum()
- {
- short s = 0;
- for(int yt = 1; yt <= 5; ++yt)
- {
- s+=nrCoins[yt];
- }
- return s;
- }
- short cols()
- {
- short nrc = 0;
- for(int yt = 1; yt <= 5; ++yt)
- {
- nrc += (nrCoins[yt] > 0);
- }
- return nrc;
- }
- int print(int n, int linear_pos)
- {
- if (!n)
- {
- screen[linear_pos] = L'0';
- return linear_pos + 2;
- }
- //digit count
- int len = 0, aux = n;
- while(aux){aux/=10;++len;}
- aux = len;
- if (n < 0)
- {
- screen[linear_pos] = L'-';
- ++linear_pos;
- n*=(-1);
- }
- while (n)
- {
- screen[linear_pos + len - 1] = n%10 + '0';
- n/=10; --len;
- }
- return linear_pos + aux + 1;
- }
- int print(int n, int x, int y)
- {
- int pos = y * screen_width + x;
- return print(n, pos);
- }
- int print(int n[], int _count, int linear_position)
- {
- int i = 0;
- while(_count)
- {
- linear_position = print(n[i], linear_position);
- --_count;++i;
- }
- return linear_position;
- }
- int print(int n[], int _count, int x, int y)
- {
- int pos = y * screen_width + x;
- print(n, _count, pos);
- return pos + 2;
- }
- //returns the linear position of the end of
- //the string + 1 (good for printing multiple
- //strings consecutively)
- int print(wchar_t n[], int linear_pos)
- {
- int i = 0;
- while (n[i] != 0)
- {
- screen[linear_pos + i] = n[i];
- ++i;
- }
- return linear_pos + i + 1;
- }
- int print(wchar_t n[], int x, int y)
- {
- int pos = y*screen_width + x;
- return print(n, pos);
- }
- int print(wchar_t n, int linear_position)
- {
- screen[linear_position] = n;
- return linear_position + 2;
- }
- int print(wchar_t n, int x, int y)
- {
- int pos = y * screen_width + x;
- return print(n, pos);
- }
- print(char n, int linear_position)
- {
- screen[linear_position] = (wchar_t)n;
- return linear_position + 2;
- }
- int print(char n, int x, int y)
- {
- int pos = y * screen_width + x;
- return print(n, pos);
- }
- int print(int n[], int _count, int linear_position, wchar_t delimitator)
- {
- int i = 0;
- while(_count > 1)
- {
- linear_position = print(n[i], linear_position);
- linear_position = print(delimitator, linear_position-1);
- --_count;++i;
- }
- linear_position = print(n[i], linear_position);
- return linear_position;
- }
- int print(int n[], int _count, int x, int y, wchar_t delimitator)
- {
- int pos = y * screen_width + x;
- return print(n, _count, pos, delimitator);
- }
- int print(int n[], int _count, int linear_position, char delimitator)
- {
- return print(n, _count, linear_position, (wchar_t)delimitator);
- }
- int print(int n[], int _count, int x, int y, char delimitator)
- {
- int pos = y * screen_width + x;
- return print(n, _count, pos, (wchar_t)delimitator);
- }
- //game stuff
- Button new_game(16, 1, 1, 8, new_game_wchar, setrestart_gametotrue);
- Button ebutton(-2, screen_width-6, 3, 10, nullstr, setrunningtofalse);
- Button options_scene(21, 1, 1, 8, options_, optionsScene);
- Button game_scene(19, 3, 1, 4, game_, gameScene);
- Button how_to_play_scene(23, 2, 2, 6, how_to_play_, howToPlayScene);
- Button change_turn(1, 1, 1, 8, nullstr, changeTurn);
- Pile p1(14, 1);
- Pile p2(28, 2);
- Pile p3(42, 3);
- Pile p4(56, 4);
- Pile p5(70, 5);
- void game()
- {
- if(cols()>1||sum()>1){
- nrCoins[1] = p1.update(mi, mj);//returns the number of
- nrCoins[2] = p2.update(mi, mj);//current coins in the pile
- nrCoins[3] = p3.update(mi, mj);
- nrCoins[4] = p4.update(mi, mj);
- nrCoins[5] = p5.update(mi, mj);
- }
- if(updated)
- {
- turn = 1 - turn;
- updated = false;
- }
- change_turn.update();
- if(restart_game)
- {
- p1.reset(14, 1);
- p2.reset(28, 2);
- p3.reset(42, 3);
- p4.reset(56, 4);
- p5.reset(70, 5);
- nrCoins[3]=2;
- turn = default_turn;
- restart_game=false;
- score_updated = false;
- }
- //display
- p1.draw(screen);
- p2.draw(screen);
- p3.draw(screen);
- p4.draw(screen);
- p5.draw(screen);
- if(cols()==1&&sum()==1)
- {
- int i;
- if(turn==0)
- i = print(player1, 35 + (10 - wstrlen(player1) - 1), 10);
- else
- i = print(player2, 35 + (10 - wstrlen(player2) - 1), 10);
- print(won, i);
- if(score_updated == false)
- {
- score_updated = true;
- if(turn == 0)
- ++score1;
- else ++score2;
- }
- i = print(player1, 31 + (10 - wstrlen(player1) - 1), 12);
- i = print(score1, i);
- i = print('|', i);
- i = print(score2, i);
- print(player2, i);
- }
- if(cols()==0)
- {
- int i = 0;
- if(turn==1)
- i = print(player1, 35 + (10 - wstrlen(player1) - 1), 10);
- else
- i = print(player2, 35 + (10 - wstrlen(player2) - 1), 10);
- print(won, i);
- if(score_updated == false)
- {
- score_updated = true;
- if(turn == 1)
- ++score1;
- else ++score2;
- }
- i = print(player1, 31 + (10 - wstrlen(player1) - 1), 12);
- i = print(score1, i);
- i = print('|', i);
- i = print(score2, i);
- print(player2, i);
- }
- }
- void howToPlay()
- {
- }
- bool __ok = false;
- void setOkToTrue(){
- __ok = !__ok;
- }
- void dropBox(int ipos, int jpos, int isize, std::vector<wchar_t*>& wlist, wchar_t* output)
- {if(!widgets_updated){widgets_updated = true;
- COORD c = {(short)jpos, (short)ipos};
- std::vector<Button>butons;
- for(size_t i = 0; i < wlist.size(); ++i){
- butons.push_back(Button(ipos+i*2+3, jpos-2, 1, isize, wlist[i], setOkToTrue));
- }
- wchar_t add_wchr[10] = L"add name";
- Button add(ipos+1, jpos+1, 1, isize-2, add_wchr, setOkToTrue);
- int cell_count2 = (wlist.size() * 2 + 3/*aditional empty space*/) * isize;
- wchar_t *screen2 = new wchar_t[cell_count2];
- bool naming = false;
- wchar_t new_name[11] = {0};
- unsigned short new_name_iterator = 0;
- bool b_held = false;
- auto print2 = [](wchar_t n[], int linear_pos, wchar_t* scr)
- {
- int i = 0;
- while (n[i] != 0)
- {
- scr[linear_pos + i] = n[i];
- ++i;
- }
- return linear_pos + i + 1;
- };
- auto print2xy = [print2, isize](wchar_t n[], int x, int y, wchar_t* scr)
- {
- int pos = y*isize + x;
- return print2(n, pos, scr);
- };
- bool loopbool = true;
- while(loopbool)//condition
- {
- //update input information
- mouse.update();
- keyboard.update();
- //content
- //int namecount = 0;
- for(int i = cell_count2 - 1; i >= 0; i--)
- screen2[i] = L' ';
- for(unsigned i = 0; i < wlist.size() * 2 + 2; ++i)
- {
- screen2[i * isize] = 9474;
- screen2[i * isize + isize - 1] = 9474;
- }
- for(int i = 0; i < isize; ++i)
- {
- screen2[cell_count2-i] = 9644;
- }
- screen2[cell_count2-isize]=9492;
- screen2[cell_count2-1] = 9496;
- add.update();
- if(__ok)
- {
- naming = true;
- testbool = !testbool;
- __ok = false;
- }
- if(!naming)
- add.draw(screen2, isize, 1, 1);
- else
- {
- print2xy(new_name, 1, 1, screen2);
- if(keyboard.keyPressed() > 0)
- {
- if(new_name_iterator < 10)new_name[new_name_iterator] = keyboard.keyPressed();
- if(new_name_iterator < 11)++new_name_iterator;
- }
- if(GetKeyState(VK_BACK) < 0)
- {
- if(!b_held)
- {
- if(new_name_iterator > 0)--new_name_iterator;
- new_name[new_name_iterator] = 0;
- b_held = true;
- }
- } else b_held = false;
- }
- for(unsigned i = 0; i < wlist.size(); i++)
- {
- if(!naming)butons[i].update();
- butons[i].draw(screen2, isize, i*2+3, 1);
- if(__ok)
- {
- int j = 0;
- while(wlist[i][j]!=0)
- {
- output[j] = wlist[i][j];
- ++j;
- }
- output[j] = 0;
- __ok = false;
- loopbool = false;
- }
- }
- if(naming && GetKeyState(VK_RETURN) < 0)
- {
- naming = false;
- wchar_t* nn = new wchar_t[11];
- for(size_t i = 0; i < 11; ++i)
- nn[i] = new_name[i];
- wlist.push_back(nn);
- loopbool = false;
- for(int i = 0; i < 10; ++i)
- output[i] = new_name[i];
- }
- //display
- c.Y = (short)ipos;
- for(unsigned un = 0; un < wlist.size() * 2 + 3; un++)
- {
- WriteConsoleOutputCharacter(hConsole, screen2 + un * isize, isize, c, &dwBytesWritten);
- c.Y = c.Y + 1;
- }
- Sleep(1);
- if(mouse.isClicked() && (mi < ipos - 2 || mi > ipos + cell_count2 / isize - 1 || mj < jpos || mj >= jpos + isize))
- loopbool = false;
- }
- }}
- std::vector<wchar_t*> names;
- void db1()
- {
- dropBox(4, 30, 13, names, player1);
- }
- void db2()
- {
- dropBox(4, 46, 13, names, player2);
- }
- int nrc = 9450;
- void nrcpp(){++nrc;}
- wchar_t box_wchr[] = {9484, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9488,
- 9474, L' ', L' ', L' ', L' ', L' ', L' ', L' ', L' ', L' ', L' ', 9660, 9474,
- 9492, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9472, 9496, 0};
- Button p1_naming_box(2, 30, 3, 13, box_wchr, db1);
- Button p2_naming_box(2, 46, 3, 13, box_wchr, db2);
- void options()
- {
- print(player_names_wchr, 15, 3);
- p1_naming_box.update();
- p1_naming_box.draw();
- print(player1, 31, 3);
- //print((wchar_t)10563 , 44, 3);
- p2_naming_box.update();
- p2_naming_box.draw();
- print(player2, 47, 3);
- //int pozz = print((wchar_t)nrc, 45, 8);
- // print(nrc, pozz);
- }
- //9660 triangle down
- //9644 horizontal line
- void sideBar()
- {
- if(keyboard.keyPressed() == 'M')
- ++nrc;
- //Show who's player's turn is
- print(turn_wchr, 2, 0);
- if(turn==0)
- print(player1, 0, 1);
- else
- print(player2, 0, 1);
- //update buttons
- new_game.update();
- ebutton.update();
- options_scene.update();
- game_scene.update();
- how_to_play_scene.update();
- //display buttons
- new_game.draw();
- options_scene.draw();
- game_scene.draw();
- how_to_play_scene.draw();
- {//shows which button (scene toggle button) is selected
- if (scene == 0)//how to play
- {
- print((wchar_t)WHITE_SPACE, 0, 23);
- print((wchar_t)WHITE_SPACE, 9, 23);
- print((wchar_t)WHITE_SPACE, 0, 24);
- print((wchar_t)WHITE_SPACE, 9, 24);
- }
- else if (scene == 1)//game scene
- {
- print((wchar_t)WHITE_SPACE, 0, 19);
- print((wchar_t)WHITE_SPACE, 9, 19);
- }
- else if (scene == 2)//options scene
- {
- print((wchar_t)WHITE_SPACE, 0, 21);
- print((wchar_t)WHITE_SPACE, 9, 21);
- }
- }
- //sidebar line
- for(int i=0; i<screen_height; i++)
- screen[i*screen_width + 10] = WHITE_SPACE;
- }
- int main()
- {
- //windows 10 compatibility stuff
- hwnd = GetConsoleWindow();
- updateVersion();
- //window output set up
- hConsole = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
- SetConsoleActiveScreenBuffer(hConsole);
- //miscellaneous
- for (int i = 0; i < 50; ++i)
- if (selected_coin_texture[i] == L'#') selected_coin_texture[i] = WHITE_SPACE;
- for (int i = 0; i < cell_count; ++i)
- screen[i] = L' ';
- wchar_t temp[10] = L"Mihai";
- names.push_back(temp);
- wchar_t temp2[10] = L"Matei";
- names.push_back(temp2);
- wchar_t temp3[10] = L"Mitca";
- names.push_back(temp3);
- wchar_t temp4[10] = L"Mihalache";
- names.push_back(temp4);
- while(running)
- {
- //update input information
- mouse.update();
- keyboard.update();
- widgets_updated = false;
- //clear screen
- for(int i = 0; i < cell_count; i++)
- screen[i]=L' ';
- if (scene == 0)
- howToPlay();
- else if(scene == 1)
- game();
- else if (scene == 2)
- options();
- sideBar();
- if(keyboard.keyPressed()>0)
- testbool = true;
- if(testbool)
- print('k', 6, 12);
- int pozz = print('i', 1, 7);
- pozz = print(mi, pozz);
- pozz = print('j', 1, 8);
- pozz = print(mj, pozz);
- //display
- WriteConsoleOutputCharacter(hConsole, screen, cell_count, zerozero, &dwBytesWritten);
- Sleep(1);
- if(!running)exit(0);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement