701 reputation
624
bio website
location
age
visits member for 2 years, 6 months
seen Aug 8 at 18:53

Aug
1
revised 2D collisions between 2 arrays
edited body
Aug
1
comment 2D collisions between 2 arrays
Nevermind I solved it, the problem was I was checking bullets.length in both for loops. Consequences of being lazy and copy/paste'ing code. Noticed it crashed once the bullets became more than the ships and figured it out.
Aug
1
revised 2D collisions between 2 arrays
edited body
Jul
31
awarded  Popular Question
Jul
31
comment How to use setInterval and clearInterval
You should look into requestAnimationFrame() instead, same basics but optimized for animation loops. Here's a good explanation: paulirish.com/2011/requestanimationframe-for-smart-animating
Jul
31
comment 2D collisions between 2 arrays
I've updated my hitboxes like in this video: youtube.com/watch?v=8b_reDI7iPM but I still get the same results of the bullet just going straight through the enemy (not always). Even when slowing down the speed to 2px per frame (width is 36 and 56, it should detect a collision between all those frames). Any clue what I could be doing wrong?
Jul
31
accepted 2D collisions between 2 arrays
Jul
31
comment 2D collisions between 2 arrays
Nevermind, judging by AlphaSpirits answer it seems it's 2 problems causing this. And the bullet not hitting has nothing to do with the loop.
Jul
31
comment 2D collisions between 2 arrays
Seems logical now that you say it.
Jul
31
comment 2D collisions between 2 arrays
Yeah I was thinking that too, but one of the enemies can't be killed first even though nothing has been spliced. If the other 2 enemies are dead though then I can kill it. It's really confusing me.
Jul
31
comment 2D collisions between 2 arrays
Oh, well if there's any other way to handle an array that can be anything between 0 and 100 let me know. :)
Jul
31
comment 2D collisions between 2 arrays
@wondra Could you elaborate? The "long life" sounds logical without even knowing what it is. What causes it and what's the solution?
Jul
31
asked 2D collisions between 2 arrays
Jul
19
awarded  Popular Question
Jul
3
awarded  Popular Question
Jul
2
awarded  Curious
May
7
awarded  Notable Question
May
7
awarded  Popular Question
Apr
26
awarded  Notable Question
Apr
2
awarded  Popular Question