aking

Members
  • Content Count

    2
  • Joined

  • Last visited

  1. Thanks for taking the time to debug the code I posted and for sharing your findings. Thanks for pointing out the issue; I was under the impress canvas values (i.e. size) could be set via CSS. I certainly plan on using frameworks (like pixi, easel, quintus, etc) but thought it best to first become familiar with the underlying toolset. Of these frameworks do you have any recommendations? FYI: The posted code has other "bugs" and/or warts, for example, I originally wrote the code in object literal syntax but later switched. I can post an acceptable (read more complete), revised version later if anyone would be interested.
  2. Hi, I'm using HTML5 (canvas) and javascript to implement the well-known snake game. I opted to encapsulate the game within the 3 following classes: "renderer", "snake", and "game". I use a "Uint8Array" to store the location (x,y) of each section of the snake, therefore the maximum distance the snake can travel is 255x255. Here lies the issue I'm facing. While the border of the game is set at 255, the snake "visually" seems to meet this border before that value. However, the x coordinate upon debugging does equal 255. I'd appreciate help in understanding why the visual does not match the underlying setup. To experience this "bug", just open the html file in a browser and when the green square displays on the canvas, hit the right arrow -- the snake piece will continue in that direction until it "dies," .i.e. meets the border. I'd appreciate any other suggestions and/or insights on improving the game both from design and code perspectives. Thanks. snake.zip