-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinteraction.js
86 lines (76 loc) · 1.82 KB
/
interaction.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
function handleMouseEvent(e){
e.preventDefault();
var x,y;
if(false){//e instanceof TouchEvent){
x = e.changedTouches[0].pageX - cvs.getBoundingClientRect().x;
y = e.changedTouches[0].pageY - cvs.getBoundingClientRect().y;
}else{
x = e.offsetX;
y = e.offsetY;
}
handleMouse(x / screenScale.x, y / screenScale.y, e.type);
}
function handleMouse(x, y, type){
if(dlg){
dlg.mouse(x,y,type);
}else{
}
sb.mouse(x,y,type);
}
function handleKeyEvent(e){
/*
if(e.key=="ArrowLeft"){
//camxgoal = 640*Math.floor(camx/640-.3);
camxgoal -= 640
if(camxgoal < 0) camxgoal = 0;
playSound("swipe");
}
if(e.key=="ArrowRight"){
//camxgoal = 640*Math.ceil(camx/640+.3);
camxgoal += 640
if(camxgoal > 640*4) camxgoal = 640*4;
playSound("swipe");
}
*/
if(e.key=="f")
{
heading.hidden = !heading.hidden;
fullscreen = !fullscreen;
if(!fullscreen){
gameCanvas.width = 720;
gameCanvas.height = 540;
}
}
}
function gotoPage(n, callback){
camxgoal = (n-1)*640;
playSound("swipe");
if(callback)
camcallback = callback;
}
function endTurn(){
sb.setNextTurnEnabled(false);
playSound("bell");
dlg.destroy(function(){
gotoPage(5,function(){
playSound("truck_drive_away");
setTimeout(function(){
dlg = new SummaryDialog();
}, 3000)
})
})
}
function startTurn(){
dlg.destroy(function(){
gotoPage(3,function(){
dlg = new ProductionDialog();
sb.setMoneyEnabled(true);
sb.setNextTurnEnabled(true);
})
})
}
function credits(){
dlg.destroy(function(){
dlg = new CreditsDialog();
})
}