Sign in to follow this  
Oliver Sch

Grid, Pathfinding and collision?

Recommended Posts

Hi :)
I have a JavaScript server for my Game.

Right now Players simply move around with X,Y coordinates and Velocity.

Collision is detected if a players X,Y is = to an objects X,Y.

I would rather work with a grid.


Grid = [



But right now I have no real Idea how to work on grids :-/ In my head I am only able to run Left and Right on an Array...

Any good tutorials?

I need to learn how to use a grid, and collision detection. Path-finding I understand mostly.

Share this post

Link to post
Share on other sites
Use a 2D array, or, an array of arrays.. Or use a 1D array, and create an indexing function that indexes it using:

index = x + (y * MAP_WIDTH)
where your array is (MAP_WIDTH * MAP_WIDTH)..

basically, this puts each 'row' of map-grid points together so that where the first row ends, the second one starts, and where that one ends, the next one starts, etc..

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this