Advertisement
Guest User

Untitled

a guest
May 25th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. .h
  2. class Interface
  3. {
  4. private:
  5. Game* game;
  6. SDL_Rect Point;
  7. SDL_Texture* Message;
  8. SDL_Surface* surfacePoint;
  9. TTF_Font* font;
  10. public:
  11. Interface(Game&);
  12. void render();
  13. ~Interface();
  14. };
  15.  
  16. .cpp
  17. Interface::Interface(Game& game)
  18. {
  19. font = TTF_OpenFont("Arial.ttf", 100);
  20. }
  21.  
  22. void Interface::render()
  23. {
  24. Point.x = game->getWindowWidth()*0.15-50;
  25. Point.h = 50;
  26.  
  27. if(game->getScore() <= 9)
  28. {
  29. Point.x = game->getWindowWidth()*0.15+30;
  30. Point.w = 20;
  31. }
  32. else …
  33.  
  34. SDL_Color color = {255, 255, 255, 255};
  35. std::string number;
  36. number = std::to_string(game->getScore());
  37. SDL_Surface* surfacePoint = TTF_RenderText_Solid(font, number.c_str(), color);
  38. SDL_Texture* Message = SDL_CreateTextureFromSurface(game->renderer, surfacePoint);
  39. SDL_RenderCopy(game->renderer, Message, NULL, &Point);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement