-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.ts
53 lines (47 loc) · 1.09 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
namespace SpriteKind {
export const Critter = SpriteKind.create()
export const Door = SpriteKind.create()
export const Sign = SpriteKind.create()
export const CarriedFood = SpriteKind.create()
}
let randDirectionY = 0
let randDirectionX = 0
let happinessFactor = 0
let happinessDegradeFactor = 1
let healthDegradeFactor = 1
// Computer handles all the overall state (like number of adopted critters)
const savedGame = Computer.getSavedGame()
console.log(JSON.stringify(savedGame))
Player.init({
savedGame
})
Environment.init({
mainCharacter: Player.ginny,
savedGame
})
Critters.init({
map: Environment.map,
savedGame
})
Events.init({
map: Environment.map,
critters: Critters.critters
})
Computer.init({
map: Environment.map,
player: Player.ginny,
critters: Critters.critters,
savedGame
})
// Loop over each critter and degrade health/happiness
forever(function () {
pause(3000)
Environment.fastTick()
Critters.fastTick()
})
forever(function() {
// 15 second ticks
pause(15000)
Critters.slowTick()
Events.slowTick()
})