Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (579)
games submitted by our members
Games in WIP (500)
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 vs Polygon Collisions  (Read 854 times)
0 Members and 1 Guest are viewing this topic.
Offline Oskuro

JGO Coder


Medals: 32
Exp: 6 years


Coding in Style


« Posted 2013-04-11 14:13:15 »

 Howdy!

Right now I'm knee-deep into the underlying data structures for my project, namely the map/collision system. Originally I expected to make the game run on a tile-based map, so I could rip off be inspired by Notch's Minicraft (Ludum Dare entry).

But as I've got to implementing the system, and seeing how I intend to have a line-of-sight lighting system, I've been thinking it might be more optimal to have an underlying polygonal collision structure to handle both collisions and lighting, which, funny enough, would be very similar to how the original DooM games did it (For those who don't know, my project is a top-down version of DooM).

So my question would be, what is the better approach? These are some of the requirements.

  • Visual representation is still a tilemap, so polygons must adhere to "manhattan" geometry, that is, 90º or 45º angles between lines, and all line lengths are integers (multiples of the predefined cell size).
  • Must run smoothly with a large number of entities.
  • Different areas (sectors) can have a different ambient light levels.
  • Small network footprint as cooperative LAN gameplay is a major objective.
  • Maps need be procedurally generated.

I'm leaning towards polygons for several reasons. Chief among them is that it's easier to represent a polygon mathematically. Additionally, by dividing the game area in "sectors", I can sort different areas into drawing/collision lists (something like BSP or portals) for more efficiency. I even might have the fringe benefit of allowing sectors to exist over one another, or even non-euclidean map structures, simply by joining "sector" edges independently of their map coordinates.


But, as is to be expected, I'm mister noobness here, so would like the board's opinion.

Oh, few caveats:

  • Java2d Rendering: yes, I know, not optimal, etc. As I've said before, I want to implement it all by hand before I rely on pre-packaged solutions.
  • I want to implement it all: I'm already looking at Straightedge for inspiration / ideas, but I really want to manually implement everything myself to better learn the nuts and bolts of the system, so I'm not interested in API recommendations, but rather on a discussion about the theoretical advantages / disadvantages of each system. Smiley

So, discuss! (And thanks in advance)

Offline Oskuro

JGO Coder


Medals: 32
Exp: 6 years


Coding in Style


« Reply #1 - Posted 2013-05-15 17:54:26 »

Thought I'd add some more info on what I'm planning and doing. Here's a quote from my devlog:



The animation shows, in no particular order:

  • Sector Lines: Inspired by how the original DooM handled it's map system, the sector edges handle collisions, area transitions, and a few other things.

    Up in the animation you can see the following:
    • Yellow: Solid edges.
    • Green: Non-Solid edges.
    • Cyan: Edge normals, that is, where the "wall" is facing.
    • Blue: Edge's starting point, as they are actually vectors, with the normal pointing to the right.

    No, I didn't forget about the red lines...

  • Collision Groups: One of the reasons why I chose this arrangement is to simplify collision calculations. The idea is that sector edges are organized in groups based on their normals (in other words, based on where the "walls" are facing). When an object moves, it only checks if collisions happen with edges in a group that would collide with it's movement vector. In other words, if an object moves to the left, collision will only be checked with edges facing to the right.

    In the animation this is represented by the Red edges. When the Doomie moves into a given direction, the edges being checked for collision (that is, those part of the appropriate collision group) are being painted red.

    Note that the diagonal edges light up more often, as they are part of two collision groups at once.

Next steps are as follows:

  • Merge the Sector and Tilemap code, so tilemaps are generated based on the sector's collision layout (Right now I have manually made them match, but they are unrelated pieces).

  • Improve the collision group sorting. The idea is to have the collision groups sorted front to back, or, in other words, organized based on position to avoid detecting a collision with an edge that is behind another edge.

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 (36 views)
2014-04-15 18:08:23

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

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

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

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

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

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

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

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

CJLetsGame (200 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!