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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.