Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (780)
Games in Android Showcase (233)
games submitted by our members
Games in WIP (856)
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 3793 times)
0 Members and 1 Guest are viewing this topic.
Offline cubertron

Junior Newbie

« Posted 2013-03-05 22: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: 28
Projects: 3
Exp: 5 years

« Reply #1 - Posted 2013-03-05 22: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 02: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 03: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 14:56:47 »

BUMPPP , can anyone help me out please Sad
Offline ctomni231

JGO Wizard

Medals: 99
Projects: 1
Exp: 7 years

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

« Reply #5 - Posted 2013-03-07 23:57:25 »

Offline seismic

Senior Devvie

Medals: 4
Projects: 1

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

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

Here(source in freebasic):

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  

hadezbladez (712 views)
2018-11-16 13:46:03

hadezbladez (353 views)
2018-11-16 13:41:33

hadezbladez (697 views)
2018-11-16 13:35:35

hadezbladez (175 views)
2018-11-16 13:32:03

EgonOlsen (2366 views)
2018-06-10 19:43:48

EgonOlsen (2478 views)
2018-06-10 19:43:44

EgonOlsen (1465 views)
2018-06-10 19:43:20

DesertCoockie (2131 views)
2018-05-13 18:23:11

nelsongames (1909 views)
2018-04-24 18:15:36

nelsongames (2576 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 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‑
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!