summaryrefslogtreecommitdiff
path: root/src/player.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/player.c')
-rw-r--r--src/player.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/player.c b/src/player.c
index b51572b..de51b1c 100644
--- a/src/player.c
+++ b/src/player.c
@@ -1,17 +1,29 @@
+#include "entity.h"
#include "entityimpl.h"
+#include "lzr.h"
IMPL(draw) {
- LZR_DrawSetColor(1, 1, 1, 1);
- LZR_DrawRectangle(true, this->pos[0] - this->width / 2,
- this->pos[1] - this->height / 2,
- this->width, this->height);
+ 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) {
- this->vel[0] = LZR_BUTTON(RIGHT) - LZR_BUTTON(LEFT);
- entity_move(this, g);
+ 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->height = this->width = 12;
+ this->width = this->height = 1;
}