Gamestudio Links
Zorro Links
Newest Posts
ZorroGPT
by TipmyPip. 02/27/26 16:40
WFO Training with parallel cores Zorro64
by Martin_HH. 02/26/26 16:03
Zorro version 3.0 prerelease!
by TipmyPip. 02/25/26 16:38
Camera always moves upwards?
by clonman. 02/21/26 09:29
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
2 registered members (Grant, TipmyPip), 4,899 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
the1, alx, ApprenticeInMuc, PatrickH90, USER0328
19200 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Jumping in an FPS.. grrr.. nearly there.. #186770
03/03/08 07:00
03/03/08 07:00
Joined: Jan 2008
Posts: 10
Brisbane, Australia
J
JJJohan Offline OP
Newbie
JJJohan  Offline OP
Newbie
J

Joined: Jan 2008
Posts: 10
Brisbane, Australia
So I came along another problem. After implementing my crouch function and my footsteps (thanks to badapple for his code contribution), I came up to my final basic movement system thingo. Jumping.

I've searched around but surprisingly I haven't found any code. I'm trying not to use any templates for my game, as I'm trying to learn as I go.

Anyway, I'm using the movement code from one of the workshops right now, so it'll probably help if I list the code here along with what I've tried to do:

Movement Code
Code:

vec_set (temp.x, my.x); // trace 10,000 quants below the player
temp.z -= 10000;
temp.z = -c_trace (my.x, temp.x, ignore_me | ignore_passable | use_box);
temp.x = movement_speed * (key_w - key_s) * time;
temp.y = movement_speed * (key_a - key_d) * 0.6 * time;
c_move (my, temp.x, nullvector, ignore_passable | glide);



Jump Code
Code:

function jump()
{
var playerisjumping;
var jumpgravity = 5;
while (playerisjumping == 0)
{
c_move (player,nullvector,vector(0,0,jumpgravity*time),IGNORE_YOU|GLIDE);
jumpgravity -= 0.01;
if (jumpgravity == 0)
{
playerisjumping = 1;
}
sleep(0.01);
}
playerisjumping = 0;
jumpgravity = 5;
}



Simple second attempt at jump code
Code:

function jump()
{
c_move (player,nullvector,vector(0,0,jumpgravity*time),IGNORE_YOU|GLIDE);
}



The only thing I can notice is that the player is put down on the ground after each sleep command since the movement code isn't cancelled out, but I haven't really been able to fix that.

Re: Jumping in an FPS.. grrr.. nearly there.. [Re: JJJohan] #186771
03/03/08 13:55
03/03/08 13:55
Joined: Dec 2006
Posts: 1,086
Queensland - Australia
Nidhogg Offline
Serious User
Nidhogg  Offline
Serious User

Joined: Dec 2006
Posts: 1,086
Queensland - Australia
How about trying wait(1) instead of sleep.

NOTE: Sleep is a pre GS v6.3 function that will be soon discontinued altogether.

The new sleep is wait(-1) for seconds where as wait(1) is for frame.

You need to use the wait in a while loop otherwise wierd things do happen
and can even crash your game.

Please read your manual about wait().


Windows XP SP3
Intel Dual Core CPU: E5200 @ 2.5GHz
4.00GB DDR3 Ram
ASUS P5G41T-M LX
PCIE x16 GeForce GTS 450 1Gb
SB Audigy 4
Spyware Doctor with AntiVirus

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1