summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--player.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/player.c b/player.c
index 2ba3885..0110b56 100644
--- a/player.c
+++ b/player.c
@@ -12,10 +12,22 @@ void init_player(Player* p) {
void update_player(Player* p, struct Services* s) {
App* a = s->a;
-/* p->r[0] -= a->dmy;*/
+ int fb, lr;
+ int dir[4];
+ int t = (p->r[1] / 10);
+ int t2 = (t + 64) & sin_table_mask;
+ t &= sin_table_mask;
+ fb = !!(a->key_states[key_W] & key_state_pressed);
+ fb -= 2 * !!(a->key_states[key_S] & key_state_pressed);
+ lr = !!(a->key_states[key_A] & key_state_pressed);
+ lr -= 2 * !!(a->key_states[key_D] & key_state_pressed);
p->r[1] -= a->dmx;
-/* p->p[0] -= sin_table[p->r[1] & sin_table_mask] / 3;
- p->p[2] += cos_table[p->r[1] & sin_table_mask] / 3;*/
+ dir[0] = -sin_table[t];
+ dir[1] = cos_table[t];
+ dir[2] = -sin_table[t2];
+ dir[3] = cos_table[t2];
+ p->p[0] += (dir[0] * fb + dir[2] * lr) / 3;
+ p->p[2] += (dir[1] * fb + dir[3] * lr) / 3;
}
void push_player_cam(const Player* p) {