Jump to content

Snake Javascript


VictorColta

Recommended Posts

your wall is a "skeleton" in a 2d array but then as far as actually building it, you create it by filling in a rectangle based on a product (*10) of the coordinates. But then when checking the location of the fruit you are about to draw, you don't take that same *10 into account. You also do the same fill trick for your fruit but don't take into account that it's basically just a dot "skeleton" with a rectangle filled in by *10 factor. So IOW you are basically checking position based on the core "skeleton" points but not offsetting it by both the *10's you created, so you need to factor in current x/y positions *10 + *10. Incidentally, you have the same issue when checking for collision of snake vs. wall. If you look when you collide into a wall, you will see it actually stops in the center of the wall, where the "skeleton" coord is. Again, you are not factoring in the same *10 you used to make the boundaries.

Link to comment
https://forums.phpfreaks.com/topic/285209-snake-javascript/#findComment-1464504
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.