BlueGit

blue-star speeltuin

Merge branch 'master' of https://gitlab.com/spark-imagination/speeltuin

timfa wsadhelios · pushed by timfa

Authored 2022-10-21 · 4 years ago

Hash
fa4893391ed50ebf4ae61b403ea4a3b7a080c10d
4 files changed +76 −23
src/chaoBehaviour/emote.js added +53 −0
@@ -0,0 +1,53 @@
1 class BehaviourEmote extends ChaoBehaviour
2 {
3 pickedAnimation = "";
4
5 startBehaviour ()
6 {
7 let potentialMoods = [];
8
9 if (Chao.Instance.mood.hungry > 0.4)
10 potentialMoods.push("hungry");
11
12 if (Chao.Instance.mood.happy > 0.6 && Chao.Instance.mood.angry < 0.3 && Chao.Instance.mood.sad < 0.3)
13 {
14 potentialMoods.push("cheer");
15 potentialMoods.push("wave");
16 potentialMoods.push("happy");
17 }
18 else
19 {
20 if (Chao.Instance.mood.angry > 0.5 || Chao.Instance.mood.sad > 0.5)
21 {
22 if (Chao.Instance.mood.angry > Chao.Instance.mood.sad)
23 {
24 potentialMoods.push("standDownAngry");
25 potentialMoods.push("tantrum");
26 }
27 else
28 {
29 potentialMoods.push("standDownSad");
30 potentialMoods.push("cry");
31 }
32 }
33 else
34 {
35 if (Chao.Instance.mood.curious > 0.4)
36 {
37 potentialMoods.push("think");
38 potentialMoods.push("think2");
39 potentialMoods.push("eureka");
40 }
41 }
42 }
43
44 this.pickedAnimation = potentialMoods.random();
45 Chao.Instance.renderer.setAnimation(this.pickedAnimation);
46 }
47
48 update (deltaTime)
49 {
50 if (Chao.Instance.renderer.currentAnimationName != this.pickedAnimation)
51 this.endBehaviour();
52 }
53 }
@@ -0,0 +1,53 @@
1class BehaviourEmote extends ChaoBehaviour
2{
3 pickedAnimation = "";
4
5 startBehaviour ()
6 {
7 let potentialMoods = [];
8
9 if (Chao.Instance.mood.hungry > 0.4)
10 potentialMoods.push("hungry");
11
12 if (Chao.Instance.mood.happy > 0.6 && Chao.Instance.mood.angry < 0.3 && Chao.Instance.mood.sad < 0.3)
13 {
14 potentialMoods.push("cheer");
15 potentialMoods.push("wave");
16 potentialMoods.push("happy");
17 }
18 else
19 {
20 if (Chao.Instance.mood.angry > 0.5 || Chao.Instance.mood.sad > 0.5)
21 {
22 if (Chao.Instance.mood.angry > Chao.Instance.mood.sad)
23 {
24 potentialMoods.push("standDownAngry");
25 potentialMoods.push("tantrum");
26 }
27 else
28 {
29 potentialMoods.push("standDownSad");
30 potentialMoods.push("cry");
31 }
32 }
33 else
34 {
35 if (Chao.Instance.mood.curious > 0.4)
36 {
37 potentialMoods.push("think");
38 potentialMoods.push("think2");
39 potentialMoods.push("eureka");
40 }
41 }
42 }
43
44 this.pickedAnimation = potentialMoods.random();
45 Chao.Instance.renderer.setAnimation(this.pickedAnimation);
46 }
47
48 update (deltaTime)
49 {
50 if (Chao.Instance.renderer.currentAnimationName != this.pickedAnimation)
51 this.endBehaviour();
52 }
53}
src/chaoBehaviour/sneeze.js deleted +0 −13
@@ -1,13 +0,0 @@
1 class BehaviourSneeze extends ChaoBehaviour
2 {
3 startBehaviour ()
4 {
5 Chao.Instance.renderer.setAnimation("sneeze");
6 }
7
8 update (deltaTime)
9 {
10 if (Chao.Instance.renderer.currentAnimationName != "sneeze")
11 this.endBehaviour();
12 }
13 }
@@ -1,13 +0,0 @@
1class BehaviourSneeze extends ChaoBehaviour
2{
3 startBehaviour ()
4 {
5 Chao.Instance.renderer.setAnimation("sneeze");
6 }
7
8 update (deltaTime)
9 {
10 if (Chao.Instance.renderer.currentAnimationName != "sneeze")
11 this.endBehaviour();
12 }
13}
src/game.js +13 −9
@@ -78,28 +78,32 @@ function setupChaoAnimations (image)
78 78 image.addAnimationCycle("sitDown", [27]);
79 79 image.addAnimationCycle("sitLeft", [28]);
80 80
81 image.addAnimationCycle("tantrum", [29, 30, 29, 31, 32, 33]);
81 image.addAnimationCycle("tantrum", [29, 30, 29, 31, 32, 33, 33], false, "standDownAngry");
82 image.addAnimationCycle("standDownAngry", [29], true);
82 83
83 84 image.addAnimationCycle("swimStruggle", [34, 35], true);
84 85 image.addAnimationCycle("eatStart", [36, 37, 38], false, "eat");
85 86 image.addAnimationCycle("eat", [37, 38], true);
86 87
87 image.addAnimationCycle("cheer", [39, 40], true);
88 image.addAnimationCycle("wave", [41, 42]);
88 image.addAnimationCycle("cheer", [39, 40, 39, 40, 39, 40, 39, 40, 39, 40], false, "standDown");
89 image.addAnimationCycle("wave", [41, 42, 42, 42, 42], false, "standDown");
89 90
90 image.addAnimationCycle("hungry", [43, 44], true);
91 image.addAnimationCycle("hungry", [43, 44, 43, 44, 43, 44, 43, 44], false, "standDown");
91 92
92 image.addAnimationCycle("no", [45, 46, 45, 47], true);
93 image.addAnimationCycle("think", [48]);
93 image.addAnimationCycle("no", [45, 46, 45, 47, 45, 46, 45, 47], false, "standDownBored");
94 image.addAnimationCycle("standDownBored", [45], false);
95
96 image.addAnimationCycle("think", [48, 48, 48, 48, 48], false, "standDown");
94 97 image.addAnimationCycle("happy", [49, 50, 49, 51], true);
95 image.addAnimationCycle("sad", [52]);
98 image.addAnimationCycle("standDownSad", [52], false);
96 99 image.addAnimationCycle("sleep", [53, 54], true);
100 image.addAnimationCycle("eureka", [60, 60, 60, 66, 66, 48], false, "wave");
97 101
98 102 image.addAnimationCycle("swim", [55, 56, 57], true);
99 103 image.addAnimationCycle("eatBig", [58, 59], true);
100 104 image.addAnimationCycle("sneeze", [60, 61, 62, 63], false, "standDown");
101 image.addAnimationCycle("cry", [64, 65], true);
102 image.addAnimationCycle("think2", [66]);
105 image.addAnimationCycle("cry", [64, 65, 64, 65, 64, 65, 64, 65, 64, 65], false, "standDownSad");
106 image.addAnimationCycle("think2", [66, 66, 66, 66, 66, 66], false, "standDown");
103 107 }
104 108
105 109 createMainScene = function (game)
@@ -78,28 +78,32 @@ function setupChaoAnimations (image)
78 image.addAnimationCycle("sitDown", [27]);
78 image.addAnimationCycle("sitDown", [27]);
79 image.addAnimationCycle("sitLeft", [28]);
79 image.addAnimationCycle("sitLeft", [28]);
80
80
81 image.addAnimationCycle("tantrum", [29, 30, 29, 31, 32, 33]);
81 image.addAnimationCycle("tantrum", [29, 30, 29, 31, 32, 33, 33], false, "standDownAngry");
82 image.addAnimationCycle("standDownAngry", [29], true);
82
83
83 image.addAnimationCycle("swimStruggle", [34, 35], true);
84 image.addAnimationCycle("swimStruggle", [34, 35], true);
84 image.addAnimationCycle("eatStart", [36, 37, 38], false, "eat");
85 image.addAnimationCycle("eatStart", [36, 37, 38], false, "eat");
85 image.addAnimationCycle("eat", [37, 38], true);
86 image.addAnimationCycle("eat", [37, 38], true);
86
87
87 image.addAnimationCycle("cheer", [39, 40], true);
88 image.addAnimationCycle("cheer", [39, 40, 39, 40, 39, 40, 39, 40, 39, 40], false, "standDown");
88 image.addAnimationCycle("wave", [41, 42]);
89 image.addAnimationCycle("wave", [41, 42, 42, 42, 42], false, "standDown");
89
90
90 image.addAnimationCycle("hungry", [43, 44], true);
91 image.addAnimationCycle("hungry", [43, 44, 43, 44, 43, 44, 43, 44], false, "standDown");
91
92
92 image.addAnimationCycle("no", [45, 46, 45, 47], true);
93 image.addAnimationCycle("no", [45, 46, 45, 47, 45, 46, 45, 47], false, "standDownBored");
93 image.addAnimationCycle("think", [48]);
94 image.addAnimationCycle("standDownBored", [45], false);
95
96 image.addAnimationCycle("think", [48, 48, 48, 48, 48], false, "standDown");
94 image.addAnimationCycle("happy", [49, 50, 49, 51], true);
97 image.addAnimationCycle("happy", [49, 50, 49, 51], true);
95 image.addAnimationCycle("sad", [52]);
98 image.addAnimationCycle("standDownSad", [52], false);
96 image.addAnimationCycle("sleep", [53, 54], true);
99 image.addAnimationCycle("sleep", [53, 54], true);
100 image.addAnimationCycle("eureka", [60, 60, 60, 66, 66, 48], false, "wave");
97
101
98 image.addAnimationCycle("swim", [55, 56, 57], true);
102 image.addAnimationCycle("swim", [55, 56, 57], true);
99 image.addAnimationCycle("eatBig", [58, 59], true);
103 image.addAnimationCycle("eatBig", [58, 59], true);
100 image.addAnimationCycle("sneeze", [60, 61, 62, 63], false, "standDown");
104 image.addAnimationCycle("sneeze", [60, 61, 62, 63], false, "standDown");
101 image.addAnimationCycle("cry", [64, 65], true);
105 image.addAnimationCycle("cry", [64, 65, 64, 65, 64, 65, 64, 65, 64, 65], false, "standDownSad");
102 image.addAnimationCycle("think2", [66]);
106 image.addAnimationCycle("think2", [66, 66, 66, 66, 66, 66], false, "standDown");
103}
107}
104
108
105createMainScene = function (game)
109createMainScene = function (game)
src/objects/chao.js +10 −1
@@ -15,6 +15,15 @@ class Chao extends GameObject
15 15
16 16 particler = null;
17 17
18 mood =
19 { //all values range from 0 to 1
20 happy: 0.5,
21 angry: 0.5,
22 hungry: 0.5,
23 sad: 0.5,
24 curious: 0.5
25 };
26
18 27 static Instance;
19 28
20 29 get busyWithBehaviour ()
@@ -53,7 +62,7 @@ class Chao extends GameObject
53 62 this.renderer.sprite = this.scene.game.chaoImages.random();
54 63
55 64 this.renderer.defaultAnimationSpeed = 0.2;
56 this.registerBehaviour(new BehaviourSneeze());
65 this.registerBehaviour(new BehaviourEmote());
57 66 this.registerBehaviour(new BehaviourWander());
58 67
59 68 }
@@ -15,6 +15,15 @@ class Chao extends GameObject
15
15
16 particler = null;
16 particler = null;
17
17
18 mood =
19 { //all values range from 0 to 1
20 happy: 0.5,
21 angry: 0.5,
22 hungry: 0.5,
23 sad: 0.5,
24 curious: 0.5
25 };
26
18 static Instance;
27 static Instance;
19
28
20 get busyWithBehaviour ()
29 get busyWithBehaviour ()
@@ -53,7 +62,7 @@ class Chao extends GameObject
53 this.renderer.sprite = this.scene.game.chaoImages.random();
62 this.renderer.sprite = this.scene.game.chaoImages.random();
54
63
55 this.renderer.defaultAnimationSpeed = 0.2;
64 this.renderer.defaultAnimationSpeed = 0.2;
56 this.registerBehaviour(new BehaviourSneeze());
65 this.registerBehaviour(new BehaviourEmote());
57 this.registerBehaviour(new BehaviourWander());
66 this.registerBehaviour(new BehaviourWander());
58
67
59 }
68 }