BlueGit

blue-star speeltuin

Files

speeltuin / src / game.js

game.js

af3d26e9 History
game.js 4.6 KiB Download Raw
1console.log("Game started!");
2window.onload = function()
3{
4 var game = new Game();
5
6 game.preloadImagesThenStart(
7 [
8 {name:"arrow", url:"images/arrow.png", subImgTotal: 4, perRow: 2},
9 {name:"grass_dark", url:"images/grass_dark.png"},
10 {name:"grass_light", url:"images/grass_light.png"},
11 {name:"frog_basic", url:"images/character/frog/frog_basic.png", subImgTotal: 4, perRow: 4},
12 {name:"frog_tongue_base", url:"images/character/frog/frog_tongue_base.png"},
13 {name:"frog_tongue_tip", url:"images/character/frog/frog_tongue_tip.png"},
14 {name:"chao_default", url:"images/character/chao/default.png", subImgTotal: 67, perRow: 9},
15 {name:"chao_blue", url:"images/character/chao/blue.png", subImgTotal: 67, perRow: 9},
16 {name:"chao_cyan", url:"images/character/chao/cyan.png", subImgTotal: 67, perRow: 9},
17 {name:"chao_dark", url:"images/character/chao/dark.png", subImgTotal: 67, perRow: 9},
18 {name:"chao_darkgreen", url:"images/character/chao/darkgreen.png", subImgTotal: 67, perRow: 9},
19 {name:"chao_green", url:"images/character/chao/green.png", subImgTotal: 67, perRow: 9},
20 {name:"chao_lightgreen", url:"images/character/chao/lightgreen.png", subImgTotal: 67, perRow: 9},
21 {name:"chao_hero", url:"images/character/chao/hero.png", subImgTotal: 67, perRow: 9},
22 {name:"chao_orange", url:"images/character/chao/orange.png", subImgTotal: 67, perRow: 9},
23 {name:"chao_pink", url:"images/character/chao/pink.png", subImgTotal: 67, perRow: 9},
24 {name:"chao_purple", url:"images/character/chao/purple.png", subImgTotal: 67, perRow: 9},
25 {name:"chao_red", url:"images/character/chao/red.png", subImgTotal: 67, perRow: 9},
26 {name:"chao_white", url:"images/character/chao/white.png", subImgTotal: 67, perRow: 9},
27 {name:"chao_yellow", url:"images/character/chao/yellow.png", subImgTotal: 67, perRow: 9}
28 ]
29 , function()
30 {
31 game.images.frog_basic.addAnimationCycle("walk", [0,1,2,1]);
32 this.setupChaoAnimations(game.images.chao_default)
33 this.setupChaoAnimations(game.images.chao_blue)
34 this.setupChaoAnimations(game.images.chao_cyan)
35 this.setupChaoAnimations(game.images.chao_dark)
36 this.setupChaoAnimations(game.images.chao_darkgreen)
37 this.setupChaoAnimations(game.images.chao_green)
38 this.setupChaoAnimations(game.images.chao_lightgreen)
39 this.setupChaoAnimations(game.images.chao_hero)
40 this.setupChaoAnimations(game.images.chao_orange)
41 this.setupChaoAnimations(game.images.chao_pink)
42 this.setupChaoAnimations(game.images.chao_purple)
43 this.setupChaoAnimations(game.images.chao_red)
44 this.setupChaoAnimations(game.images.chao_white)
45 this.setupChaoAnimations(game.images.chao_yellow)
46
47 this.createMainScene(game);
48 });
49}
50
51function setupChaoAnimations(image)
52{
53 image.addAnimationCycle("walkDown", [0, 1, 2])
54 image.addAnimationCycle("walkLeft", [3, 4, 5])
55 image.addAnimationCycle("walkUp", [6, 7, 8])
56
57 image.addAnimationCycle("flyDown", [9, 10, 11])
58 image.addAnimationCycle("flyLeft", [12, 13, 14])
59 image.addAnimationCycle("flyUp", [15, 16, 17])
60
61 image.addAnimationCycle("tripDown", [18, 19, 20])
62 image.addAnimationCycle("tripLeft", [21, 22, 23])
63 image.addAnimationCycle("tripUp", [24, 25, 26])
64
65 image.addAnimationCycle("sitDown", [27])
66 image.addAnimationCycle("sitLeft", [28])
67
68 image.addAnimationCycle("tantrum", [29, 30, 31, 32, 33])
69
70 image.addAnimationCycle("swimStruggle", [34, 35])
71 image.addAnimationCycle("beginSit", [36, 37, 38])
72
73 image.addAnimationCycle("cheer", [39, 40])
74 image.addAnimationCycle("wave", [41, 42])
75
76 image.addAnimationCycle("hungry", [43, 44])
77
78 image.addAnimationCycle("no", [45, 46, 47])
79 image.addAnimationCycle("think", [48])
80 image.addAnimationCycle("happy", [49, 50, 51, 52])
81 image.addAnimationCycle("sleep", [53, 54])
82
83 image.addAnimationCycle("swim", [55, 56, 57])
84 image.addAnimationCycle("sitHappy", [58, 59])
85 image.addAnimationCycle("sneeze", [60, 61, 62, 63])
86 image.addAnimationCycle("cry", [64, 65])
87 image.addAnimationCycle("think2", [66])
88}
89
90createMainScene = function(game)
91{
92 var scene = new Scene(0, 0, 1, 1, Scene.DisplayModes.relativeToParent);
93
94 game.loadScene(scene);
95
96 scene.addObject(new GrassTiler(50, 50, game.images.arrow, 0));
97 frog = new Frog(60,60, game.images.frog_basic, 0);
98 scene.addObject(frog);
99}