-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameOne.ts
More file actions
89 lines (81 loc) · 2.02 KB
/
GameOne.ts
File metadata and controls
89 lines (81 loc) · 2.02 KB
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
/// <reference path="GameView.ts" />
module Game{
export class GameOne extends Model{
recentPassOrFail:boolean;
heldSideways:boolean;
gameView;
gameCount;
canChange;
gameLoop;
clearVariables(){
super.clearVariables();
this.heldSideways = false;
this.gameCount = 0;
this.canChange = false;
}
constructor(){
super();
this.gameStarted = false;
this.changeWord();
this.gameCount = 0;
}
setGameView(gv){
this.gameView = gv
}
setRecentPassOrFail(p:boolean){
this.recentPassOrFail = p;
this.newItem = true;
}
beginGame(){
this.gameView.renderForehead();
}
countdown(){
if(this.gameCount == 0){
this.gameView.renderCountdown(3.2,this.gameView.height,0);
}
++this.gameCount;
}
notEnoughCategories(){
this.gameView.renderNotEnoughCategories
}
setEndGameStartingHeight(startingHeight:number){
this.gameView.startingHeight = startingHeight;
}
startGame(timeOfRound:number){
this.gameStarted = true;
var self = this;
var f = function(){self.startGame(timeOfRound)};
this.gameLoop = setTimeout(f, 100);
this.gameView.renderCurrentWordOne(this.currentItem,timeOfRound);
if(timeOfRound <= 0){
//console.log("gameLoop Height! "+this.gameLoop.height);
clearTimeout(this.gameLoop);
this.gameOver = true;
this.gameView.renderGameOver(this.playedWords.length,this.playedWords,this.correctPlayedWords);
}
if(this.newItem){
this.playedWords.push(this.currentItem);
this.correctPlayedWords.push(this.recentPassOrFail);
this.recentlyUsedWords.push(this.currentItem);
console.log("len" + this.playedWords.length);
console.log("cuur" + this.currentItem);
this.changeWord();
this.newItem = false;
}
if(this.heldSideways){
if(this.recentPassOrFail){
this.gameView.renderCorrect();
}else{
this.gameView.renderPass();
}
}else{
timeOfRound = timeOfRound - 0.1;
}
}
endGame(){
if(this.gameLoop){
clearTimeout(this.gameLoop)
}
}
}
}