Jump to content

  • Log In with Google      Sign In   
  • Create Account


Grid, Pathfinding and collision?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Schoening   Members   -  Reputation: 141

Like
1Likes
Like

Posted 18 December 2012 - 12:37 PM

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.

Like:

Grid = [

[0,0],[0,1],
[etc..],

]

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.

Sponsor:

#2 radioteeth   Prime Members   -  Reputation: 918

Like
0Likes
Like

Posted 18 December 2012 - 04:28 PM

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..

http://www.flipcode.com/archives/Basic_Collision_Detection.shtml

#3 Solid_Spy   Members   -  Reputation: 392

Like
0Likes
Like

Posted 19 December 2012 - 12:54 AM

first, I would learn about collision, then learn ai programming. for Ai, you would use the A* algroithm, google it it's awesome XD.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS