BlueGit

blue-star speeltuin

Files

speeltuin / src / objects / grasstiler.js

grasstiler.js

grasse
timfa Tim · pushed by timfa · 4 years ago
45deaf4b History
grasstiler.js 881 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 let width = this.scene.real_size.x + this.ground_dark.width
15 let height = this.scene.real_size.y + this.ground_dark.height
16 let count = 0;
17 for(let x = 0; x < width; x += this.ground_dark.width)
18 {
19 for(let y = 0; y < height; y += this.ground_light.height)
20 {
21 count++;
22 ((count) %2 == 1? this.ground_dark : this.ground_light).draw(this.scene, 0, 0, this.ground_dark.width, this.ground_dark.height, x, y, this.ground_dark.width, this.ground_light.height, 0, 1)
23 }
24
25 count = x/64 % 2;
26 }
27 }
28}