summaryrefslogtreecommitdiff
path: root/src/player.c
blob: de51b1c1acfb23f752d34f1350f4805a299895d0 (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
#include "entity.h"
#include "entityimpl.h"
#include "lzr.h"

IMPL(draw) {
	const float a = 1.0 - this->player.recoil;
	LZR_DrawSetColor(1, a, a, 1);
	const LZR_ImageDrawSettings stg =
		{0, 0, -1, -1, 1.0, 1.0, 0.0, true,
		 LZR_GetTick() / 8 % 2, (LZR_GetTick() + 4) / 8 % 2};
	LZR_DrawImageEx(LZR_IMAGE("res/cursor.bmp"), this->pos[0], this->pos[1],
	                stg);
}

IMPL(update) {
	LZR_MousePosition(&this->pos[0], &this->pos[1]);
	this->player.recoil *= 0.9;
	if (LZR_BUTTON(MOUSE_L) && this->player.recoil < 0.1) {
		this->player.recoil = 1.0;
		LZR_PlaySound(0);
		__auto_type e = entity_place_meeting(this, g, -1);
		if (e != NULL && e->smash != NULL)
			e->smash(e, g);
	}
}

IMPL_INIT(player) {
	this->width = this->height = 1;
}