37 lines
863 B
C
37 lines
863 B
C
#include "entity.h"
|
|
#include "player.h"
|
|
#include "wall.h"
|
|
#include <gint/display.h>
|
|
#include <gint/keyboard.h>
|
|
|
|
void
|
|
main(void)
|
|
{
|
|
struct Player player;
|
|
struct Wall walls[5];
|
|
|
|
player_init(&player, 16, 32);
|
|
wall_init(&walls[0], 16, 0, DWIDTH - 32, 16);
|
|
wall_init(&walls[1], 16, DHEIGHT - 16, DWIDTH - 32, 16);
|
|
wall_init(&walls[2], 0, 0, 16, DHEIGHT);
|
|
wall_init(&walls[3], DWIDTH - 16, 0, 16, DHEIGHT);
|
|
wall_init(&walls[4], DWIDTH / 2 - 24, DHEIGHT - 64, 48, 48);
|
|
|
|
do {
|
|
const int previous_x = player.x;
|
|
const int previous_y = player.y;
|
|
dclear(C_BLACK);
|
|
entity_grid_draw_hitboxes();
|
|
dupdate();
|
|
clearevents();
|
|
player.x += keydown(KEY_RIGHT) - keydown(KEY_LEFT);
|
|
player.y += keydown(KEY_DOWN) - keydown(KEY_UP);
|
|
if (entity_collide(&player)) {
|
|
player.x = previous_x;
|
|
player.y = previous_y;
|
|
}
|
|
} while (!keydown(KEY_EXIT));
|
|
|
|
return;
|
|
}
|