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
|
#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) {
static int prev_mouse_l;
LZR_MousePosition(&this->pos[0], &this->pos[1]);
this->player.recoil *= 0.9;
if (LZR_BUTTON(MOUSE_L) && !prev_mouse_l) {
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);
}
prev_mouse_l = LZR_BUTTON(MOUSE_L);
}
IMPL_INIT(player) {
this->width = this->height = 1;
}
|