The UISprite class is pretty simple. It has only two functions: a constructor and a rendering function. Like with every other CPP file in our project, the first thing we must do is include the game.hpp file:
#include "game.hpp"
United States
Great Britain
India
Germany
France
Canada
Russia
Spain
Brazil
Australia
South Africa
Thailand
Ukraine
Switzerland
Slovakia
Luxembourg
Hungary
Romania
Denmark
Ireland
Estonia
Belgium
Italy
Finland
Cyprus
Lithuania
Latvia
Malta
Netherlands
Portugal
Slovenia
Sweden
Argentina
Colombia
Ecuador
Indonesia
Mexico
New Zealand
Norway
South Korea
Taiwan
Turkey
Czechia
Austria
Greece
Isle of Man
Bulgaria
Japan
Philippines
Poland
Singapore
Egypt
Chile
Malaysia
The UISprite class is pretty simple. It has only two functions: a constructor and a rendering function. Like with every other CPP file in our project, the first thing we must do is include the game.hpp file:
#include "game.hpp"
The constructor is very familiar. It sets the m_dest rectangle's x and y values to the values that were passed into the constructor. It loads the texture from the virtual filesystem using the file_name variable that we passed in as a parameter. Finally, it centers the m_dest rectangle using the width and height values that were retrieved using the SDL_QueryTexture function. Here is the code for the constructor:
UISprite::UISprite( int x, int y,...