Skip to content
Advertisement

Snake Game with Mobile Button Controls

In this Snake game, I need the buttons to control the snake just like the arrow keys do. This will allow the game to be played on a mobile device. You can see i have code in there for the buttons, but they are not working properly and not controlling the movement of the snake.

Any advice to make the buttons work would be greatly appreciated! thanks!

HTML

JavaScript

JAVASCRIPT

JavaScript

FIDDLE

Advertisement

Answer

AND TIME

So basically you have some errors going on. Your first one is your styling. You really need to make your styles more flexible, but this will solve the right button problem I was having.

JavaScript

http://jsfiddle.net/34oeacnm/8/

JavaScript

You had some of your selectors off. And I stole some information on how to trigger from Definitive way to trigger keypress events with jQuery.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement