Advertisement
Vlad3955

LevelGUI.cpp

Sep 18th, 2022
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.35 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include "LevelGUI.h"
  4. #include "MyTools.h"
  5.  
  6. using namespace std;
  7. using namespace MyTools;
  8.  
  9. void LevelGUI::Draw() const
  10. {
  11.     MyTools::SetColor(CC_White);
  12.  
  13.     GotoXY(x, y);
  14.     char* buf = new (nothrow) char[width + 1];
  15.     if (buf == nullptr)
  16.     {
  17.         return;
  18.     }
  19.     memset(buf, '+', width);
  20.     buf[width] = '\0';
  21.     cout << buf;
  22.     GotoXY(x, y + height);
  23.     cout << buf;
  24.     delete [] buf;
  25.     buf = nullptr;
  26.    
  27.     for (size_t i = size_t(y); i < height + y; i++)
  28.     {
  29.         GotoXY(x, (double)i);
  30.         cout << "+";
  31.         GotoXY(x + width - 1, (double)i);
  32.         cout << "+";
  33.     }
  34.  
  35.     GotoXY(3, 1);
  36.     cout << "FramePerSecond: " << static_cast<int>(fps / (passedTime / 1000.0));
  37.     GotoXY(25, 1);
  38.     cout << "PassedTime: " << static_cast<int>(passedTime / 1000.0) << " sec";
  39.     GotoXY(46, 1);
  40.     cout << "BombsNum: " << bombsNumber;
  41.     GotoXY(62, 1);
  42.     cout << "Score: " << score;
  43.     GotoXY(3, 3);
  44.     if (!(_receiveMessage.empty()))
  45.     {
  46.         cout << _receiveMessage.front();
  47.         _receiveMessage.pop();
  48.     }
  49. }
  50.  
  51. void __fastcall LevelGUI::SetParam(uint64_t passedTimeNew, uint64_t fpsNew, uint16_t bombsNumberNew, int16_t scoreNew)
  52. {
  53.     passedTime = passedTimeNew;
  54.     fps = fpsNew;
  55.     bombsNumber = bombsNumberNew;
  56.     score = scoreNew;
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement