The UIButton object has several functions that must be defined. We have created a new ui_button.cpp file that will hold all of these new functions. We will need to define a constructor, as well as MouseMove, MouseClick, MouseUp, KeyDown, and RenderUI.
First, we will include our game.hpp file:
#include "game.hpp"
Now, we will define our constructor function:
UIButton::UIButton( int x, int y, char* file_name, char* hover_file_name, char* click_file_name, void (*callback)() ) {
m_Callback = callback;
m_dest.x = x;
m_dest.y = y;
SDL_Surface *temp_surface = IMG_Load( file_name );
if( !temp_surface ) {
printf("failed to load image: %s\n", IMG_GetError() );
return;
}
else {
printf("success creating ui button surface\n");
}
m_SpriteTexture = SDL_CreateTextureFromSurface( renderer,
temp_surface...