Resolving Collisions for Mario Tiles: Simple Algorithm?

  • Thread starter Thread starter Alkatran
  • Start date Start date
  • Tags Tags
    Collision
AI Thread Summary
The discussion centers on developing a Mario game, specifically focusing on how Mario and enemies interact with bricks and blocks in a level. The blocks are organized in a 2D array, allowing for efficient collision detection by only checking blocks that Mario interacts with during a time step. The participant has created an algorithm capable of handling moving objects at various speeds, though it lacks aesthetic appeal. They are building a JavaScript tile engine where occupiable tiles are represented by integers in the array. The conversation touches on memory management, suggesting that only the active area and a buffer zone of the array should be kept in memory to optimize performance. When scrolling, the method of managing tiles—whether to shift all tiles or use a circular array—depends on the platform, with performance being a key concern in tile scrolling for engines developed in Flash and JavaScript. Collision detection is also discussed, with the use of arrays for defining hotspots.
Alkatran
Science Advisor
Homework Helper
Messages
959
Reaction score
0
I found an old Mario game I was writing a long time ago the other day, and I've been working on how Mario and enemies interact with the various bricks and blocks in the level. The blocks are stored in a 2-dimensional array, which gives the obvious advantage of only having to check the blocks Mario passes through during one time step instead of all blocks.

My question is: is there a simple, well-known way to do this? I've banged out an algorithm today which handles arbitrary sized moving objects at arbitrary speeds. The thing works FANTASTIC (I tested it a bit excessively) but isn't very pretty.
 
Technology news on Phys.org
I've done some engines in the past and I'm actually working on a javascript tile engine. I use 2D arrays of ints, each int representing a tile. Occupiable tiles are < X and the rest > X, where X is 2000 for instance.
For moving characters you do a transformation of the 2D array on some time interval.

Only the active area of the array plus a buffer zone should be in memory. When scrolling left, for example i add a column of tiles to the left, remove the right most column and move the screen by the tile width.
 
I'm talking more about the algorithm to do the collision, not how the tiles are actually stored or used. Obviously mario maps are so small worrying about the memory size is a bit overdoing it :smile: .

But, interesting question: when you read your tiles in, do you shift all the other tiles over to make room or do you just use a circular array to write over a single column/row?
 
Depends on the platform. I've had to do engines in Flash and JS and getting good performance in tile scrolling can be an issue.

The collisions would also be done with arrays, for hotspots for example.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Thread 'Project Documentation'
Trying to package up a small bank account manager project that I have been tempering on for a while. One that is certainly worth something to me. Although I have created methods to whip up quick documents with all fields and properties. I would like something better to reference in order to express the mechanical functions. It is unclear to me about any standardized format for code documentation that exists. I have tried object orientated diagrams with shapes to try and express the...
Back
Top