diff --git a/Player.js b/Player.js
index 42bc4b5..fc8ad6f 100644
--- a/Player.js
+++ b/Player.js
@@ -162,7 +162,6 @@ cs.Player = function(gl, x, y, z, data) {
});
KeyboardJS.on("space", function(event, keys, combo) {
- //Cannot access outer scope, so we have to do the jump code in here :(
var d = dir[2];
if(d < 0.0001 && d > -0.0001) {
dir[2] = 1;
diff --git a/README.md b/README.md
index 8d3e931..a60a092 100644
--- a/README.md
+++ b/README.md
@@ -6,8 +6,9 @@ Counter-Strike 1.6 implementation in JavaScript utilizing state of the art brows
Current state
- Parses and renders .bsp files (version 30) containing map data
+- Parses and renders .mdl files (version 10) with textures
- Camera movement, yaw and pitch fully implemented
-- Collision detection mostly completed
+- Collision detection implemented
- Naive gravity implemented
@@ -20,4 +21,4 @@ Counter-Strike 1.6 implementation in JavaScript utilizing state of the art brows
Commiting changes
- Please note: No actual data (maps, models, textures, etc.) is included in the project, due to copyright reasons!
-
\ No newline at end of file
+
diff --git a/index.html b/index.html
index 3470bbe..ec3b629 100644
--- a/index.html
+++ b/index.html
@@ -26,6 +26,57 @@
menu.style.visibility = "hidden";
}
+ function webGLStart() {
+ var canvas = document.getElementById("canvas");
+ initGL(canvas);
+
+ download(cs.config.MAP_PATH, function(data) {
+ //Parse map
+ cs.map = new cs.Map(gl, data);
+
+ download(cs.config.PLAYER_PATH, function(data) {
+ //Hardcoded cs_assault position. TODO: Read this from the entity set
+ cs.player = new cs.Player(gl, -186, 2597, 165, data);
+
+ gl.clearColor(0.0, 0.0, 0.0, 1.0);
+
+ //Set event handler for resizing the screen every time
+ //the window changes size
+ var resizeCallback = function() {
+ canvas.width = window.innerWidth;
+ canvas.height = window.innerHeight;
+ gl.viewportWidth = window.innerWidth;
+ gl.viewportHeight = window.innerHeight;
+ };
+ resizeCallback();
+ window.addEventListener("resize", resizeCallback, false);
+
+ //Listen for clicks on the canvas
+ canvas.addEventListener("click", function() {
+ //is the mouse not currently locked?
+ if(!PointerLock.pointerLockElement()) {
+ //Nope. Request locking
+ PointerLock.requestPointerLock(canvas);
+ }
+ }, false);
+
+ //Listen for pointer locking
+ PointerLock.addPointerLockExchangeEventListener(document, function(e) {
+ //Did the pointer just go from unlocked to locked?
+ if(!!PointerLock.pointerLockElement()) {
+ //Yep! Add mousemove listener
+ PointerLock.addMouseMoveEventListener(document, rotatePlayer, false);
+ }
+ else { //Nope. Remove mouse move listener
+ PointerLock.removeMouseMoveEventListener(document, rotatePlayer);
+ }
+ }, false);
+
+ mainLoop();
+ });
+ });
+ }
+
function startGame() {
var e = document.getElementById("map");
var map = e.options[e.selectedIndex].value;