Day 88/100 100 Days of Code

Day 88/100 100 Days of Code

Jumping Ball

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.