Resolving Collisions for Mario Tiles: Simple Algorithm?

  • Thread starter Thread starter Alkatran
  • Start date Start date
  • Tags Tags
    Collision
Click For Summary

Discussion Overview

The discussion revolves around developing a collision resolution algorithm for Mario tiles in a game environment. It includes considerations of how to efficiently manage and check collisions between moving characters and static tiles within a 2-dimensional array structure. The focus is on algorithmic approaches rather than memory management or tile storage specifics.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes a working algorithm for handling collisions with moving objects at arbitrary speeds, noting its effectiveness but acknowledging its lack of aesthetic appeal.
  • Another participant shares their experience with a JavaScript tile engine, mentioning the use of 2D arrays to represent tiles and suggesting that only the active area plus a buffer zone should be kept in memory for performance reasons.
  • A third participant emphasizes the focus on the collision algorithm itself rather than tile storage, posing a question about whether tiles are shifted or if a circular array is used for managing tile positions during scrolling.
  • One participant notes that performance can vary by platform and mentions using arrays for collision detection with hotspots.

Areas of Agreement / Disagreement

Participants express differing views on the specifics of tile management and collision detection, indicating that multiple approaches and considerations are present in the discussion. No consensus is reached on a singular method for collision resolution.

Contextual Notes

Participants mention performance considerations related to different platforms, but the discussion does not resolve the implications of these factors on the proposed algorithms.

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.
 

Similar threads

Replies
7
Views
4K
  • · Replies 4 ·
Replies
4
Views
6K
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 2 ·
Replies
2
Views
9K
  • · Replies 3 ·
Replies
3
Views
1K
  • · Replies 29 ·
Replies
29
Views
4K