diff options
-rw-r--r-- | player.c | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -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) { |