Input processor interface and sdl implementation added, now frees text textures after displaying text, need to look into caching so we can let manager handle it
This commit is contained in:
@@ -3,12 +3,15 @@
|
||||
//
|
||||
|
||||
#include "visualizer.hpp"
|
||||
bool Visualizer::update() {
|
||||
bool Visualizer::update(InputResult input) {
|
||||
this->x += 1;
|
||||
if(this->x > WIN_WIDTH) {
|
||||
if(this->x > WIN_WIDTH || input.keycode == KEY_ESCAPE) {
|
||||
this->x = 0;
|
||||
return true;
|
||||
}
|
||||
if(input.keycode == KEY_RIGHT) {
|
||||
this->sprite_index += 1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -23,7 +26,7 @@ unsigned int Visualizer::get_framerate() {
|
||||
void Visualizer::render(Renderer *renderer) {
|
||||
Color color = COLOR_WHITE;
|
||||
SpriteSheet sheet = SpriteSheet{"sprites/character.bmp", 48, 48};
|
||||
auto sprite = Sprite{&sheet, 1};
|
||||
auto sprite = Sprite{&sheet, this->sprite_index};
|
||||
RendererParams window_params = get_renderer_params();
|
||||
renderer->draw_sprite(sprite, window_params.width/2, window_params.height/2);
|
||||
for(int y=0;y<WIN_HEIGHT;y++) {
|
||||
|
||||
Reference in New Issue
Block a user