Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Ayumi), 1,170 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 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 | chip programmers | 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