Fumofumotris/source/fumotris/fumotris.c

48 lines
1,011 B
C
Raw Normal View History

2024-05-07 22:10:15 +00:00
#include "fumotris.h"
2024-05-02 22:17:37 +00:00
2024-05-08 12:47:46 +00:00
struct Fumotris {
struct TetrMap board;
struct TetrMap piece;
};
void FumotrisStart(void *engine, void *app)
2024-05-02 22:17:37 +00:00
{
2024-05-08 12:47:46 +00:00
struct FumoInstance *inst = engine;
struct Fumotris *game = app;
2024-05-02 22:17:37 +00:00
2024-05-08 12:47:46 +00:00
ControllerMapMulti(&inst->ctrl, CODE_COUNT, mappings_global);
CreateTetrMap(&game->board, 10, 10);
CreateTetrMap(&game->piece, 3, 3);
game->piece.blks = T;
2024-05-07 22:10:15 +00:00
}
2024-05-07 03:29:10 +00:00
2024-05-08 12:47:46 +00:00
void FumotrisUpdate(void *engine, void *app)
2024-05-07 22:10:15 +00:00
{
2024-05-08 12:47:46 +00:00
struct FumoInstance *inst = engine;
struct Fumotris *game = app;
if (mappings_global[LEFT].axis->is_down)
game->piece.x -= 1;
if (mappings_global[RIGHT].axis->is_down)
game->piece.x += 1;
2024-05-06 05:52:30 +00:00
2024-05-08 12:47:46 +00:00
TetrMapDraw(&game->board, &inst->term);
TetrMapDraw(&game->piece, &inst->term);
2024-05-02 22:17:37 +00:00
}
int main()
{
2024-05-08 12:47:46 +00:00
struct FumoInstance inst;
CreateFumoInstance(&inst);
2024-05-02 22:17:37 +00:00
2024-05-07 22:10:15 +00:00
struct Fumotris game;
2024-05-08 12:47:46 +00:00
EventAdd(&inst.on_start, FumotrisStart, &game);
EventAdd(&inst.on_update, FumotrisUpdate, &game);
2024-05-02 22:17:37 +00:00
2024-05-08 12:47:46 +00:00
FumoInstanceRun(&inst);
2024-05-02 22:17:37 +00:00
2024-05-07 22:10:15 +00:00
return 0;
}