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.

Newcomers DBPro Corner / Make object jump??

Author
Message
grimx
19
Years of Service
User Offline
Joined: 13th Jul 2005
Location:
Posted: 13th Jul 2005 18:18
I'm using DarkBasic Pro.
Need to know how to make a primitive object jump??
I'm making a sidescroller and need the object to
jump over obstcales.
Plz Help!
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 13th Jul 2005 20:29
What in gods name happened here???

Immunity and Annihalation makes Immunihalation...
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 15th Jul 2005 14:13
what do you have so far? if you can show us some code, we could help a little more. if you don't know where to begin here is basically what you would do (this is a form of gravity and then how to implement jumping based on that).

1.create an array that has enough slots for every object that will be moving. this is your verticle speed variable.
2.in your main loop, put a for next loop for 1 to 65535(the max number of objects you can have)
3. inside the for next loop, have it check if the object(that is equal to the variable used in the for next loop(example below)) exists and then go to a subroutine to handle gravity if it does.
NOTE: everything in the subroutine that has to do with certain objects must be done using the variable in your for next loop. ex

obviously, this isn't what you want code wise but is gives you an idea of what the structure should look like.
4.check for collision with the object and your landscape.
5.if it isn't, decrease that objects spot in the array you created earlier by whatever number you are using.(ex if the object is #5 then use the array slot 5 and decrease it by 1 if that is your gravity value)this can be done using the variable from your for next loop.
6.now, the actual JUMPING part. in your main loop, check to see if the player pressed the jump button then(if they did) go to a jump subroutine.
7.this subroutine should be fairly small. it checks for collision between the player and the terrain, and if they are colliding, set the array slot for the player(you should use the same slot# as the object's#) to a high number, say 20(experiment and see what works)

these steps make it seem more complicated than it really is but try it. i didn't give you the code because it helps if you figure out how to do most of it on your own.

Login to post a reply

Server time is: 2024-11-27 22:32:07
Your offset time is: 2024-11-27 22:32:07