"Remove" Rect/image |
Naith
|
Instead of "removing" the rect / quad, you can choose to only render it when you want to. Use a boolean ('RenderRect ' for example) that you set to True when the mouse pointer is inside it and set it to False when the mouse pointer is outside of it (only an example of when to change the boolean state). Whenever the boolean is True, render the rect / quad, and when it's False, don't render the rect / quad.
Psuedo code:
|
|||||||||||||
|
Tyzor
|
Thanks for the reply. Please bear with me as I've only started SDL
I took your advice and used a bool. I was successful in that aspect but the problem now is just refreshing the screen. As of this moment i have 2 rectangles, when i press 1 it'll draw a red rectangle and if i press 1 again it'll clear the screen (this is perfect!). If i press 2, it'll draw a blue rectangle and if i press it again it'll clear the screen. HOWEVER if i have both rectangles on the screen at the same time it'll clear the entire screen resulting in an empty window. Again, any suggestions in terms of design or solutions will be GREATLY appreciated.
|
|||||||||||||
|
Naith
|
The problem with your code, as of now, is that you're only render the rectangles one frame, which is in the SDL_KEYDOWN event. There's a few things that can be changed in your code. Some of them regarding the design and some of them regarding to make the program works the way it's planned. Here's my version of your code.
Code:
|
|||||||||||||
|
Tyzor
|
Ahh worked like a charm. Thank you very much.
|
|||||||||||
|