-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.js
126 lines (107 loc) · 3.21 KB
/
game.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
//leave
var player;
var car2;
window.onload = function() {
var car1 = document.getElementById("car1");
var speedLimit = document.getElementById("speedLimit");
var slightbendinroadright = document.getElementById("slightbendinroadright");
var stoplightahead = document.getElementById("stoplightahead");
document.querySelector(".steering").style.transform = "rotate(0deg)";
player = {
x: 0,
y: 0,
w: 100,
hvalue: 1.893,
h: 189.3,
//physics vals
xv: 0,
yv: 0,
vt: 0,
mass: 1759,
TCF: 3,
centGravity: 3/8,
corneringStiffnessFront: 0.2,
corneringStiffnessRear: 0.25,
skidding: false,
curtoq: 1,
spinCo: 10,
skiddColor: "rgba(39, 23, 23, 0.9)",
skiddWidth: 20,
//----
healthN: 50000,
healthStart: 50000,
//----
lastPosx: 0,
lastPosy: 0,
wheelAngle: 0,
angle: 0,
vectorAngle: undefined,
dir: "F",
img: car1,
funnyBoxMode: false,
mode: "s",
signs: {
"speedLimit": speedLimit,
"stoplightahead": stoplightahead,
"slightbendinroadleft": slightbendinroadleft,
},
maxTurnAngle: 50,
// in degrees
turnIncrement: 5,
WheelturnIncrement: 3,
// in degrees
brakeSensitivity: 1.05,
// needs to be over 1
maxSpeed: 150,
maxReverSpeed: 50,
// in px per second
acceleration: 20,
// in px per second
predictPath: false,
carFriction: false,
friction: 80,
nameOfCar: "Acura/Honda NSX",
color: "red",
scale: 2,
map: {zoom: 300},
speedkph: 0,
}
console.log("yo")
document.querySelector("#health").max = player.healthN;
updateSliders();
createNPC();
}
function start() {
if(player.mode == "e") {
document.querySelector("#togbtn1").innerHTML = "Explorer";
}
document.querySelector(".startScreen").style.display = "none";
document.querySelector(".menu").style.display = "block";
document.querySelector(".steering").style.display = "block";
setInterval(update, 1000/60);
}
document.querySelector("#survival").style.backgroundColor = "green";
function survival() {
document.querySelector("#survival").style.backgroundColor = "green";
document.querySelector("#explorer").style.backgroundColor = '';
player.mode = "s";
}
function explorer() {
document.querySelector("#survival").style.backgroundColor = '';
document.querySelector("#explorer").style.backgroundColor = "green";
player.mode = "e";
}
function newGame() {
location.reload();
}
function continueGame(mode) {
player.healthN = player.healthStart;
player.mode = mode;
if(mode == "s") {
document.querySelector("#togbtn1").innerHTML = "Survival";
}
else {
document.querySelector("#togbtn1").innerHTML = "Explorer";
}
document.querySelector(".deathScreen").style.display = "none";
}