#include "commands.h" #include "lzr.h" #include "cfg.h" #include int mouse_x, mouse_y, hovered = -1, editing = -1; static const unsigned int commands[COM_LEN] = { COM_RIGHT, COM_RIGHT, COM_UP, COM_DOWN, COM_LEFT, COM_LEFT, COM_DOWN, COM_UP }; void commands_update(void) { LZR_MousePosition(&mouse_x, &mouse_y); hovered = -1; if (mouse_x > CFG_TSIZE / 2 && mouse_x <= CFG_TSIZE * 2.5) { int y = (mouse_y - CFG_TSIZE / 2) / (int)(CFG_TSIZE * 1.5); if (y < 0 || y >= COM_LEN) return; hovered = y; if (LZR_BUTTON(MOUSE_L)) editing = commands[y]; } } void commands_draw(void) { for (int i = 0; i < COM_LEN; i++) { const int dx = CFG_TSIZE / 2; const int dy = CFG_TSIZE / 2 + i * (int)(CFG_TSIZE * 1.5); const int cmd = commands[i]; const int blink = hovered != i || (LZR_GetTick() & 1); if (cmd == editing) LZR_DrawSetColor(rand() & 1, rand() & 1, rand() & 1, 1); else LZR_DrawSetColor(blink, blink, blink, 1); LZR_DrawImage(cmd, dx, dy); } }