I am new to the forum and to games development in general.
I've been programming for about 2 years (web applications - js/php..mainly) have some experience with c# and c back from high school.
Recently i've decided to test and see if i could create a game with js and HTML elements(not canvas - for now) with no previous expereince so i basically made things up as i go.
so i have a main loop that refreshes as fast as it could. this loop controls everything. its checks for keyclicks, set objects position, set object graphics and test for colission and this is where i have issues with.
To handle colission i have a big 2d matrix array with the same size of the game area in pixes so if i have 500 width, 500 height, the array is 500x500.. the content of the cells are true/false.
To check for collision i take my current x/y add the radius add my walking distance and together with the angel i calculate my future x/y. i then check the array if there's anything there for every step between me to the future position. this seems to work fine for about 300-500 elementss. then things get slow and everything get bugy (things get out of the screen border etc.)
is my approuch completely wrong ? do i need to try and use quadtree ? or another method ?
You can see an example of what i already have at: http://myfirstgame.e-ddl.com/ - you can go up/down.... and by clicking on the NPC and clicking number 1 you fire at him
Edited by netameta, 24 January 2014 - 09:15 PM.