fun: optional growAt, fast tomatoes

This commit is contained in:
cha0s 2019-05-31 15:59:29 -05:00
parent 09511e8ed5
commit f0db5fe3d0
6 changed files with 15 additions and 11 deletions

View File

@ -68,6 +68,9 @@ export class Plant extends decorate(Trait) {
growToNextStage: () => {
const growthStage = this.entity.growthStage;
const stageSpec = this.params.stageSpecs[growthStage];
if (!('growAt' in stageSpec)) {
return;
}
this.growthElapsed = stageSpec.growAt;
this.entity.growthStage = growthStage + 1;
},
@ -81,8 +84,10 @@ export class Plant extends decorate(Trait) {
const stageSpec = this.params.stageSpecs[growthStage];
// TODO variance
this.growthElapsed += elapsed;
if (this.growthElapsed >= stageSpec.growAt) {
this.entity.growthStage = growthStage + 1;
if ('growAt' in stageSpec) {
if (this.growthElapsed >= stageSpec.growAt) {
this.entity.growthStage = growthStage + 1;
}
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 B

After

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 241 B

After

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 313 B

After

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 296 B

After

Width:  |  Height:  |  Size: 384 B

View File

@ -20,22 +20,22 @@ export function tomatoPlantJSON() {
uri: '/tomato-stage-0.png',
},
'stage-1': {
offset: [0, 0],
offset: [0, 3],
size: [16, 16],
uri: '/tomato-stage-1.png',
},
'stage-2': {
offset: [0, 0],
offset: [0, 3],
size: [16, 16],
uri: '/tomato-stage-2.png',
},
'stage-3': {
offset: [0, 0],
offset: [0, 3],
size: [16, 16],
uri: '/tomato-stage-3.png',
},
'stage-4': {
offset: [0, 0],
offset: [0, 3],
size: [16, 16],
uri: '/tomato-stage-4.png',
},
@ -46,23 +46,22 @@ export function tomatoPlantJSON() {
params: {
stageSpecs: {
0: {
growAt: 20,
growAt: 2,
image: 'initial',
},
1: {
growAt: 40,
growAt: 4,
image: 'stage-1',
},
2: {
growAt: 60,
growAt: 6,
image: 'stage-2',
},
3: {
growAt: 80,
growAt: 8,
image: 'stage-3',
},
4: {
growAt: 99999999,
image: 'stage-4',
},
}