diff --git a/README.md b/README.md
index 223c339..13eae6e 100644
--- a/README.md
+++ b/README.md
@@ -53,7 +53,3 @@ Legal: http://opensource.org/licenses/MIT
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/hgouveia/html5multiplayer/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
-
-
-[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/hgouveia/html5multiplayer/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
-
diff --git a/index.html b/index.html
index 68ebaf3..c70d7fd 100644
--- a/index.html
+++ b/index.html
@@ -1,9 +1,19 @@
+
@@ -24,5 +34,20 @@
Block Multiplayer
ga('send', 'pageview');
+
+
+
+
diff --git a/scripts/game/entities/player.js b/scripts/game/entities/player.js
index 99e61af..b415b87 100644
--- a/scripts/game/entities/player.js
+++ b/scripts/game/entities/player.js
@@ -20,7 +20,7 @@ var Player = function(_name,_x,_y,_angle,_life,_color,_isLocalPlayer){
lastX = 0, lastY = 0, elapseTime;
//Update var helpers
- var lastState = false; var time=0; flickeringToggle=false;
+ var lastState = false, time=0, flickeringToggle=false;
//Public
this.x = 0, this.y = 0, this.id = 0,this.angle = 0;
diff --git a/server/server.js b/server/server.js
index b29a66f..976c66d 100644
--- a/server/server.js
+++ b/server/server.js
@@ -5,11 +5,16 @@ var util = require("util"), // Utility resources (logging, object inspection
var port = 3478;
var expressServer;
-var clients;
+var clients= [],
+ players= [],
+ logPlayers= [],
+ enableLogPlayer = true;
//Initializ the server
function initialize(){
- players = clients = [];
+ players = [];
+ logPlayers = [];
+ clients = [];
expressServer = app.listen(port);
@@ -51,6 +56,10 @@ function socketEvents(client) {
//[MSG] General message: emitted from onPlayerDead [DEP] event only for now
//[KLL] Player Kill: emitted from onPlayerDead [DEP] event
+ //update log player
+ if(enableLogPlayer){
+ updatelogPlayer(client.id);
+ }
};
@@ -94,6 +103,9 @@ function onNewPlayer(data) {
// Add new player to the players array
players.push(newPlayer);
+ if(enableLogPlayer){
+ logPlayers.push(newPlayer);
+ }
};
// Player has moved
@@ -174,7 +186,22 @@ function playerById(id) {
return false;
};
+//Update the player info in the logPlayer array
+function updatelogPlayer(id){
+
+ var player = playerById(id);
+
+ if (player){
+ for (var i = 0; i < logPlayers.length; i++) {
+ if (logPlayers[i].id == id){
+ logPlayers[i] = player;
+ break;
+ }
+ };
+
+ }
+}
/*_____________EXPRESS_________*/
var app = express();
app.set('views', __dirname + '/views');
@@ -188,7 +215,12 @@ app.get('/', function (req, res) {
});
app.get('/list', function (req, res) {
- res.render('playerlist', { players: players });
+ var params = {
+ "players" : players,
+ "logPlayers" : logPlayers,
+ "enableLogPlayer" : enableLogPlayer
+ };
+ res.render('playerlist', params);
});
/// catch 404 and forwarding to error handler
diff --git a/server/views/playerlist.html b/server/views/playerlist.html
index eeb631a..16ca58f 100644
--- a/server/views/playerlist.html
+++ b/server/views/playerlist.html
@@ -1,4 +1,5 @@
<% layout('layout') -%>
+
Active Players
|
@@ -25,4 +26,34 @@
<% } %>
-
\ No newline at end of file
+
+<% if (enableLogPlayer){ %>
+
History Players
+
+
+ |
+ Name |
+ Life |
+ Dead |
+ Kill |
+ X |
+ Y |
+ ID |
+
+ <% for (var i = 0; i < logPlayers.length; i++) {
+ var player = logPlayers[i];
+ %>
+
+ <%= (i+1) %> |
+ <%= player.name %> |
+ <%= player.getLife() %> |
+ <%= player.getDead() %> |
+ <%= player.getKill() %> |
+ <%= player.x %> |
+ <%= player.y %> |
+ <%= player.id %> |
+
+ <% } %>
+
+
+<% } %>
\ No newline at end of file