Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathias committed Dec 4, 2013
2 parents 65a4fe7 + 2d4a47f commit 62c2f95
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
1 change: 0 additions & 1 deletion Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ Counter-Strike 1.6 implementation in JavaScript utilizing state of the art brows
<b>Current state</b>
<ul>
<li>Parses and renders .bsp files (version 30) containing map data</li>
<li>Parses and renders .mdl files (version 10) with textures </li>
<li>Camera movement, yaw and pitch fully implemented</li>
<li>Collision detection mostly completed</li>
<li>Collision detection implemented</li>
<li>Naive gravity implemented</li>
</ul>

Expand All @@ -20,4 +21,4 @@ Counter-Strike 1.6 implementation in JavaScript utilizing state of the art brows
<b>Commiting changes</b><br />
<ul>
<li>Please note: No actual data (maps, models, textures, etc.) is included in the project, due to copyright reasons!</li>
</ul>
</ul>
51 changes: 51 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 62c2f95

Please sign in to comment.