BlueGit

blue-star speeltuin

wandering

timfa Tim · pushed by timfa

Authored 2022-10-20 · 4 years ago

Hash
656b954c2b0854c2ce9ce6a94248cd4e9948c92f
Parent
7781d255
4 files changed +130 −21
build/framework.js +27 −12
@@ -1696,6 +1696,9 @@ class ParticleEmitter
1696 1696 animationSpeed = 0;
1697 1697 startFrame = 0;
1698 1698
1699 friction = null;
1700 angularFriction = 0;
1701
1699 1702 constructor(position, sprite, emissionRate, emissionAngle,
1700 1703 startRotation, startVelocity, startAngularVelocity, acceleration,
1701 1704 angularAcceleration, startSize, endSize, lifetimeMin,
@@ -1712,10 +1715,10 @@ class ParticleEmitter
1712 1715 this.emissionAngle = emissionAngle;
1713 1716
1714 1717 this.startRotation = startRotation;
1715 this.startVelocity = startVelocity;
1716 this.startAngularVelocity = startAngularVelocity;
1717 this.acceleration = acceleration;
1718 this.angularAcceleration = angularAcceleration;
1718 this.startVelocity = startVelocity * 10;
1719 this.startAngularVelocity = startAngularVelocity * 10;
1720 this.acceleration = acceleration.stretch(10);
1721 this.angularAcceleration = angularAcceleration * 10;
1719 1722 this.startSize = startSize;
1720 1723 this.endSize = endSize;
1721 1724 this.lifetimeMin = lifetimeMin;
@@ -1724,6 +1727,8 @@ class ParticleEmitter
1724 1727 this.fadeOut = fadeOut;
1725 1728 this.startFrame = startFrame;
1726 1729 this.animationSpeed = animationSpeed;
1730
1731 this.friction = new vector(0,0);
1727 1732 }
1728 1733
1729 1734 start()
@@ -1748,7 +1753,8 @@ class ParticleEmitter
1748 1753 velocity.x, velocity.y, this.startAngularVelocity, this.acceleration.x,
1749 1754 this.acceleration.y, this.angularAcceleration, this.sprite, this.startSize.x,
1750 1755 this.startSize.y, this.endSize.x, this.endSize.y, this.lifetimeMin,
1751 this.lifetimeMax, this.fadeIn, this.fadeOut, this.startFrame, this.animationSpeed)
1756 this.lifetimeMax, this.fadeIn, this.fadeOut, this.startFrame, this.animationSpeed,
1757 this.friction, this.angularFriction)
1752 1758 }
1753 1759 }
1754 1760
@@ -1822,6 +1828,8 @@ class Particle
1822 1828 fadeOutTime = 0;
1823 1829 lifeTime = 0;
1824 1830 lifeTimeStart = 0;
1831 friction = null;
1832 angularfriction = 0;
1825 1833
1826 1834 constructor()
1827 1835 {
@@ -1832,7 +1840,7 @@ class Particle
1832 1840 this.endSize = new vector(0,0)
1833 1841 }
1834 1842
1835 emit(parent, x, y, r, vx, vy, va, ax, ay, ar, spr, ssx, ssy, esx, esy, lmin, lmax, fi = 0, fo = 0, sf = 0, as = 0)
1843 emit(parent, x, y, r, vx, vy, va, ax, ay, ar, spr, ssx, ssy, esx, esy, lmin, lmax, fi = 0, fo = 0, sf = 0, as = 0, fric, anfric)
1836 1844 {
1837 1845 this.parent = parent;
1838 1846 this.position.x = x;
@@ -1857,17 +1865,24 @@ class Particle
1857 1865 this.animationSpeed = as;
1858 1866 this.animTimer = as;
1859 1867 this.subImage = sf;
1868 this.friction = fric;
1869 this.angularFriction = anfric;
1860 1870 }
1861 1871
1862 1872 update(deltaTime)
1863 1873 {
1864 this.position.x += this.velocity.x;
1865 this.position.y += this.velocity.y;
1866 this.velocity.x += this.acceleration.x;
1867 this.velocity.y += this.acceleration.y;
1874 this.position.x += this.velocity.x * deltaTime;
1875 this.position.y += this.velocity.y * deltaTime;
1876 this.velocity.x += this.acceleration.x * deltaTime;
1877 this.velocity.y += this.acceleration.y * deltaTime;
1878
1879 this.velocity.x += this.friction.x * deltaTime * -Math.sign(this.velocity.x * 10);
1880 this.velocity.y += this.friction.y * deltaTime * -Math.sign(this.velocity.y * 10);
1868 1881
1869 this.rotation += this.angularVelocity;
1870 this.angularVelocity += this.angularAcceleration;
1882 this.rotation += this.angularVelocity * deltaTime;
1883 this.angularVelocity += this.angularAcceleration * deltaTime;
1884
1885 this.angularVelocity += this.angularFriction * deltaTime * -Math.sign(this.angularVelocity * 10);
1871 1886
1872 1887 this.lifeTime -= deltaTime;
1873 1888
@@ -1696,6 +1696,9 @@ class ParticleEmitter
1696 animationSpeed = 0;
1696 animationSpeed = 0;
1697 startFrame = 0;
1697 startFrame = 0;
1698
1698
1699 friction = null;
1700 angularFriction = 0;
1701
1699 constructor(position, sprite, emissionRate, emissionAngle,
1702 constructor(position, sprite, emissionRate, emissionAngle,
1700 startRotation, startVelocity, startAngularVelocity, acceleration,
1703 startRotation, startVelocity, startAngularVelocity, acceleration,
1701 angularAcceleration, startSize, endSize, lifetimeMin,
1704 angularAcceleration, startSize, endSize, lifetimeMin,
@@ -1712,10 +1715,10 @@ class ParticleEmitter
1712 this.emissionAngle = emissionAngle;
1715 this.emissionAngle = emissionAngle;
1713
1716
1714 this.startRotation = startRotation;
1717 this.startRotation = startRotation;
1715 this.startVelocity = startVelocity;
1718 this.startVelocity = startVelocity * 10;
1716 this.startAngularVelocity = startAngularVelocity;
1719 this.startAngularVelocity = startAngularVelocity * 10;
1717 this.acceleration = acceleration;
1720 this.acceleration = acceleration.stretch(10);
1718 this.angularAcceleration = angularAcceleration;
1721 this.angularAcceleration = angularAcceleration * 10;
1719 this.startSize = startSize;
1722 this.startSize = startSize;
1720 this.endSize = endSize;
1723 this.endSize = endSize;
1721 this.lifetimeMin = lifetimeMin;
1724 this.lifetimeMin = lifetimeMin;
@@ -1724,6 +1727,8 @@ class ParticleEmitter
1724 this.fadeOut = fadeOut;
1727 this.fadeOut = fadeOut;
1725 this.startFrame = startFrame;
1728 this.startFrame = startFrame;
1726 this.animationSpeed = animationSpeed;
1729 this.animationSpeed = animationSpeed;
1730
1731 this.friction = new vector(0,0);
1727 }
1732 }
1728
1733
1729 start()
1734 start()
@@ -1748,7 +1753,8 @@ class ParticleEmitter
1748 velocity.x, velocity.y, this.startAngularVelocity, this.acceleration.x,
1753 velocity.x, velocity.y, this.startAngularVelocity, this.acceleration.x,
1749 this.acceleration.y, this.angularAcceleration, this.sprite, this.startSize.x,
1754 this.acceleration.y, this.angularAcceleration, this.sprite, this.startSize.x,
1750 this.startSize.y, this.endSize.x, this.endSize.y, this.lifetimeMin,
1755 this.startSize.y, this.endSize.x, this.endSize.y, this.lifetimeMin,
1751 this.lifetimeMax, this.fadeIn, this.fadeOut, this.startFrame, this.animationSpeed)
1756 this.lifetimeMax, this.fadeIn, this.fadeOut, this.startFrame, this.animationSpeed,
1757 this.friction, this.angularFriction)
1752 }
1758 }
1753 }
1759 }
1754
1760
@@ -1822,6 +1828,8 @@ class Particle
1822 fadeOutTime = 0;
1828 fadeOutTime = 0;
1823 lifeTime = 0;
1829 lifeTime = 0;
1824 lifeTimeStart = 0;
1830 lifeTimeStart = 0;
1831 friction = null;
1832 angularfriction = 0;
1825
1833
1826 constructor()
1834 constructor()
1827 {
1835 {
@@ -1832,7 +1840,7 @@ class Particle
1832 this.endSize = new vector(0,0)
1840 this.endSize = new vector(0,0)
1833 }
1841 }
1834
1842
1835 emit(parent, x, y, r, vx, vy, va, ax, ay, ar, spr, ssx, ssy, esx, esy, lmin, lmax, fi = 0, fo = 0, sf = 0, as = 0)
1843 emit(parent, x, y, r, vx, vy, va, ax, ay, ar, spr, ssx, ssy, esx, esy, lmin, lmax, fi = 0, fo = 0, sf = 0, as = 0, fric, anfric)
1836 {
1844 {
1837 this.parent = parent;
1845 this.parent = parent;
1838 this.position.x = x;
1846 this.position.x = x;
@@ -1857,17 +1865,24 @@ class Particle
1857 this.animationSpeed = as;
1865 this.animationSpeed = as;
1858 this.animTimer = as;
1866 this.animTimer = as;
1859 this.subImage = sf;
1867 this.subImage = sf;
1868 this.friction = fric;
1869 this.angularFriction = anfric;
1860 }
1870 }
1861
1871
1862 update(deltaTime)
1872 update(deltaTime)
1863 {
1873 {
1864 this.position.x += this.velocity.x;
1874 this.position.x += this.velocity.x * deltaTime;
1865 this.position.y += this.velocity.y;
1875 this.position.y += this.velocity.y * deltaTime;
1866 this.velocity.x += this.acceleration.x;
1876 this.velocity.x += this.acceleration.x * deltaTime;
1867 this.velocity.y += this.acceleration.y;
1877 this.velocity.y += this.acceleration.y * deltaTime;
1878
1879 this.velocity.x += this.friction.x * deltaTime * -Math.sign(this.velocity.x * 10);
1880 this.velocity.y += this.friction.y * deltaTime * -Math.sign(this.velocity.y * 10);
1868
1881
1869 this.rotation += this.angularVelocity;
1882 this.rotation += this.angularVelocity * deltaTime;
1870 this.angularVelocity += this.angularAcceleration;
1883 this.angularVelocity += this.angularAcceleration * deltaTime;
1884
1885 this.angularVelocity += this.angularFriction * deltaTime * -Math.sign(this.angularVelocity * 10);
1871
1886
1872 this.lifeTime -= deltaTime;
1887 this.lifeTime -= deltaTime;
1873
1888
src/chaoBehaviour/wander.js added +13 −0
@@ -0,0 +1,13 @@
1 class BehaviourWander extends ChaoBehaviour
2 {
3 startBehaviour()
4 {
5 Chao.Instance.walkToPosition(new vector(Math.randomRange(0, Chao.Instance.scene.real_size.x), Math.randomRange(0, Chao.Instance.scene.real_size.y)));
6 }
7
8 update(deltaTime)
9 {
10 if(!Chao.Instance.walking)
11 this.endBehaviour();
12 }
13 }
@@ -0,0 +1,13 @@
1class BehaviourWander extends ChaoBehaviour
2{
3 startBehaviour()
4 {
5 Chao.Instance.walkToPosition(new vector(Math.randomRange(0, Chao.Instance.scene.real_size.x), Math.randomRange(0, Chao.Instance.scene.real_size.y)));
6 }
7
8 update(deltaTime)
9 {
10 if(!Chao.Instance.walking)
11 this.endBehaviour();
12 }
13}
src/objects/chao.js +85 −5
@@ -2,7 +2,9 @@ class Chao extends GameObject
2 2 {
3 3 speed = 40;
4 4 scenePadding = 50;
5 prevPosition = null;
5 6 targetDestination = null;
7 hBeforeV = false;
6 8
7 9 minTimeBetweenBehaviour = 3; //in seconds
8 10 maxTimeBetweenbehaviour = 10; // in seconds
@@ -20,12 +22,18 @@ class Chao extends GameObject
20 22 return this.currentBehaviour != null;
21 23 }
22 24
25 get walking()
26 {
27 return this.transform.position.distanceTo(this.targetDestination) > 5;
28 }
29
23 30 constructor(x, y, sprite, layer)
24 31 {
25 32 super(x, y, sprite, layer);
26 33 this.wasHeld = {}
27 34 this.collider.enabled = true;
28 35 Chao.Instance = this;
36 this.targetDestination = new vector(x, y);
29 37 }
30 38
31 39 registerBehaviour(behaviour)
@@ -35,6 +43,7 @@ class Chao extends GameObject
35 43
36 44 endBehaviour()
37 45 {
46 console.log("Ending Behaviour '" + this.currentBehaviour.constructor.name + "'")
38 47 this.currentBehaviour = null;
39 48 this.behaviourTimer = Math.randomRange(this.minTimeBetweenBehaviour, this.maxTimeBetweenbehaviour);
40 49 }
@@ -45,8 +54,10 @@ class Chao extends GameObject
45 54
46 55 this.renderer.defaultAnimationSpeed = 0.2;
47 56 this.registerBehaviour(new BehaviourSneeze());
57 this.registerBehaviour(new BehaviourWander());
48 58
49 this.particler = new ParticleEmitter(new vector(100, 100), this.scene.game.images.gem, 0.1, 45, 0, 4, 0, new vector(0, 0.1), 0, new vector(30, 30), new vector(50, 50), 2, 2.5, 0.5, 1, 0)
59 this.particler = new ParticleEmitter(new vector(100, 100), this.scene.game.images.gem, 0.1, 45, 0, 25, 0, new vector(0, 50), 0, new vector(30, 30), new vector(50, 50), 2, 2.5, 0.5, 1, 0)
60 this.particler.friction = new vector(50, 50);
50 61 this.particler.start();
51 62 }
52 63
@@ -60,24 +71,93 @@ class Chao extends GameObject
60 71 return this.wasHeld.right || this.wasHeld.left || this.wasHeld.up || this.wasHeld.down;
61 72 }
62 73
74 walkToPosition(position)
75 {
76 console.log("Walking towards", position)
77 this.targetDestination = position.getCopy();
78 this.prevPosition = this.transform.position.getCopy();
79 this.hBeforeV = Math.random() > 0.5;
80 }
81
63 82 update(deltaTime)
64 83 {
65 84 super.update(deltaTime);
66 85 this.particler.emissionAngle = Math.randomRange(10, 60)
67 86 this.particler.startFrame = Math.floor(Math.randomRange(0, this.scene.game.images.gem.subImages))
68 87 this.particler.update(deltaTime)
88
89 if(GameInput.isPressed(GameInput.keys.a))
90 {
91 this.walkToPosition(GameInput.mousePosition.getCopy());
92 }
69 93
70 94 if(this.busyWithBehaviour)
71 95 this.currentBehaviour.update(deltaTime);
72 96 else
73 97 {
74 this.behaviourTimer -= deltaTime;
98 if(!this.walking)
99 {
100 this.behaviourTimer -= deltaTime;
101
102 if(this.behaviourTimer <= 0)
103 {
104 this.currentBehaviour = this.behaviourList.random();
105 console.log("Starting Behaviour '" + this.currentBehaviour.constructor.name + "'")
106 this.currentBehaviour.startBehaviour();
107 }
108 }
109 }
110
111 if(this.walking)
112 {
113 let halfTotalDistanceH = Math.abs(this.prevPosition.x - this.targetDestination.x) / 2
114 let halfTotalDistanceV = Math.abs(this.prevPosition.y - this.targetDestination.y) / 2
115
116 let currentDistanceH = Math.abs(this.transform.position.x - this.targetDestination.x)
117 let currentDistanceV = Math.abs(this.transform.position.y - this.targetDestination.y)
118
119 let hDir = -Math.sign(this.transform.position.x - this.targetDestination.x)
120 let vDir = -Math.sign(this.transform.position.y - this.targetDestination.y)
75 121
76 if(this.behaviourTimer <= 0)
122 if(this.hBeforeV)
77 123 {
78 this.currentBehaviour = this.behaviourList.random();
79 this.currentBehaviour.startBehaviour();
124 if(currentDistanceH > halfTotalDistanceH || currentDistanceV < 1)
125 {
126 this.renderer.mirrorX = hDir > 0;
127 this.transform.velocity.x = this.speed * hDir;
128 this.transform.velocity.y = 0;
129 this.renderer.setAnimation("walkLeft")
130 }
131 else
132 {
133 this.transform.velocity.x = 0;
134 this.transform.velocity.y = this.speed * vDir;
135 this.renderer.setAnimation(vDir < 0? "walkUp" : "walkDown")
136 }
80 137 }
138 else
139 {
140 if(currentDistanceV > halfTotalDistanceV || currentDistanceH < 1)
141 {
142 this.transform.velocity.x = 0;
143 this.transform.velocity.y = this.speed * vDir;
144 this.renderer.setAnimation(vDir < 0? "walkUp" : "walkDown")
145 }
146 else
147 {
148 this.renderer.mirrorX = hDir > 0;
149 this.transform.velocity.x = this.speed * hDir;
150 this.transform.velocity.y = 0;
151 this.renderer.setAnimation("walkLeft")
152 }
153 }
154 }
155 else if(this.renderer.currentAnimationName && this.renderer.currentAnimationName.indexOf("walk") >= 0)
156 {
157 this.renderer.setAnimation(this.renderer.currentAnimationName.replace("walk", "stand"))
158
159 this.transform.velocity.x = 0
160 this.transform.velocity.y = 0;
81 161 }
82 162 }
83 163
@@ -2,7 +2,9 @@ class Chao extends GameObject
2{
2{
3 speed = 40;
3 speed = 40;
4 scenePadding = 50;
4 scenePadding = 50;
5 prevPosition = null;
5 targetDestination = null;
6 targetDestination = null;
7 hBeforeV = false;
6
8
7 minTimeBetweenBehaviour = 3; //in seconds
9 minTimeBetweenBehaviour = 3; //in seconds
8 maxTimeBetweenbehaviour = 10; // in seconds
10 maxTimeBetweenbehaviour = 10; // in seconds
@@ -20,12 +22,18 @@ class Chao extends GameObject
20 return this.currentBehaviour != null;
22 return this.currentBehaviour != null;
21 }
23 }
22
24
25 get walking()
26 {
27 return this.transform.position.distanceTo(this.targetDestination) > 5;
28 }
29
23 constructor(x, y, sprite, layer)
30 constructor(x, y, sprite, layer)
24 {
31 {
25 super(x, y, sprite, layer);
32 super(x, y, sprite, layer);
26 this.wasHeld = {}
33 this.wasHeld = {}
27 this.collider.enabled = true;
34 this.collider.enabled = true;
28 Chao.Instance = this;
35 Chao.Instance = this;
36 this.targetDestination = new vector(x, y);
29 }
37 }
30
38
31 registerBehaviour(behaviour)
39 registerBehaviour(behaviour)
@@ -35,6 +43,7 @@ class Chao extends GameObject
35
43
36 endBehaviour()
44 endBehaviour()
37 {
45 {
46 console.log("Ending Behaviour '" + this.currentBehaviour.constructor.name + "'")
38 this.currentBehaviour = null;
47 this.currentBehaviour = null;
39 this.behaviourTimer = Math.randomRange(this.minTimeBetweenBehaviour, this.maxTimeBetweenbehaviour);
48 this.behaviourTimer = Math.randomRange(this.minTimeBetweenBehaviour, this.maxTimeBetweenbehaviour);
40 }
49 }
@@ -45,8 +54,10 @@ class Chao extends GameObject
45
54
46 this.renderer.defaultAnimationSpeed = 0.2;
55 this.renderer.defaultAnimationSpeed = 0.2;
47 this.registerBehaviour(new BehaviourSneeze());
56 this.registerBehaviour(new BehaviourSneeze());
57 this.registerBehaviour(new BehaviourWander());
48
58
49 this.particler = new ParticleEmitter(new vector(100, 100), this.scene.game.images.gem, 0.1, 45, 0, 4, 0, new vector(0, 0.1), 0, new vector(30, 30), new vector(50, 50), 2, 2.5, 0.5, 1, 0)
59 this.particler = new ParticleEmitter(new vector(100, 100), this.scene.game.images.gem, 0.1, 45, 0, 25, 0, new vector(0, 50), 0, new vector(30, 30), new vector(50, 50), 2, 2.5, 0.5, 1, 0)
60 this.particler.friction = new vector(50, 50);
50 this.particler.start();
61 this.particler.start();
51 }
62 }
52
63
@@ -60,24 +71,93 @@ class Chao extends GameObject
60 return this.wasHeld.right || this.wasHeld.left || this.wasHeld.up || this.wasHeld.down;
71 return this.wasHeld.right || this.wasHeld.left || this.wasHeld.up || this.wasHeld.down;
61 }
72 }
62
73
74 walkToPosition(position)
75 {
76 console.log("Walking towards", position)
77 this.targetDestination = position.getCopy();
78 this.prevPosition = this.transform.position.getCopy();
79 this.hBeforeV = Math.random() > 0.5;
80 }
81
63 update(deltaTime)
82 update(deltaTime)
64 {
83 {
65 super.update(deltaTime);
84 super.update(deltaTime);
66 this.particler.emissionAngle = Math.randomRange(10, 60)
85 this.particler.emissionAngle = Math.randomRange(10, 60)
67 this.particler.startFrame = Math.floor(Math.randomRange(0, this.scene.game.images.gem.subImages))
86 this.particler.startFrame = Math.floor(Math.randomRange(0, this.scene.game.images.gem.subImages))
68 this.particler.update(deltaTime)
87 this.particler.update(deltaTime)
88
89 if(GameInput.isPressed(GameInput.keys.a))
90 {
91 this.walkToPosition(GameInput.mousePosition.getCopy());
92 }
69
93
70 if(this.busyWithBehaviour)
94 if(this.busyWithBehaviour)
71 this.currentBehaviour.update(deltaTime);
95 this.currentBehaviour.update(deltaTime);
72 else
96 else
73 {
97 {
74 this.behaviourTimer -= deltaTime;
98 if(!this.walking)
99 {
100 this.behaviourTimer -= deltaTime;
101
102 if(this.behaviourTimer <= 0)
103 {
104 this.currentBehaviour = this.behaviourList.random();
105 console.log("Starting Behaviour '" + this.currentBehaviour.constructor.name + "'")
106 this.currentBehaviour.startBehaviour();
107 }
108 }
109 }
110
111 if(this.walking)
112 {
113 let halfTotalDistanceH = Math.abs(this.prevPosition.x - this.targetDestination.x) / 2
114 let halfTotalDistanceV = Math.abs(this.prevPosition.y - this.targetDestination.y) / 2
115
116 let currentDistanceH = Math.abs(this.transform.position.x - this.targetDestination.x)
117 let currentDistanceV = Math.abs(this.transform.position.y - this.targetDestination.y)
118
119 let hDir = -Math.sign(this.transform.position.x - this.targetDestination.x)
120 let vDir = -Math.sign(this.transform.position.y - this.targetDestination.y)
75
121
76 if(this.behaviourTimer <= 0)
122 if(this.hBeforeV)
77 {
123 {
78 this.currentBehaviour = this.behaviourList.random();
124 if(currentDistanceH > halfTotalDistanceH || currentDistanceV < 1)
79 this.currentBehaviour.startBehaviour();
125 {
126 this.renderer.mirrorX = hDir > 0;
127 this.transform.velocity.x = this.speed * hDir;
128 this.transform.velocity.y = 0;
129 this.renderer.setAnimation("walkLeft")
130 }
131 else
132 {
133 this.transform.velocity.x = 0;
134 this.transform.velocity.y = this.speed * vDir;
135 this.renderer.setAnimation(vDir < 0? "walkUp" : "walkDown")
136 }
80 }
137 }
138 else
139 {
140 if(currentDistanceV > halfTotalDistanceV || currentDistanceH < 1)
141 {
142 this.transform.velocity.x = 0;
143 this.transform.velocity.y = this.speed * vDir;
144 this.renderer.setAnimation(vDir < 0? "walkUp" : "walkDown")
145 }
146 else
147 {
148 this.renderer.mirrorX = hDir > 0;
149 this.transform.velocity.x = this.speed * hDir;
150 this.transform.velocity.y = 0;
151 this.renderer.setAnimation("walkLeft")
152 }
153 }
154 }
155 else if(this.renderer.currentAnimationName && this.renderer.currentAnimationName.indexOf("walk") >= 0)
156 {
157 this.renderer.setAnimation(this.renderer.currentAnimationName.replace("walk", "stand"))
158
159 this.transform.velocity.x = 0
160 this.transform.velocity.y = 0;
81 }
161 }
82 }
162 }
83
163
src/objects/grasstiler.js +5 −4
@@ -13,16 +13,17 @@ class GrassTiler extends GameObject
13 13 {
14 14 let width = this.scene.real_size.x + this.ground_dark.width
15 15 let height = this.scene.real_size.y + this.ground_dark.height
16 let size = 32
16 17 let count = 0;
17 for(let x = 0; x < width; x += this.ground_dark.width)
18 for(let x = 0; x < width; x += size)
18 19 {
19 for(let y = 0; y < height; y += this.ground_light.height)
20 for(let y = 0; y < height; y += size)
20 21 {
21 22 count++;
22 ((count) %2 == 1? this.ground_dark : this.ground_light).draw(this.scene, x - 32, y, this.ground_dark.width, this.ground_light.height, 0, 0, 0, 1, 0)
23 ((count) %2 == 1? this.ground_dark : this.ground_light).draw(this.scene, x - (size/2), y, size, size, 0, 0, 0, 1, 0)
23 24 }
24 25
25 count = x/64 % 2;
26 count = x/size % 2;
26 27 }
27 28 }
28 29 }
@@ -13,16 +13,17 @@ class GrassTiler extends GameObject
13 {
13 {
14 let width = this.scene.real_size.x + this.ground_dark.width
14 let width = this.scene.real_size.x + this.ground_dark.width
15 let height = this.scene.real_size.y + this.ground_dark.height
15 let height = this.scene.real_size.y + this.ground_dark.height
16 let size = 32
16 let count = 0;
17 let count = 0;
17 for(let x = 0; x < width; x += this.ground_dark.width)
18 for(let x = 0; x < width; x += size)
18 {
19 {
19 for(let y = 0; y < height; y += this.ground_light.height)
20 for(let y = 0; y < height; y += size)
20 {
21 {
21 count++;
22 count++;
22 ((count) %2 == 1? this.ground_dark : this.ground_light).draw(this.scene, x - 32, y, this.ground_dark.width, this.ground_light.height, 0, 0, 0, 1, 0)
23 ((count) %2 == 1? this.ground_dark : this.ground_light).draw(this.scene, x - (size/2), y, size, size, 0, 0, 0, 1, 0)
23 }
24 }
24
25
25 count = x/64 % 2;
26 count = x/size % 2;
26 }
27 }
27 }
28 }
28}
29}