1 Star 0 Fork 0

余赟昊 / Flappy-polimin

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Background.js 683 Bytes
一键复制 编辑 原始数据 按行查看 历史
余赟昊 提交于 2020-11-16 20:57 . 我修复了不能连点的bug
class Background{
constructor(params){
this.image = params.image;
this.width = params.width;
this.height = params.height;
this.speed = params.speed;
this.y = params.y;
this.x = 0
this.amount = Math.ceil(game.canvas.width / this.width);
}
update(){
this.x -= this.speed;
if(this.x <= -this.amount * this.width){
this.x = 0
}
}
render(){
for(let i = 0; i < this.amount*2; ++i){
game.pen.drawImage(this.image,0,0,this.width,this.height, this.width*i + this.x, this.y, this.width,this.height);
}
}
pause(){
this.speed = 0;
}
}
1
https://gitee.com/yu_yunhao/flappy-polimin.git
git@gitee.com:yu_yunhao/flappy-polimin.git
yu_yunhao
flappy-polimin
Flappy-polimin
master

搜索帮助