Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed players couldnt fire at the same time

  • Loading branch information...
commit d3e59eaad752710f74a5cfc092e546e2bdc6558a 1 parent 558adb6
robin Tissot authored
Showing with 53 additions and 30 deletions.
  1. +25 −2 README
  2. +28 −26 client/js/Controls.js
  3. +0 −2  client/js/Player.js
27 README
View
@@ -1,2 +1,25 @@
-foobar
-sa maman
+This is a Prototype/technology test for a small Multiplayer Game based on WebGL/node.js
+
+Known bugs:
+* Keyboard bug : On some keyboards, you can't push UP+LEFT+SPACE (http://en.wikipedia.org/wiki/Rollover_(key)#Key_jamming_and_ghosting)
+* The player 'ship' is not on the same plane as others (roughtly 45°)
+* the positions of enemy players seems not to be well synched
+* when you change tab the game stays in the same state (may have to use timers for everything !)
+
+TODO:
+* make a 'weapon' class to handle all weapons related stuff (allowing to clean up controls)
+* collisions
+* weapon hits & player life
+* try to lower/optimize the datas sent
+ - don't send moving data if a player don't move
+ - try to merge some queries
+ - check if there is a way to lower the http datas
+* benchmark for memory usage client side
+* cleanup the names in Game.js and Api.js so it is more clear what method is called when receiving data and when sending data (bomb addBomb are not explicit enough)
+
+less important
+* do some server side checks for cheating
+* third person camera
+* make a UI class with hooks
+* a real game field
+* better player model
54 client/js/Controls.js
View
@@ -26,9 +26,8 @@ var Controls = function(player) { //, domElement
this.movingDown = true;
if(e.keyCode == 32)
this.shooting = true;
- if(e.keyCode == 17 && getBombJauge() > 20)
+ if(e.keyCode == 17 && getBombJauge() > 20) //move this, along with the shoot cooldown and ressource logic
this.bombing = true;
-
};
this.onKeyUp = function(e){
if(e.keyCode == 37) {
@@ -50,13 +49,13 @@ var Controls = function(player) { //, domElement
if(e.keyCode == 32)
this.shooting = false;
if(e.keyCode == 17)
+ {
+ if(this.bombing == true)
{
- if(this.bombing == true)
- {
- this.bombing = false;
- this.dropBomb();
- }
+ this.bombing = false;
+ this.dropBomb();
}
+ }
};
function getBombJauge()
@@ -104,17 +103,19 @@ var Controls = function(player) { //, domElement
if(this.shooting == true)
{
shootJauge = $("#shootCooldown").progressbar( "option", "value" );
- if(game.lastShotTime + game.shotCooldown < Date.now() && shootJauge > 3)
- {
- shootJauge = shootJauge - 3;
- $("#shootCooldown").progressbar({ value: shootJauge });
- if(shootJauge > 50 && shootJauge < 75)
- $("#shootCooldown > div").css({ 'background': '#ff0' });
- if(shootJauge < 25)
- $("#shootCooldown > div").css({ 'background': '#f00' });
- var shoot = this.player.addShoot();
- game.shoot(shoot);
- }
+ if(game.lastShotTime + game.shotCooldown < Date.now() && shootJauge > 3)
+ {
+ shootJauge = shootJauge - 3;
+ $("#shootCooldown").progressbar({ value: shootJauge });
+ if(shootJauge > 50 && shootJauge < 75)
+ $("#shootCooldown > div").css({ 'background': '#ff0' });
+ if(shootJauge < 25)
+ $("#shootCooldown > div").css({ 'background': '#f00' });
+ var shoot = this.player.addShoot();
+
+ game.lastShotTime = Date.now();
+ game.shoot(shoot);
+ }
}
if(this.bombing == true)
{
@@ -146,12 +147,13 @@ var Controls = function(player) { //, domElement
this.player.model.mesh.updateMatrix();
this.player.updateFromControl();
};
-
- this.dropBomb = function()
- {
- var bomb = this.player.addBomb(this.bombPower);
- game.bomb(bomb);
- this.bombPower = 0;
- this.firstPush = true;
- }
+
+ this.dropBomb = function()
+ {
+ var bomb = this.player.addBomb(this.bombPower);
+ game.lastBombTime = Date.now();
+ game.bomb(bomb);
+ this.bombPower = 0;
+ this.firstPush = true;
+ }
}
2  client/js/Player.js
View
@@ -40,7 +40,6 @@ var Player = function(data)
//we may need a 'Shoot' or 'Bullet' class at some point, but not for now
var shoot = new ShootModel(this);
this.shoots.push(shoot);
- game.lastShotTime = Date.now();
return shoot;
}
@@ -70,7 +69,6 @@ var Player = function(data)
// bomb only if cooldown ok
var bomb = new BombModel(this,power);
this.bombs.push(bomb);
- game.lastBombTime = Date.now();
return bomb
}
Please sign in to comment.
Something went wrong with that request. Please try again.