Day 88/100 100 Days of Code
I started working on the button but couldn't do much today because I was quite busy. I always try to squeeze in as much programming time as possible.
Button Structure
struct StartButton
{
int x;
int y;
float width;
float height;
};
Generate Button Function
void GenerateButton(TTF_Font *font, SDL_Renderer *renderer, struct StartButton &startButton, bool isHovering)
{
SDL_Color color = {0xFF, 0xFF, 0xFF, 0xFF};
SDL_Surface *buttonTextSurface = TTF_RenderText_Solid(font, "Start", color);
if (startButton.width == 0 || startButton.height == 0)
{
startButton.width = buttonTextSurface->w;
startButton.height = buttonTextSurface->height;
}
SDL_Texture *buttonTextTexture = SDL_CreateTextureFromSurface(renderer, buttonTextSurface);
const SDL_FRect buttonTextHolder = {startButton.x, startButton.y,
startButton.width, startButton.height};
SDL_RenderTexture(renderer, buttonTextTexture, NULL, &buttonTextHolder);
}
The GenerateButton function still requires some work to be completed.
Subscribe to my newsletter
Read articles from Chris Douris directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Chris Douris
Chris Douris
AKA Chris, is a software developer from Athens, Greece. He started programming with basic when he was very young. He lost interest in programming during school years but after an unsuccessful career in audio, he decided focus on what he really loves which is technology. He loves working with older languages like C and wants to start programming electronics and microcontrollers because he wants to get into embedded systems programming.