贪吃蛇

学编程初期我写过两个版本的贪吃蛇,他们的逻辑都一样,只是贪吃蛇2使用了canvas渲染,贪吃蛇1使用了dom元素渲染(效果差),我推荐读者优先体验贪吃蛇2

贪吃蛇2

https://www.565455.xyz/mapping.html?link=https://fancc666.gitee.io/test/snake/newsnake/

操作说明

  • 下方的上下左右可以控制蛇头运动

  • 如果用电脑访问,可以直接用上下左右键控制

  • 当蛇移动到边缘或者撞到自己的身体,游戏就结束了

贪吃蛇1

https://www.565455.xyz/mapping.html?link=https://fancc666.gitee.io/test/snake/

此处说明略。