Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .h
- class Interface
- {
- private:
- Game* game;
- SDL_Rect Point;
- SDL_Texture* Message;
- SDL_Surface* surfacePoint;
- TTF_Font* font;
- public:
- Interface(Game&);
- void render();
- ~Interface();
- };
- .cpp
- Interface::Interface(Game& game)
- {
- font = TTF_OpenFont("Arial.ttf", 100);
- }
- void Interface::render()
- {
- Point.x = game->getWindowWidth()*0.15-50;
- Point.h = 50;
- if(game->getScore() <= 9)
- {
- Point.x = game->getWindowWidth()*0.15+30;
- Point.w = 20;
- }
- else …
- SDL_Color color = {255, 255, 255, 255};
- std::string number;
- number = std::to_string(game->getScore());
- SDL_Surface* surfacePoint = TTF_RenderText_Solid(font, number.c_str(), color);
- SDL_Texture* Message = SDL_CreateTextureFromSurface(game->renderer, surfacePoint);
- SDL_RenderCopy(game->renderer, Message, NULL, &Point);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement