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 28 Oct 2012
Offline Last Active Mar 06 2013 03:32 PM

#5012129 Grid, Pathfinding and collision?

Posted by Schoening on 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.


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.

#4994868 Just starting out...python a good choice?

Posted by Schoening on 28 October 2012 - 05:28 PM

I suggest JavaScript too!

It's very easy to learn. Event Based. And fits perfectly into your workflow of HTML and CSS!

Check out the Three.JS libary (If you like 3D)

All JavaScript ^^

Oh yeah, and JavaScript runs on EVERYTHING :D Browsers, Smartphones, Linux, Mac and PC. (It runs on OS if you export in into a Wrapper)

#4994682 JavaScript Pathfinding - Split into several "Ticks"

Posted by Schoening on 28 October 2012 - 06:41 AM

(Sorry, First Post, Please move to Game Programming if needed)

I want to run Astar for my Pathfinding on every Unit.

I would like to reduce possible lag by only using it for X amount of units per game tick.

So that the "For each Unit" loop does not run pathfinder for every unit before it goes on to the next function.

Instead it should only find the Path of a few Units each time the Game Loop is at the Pathfinding Function again.

I am pretty sure I gotta run this with a Start-Stop Variables. But I don't know how that should look.

Here is a Quick Doodle how it might look:

[source lang="jscript"]var Unit = new Array(500);var arrayStart=0;var arrayStop=0;"GameLoop"{// Checks If at start of Arrayif (arrayStart = 0){arrayStop = 50;}// Not the first unit. Set starting point to last Pathfindelse{arrayStart = arrayStop;arrayStop = arrayStop + 50;}for (var count = arrayStart; count < arrayStop; count++){"Pathfinder Function" Unit[count];}arrayStart = count;};[/source]

Unless JavaScript if functions are executed in a different manner, I would like to know if this is a viable solution, or if you got better ones.