Sarge
Register | User Profile | Member List | F.A.Q | Privacy Policy | New Blog | Search Forums | Forums Home
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Classic Doom > Source Ports > Question about coding
 
Author
All times are GMT. The time now is 05:41. Post New Thread    Post A Reply
Sodaholic
I feel justified yet disgusted with myself at the same time


Posts: 2993
Registered: 04-07


So, I'm trying to edit Hexen's jumping code to cut the player's jump off if they're not holding the button. Unfortunately, it seems to ignore that I tell it to reduce the z velocity to 2.83 if it's greater than that, when the player is in midair but is NOT holding the jump button. How would I go about fixing this?

code:
if ((cmd->arti & AFLAG_JUMP) && onground) { player->mo->momz = 6.33 * FRACUNIT; player->mo->flags2 &= ~MF2_ONMOBJ; } if (!(cmd->arti & AFLAG_JUMP) && !onground && player->mo->momz > 2.83) { player->mo->momz = 2.83 * FRACUNIT; }

Old Post 09-06-12 21:25 #
Sodaholic is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit || Quote
boris
meow


Posts: 3634
Registered: 05-00


I don't know anything about the Doom source, but don't you have to multiply by FRACUNIT in the if statement? I.e.
code:
if (!(cmd->arti & AFLAG_JUMP) && !onground && player->mo->momz > 2.83 * FRACUNIT)

Old Post 09-06-12 21:56 #
boris is offline Profile || Blog || PM || Search || Add Buddy IP || Edit || Quote
Sodaholic
I feel justified yet disgusted with myself at the same time


Posts: 2993
Registered: 04-07



boris said:
I don't know anything about the Doom source, but don't you have to multiply by FRACUNIT in the if statement? I.e.
code:
if (!(cmd->arti & AFLAG_JUMP) && !onground && player->mo->momz > 2.83 * FRACUNIT)


Oh, shit, you're right. Either way, in that case, it should still be cutting off the jump, assuming that fracunit is over, and not under 1.

Old Post 09-06-12 22:27 #
Sodaholic is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit || Quote
Ladna
Member


Posts: 317
Registered: 04-10


You're gonna have to get a little more serious if you want this behavior. This is a 1-time check for the jump button, and it propels you 6.33 whatevers that 1 time.

My approach would be to figure how that works out over TICs. Say for example the top height (assuming normal gravity) is reached after 10 TICs. You can check every TIC to see if the jump button is held and add another 6.33/10 momz thrust. You would also have to see how many thrusts you'd already applied so you don't jump infinitely.

Old Post 09-07-12 07:43 #
Ladna is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit || Quote
wesleyjohnson
Senior Member


Posts: 1067
Registered: 04-09


Unless this player character has wings or a jet pack, Why are they able to modify their path after leaving the ground ??

Old Post 09-09-12 00:36 #
wesleyjohnson is offline Profile || Blog || PM || Search || Add Buddy IP || Edit || Quote
chungy
Senior Member


Posts: 1916
Registered: 06-05


Fairly standard feature in video game jumps (though I find it interesting that Pitfall on the Atari 2600 deliberately avoided that); no matter how non-sensical it is in real-world terms it's basically standard.

Hell as far as real world terms go, jumping barely gets you any height and it certainly doesn't speed you up ;)

Old Post 09-09-12 05:16 #
chungy is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit || Quote
Sodaholic
I feel justified yet disgusted with myself at the same time


Posts: 2993
Registered: 04-07


Well, I got this working as intended. Maes suggested to me that I use an "unjump" flag, so that it would be 1 if the jump button is NOT being pressed. After implementing this, the jumping feels very Mario-like now. If you're wondering about the rather low values of vertical momentum, note that the gravity is lower.


Ladna said:
You're gonna have to get a little more serious if you want this behavior. This is a 1-time check for the jump button, and it propels you 6.33 whatevers that 1 time.

My approach would be to figure how that works out over TICs. Say for example the top height (assuming normal gravity) is reached after 10 TICs. You can check every TIC to see if the jump button is held and add another 6.33/10 momz thrust. You would also have to see how many thrusts you'd already applied so you don't jump infinitely.


Surprisingly, many games from the era that did this with jumping didn't handle it the way you describe. It literally only did just one push that was your maximum jump height, and it would go uninterrupted only as long as you still held the jump button down, otherwise it would cap off your vertical momentum if it was already above the cap's value. Mario and Sonic did it this way, at least.


wesleyjohnson said:
Unless this player character has wings or a jet pack, Why are they able to modify their path after leaving the ground ??

because vidya gaim logic

Chungy pretty much explained it better than I could.

Old Post 09-10-12 09:02 #
Sodaholic is offline Profile || Blog || PM || Email || Search || Add Buddy IP || Edit || Quote
All times are GMT. The time now is 05:41. Post New Thread    Post A Reply
 
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Classic Doom > Source Ports > Question about coding

Show Printable Version | Email this Page | Subscribe to this Thread

 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are OFF
[IMG] code is ON
 

< Contact Us - Doomworld >

Powered by: vBulletin Version 2.2.5
Copyright ©2000, 2001, Jelsoft Enterprises Limited.