canvas 绘制一条属于自己的贪吃蛇
效果如下 --_063 代码 < ! DOCTYPE html > < html lang = "zh_CN" > < head > < meta charset = "UTF-8" > < title > 贪吃蛇 < / title > < script src = "https://code.jquery.com/jquery-3.3.1.js" > < / script > < / head > < body > < canvas id = "canvas" width = "400" height = "400" > < / canvas > < script src = "./js/main.js" > < / script > < / body > < / html > let canvas = document . getElementById ( "canvas" ) ; let context = canvas . getContext ( "2d" ) ; // 分数记录 let fraction = 0 ; // 定义贪吃蛇的组成,方块对象 class Block { // 按照size的大小划分行列 // 列 col ; // 行 row ; // 大小 size ; constructor ( col , row , size ) { this . col