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 / Dark GDK need help with jumping onto a sprite and jumping off the sprite. 2D side scroller.

Author
Message
CHADALAK1
13
Years of Service
User Offline
Joined: 16th Sep 2011
Location: Sioux City
Posted: 19th Sep 2011 20:33


Hello,
I need help with being able to jump on a sprite and jumping off the same sprite. I can jump on the brick sprite just fine, but when I try to jump off of the brick, my mario sprite won't jump. Can anyone help me? My code is above.

w00t! ^_^
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 19th Sep 2011 22:45

This part stops the jumping when there is a collision with the sprite.

I'm not sure what you are trying to do with this code. You have similar code above it.

Try this:


The fastest code is the code never written.
CHADALAK1
13
Years of Service
User Offline
Joined: 16th Sep 2011
Location: Sioux City
Posted: 20th Sep 2011 04:35
Thank you soo much!! just one simple code to make it work. i didnt know you had to recall the mario sprite again if it was on the brick. still yet a bit of trouble trying to make him go back to the ground if he walks off the brick, but hell yea been trying to figure out this jump problem for awhile -_-.

w00t! ^_^
CHADALAK1
13
Years of Service
User Offline
Joined: 16th Sep 2011
Location: Sioux City
Posted: 21st Sep 2011 16:49
do you know how to make mario stop air walking after he jumps on the brick??

w00t! ^_^
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 21st Sep 2011 18:52
Make a bool.
bool OnBrick;
I'm assuming you are going to have more than one brick.... When you make a loop to check the bricks for collision, use the "OnBrick" like this:
psudocode:


The fastest code is the code never written.
CHADALAK1
13
Years of Service
User Offline
Joined: 16th Sep 2011
Location: Sioux City
Posted: 22nd Sep 2011 00:38
ok i got the bool idea, but the problem is i dont know what to put in the (!OnBrick) arguement :/ here's what I put



w00t! ^_^
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 22nd Sep 2011 20:41

This should be outside your
if(Jumping){
......
}
The rest should take care of itself. The if (!OnBrick){...} will cause your Mario to fall when not on something.

The fastest code is the code never written.
CHADALAK1
13
Years of Service
User Offline
Joined: 16th Sep 2011
Location: Sioux City
Posted: 23rd Sep 2011 02:48
i tried the code you posted and it wont work. if you have

it will make mario fall throught the floor ://
i also tried this

i put the if(!OnBrick){..} outside the if(Jumping){..}. but it still doesnt work. would you want me to send my project to you to take a look for urself??

w00t! ^_^
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 23rd Sep 2011 05:56
No need to send me all of it now. The problem with falling through the floor is that you are not testing the floor for collision. I assumed STARTY was your floor value. Also, I forget that sprites are using screen coordinates (duh). That means "if(marioY > STARTY) Jumping = true;" will be true as long as Mario is "below" STARTY. In 3D the Y+ is usually up.....

If you put if(!OnBrick){..} inside your if(Jumping){..} you will only make that test if you are jumping and will result in "air walk".

The fastest code is the code never written.

Login to post a reply

Server time is: 2024-11-19 07:39:26
Your offset time is: 2024-11-19 07:39:26