Landing after jumping

BlitzMax Forums/BlitzMax Beginners Area/Landing after jumping

Jebbs(Posted 2008) [#1]
I want to make my game maneuverable enough so that I do not have to write an "imagescollide" code for every image that comes in contact with my main character. But I just can't figure out how to do this without my character going through the other objects. My main goal is to make a side scrolling game similar to mario and donkey kong country.

If anyone could tell me a simple way of either setting an image so that I could make multiples of it where ever I please and be able to land on it after jumping or falling onto it successfully, I would be very happy. Thanks!


Jebbs(Posted 2008) [#2]
Also, I've been having trouble with my character floating in mid-air until I jump. After I have him jump, he will fall through. Is there any way of making my guy fall once he has barely walked off a ledge?
I think it might be because I set it so that after landing on an image, the character's y-coordinate inherited the image's y-coordinate (minus 75 pixels so that the character is standing ontop of the ground and not level with it).
Thanks to anyone that helps me with my questions.


computercoder(Posted 2008) [#3]
As for the collision detection algorithm issue, I'd make a class for each of the various types of things in your game. Have a collision routine that returns a boolean if it happened. You'll need to make a matrix (or some way) to track all the objects to determine where the avatar is then check collsion in the matrix coords of where its at.

Just iterate through the objects until a collision (or multiple collisions) is found. You can then apply what code you need to then for the reaction to the collision.

Your movement should use a gravity algorithm with speed. This will keep your avatar from floating, as it constantly applies gravity. You can search on the web for gravity and speed algorithms. If you get stuck, I'll see what I have to give you help there. I'm at work atm, so I don't have it handy with me.

I'll see what I can find for you later tonight.


computercoder(Posted 2008) [#4]
Ok, I did some searching around for you on this as I promised. I didn't find the exact example I was originally looking for, BUT this one definitely does what I was looking for!



The original thread is here as posted by altitudems. I updated it a bit (removed the FlushMem command, as its been since deprecated)

You can also read up on this tutorial

I hope this helps, and good luck with your game!