#include "scenes.h" #include "liquid.h" #include "../graphics/nokia.h" #include struct CarScene { struct Scene base; int32_t pos; }; static struct SceneEvent Car_onInput(struct CarScene *self, struct InputEvent event) { switch (event.kind) { case InputEventKind_Wheel: self->pos += event.wheel.delta; if (self->pos < 0) self->pos = 0; if (self->pos > LCD_WIDTH-21) self->pos = LCD_WIDTH-21; return SceneEvent_Repaint(); case InputEventKind_Button: if (event.button.state) { return SceneEvent_Close(0, NULL); } // fall through default: return SceneEvent_None(); } } static void Car_paint(struct CarScene *self) { LCD_clearDisplay(0); LCD_setRect(self->pos, LCD_HEIGHT/2-10, self->pos+20,LCD_HEIGHT/2+10,0,1); LCD_updateDisplay(); } struct Scene *NewScene_Car(void) { struct CarScene *scene = calloc(1, sizeof(struct CarScene)); if (!scene) return NULL; scene->base.onInput = (Scene_onInput_t) Car_onInput; scene->base.paint = (Scene_paint_t) Car_paint; return (struct Scene *) scene; }