Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 18,767 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 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