hyperultra/src/player.c

41 lines
837 B
C
Raw Normal View History

2023-03-17 10:51:17 +01:00
#include "player.h"
#include "entity.h"
#include "game.h"
2023-03-17 10:57:19 +01:00
#include "lzy.h"
2023-03-17 13:45:20 +01:00
#include "cfg.h"
2023-03-17 10:51:17 +01:00
#include <string.h>
static void
player_update(Entity *this, Game *g)
{
2023-03-17 11:06:37 +01:00
this->vel[0] = 1.2;
this->vel[1] += 0.1;
entity_move(this, g);
2023-03-17 10:51:17 +01:00
}
static void
player_draw(Entity *this, Game *g)
{
2023-03-17 10:57:19 +01:00
(void)g;
2023-03-17 13:45:20 +01:00
LZY_DrawSetColor(BLACK);
LZY_DrawRect(this->pos[0] - this->width / 2,
this->pos[1] - this->height / 2,
this->width, this->height);
LZY_DrawRect(this->pos[0] - this->width / 2 + 1,
this->pos[1] - this->height / 2 + 1,
this->width - 2, this->height - 2);
2023-03-17 10:51:17 +01:00
}
void
player_init(Entity *this)
{
memset(this, 0, sizeof(*this));
2023-03-17 13:45:20 +01:00
this->pos[0] = 32;
this->pos[1] = 32;
2023-03-17 10:51:17 +01:00
this->type = ET_PLAYER;
this->update = player_update;
this->draw = player_draw;
2023-03-17 10:57:19 +01:00
this->width = 12;
this->height = 12;
2023-03-17 10:51:17 +01:00
}