diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2007-10-28 11:30:25 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2007-10-28 11:30:25 +0000 |
| commit | a3ce2eb90cd26fe87042344175e5c9669adb7dcd (patch) | |
| tree | d936a8ffafe366caea08c5bb384794034c590322 /src/game/game.cpp | |
| parent | eba83b7e194cc6b4ba76fd5e048d81279becfc35 (diff) | |
| download | zcatch-a3ce2eb90cd26fe87042344175e5c9669adb7dcd.tar.gz zcatch-a3ce2eb90cd26fe87042344175e5c9669adb7dcd.zip | |
major update. splitted the player information into two diffrent network items
Diffstat (limited to 'src/game/game.cpp')
| -rw-r--r-- | src/game/game.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/game/game.cpp b/src/game/game.cpp index c8c6acb3..136137e8 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -101,6 +101,10 @@ void player_core::tick() { float phys_size = 28.0f; + #define MACRO_CHECK_VELOCITY { dbg_assert(length(vel) < 1000.0f, "velocity error"); } + + MACRO_CHECK_VELOCITY + bool grounded = false; if(col_check_point((int)(pos.x+phys_size/2), (int)(pos.y+phys_size/2+5))) grounded = true; @@ -111,6 +115,8 @@ void player_core::tick() vel.y += gravity; + MACRO_CHECK_VELOCITY + float max_speed = grounded ? ground_control_speed : air_control_speed; float accel = grounded ? ground_control_accel : air_control_accel; float friction = grounded ? ground_friction : air_friction; @@ -121,9 +127,13 @@ void player_core::tick() if(input.right) vel.x = saturated_add(-max_speed, max_speed, vel.x, accel); + MACRO_CHECK_VELOCITY + if(!input.left && !input.right) vel.x *= friction; + MACRO_CHECK_VELOCITY + // handle jumping if(input.jump) { @@ -136,7 +146,9 @@ void player_core::tick() } else jumped = 0; - + + MACRO_CHECK_VELOCITY + // do hook if(input.hook) { @@ -247,9 +259,12 @@ void player_core::tick() // check if we are under the legal limit for the hook if(length(new_vel) < hook_drag_speed || length(new_vel) < length(vel)) vel = new_vel; // no problem. apply + } } + MACRO_CHECK_VELOCITY + if(true) { for(int i = 0; i < MAX_CLIENTS; i++) @@ -265,12 +280,14 @@ void player_core::tick() // handle player <-> player collision float d = distance(pos, p->pos); vec2 dir = normalize(pos - p->pos); - if(d < phys_size*1.25f) + if(d < phys_size*1.25f && d > 1.0f) { float a = phys_size*1.25f - d; vel = vel + dir*a; } + MACRO_CHECK_VELOCITY + // handle hook influence if(hooked_player == i) { @@ -279,6 +296,8 @@ void player_core::tick() float accel = hook_drag_accel * (d/hook_length); vel.x = saturated_add(-hook_drag_speed, hook_drag_speed, vel.x, -accel*dir.x); vel.y = saturated_add(-hook_drag_speed, hook_drag_speed, vel.y, -accel*dir.y); + + MACRO_CHECK_VELOCITY } } } |