简体   繁体   中英

HTML5 game freezes in browser

I'm trying to develop a game (Spaceship and Rocks) using only HTML5 and pure JavaScript. But the game is freezing unexpectedly. Everything works fine before Spawning the rocks in CANVAS. I'm not able to rectify the problem.
here's my game in codepen:
http://cdpn.io/vJaoi

update:

I've updated the code for the previous question

But the missile sprites when collide with the rocks, the rocks are popping out unevenly.

Any suggestions on colliding the roks and missiles. Or better algorithms for collision detection in groups of sprites.

This loop never ends :)

    while (distance < 100){
        rock_pos = [random(0, WIDTH), random(0, HEIGHT)];
    }

distance is never incremented

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM