Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / frame by frame jumping

Author
Message
Wikaman1
16
Years of Service
User Offline
Joined: 17th Aug 2008
Location: Scotland
Posted: 21st Sep 2008 23:34
I heard that a good way to do jumping was to increase the height of an object slightly every frame until they reach a certain height then do the same in reverse. How would you do this? a loop? How would you get it change each frame? Thanks
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 22nd Sep 2008 05:25
one way to do it would be to assign a height variable to your object that is jumping, and use that to assign its heights from the ground..
ie. instead of having constant values for the ObjectPosition commands, use a variable... that way you can change the value of the variable in loops depening on input or triggers or something...

the logic in the main game loop might go something like :


detecting player input here.....
if player input says to jump...
make sure that once it starts jumping, no further jumping can take place until the current jump has finished by setting appropriate flags.
increment the object height variable by the amount of movement each loop...(ie, it might take 30 loops to get the object from the ground to the top of the jump, then another 30 loops to come back down to the ground, so if you wanted the jump to be 15 units high, each loop would be incrementing/decrementing the height value by 0.5 units...)
while checking to make sure that the object height variable is not larger than the maximum height value of the jump...
if the object height var is equal to or higher than the maximum height value of the jump, start decrementing the value of the object height variable until its back on the ground...
then reset all flag/vars so the next jump can begin...

That would be the basic logic of one way of making an object jump(no code, just the logic behind it)... although its very very basic logic, there is no "gravity" or fall of or anything accounted for, as thats something that would need to be done in the actual loops themselves.. perhaps using dbCurveValue() or loops to make the value increment faster and faster or slower and slower to simulate a fall off type effect for gravity...something like that might work....

If you are having trouble working out the actual code to do something like the above logic says, just reply and say so, i know that sometimes it can seem kinda difficult to get your head around the ways it all works, but there is plenty of help to be had in these forums, and plenty of people to help (you could use bool types to track if your object has reached the max height of the jump or is on the ground, and to stop it being able to jump a second time, until the first "jump cycle" has finished... could use for/while-do loops to assign and increment/decrement values, breaking out of them if certain flags arent/are set, or alternatively if loops.. that there are a number of valid yet different approaches to developing code to achieve the above logic is what im getting at...)

If it ain't broke.... DONT FIX IT !!!
Gasilli
16
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Having a party in your garage
Posted: 22nd Sep 2008 05:42
For gravity you could do a check inside the loop to see if Z equals what it should, like in matrixes there is the dbGetGroundHeight(), so you could do that. Here is an example of what I mean:



Now, I have no idea if that would actually work, but then for the jump code all you would need to do is add a && playerjump != 1 or something.
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 22nd Sep 2008 20:05
There is a much more realistic method than the one you suggested, that I have posted several other times on this forums, and cant be bothered to explain. Bascially the effect is not up then down but up, then slowing down, then fallinf and speeding up. search forums for it.

Login to post a reply

Server time is: 2024-09-30 07:30:33
Your offset time is: 2024-09-30 07:30:33