add animations to keys 1-0 and q-[
@@ -218,9 +218,16 @@ class image{
218
218
}
219
219
}
220
220
221
addAnimationCycle(label, cycle)
221
addAnimationCycle(label, cycle, loops, chain, chainDefaultIndex, chainSpeed)
222
222
{
223
this.animationCycles[label] = cycle;
223
this.animationCycles[label] =
224
{
225
frames: cycle,
226
loop: loops,
227
chain: chain,
228
chainDefaultIndex: chainDefaultIndex,
229
chainSpeed: chainSpeed
230
}
224
231
}
225
232
226
233
get width()
@@ -406,10 +413,11 @@ class Renderer
406
413
if(this.cycle.timer > this.cycle.cycleSpeed)
407
414
{
408
415
this.cycle.timer -= this.cycle.cycleSpeed;
416
let next;
409
417
410
418
if(this.cycle.loop)
411
419
{
412
let next = (this.cycle.current + 1) % this.cycle.cycleArray.length;
420
next = (this.cycle.current + 1) % this.cycle.cycleArray.length;
413
421
}
414
422
else
415
423
{
@@ -417,15 +425,19 @@ class Renderer
417
425
{
418
426
if(this.cycle.chain)
419
427
{
428
this.cycle.chainDefaultIndex = this.cycle.chainDefaultIndex || this.cycle.default;
429
this.cycle.chainSpeed = this.cycle.chainSpeed || this.cycle.cycleSpeed;
420
430
this.setAnimation(this.cycle.chain, this.cycle.chainDefaultIndex, this.cycle.chainSpeed);
421
return;
422
431
}
432
433
return;
423
434
}
424
435
else
425
436
{
426
this.cycle.current ++;
437
next = this.cycle.current + 1;
427
438
}
428
439
}
440
429
441
this.updateCycleSprite(next)
430
442
}
431
443
}
@@ -497,14 +509,21 @@ class Renderer
497
509
return;
498
510
}
499
511
}
500
512
513
let cycleData = this.sprite.animationCycles[label];
514
501
515
this.cycle = {
502
516
label: label,
503
cycleArray: this.sprite.animationCycles[label],
517
cycleArray: cycleData.frames,
504
518
default: defaultIndex,
505
519
current: defaultIndex,
506
520
cycleSpeed: cycleSpeed,
507
timer: 0};
521
loop: cycleData.loop,
522
chain: cycleData.chain,
523
chainDefaultIndex: cycleData.chainDefaultIndex,
524
chainSpeed: cycleData.chainSpeed,
525
timer: 0
526
};
508
527
509
528
this.subImage = this.cycle.cycleArray[this.cycle.current];
510
529
}
@@ -218,9 +218,16 @@ class image{218
}218
}219
}219
}220
220
221
addAnimationCycle(label, cycle) 221
addAnimationCycle(label, cycle, loops, chain, chainDefaultIndex, chainSpeed) 222
{222
{223
this.animationCycles[label] = cycle;223
this.animationCycles[label] = 224
{225
frames: cycle,226
loop: loops,227
chain: chain,228
chainDefaultIndex: chainDefaultIndex,229
chainSpeed: chainSpeed230
}224
}231
}225
232
226
get width() 233
get width() @@ -406,10 +413,11 @@ class Renderer406
if(this.cycle.timer > this.cycle.cycleSpeed) 413
if(this.cycle.timer > this.cycle.cycleSpeed) 407
{414
{408
this.cycle.timer -= this.cycle.cycleSpeed;415
this.cycle.timer -= this.cycle.cycleSpeed;416
let next;409
417
410
if(this.cycle.loop)418
if(this.cycle.loop)411
{419
{412
let next = (this.cycle.current + 1) % this.cycle.cycleArray.length;420
next = (this.cycle.current + 1) % this.cycle.cycleArray.length;413
}421
}414
else422
else415
{423
{@@ -417,15 +425,19 @@ class Renderer417
{425
{418
if(this.cycle.chain)426
if(this.cycle.chain)419
{427
{428
this.cycle.chainDefaultIndex = this.cycle.chainDefaultIndex || this.cycle.default;429
this.cycle.chainSpeed = this.cycle.chainSpeed || this.cycle.cycleSpeed;420
this.setAnimation(this.cycle.chain, this.cycle.chainDefaultIndex, this.cycle.chainSpeed);430
this.setAnimation(this.cycle.chain, this.cycle.chainDefaultIndex, this.cycle.chainSpeed);421
return;422
}431
}432
433
return;423
}434
}424
else435
else425
{436
{426
this.cycle.current ++;437
next = this.cycle.current + 1;427
}438
}428
}439
}440
429
this.updateCycleSprite(next)441
this.updateCycleSprite(next)430
}442
}431
}443
}@@ -497,14 +509,21 @@ class Renderer497
return;509
return;498
}510
}499
}511
}500
512
513
let cycleData = this.sprite.animationCycles[label];514
501
this.cycle = {515
this.cycle = {502
label: label,516
label: label,503
cycleArray: this.sprite.animationCycles[label], 517
cycleArray: cycleData.frames, 504
default: defaultIndex,518
default: defaultIndex,505
current: defaultIndex, 519
current: defaultIndex, 506
cycleSpeed: cycleSpeed,520
cycleSpeed: cycleSpeed,507
timer: 0};521
loop: cycleData.loop,522
chain: cycleData.chain,523
chainDefaultIndex: cycleData.chainDefaultIndex,524
chainSpeed: cycleData.chainSpeed,525
timer: 0526
};508
527
509
this.subImage = this.cycle.cycleArray[this.cycle.current];528
this.subImage = this.cycle.cycleArray[this.cycle.current];510
}529
}@@ -69,11 +69,11 @@ function setupChaoAnimations(image)
69
69
image.addAnimationCycle("sitDown", [27])
70
70
image.addAnimationCycle("sitLeft", [28])
71
71
72
image.addAnimationCycle("tantrum", [29, 30, 29, 31, 32, 33], true)
72
image.addAnimationCycle("tantrum", [29, 30, 29, 31, 32, 33])
73
73
74
74
image.addAnimationCycle("swimStruggle", [34, 35], true)
75
75
image.addAnimationCycle("eatStart", [36, 37, 38], false, "eat")
76
image.addAnimationCycle("eat", [37, 38], false, "eat")
76
image.addAnimationCycle("eat", [37, 38], true)
77
77
78
78
image.addAnimationCycle("cheer", [39, 40], true)
79
79
image.addAnimationCycle("wave", [41, 42])
@@ -87,7 +87,7 @@ function setupChaoAnimations(image)
87
87
image.addAnimationCycle("sleep", [53, 54], true)
88
88
89
89
image.addAnimationCycle("swim", [55, 56, 57], true)
90
image.addAnimationCycle("eatBig", [58, 59])
90
image.addAnimationCycle("eatBig", [58, 59], true)
91
91
image.addAnimationCycle("sneeze", [60, 61, 62, 63], false, "standDown")
92
92
image.addAnimationCycle("cry", [64, 65], true)
93
93
image.addAnimationCycle("think2", [66])
@@ -69,11 +69,11 @@ function setupChaoAnimations(image)69
image.addAnimationCycle("sitDown", [27])69
image.addAnimationCycle("sitDown", [27])70
image.addAnimationCycle("sitLeft", [28])70
image.addAnimationCycle("sitLeft", [28])71
71
72
image.addAnimationCycle("tantrum", [29, 30, 29, 31, 32, 33], true)72
image.addAnimationCycle("tantrum", [29, 30, 29, 31, 32, 33])73
73
74
image.addAnimationCycle("swimStruggle", [34, 35], true)74
image.addAnimationCycle("swimStruggle", [34, 35], true)75
image.addAnimationCycle("eatStart", [36, 37, 38], false, "eat")75
image.addAnimationCycle("eatStart", [36, 37, 38], false, "eat")76
image.addAnimationCycle("eat", [37, 38], false, "eat")76
image.addAnimationCycle("eat", [37, 38], true)77
77
78
image.addAnimationCycle("cheer", [39, 40], true)78
image.addAnimationCycle("cheer", [39, 40], true)79
image.addAnimationCycle("wave", [41, 42])79
image.addAnimationCycle("wave", [41, 42])@@ -87,7 +87,7 @@ function setupChaoAnimations(image)87
image.addAnimationCycle("sleep", [53, 54], true)87
image.addAnimationCycle("sleep", [53, 54], true)88
88
89
image.addAnimationCycle("swim", [55, 56, 57], true)89
image.addAnimationCycle("swim", [55, 56, 57], true)90
image.addAnimationCycle("eatBig", [58, 59])90
image.addAnimationCycle("eatBig", [58, 59], true)91
image.addAnimationCycle("sneeze", [60, 61, 62, 63], false, "standDown")91
image.addAnimationCycle("sneeze", [60, 61, 62, 63], false, "standDown")92
image.addAnimationCycle("cry", [64, 65], true)92
image.addAnimationCycle("cry", [64, 65], true)93
image.addAnimationCycle("think2", [66])93
image.addAnimationCycle("think2", [66])@@ -91,5 +91,112 @@ class Chao extends GameObject
91
91
this.renderer.mirrorX = false;
92
92
this.wasHeld.down = true;
93
93
}
94
else
95
{
96
if(GameInput.isPressed(GameInput.keys["1"]))
97
{
98
this.renderer.setAnimation("tripDown", 0, .2)
99
}
100
101
if(GameInput.isPressed(GameInput.keys["2"]))
102
{
103
this.renderer.setAnimation("tripLeft", 0, .2)
104
}
105
106
if(GameInput.isPressed(GameInput.keys["3"]))
107
{
108
this.renderer.setAnimation("tripUp", 0, .2)
109
}
110
111
if(GameInput.isPressed(GameInput.keys["4"]))
112
{
113
this.renderer.setAnimation("sitDown", 0, .2)
114
}
115
116
if(GameInput.isPressed(GameInput.keys["5"]))
117
{
118
this.renderer.setAnimation("sitLeft", 0, .2)
119
}
120
121
if(GameInput.isPressed(GameInput.keys["6"]))
122
{
123
this.renderer.setAnimation("tantrum", 0, .2)
124
}
125
126
if(GameInput.isPressed(GameInput.keys["7"]))
127
{
128
this.renderer.setAnimation("swimStruggle", 0, .2)
129
}
130
131
if(GameInput.isPressed(GameInput.keys["8"]))
132
{
133
this.renderer.setAnimation("swim", 0, .2)
134
}
135
136
if(GameInput.isPressed(GameInput.keys["9"]))
137
{
138
this.renderer.setAnimation("eatStart", 0, .2)
139
}
140
141
if(GameInput.isPressed(GameInput.keys["0"]))
142
{
143
this.renderer.setAnimation("cheer", 0, .2)
144
}
145
146
if(GameInput.isPressed(GameInput.keys["q"]))
147
{
148
this.renderer.setAnimation("wave", 0, .2)
149
}
150
151
if(GameInput.isPressed(GameInput.keys["w"]))
152
{
153
this.renderer.setAnimation("hungry", 0, .2)
154
}
155
156
if(GameInput.isPressed(GameInput.keys["e"]))
157
{
158
this.renderer.setAnimation("no", 0, .2)
159
}
160
161
if(GameInput.isPressed(GameInput.keys["r"]))
162
{
163
this.renderer.setAnimation("think", 0, .2)
164
}
165
166
if(GameInput.isPressed(GameInput.keys["t"]))
167
{
168
this.renderer.setAnimation("happy", 0, .2)
169
}
170
171
if(GameInput.isPressed(GameInput.keys["y"]))
172
{
173
this.renderer.setAnimation("sad", 0, .2)
174
}
175
176
if(GameInput.isPressed(GameInput.keys["u"]))
177
{
178
this.renderer.setAnimation("sleep", 0, .2)
179
}
180
181
if(GameInput.isPressed(GameInput.keys["i"]))
182
{
183
this.renderer.setAnimation("eatBig", 0, .2)
184
}
185
186
if(GameInput.isPressed(GameInput.keys["o"]))
187
{
188
this.renderer.setAnimation("sneeze", 0, .2)
189
}
190
191
if(GameInput.isPressed(GameInput.keys["p"]))
192
{
193
this.renderer.setAnimation("cry", 0, .2)
194
}
195
196
if(GameInput.isPressed(GameInput.keys["["]))
197
{
198
this.renderer.setAnimation("think2", 0, .2)
199
}
200
}
94
201
}
95
202
}
@@ -91,5 +91,112 @@ class Chao extends GameObject91
this.renderer.mirrorX = false;91
this.renderer.mirrorX = false;92
this.wasHeld.down = true;92
this.wasHeld.down = true;93
}93
}94
else95
{96
if(GameInput.isPressed(GameInput.keys["1"]))97
{98
this.renderer.setAnimation("tripDown", 0, .2)99
}100
101
if(GameInput.isPressed(GameInput.keys["2"]))102
{103
this.renderer.setAnimation("tripLeft", 0, .2)104
}105
106
if(GameInput.isPressed(GameInput.keys["3"]))107
{108
this.renderer.setAnimation("tripUp", 0, .2)109
}110
111
if(GameInput.isPressed(GameInput.keys["4"]))112
{113
this.renderer.setAnimation("sitDown", 0, .2)114
}115
116
if(GameInput.isPressed(GameInput.keys["5"]))117
{118
this.renderer.setAnimation("sitLeft", 0, .2)119
}120
121
if(GameInput.isPressed(GameInput.keys["6"]))122
{123
this.renderer.setAnimation("tantrum", 0, .2)124
}125
126
if(GameInput.isPressed(GameInput.keys["7"]))127
{128
this.renderer.setAnimation("swimStruggle", 0, .2)129
}130
131
if(GameInput.isPressed(GameInput.keys["8"]))132
{133
this.renderer.setAnimation("swim", 0, .2)134
}135
136
if(GameInput.isPressed(GameInput.keys["9"]))137
{138
this.renderer.setAnimation("eatStart", 0, .2)139
}140
141
if(GameInput.isPressed(GameInput.keys["0"]))142
{143
this.renderer.setAnimation("cheer", 0, .2)144
}145
146
if(GameInput.isPressed(GameInput.keys["q"]))147
{148
this.renderer.setAnimation("wave", 0, .2)149
}150
151
if(GameInput.isPressed(GameInput.keys["w"]))152
{153
this.renderer.setAnimation("hungry", 0, .2)154
}155
156
if(GameInput.isPressed(GameInput.keys["e"]))157
{158
this.renderer.setAnimation("no", 0, .2)159
}160
161
if(GameInput.isPressed(GameInput.keys["r"]))162
{163
this.renderer.setAnimation("think", 0, .2)164
}165
166
if(GameInput.isPressed(GameInput.keys["t"]))167
{168
this.renderer.setAnimation("happy", 0, .2)169
}170
171
if(GameInput.isPressed(GameInput.keys["y"]))172
{173
this.renderer.setAnimation("sad", 0, .2)174
}175
176
if(GameInput.isPressed(GameInput.keys["u"]))177
{178
this.renderer.setAnimation("sleep", 0, .2)179
}180
181
if(GameInput.isPressed(GameInput.keys["i"]))182
{183
this.renderer.setAnimation("eatBig", 0, .2)184
}185
186
if(GameInput.isPressed(GameInput.keys["o"]))187
{188
this.renderer.setAnimation("sneeze", 0, .2)189
}190
191
if(GameInput.isPressed(GameInput.keys["p"]))192
{193
this.renderer.setAnimation("cry", 0, .2)194
}195
196
if(GameInput.isPressed(GameInput.keys["["]))197
{198
this.renderer.setAnimation("think2", 0, .2)199
}200
}94
}201
}95
}202
}