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 {
|
2024-05-08 22:07:31 +00:00
|
|
|
struct ControlMapping mappings[BINDS_N];
|
|
|
|
struct ControlAxis *input[BINDS_N];
|
|
|
|
|
2024-05-08 12:47:46 +00:00
|
|
|
struct TetrMap board;
|
|
|
|
struct TetrMap piece;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2024-05-08 22:07:31 +00:00
|
|
|
void FumotrisStart(void *inst_arg, void *game_arg)
|
2024-05-02 22:17:37 +00:00
|
|
|
{
|
2024-05-08 22:07:31 +00:00
|
|
|
struct FumoInstance *inst = inst_arg;
|
|
|
|
struct Fumotris *game = game_arg;
|
2024-05-02 22:17:37 +00:00
|
|
|
|
2024-05-08 22:07:31 +00:00
|
|
|
ControllerMapMulti(&inst->ctrl, BINDS_N, game->mappings, game->input);
|
2024-05-08 12:47:46 +00:00
|
|
|
|
|
|
|
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 22:07:31 +00:00
|
|
|
void FumotrisUpdate(void *inst_arg, void *game_arg)
|
2024-05-07 22:10:15 +00:00
|
|
|
{
|
2024-05-08 22:07:31 +00:00
|
|
|
struct FumoInstance *inst = inst_arg;
|
|
|
|
struct Fumotris *game = game_arg;
|
2024-05-08 12:47:46 +00:00
|
|
|
|
2024-05-08 22:07:31 +00:00
|
|
|
if (game->input[LEFT]->is_down)
|
2024-05-08 12:47:46 +00:00
|
|
|
game->piece.x -= 1;
|
2024-05-08 22:07:31 +00:00
|
|
|
if (game->input[RIGHT]->is_down)
|
2024-05-08 12:47:46 +00:00
|
|
|
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;
|
|
|
|
}
|