Day13 - 明天复习贪食蛇,今天先铺舞台

class Game {
    constructor(){
        // 每格宽为 26px
        this.blockWidth = 26;
        // 格与格之间间距 2px
        this.blockSpace = 2;
        // 总共铺设 20 格
        this.blocks = 20;
        
        // init
        this.init();
    }
    init(){
        // set canvas
        this.canvas = document.getElementById('canvasSnake');
        this.canvas.width = this.blockWidth * this.blocks + this.blockSpace * (this.blocks - 1);
        this.canvas.height = this.canvas.width;
        this.ctx = this.canvas.getContext('2d');

        // render canvas view
        this.render();

    };

    render(){
        // bg
        this.ctx.fillStyle = '#dbe3c5';
        this.ctx.fillRect(0, 0, this.canvas.width, this.canvas.width);
        // 铺设 blocks
        for (var bX = 0; bX < this.blocks; bX++) {
            for (var bY = 0; bY < this.blocks; bY++) {
                this.drawBlock(new Vector(bX, bY), '#ced6b8')
            };
        };
    }
};


今天笔记到这,如果内容有出入,都在麻烦纠正了,谢谢您 ε= ᕕ( ᐛ )ᕗ


<<:  【领域展开 13 式】 有了骨头与皮肤,再搞清楚主要肌群 Menu 层级与操作

>>:  Day14 - 做一半的产品编辑 modal

Day 25:动态规划(dynamic programming)

动态规划也是一种演算法设计模式,常用来解决最佳化问题。它的方法是将问题(通常是递回地)分解成子问题,...

DAY6 MongoDB 资料新增(Insert) 与删除(Delete)

DAY6 MongoDB 资料新增(Insert) 与删除(Delete) 连线 连线方法如同前面文...

Day28 我还是视觉动物

Integration with pivot table and chart 承续昨天所列的第一点...

[影片]第26天:物件导向程序设计-运算子(实例100~104)

GitHub:https://github.com/dannypc1628/NetCore380 ...