Monday, July 2, 2012

Subversion Time

Let me rephrase my original statement about this blog. I will update every day except weekends. This is because I spend most of my weekends away from technology and my PC. For instance, yesterday you could find me sleeping in a small cabin on top of a mountain 200 miles away from here.

Today I played around with collision detection between Mario and the tiles that make up the level. First I needed an indicator to show whether each tile was solid. Next I implemented an algorithm to return the tile from any point on screen. Finally, I looked at where Mario was located and if he was colliding with a tile or not.

This took a lot of experimenting to get it right but I think I implemented a good solution. In previous games I would take every object on screen and compare it to every other object on screen to find collisions. This algorithm becomes very slow as the number of objects increases so I decided to find a better solution. I check each corner of Mario and if that point happens to fall on a solid tile then figure out what to do with Mario. This gives me a constant speed of 4 instead of n^2.

I'm still having a few issues with Mario's movement, but progress is coming along nicely.

If you want to view my source code, check it out on GitHub at https://github.com/Exor/SuperMarimoBros


No comments:

Post a Comment