Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 17 Nov 2011
Offline Last Active Jun 15 2013 10:04 AM

Posts I've Made

In Topic: Tile based game NPC's / Collision

19 November 2011 - 07:54 AM

As checking for collision in your game is slowing down things , you are probably checking your character for collision with every tile in your map per frame which are even not visible on the screen.i.e if your level has 500 tiles you are checking 500 collisions for each Npc per frame resulting in 500 n collision checks which is not acceptable.you need to consider only those tiles which are visible on the screen and check collisions with them only .

As Tiblanc mentioned implementing a scrolling camera , you can use it to filter the objects . Create a camera bounding box and use it to filter tiles first that will be visible on the screen.So , assume now you know you have 50 tiles visible on the screen out of 500 and also you know NPCs currently visible from camera . So , you will only check 50 collisions per visible NPC per frame .

To further speed up things you can use spatial partitioning techniques like grids.

In Topic: Which game engine to choose?

18 November 2011 - 01:49 AM

if you are comfortable with C# and have worked in XNA , consider looking at SunBurn Game Engine .

In Topic: 2D collision

18 November 2011 - 01:41 AM

Collision detection works in two phase - Broad phase and Narrow phase.

Since you are working on a 2D game and i assume a platformer , you should use QuadTree for BroadPhase or just store your tiles in a 2D array grid and create a mapping function that would take a coordinate as input and generate the row and column index (i and j) that contains the input coordinates. If the grid[i,j] contains a tile , you can directly check collision with that tile.

For Narrow phase , depending on the accuracy you need for your game , you can just create a rectangle(Bounding Box) surrounding your character and tiles and gems etc and check collision between Bounding box of two objects . For example - check if the rectangle enclosing your character intersects with the rectangle enclosing your gem. If they intersect , there is a collision .

If you need more accuracy you will need to create a convex hull for the character (Quick hull algorithm can be used to create Hull) and check collision between the hulls instead.

XNA also supports pixel level collision detection for Sprites . There is a sample on App hub on this . You shall consider looking at it.

However , Rectangle bounding box shall do just fine for a 2D side scroller game.

The Rectangle Structure in Microsoft.XNA.Framework contains two methods Rectangle.Contains(Rectangle) and Rectangle.Intersects(Rectangle) that can help you with checking collision between them. There are overloads for vectors,etc as well to Contains() and Intersects() methods .

This is a platformer game i had programmed : Platformer game . I had used 2D array grid to store map and Rectangle as bounding box for all entities in game . I used an offset on Rectangles while checking collision to get more accurate results .

In Topic: Binary space partitioning

17 November 2011 - 11:40 PM

kewl that answers my question . Thnx a lot .

I guess i will just do some google to find how to partition a model for rendering case :D

In Topic: Binary space partitioning

17 November 2011 - 11:21 PM

I understand that i have to store the polygons in the positive and negative halfspaces of the dividing plane and split the polygon being intersected by dividing plane . What i am failing to understand is which polygons??

Polygons that make the model or Polygons from the convex hull or Bounding Volume of the model ? What will be my input ?? Polygon soup or Model Vertices + Indices (and i will construct triangles and then split them)??

And how do i store them once i recognize the polygons in negative and positve halfspaces?? Do i create two new models and store the polygons belonging to opp halfspaces in one model each? Also if that is the case how can i partition a model in XNA ?