Results 1 to 1 of 1
Thread: Collision Detection (Game)
- 01-28-2008, 08:34 PM #1
Member
- Join Date
- Jan 2008
- Posts
- 1
- Rep Power
- 0
Collision Detection (Game)
I am making my first game using the J2ME platform and have a question about collision detection. The game is a "super Mario" game which uses a TiledLayer to draw the "world".
Basically I need to figure out a way of detecting when the "Mario" sprite the user plays with lands on the ground, a hill or another item (represented by the TiledLayer).
Take a look at these two images to understand better what I am trying to explain:
Image 1:
http://img2.freeimagehosting.net/uploads/c17b5e6e92.jpg
Image 2:
http://img2.freeimagehosting.net/uploads/1c6b0c514a.jpg
Currently to determine whether Mario has landed on the ground or another item I use the following code:
if(MarioCanvas.marioSprite.collidesWith(MarioCanva s.gameLevel, false)) {
// ...Note: MarioCanvas.gameLevel is the TiledLayer
}
It works to a certain degree, however as you can see from Image 1, Mario can land on the lower "hill" walk off it and float as the sprite is colliding with the taller hill behind it.
What I ideally want is a method to determine if the sprite has landed on a particular vector/line (between two points) as illustrated in Image 2 with the yellow lines. This way would work much nicer than simply detecting if Mario has collided with a tile in the TiledLayer.
Is there a way to do this?
Similar Threads
-
Implementing "Game Over" in Minesweeper game based on Gridworld framework.
By JFlash in forum New To JavaReplies: 2Last Post: 08-05-2010, 04:49 AM -
HashMap: Obtaining all values in a collision?
By markus-sukram in forum New To JavaReplies: 2Last Post: 03-29-2008, 10:25 PM -
Two Problems Rotating and collision detection help
By jaferris in forum Java AppletsReplies: 2Last Post: 01-07-2008, 11:19 PM -
Listener collision on game
By cachi in forum Java AppletsReplies: 1Last Post: 08-07-2007, 07:48 AM -
Deadlock detection tools documentation
By goldhouse in forum Threads and SynchronizationReplies: 0Last Post: 07-18-2007, 05:18 AM


LinkBack URL
About LinkBacks

Bookmarks