-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinitVariables.js
113 lines (97 loc) · 2.11 KB
/
initVariables.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
// Global variable definitionvar canvas;
var canvas;
var gl;
var shaderProgram;
// Buffers
var worldVertexPositionBuffer = null;
var worldVertexTextureCoordBuffer = null;
var mesh = null;
var bomb = null;
var house = null;
var ammo;
var bulletMesh;
var rockMesh;
var bombList = [];
// Model-view and projection matrix and model-view matrix stack
var mvMatrixStack = [];
var mvMatrix = mat4.create();
var pMatrix = mat4.create();
// Variables for storing textures
var wallTexture = null;
var midTexture = null;
var bombTexture = null;
var houseTexture = null;
var ammoTexture = null;
var bulletTexture = null;
var rockTexture = null;
// Variable that stores loading state of textures.
var texturesLoaded = false;
// Keyboard handling helper variable for reading the status of keys
var currentlyPressedKeys = {};
// Variables for storing current position and speed
var yaw = 0;
var xPosition = 0;
var yPosition = 3;
var zPosition = 0;
var speedForward = 0;
var speedSide = 0;
//mouse position
var xMouse = 0;
var yMouse = 0;
var rotMouse = 0;
// Used to make us "jog" up and down as we move forward.
var joggingAngle = 0;
var movingSpeed = 0.008;
var spawnPosition = [1,0,0];
// Helper variable for animation
var lastTime = 0;
var isCollision = false;
//
// Firing
var fire=false;
var lastFire = 0;
var ammoCount = 50;
var fireCooldown = 1500;
var bulletLifetime = 1000;
var xBulletPosition;
var zBulletPosition;
var bulletRot;
var bulletSpeed = 0.3;
var bulletBody;
//
// Moving bombs
var bombSpeed = 0.005;
var bombSize;
var bombResponseText;
var lastSpawn = 0;
var spawnInterval = 3000;
var bombSpawnPoints = [
[10,0,-23],
[-10,0,-23],
[15,0,-20],
[-15,0,-20]];
var bombMoveProgram = [
[[8,0], [6, 0], [14, 0], [10, 10]],
[[-8,0], [-6, 0], [-14, 0], [10, 10]],
[[4, -8], [3, -6], [12, -4], [10, 10]],
[[-4, -8], [-3, -6], [-12, -4], [10, 10]]];
//
// Ammo
var lastAmmoPickup = 0;
var ammoSpawnInterval = 10000;
var ammoActive = true;
var ammoSpawnPoints = [
[15,0,-5],
[-10,0,0],
[5,0,-12],
[-5,0,-10]];
//
// Nature
var rocks;
var rockResponseText;
var rockSize;
//
// Game
var timer = 0;
var houseHP = 3;
var gameActive = true;