-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
111 lines (92 loc) · 3.39 KB
/
script.js
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// main variables
var hunger = 0;
var mood = 0;
var age = 0;
var correctDirection = 0;
// Button setup
document.getElementById('hungerBut').style.visibility = 'hidden';
document.getElementById('happyBut').style.visibility = 'hidden';
document.getElementById('left').style.visibility = 'hidden';
document.getElementById('right').style.visibility = 'hidden';
// evolution sequence
var timeTillEvo = 65*60;
if (timeTillEvo == 0) {
document.getElementById("tama").src="child.gif";
} else {
setInterval(function() {
timeTillEvo--;
}, 1000);
}
function wrongChoice() {
document.getElementById("tama").src="AngerShiro.gif";
document.getElementById('left').style.visibility = 'hidden';
document.getElementById('right').style.visibility = 'hidden';
const backToBaby = setTimeout(normalBaby, 2000);
}
function rightChoice() {
document.getElementById("tama").src="happyshiro.gif";
document.getElementById('left').style.visibility = 'hidden';
document.getElementById('right').style.visibility = 'hidden';
const backToBaby = setTimeout(normalBaby, 2000);
if (mood < 4) {
mood++;
document.getElementById("happy").innerText= mood;
}
}
function normalBaby() {
document.getElementById("tama").src="baby.gif";
document.getElementById('hungerBut').style.visibility = 'visible';
document.getElementById('happyBut').style.visibility = 'visible';
}
function hatchTama() {
document.getElementById("tama").src="baby.gif";
document.getElementById("stomach").innerText= hunger;
document.getElementById("happy").innerText= mood;
document.getElementById("tamaAge").innerText= age;
document.getElementById('hatch').style.visibility = 'hidden';
document.getElementById('hungerBut').style.visibility = 'visible';
document.getElementById('happyBut').style.visibility = 'visible';
}
function feedTama() {
if (hunger < 4) {
hunger++;
}
document.getElementById("stomach").innerText= hunger;
}
function cheerUpTama() {
document.getElementById("tama").src="leftorright.gif";
document.getElementById('left').style.visibility = 'visible';
document.getElementById('right').style.visibility = 'visible';
document.getElementById('hungerBut').style.visibility = 'hidden';
document.getElementById('happyBut').style.visibility = 'hidden';
}
function leftTama() {
var correctDirection = Math.round(Math.random());
if (correctDirection == 0) {
document.getElementById("tama").src="leftleft.png";
document.getElementById('right').style.visibility = 'hidden';
document.getElementById('left').style.visibility = 'hidden';
const correct = setTimeout(rightChoice, 1000);
}
else {
document.getElementById("tama").src="rightleft.gif";
document.getElementById('right').style.visibility = 'hidden';
document.getElementById('left').style.visibility = 'hidden';
const wrong = setTimeout(wrongChoice, 1000);
}
}
function rightTama() {
var correctDirection = Math.round(Math.random());
if (correctDirection == 1) {
document.getElementById("tama").src="rightright.gif";
document.getElementById('right').style.visibility = 'hidden';
document.getElementById('left').style.visibility = 'hidden';
const correct = setTimeout(rightChoice, 1000);
}
else {
document.getElementById("tama").src="leftright.gif";
document.getElementById('right').style.visibility = 'hidden';
document.getElementById('left').style.visibility = 'hidden';
const wrong = setTimeout(wrongChoice, 1000);
}
}