summaryrefslogtreecommitdiff
path: root/src/main.c
blob: f9ae592de131759aa8cff5fef3fbabe89687a2ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "lzy.h"
#include "game.h"
#include "player.h"
#include "background.h"
#include "cfg.h"
#include "input.h"
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
	if (LZY_Init("Hyperultra!", 30, "res/tset.png", "res/font.png")) {
		LZY_Log("LZY_Init failed: %s", LZY_GetError());
		LZY_Quit();
		return 1;
	}

	Game *const game = malloc(sizeof(Game));
	if (game == NULL) {
		LZY_Log("malloc failed");
		LZY_Quit();
		return 1;
	}
	game_init(game);

	while (!LZY_ShouldQuit()) {
		LZY_CycleEvents();
		input_update();
		game_update(game);

		LZY_DrawBegin();
		LZY_DrawSetColor(WHITE);
		LZY_DrawClear();
		background_draw();
		game_draw(game);
		LZY_DrawEnd();
	}

	game_deinit(game);
	free(game);
	LZY_Quit();
	return 0;
}