summaryrefslogtreecommitdiff
path: root/kon
diff options
context:
space:
mode:
Diffstat (limited to 'kon')
-rw-r--r--kon/konworld.c8
-rw-r--r--kon/konworld.h4
2 files changed, 8 insertions, 4 deletions
diff --git a/kon/konworld.c b/kon/konworld.c
index 1806099..be9d2c2 100644
--- a/kon/konworld.c
+++ b/kon/konworld.c
@@ -423,13 +423,15 @@ void kon_bodyInit(kon_body_t *body, float x, float y, float z, float radius, flo
body->height = height;
body->sector = -1;
body->touching = -1;
+ body->jumpSpeed = 6.0f;
}
-void kon_bodyJump(kon_body_t *body, float speed)
+int kon_bodyJump(kon_body_t *body)
{
- if (!body->onGround) return;
- body->vy = speed;
+ if (!body->onGround || body->jumpSpeed <= 0.0f) return 0;
+ body->vy = body->jumpSpeed;
body->onGround = 0;
+ return 1;
}
void kon_worldPlace(const kon_world_t *world, kon_body_t *body)
diff --git a/kon/konworld.h b/kon/konworld.h
index 4be1d1c..bce5187 100644
--- a/kon/konworld.h
+++ b/kon/konworld.h
@@ -85,6 +85,7 @@ typedef struct kon_body {
kon_vec3_t position;
float radius, height; /* 0.2 and 1.0 are fine for a person in this scale */
float vy; /* up speed, only jumps and falls change it */
+ float jumpSpeed; /* how fast a jump starts, 6 is about a metre. 0 turns jumping off for this body, like in a doom-style game */
int onGround;
int sector; /* the room it is in, -1 if none, kept up to date by kon_worldMove */
int touching; /* the collider it was pushed by in the last move, -1 if none. a monster hitting a door, say */
@@ -109,7 +110,8 @@ float kon_worldGround(const kon_world_t *world, float x, float z, float feet, in
/*** bodies ***/
void kon_bodyInit(kon_body_t *body, float x, float y, float z, float radius, float height);
-void kon_bodyJump(kon_body_t *body, float speed);
+/* does nothing in the air or when jumpSpeed is 0. returns 1 if it jumped */
+int kon_bodyJump(kon_body_t *body);
/* puts the feet on the ground under them right away */
void kon_worldPlace(const kon_world_t *world, kon_body_t *body);