eliasreid / rad-shooter

Simply c++ arcade-y shooting game using SDL. WIP, no installer
1 stars 0 forks source link

UI elements #7

Closed eliasreid closed 4 years ago

eliasreid commented 4 years ago
eliasreid commented 4 years ago

http://lazyfoo.net/tutorials/SDL/16_true_type_fonts/index.php

Tutorial doesn't seem to cover how to update text dynamically. See this answer on stack overflow https://stackoverflow.com/a/31652567.

Optimally, would be rendering text form a pre-created texture containing all text. But in this small case, probably ok to render whole thing each cycle. In the case of health text, only update when there is actually a change.

Maybe better off moving to openGL eventually: https://stackoverflow.com/a/41362410

eliasreid commented 4 years ago

Am I managing resources (destroying texture) properly in TextBox? should be freeing texture in destructor. Should TextBox inherit from GameObject?

eliasreid commented 4 years ago

Score UI only one left. Going to go for composition over inheritance in this case.

Create a class that has a textbox.

Extend this to healthui and refactorif makes more sense

eliasreid commented 4 years ago

Should give text box a second constructor. one that takes a screen position enum instead of explicit x and y coordinates.