BlueGit

blue-star speeltuin

Files

speeltuin / src / objects / grasstiler.js

grasstiler.js

workaround
timfa Tim · pushed by timfa · 4 years ago
5ed72b3c History
grasstiler.js 979 B Download Raw
1class GrassTiler extends GameObject
2{
3 ground_light = null;
4 ground_dark = null;
5
6 addedToScene()
7 {
8 this.ground_dark = this.scene.game.images.grass_dark;
9 this.ground_light = this.scene.game.images.grass_light;
10 }
11
12 draw(context)
13 {
14 if(this.ground_dark.width == 0 || this.ground_light.width == 0)
15 return;
16
17 let width = this.scene.real_size.x + this.ground_dark.width
18 let height = this.scene.real_size.y + this.ground_dark.height
19 let count = 0;
20 for(let x = 0; x < width; x += this.ground_dark.width)
21 {
22 for(let y = 0; y < height; y += this.ground_light.height)
23 {
24 count++;
25 ((count) %2 == 1? this.ground_dark : this.ground_light).draw(this.scene, 0, 0, this.ground_dark.width, this.ground_dark.height, x - 32, y, this.ground_dark.width, this.ground_light.height, 0, 1)
26 }
27
28 count = x/64 % 2;
29 }
30 }
31}