Rectangles and SDL_Rect

Learn to create, render, and interact with basic rectangles using the SDL_Rect and SDL_Color types.

Ryan McCombe
Updated
Hello! I'm here to help you with any questions about this lesson. Feel free to ask me anything - whether it's about specific concepts, examples, or how to apply what you've learned!

Questions & Answers

Answers are generated by AI models and may not have been reviewed. Be mindful when running any code on your device.

Difference Between SDL_Rect and SDL_FRect in SDL2
What's the difference between SDL_Rect and SDL_FRect? When should I use floats?
Drawing Rectangle Outlines in SDL2
How do I draw just the outline of a rectangle instead of filling it?
Using Alpha for Semi-Transparency with SDL_Color in SDL2
Can I make the rectangle semi-transparent using the alpha channel in SDL_Color? How?
Passing SDL_Event by Reference (&E) in SDL2 Event Handling
Why pass the SDL_Event by reference (&E) to HandleEvent()?
Fading Rectangle Color on Hover in SDL2
What if I want the rectangle's color to change gradually when hovered (fade)?
Alternatives to Structured Binding for SDL_Color in Render()
Why did we use structured binding for the color in Render()? What are the alternatives?
Moving a Rectangle in SDL2
How would I move the rectangle around the screen?