Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (580)
games submitted by our members
Games in WIP (499)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Tile map collision  (Read 1006 times)
0 Members and 1 Guest are viewing this topic.
Offline cubertron

Junior Newbie





« Posted 2013-03-05 23:38:50 »

Hello everyone! I am making a tile based platformer game. The problem that I am running in is the collision detection of the player with the walls(unwalkable tiles) . Is there a better way of checking the collision without using the four corner points of the player? and as my game will have large levels so I will be needing an efficient algorithm for that, and sorry for my english  Roll Eyes
Offline wreed12345

JGO Knight


Medals: 22
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #1 - Posted 2013-03-05 23:49:14 »

Normally the "four corner points" is the most efficient way to do this, is there any reason why this is not adequate for you?

Offline MindOfCorruption97

Senior Newbie





« Reply #2 - Posted 2013-03-06 03:23:36 »

What kind of movement system are you using? Are you using "Rogue-Like Movement" AKA you move Tile to Tile or are you using smooth normal movement?

If you are using Tile based movement then simply make it so that the application checks whether the tile next to it is a wall or not and if there isn't a wall next to it then make it so the player can move there...

If you are using smooth normal movement then using the four corner points is more efficient if you are using rectangles that follow the player. Just place a rectangle on the four corners of the player object and if the rectangles are about to intersect another rectangle(let's say the tile's rectangle), then it cannot move that direction.

Chaos is Beatiful...
For without Chaos the world will never spin...
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline cubertron

Junior Newbie





« Reply #3 - Posted 2013-03-06 04:35:16 »

Well i don't know but my four corner algorithm not working properly ( must be some problem at my end )
I actually followed actionscript 3 tutorials for file map collision and the major difference between it and java is that origin point in as3 is the center of sprite, whereas java engine i am using uses the left top corner as origin.

Is there any java based article or tutorial on it?
Oh and I am using it for smooth movement
Offline cubertron

Junior Newbie





« Reply #4 - Posted 2013-03-07 15:56:47 »

BUMPPP , can anyone help me out please Sad
Offline ctomni231

JGO Ninja


Medals: 71
Projects: 1
Exp: 7 years


Not a glitch. Just have a lil' pixelexia...


« Reply #5 - Posted 2013-03-08 00:57:25 »

http://stackoverflow.com/questions/10289407/collision-detection-using-bounded-boxes

Offline seismic

Senior Member


Medals: 3
Projects: 1



« Reply #6 - Posted 2013-03-08 08:04:35 »

Some code to look at would certainly help this Thread Smiley
Offline relminator
« Reply #7 - Posted 2013-03-08 15:02:53 »

Here(source in freebasic):

http://rel.phatcode.net/index.php?action=contents&item=Pyromax-Dax

Note that I don't use a 4-cornered approach to collision.  I use an axis-to-tile collision.  The 4-cornered approach fails when your player dimension is bigger than the tile dimension.  The approach I used will work on any sized sprite (be it larger or smaller the tilesize) an is quite fast.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (44 views)
2014-04-15 18:08:23

BurntPizza (40 views)
2014-04-15 03:46:01

UprightPath (56 views)
2014-04-14 17:39:50

UprightPath (38 views)
2014-04-14 17:35:47

Porlus (54 views)
2014-04-14 15:48:38

tom_mai78101 (77 views)
2014-04-10 04:04:31

BurntPizza (136 views)
2014-04-08 23:06:04

tom_mai78101 (236 views)
2014-04-05 13:34:39

trollwarrior1 (197 views)
2014-04-04 12:06:45

CJLetsGame (205 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!