Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.



This topic is 6625 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am making a side scrolling platform game similar to Mario. I am using a generic tile-based map system with scrolling capabilities. example for(int x, x < NUM_XTILES; x++) { for(int y, y < NUM_YTILES; y++) { tile = MAP[x,y]; draw tile } } ... something similar to that. Anyways, i was just wondering how to detect for collision with the tiles. How did they do it in the old Mario games? Like, if the character hit a wall tile and needs to stop moving, how would I detect such a thing. Please help me with anything you have. (C source code would be nice!) thanks

Share this post

Link to post
Share on other sites
I''m guessing you have your own map editor that goes along with your actual game.
You should incorporate into your map editor the feature of editing the properties of each tile on the screen.
You edit for tile #45 (for example) that there should be collision from the right.
Then in your game you game_engine->GetBlockProperties(int Block_x,int Block_y);
That''s what your supposed to do anyway

The road to success is always under construction

Share this post

Link to post
Share on other sites
Just compare your character rect with the wall, ceiling, whatevers rect. nothing spectacular, 4 ifs

if (character.right > wall.left)

but think logically, obviously you wont have to check if the character is less than the ceilings top, all you wanna check for is the ceilings bottom, etc.


A wise man once said "A person with half a clue is more dangerous than a person with or without one."

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!