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.

DarkBASIC Discussion / A jumping predicament

Author
Message
Yodaman Jer
User Banned
Posted: 20th May 2009 20:31
I of course know how to make an object 'jump' in DBC. It's just that I'm having a few issues with preventing the ever-annoying side jumping problem.

I asked about it in another thread a few months ago and got a great solution: create invisible plains on top of the platforms the player is to jump on, then check to see if the player is touching that object and if the jump key is being pressed. If both conditions are met, jump! If one condition isn't met (the collision with the plain), then the player doesn't jump, thus preventing side jumping. There's just one eency-weency problem, and that is that eventually, the jumping code looks something like this:



Obviously, the more platforms you have, the more plains you have to have and the more if...endifs you have to have!

So, I thought about trying to reduce it all to one condition and also remove all of those extra plains (they're a HUGE hassle to delete!), like so:




The problem I'm having with this is that I can't figure out how to make it check for the yposition of every platform. I thought by putting '0' as the object number it would check for every object. If this technique worked, it would eliminate side jumping by only jumping if the player was at the yposition (+.1 to make sure it's on top of the platform) of whatever platform.

I'm asking if anybody has used a technique similar to this. I'd really like to see if this will work, and I'm sorry if I'm missing something obvious...I really can't think of anything though. Any advice is appreciated!

"If you want lots of people to play your game make it simple; lots of people are simple." -Obese87
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 20th May 2009 20:37 Edited at: 20th May 2009 20:37
Try this:



and for deleting:



TheComet

Peachy, and the Chaos of the Gems

Yodaman Jer
User Banned
Posted: 20th May 2009 21:22


A for...next loop. Dang, I can't believe I didn't think of that!! One of the most basic things and I completely didn't think about it. Heh, oh well. Thanks Comet!

I guess to keep things easier, I'll do everything in sequential order. The player will be object 1, the shadow will be object 2, then all of the platforms will be objects 3 to 27...you get the idea. That ought to keep everything more manageable!

I found that something else that's keeping my project more manageable is keeping all of my functions (every single one) in a separate library. It took me a year and a half to finally do that.

"If you want lots of people to play your game make it simple; lots of people are simple." -Obese87
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 20th May 2009 21:37
actually what might work betr is to have ur platforms be 101-...

that way if you need to add more later or add other things it wont become a jumbled mess of:

player-1
shadow-2
platforms-3-27
enemy-28
platforms-29-40
ally-41
...

There are only 10 kinds of people in the world, those who understand binary and those who dont
Yodaman Jer
User Banned
Posted: 20th May 2009 21:58 Edited at: 20th May 2009 21:58
Yeah, that's true.

For some reason I'm encountering a strange bug by trying to use functions in a separate file. I had to take the jumping routine out of the input function and place it in the do...loop. Then I tried Comet's technique, which wasn't working for some reason. So I went back to the original technique that requires so much coding and is rather annoying. At least it gets the job done! I'm trying to see if I can figure out why it's only working 10% of the time though...

"If you want lots of people to play your game make it simple; lots of people are simple." -Obese87
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 20th May 2009 22:05
What is the problem? If DBC can't find the functions in it (always saying it doesn't exist or something), it could be because there are spaces in the file's name, something DBC doesn't like in included files.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
Yodaman Jer
User Banned
Posted: 20th May 2009 22:17
It's not a bug really, it's just that I was trying to put the jumping routine into the function CheckInput() in the include file. It just wouldn't jump, but when I put the jumping routine in the main do...loop it then works.

@Comet:

Got your technique to work! I just forgot to change one 't' to 'plat', as that's easier to identify than 't' when I'm skimming through the code.

So far, with using a separate functions file my main source code isn't even 100 lines! And with using for..next loops it really cuts down on a ton of repetitive coding.

"If you want lots of people to play your game make it simple; lots of people are simple." -Obese87
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 20th May 2009 22:19
What is side jumping?

Enjoy your day.
Yodaman Jer
User Banned
Posted: 20th May 2009 22:23
Side jumping is the ability (or in my case, annoyance) to jump off of the side of an object. Say you're on one platform and there's another just ahead of you. If you jump but almost don't make it and you hit the side of the other platform, you could 'jump' off of it. It's a huge pain when it's not supposed to happen.

Also, think of a side jump as Mario's wall-kick in Mario 64, Sunshine and Galaxy. Only it's supposed to happen then.

"If you want lots of people to play your game make it simple; lots of people are simple." -Obese87
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 20th May 2009 23:08
So you mean like you hit the side face of an object instead of the top and as a result, if you are holding the jump button/key the character will jump again - usually completely off to it's doom! Is that correct?

Enjoy your day.
Yodaman Jer
User Banned
Posted: 20th May 2009 23:15 Edited at: 20th May 2009 23:16
@Latch:

I'm having difficulty implementing a shadow. It will draw the shadow, but instead of placing the plain under the player it places it about 3 units ABOVE the player.

There's an EXE attached to this post to show you what I mean. Here's the code I'm using too, it's coped from your technique in that thread from whenever ago:



Any ideas as to why this isn't positioning the shadow properly? I have tried everything I can think of.

[EDIT]
Yeah, that's basically what the side jumping was doing.

"If you want lots of people to play your game make it simple; lots of people are simple." -Obese87

Attachments

Login to view attachments
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 20th May 2009 23:57
Is object 2 the shadow and object 600 the feeler?

For some weird reason this code doesn't seem to do it's job:
position object 2,posx#,get object collision y(),posz#

Get rid of that line or comment it out and just use the line that follows it:
position object 2,posx#,y#,posz#

Otherwise, it should work like the example from the post back when.

And as far as side jumping, if you know the height and the position of your platforms, you can test for height against the feet of your character. Let's say a platform has a y size of 10 and it's located at position 100,30,50. The top of the platform would be at 100,35,50 . If your character's y size is 5, then it's feet are at object position y(character)-2.5 . So if there is collision, and the feet are greater than or equal to the top of the platform that the character is colliding with, then you can jump again, otherwise, you can't - in which case maybe you have a grapple or climb routine if the character is close enough to the top. No need for addition planes.

Or, you could calculate tilt. If there is collision and the tilt angle isn't greater than say 30 degrees, you can jump again. Otherwize you can't.

Enjoy your day.
Yodaman Jer
User Banned
Posted: 21st May 2009 00:25
I commented the line out and it still didn't work. Object 2 is the shadow and object 600 is the feeler, that's correct.

I guess I'll just forget the shadow for now and implement other things that need to be done. I need to build the basic levels and still optimize some code, especially in the functions library. I just learned how to uncap the 60fps lock, so that's going to prove very useful.

"If you want lots of people to play your game make it simple; lots of people are simple." -Obese87
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 21st May 2009 06:38
Quote: "Obviously, the more platforms you have, the more plains you have to have and the more if...endifs you have to have!"

That's why the programming gods gave us for loops.

There is an eight letter word. You can insert a letter into it or remove a letter from it without changing its meaning. Answer
Caleb1994
16
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 21st May 2009 06:53
Quote: "That's why the programming gods gave us for loops.
"


Ummmm Lee? hahaha and the other guys named "Something" i can't remember lol

New Site! Check it out \/
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 21st May 2009 06:55
right, I cant remember who but some guy on here one day came in here askin about a problem, I cant remember what, but there were sections of code that went something like this:

color object 1,color
color object 2,color
color object 3,color
...
color object 200,color

AND THATS THE SAME COLOR EVERY TIME, 200 TIMES!!!!!

AND HE HAD SEVERAL SECTIONS LIKE THAT!!!!!

after I showed him the for-next loop, we reduced over a 1000 lines of code to like 60

There are only 10 kinds of people in the world, those who understand binary and those who dont
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 21st May 2009 18:12
@smartguy
Yodaman knows about for loops.
Forgets his training he does

There is an eight letter word. You can insert a letter into it or remove a letter from it without changing its meaning. Answer
Yodaman Jer
User Banned
Posted: 21st May 2009 19:34
I do tend to forget a lot of basic programming concepts, but I'm getting better about it. Practice makes perfect! And caffeine helps as well.

"If you want lots of people to play your game make it simple; lots of people are simple." -Obese87

Login to post a reply

Server time is: 2025-05-14 16:45:21
Your offset time is: 2025-05-14 16:45:21