From 3d9da1ec9e45e8bd16e8b784c048ddf89e109e65 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Tue, 27 Dec 2011 11:56:16 +0100 Subject: [PATCH] bpong-client improved incl. player ctr --- tools/game/bong/bong.html | 10 ++++++++++ tools/game/bong/bong.js | 22 ++++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/tools/game/bong/bong.html b/tools/game/bong/bong.html index bb00663..39f122b 100644 --- a/tools/game/bong/bong.html +++ b/tools/game/bong/bong.html @@ -28,6 +28,14 @@ div } div.score +{ + color: #33FF33; + background-color: transparent; + width: 640px; + font-size: 20px; + font-family: courier new; +} +div.player { color: #33FF33; background-color: transparent; @@ -46,5 +54,7 @@ div.score
s_data...
debug
+
0
+
0
diff --git a/tools/game/bong/bong.js b/tools/game/bong/bong.js index d172cc0..bfe79ea 100644 --- a/tools/game/bong/bong.js +++ b/tools/game/bong/bong.js @@ -1,5 +1,5 @@ // Initialisation -var socket = "ws://83.133.179.198:8888/data"; +var socket = "ws://127.0.0.1:8888/data"; var field= { w: 320, h: 240 }; var paddle = { w: 2, h: 30 }; var ball = { w: 5, h: 5, s: 5 }; @@ -12,6 +12,9 @@ function pong() { this.score = {}; this.score.left = {}; this.score.right = {}; + this.cnt = {}; + this.cnt.left = {}; + this.cnt.right = {}; this.field = {}; this.game = { run: 0 }; @@ -40,6 +43,12 @@ function pong() { setupavatar(this.right); setupavatar(this.field); + this.cnt.left.avatar=$('div#player_left'); + this.cnt.right.avatar=$('div#player_right'); + + $('div#player_left').css({top: 2*this.field.size.h-30}); + $('div#player_right').css({top: 2*this.field.size.h-30}); + this.field.avatar.focus(); this.score.left.pts=0; @@ -209,10 +218,15 @@ pong.prototype.socketstart = function(uri){ var result=JSON.parse(data); if (result.right){ this.setright(result.right); - } else if (result.left){ + } ; + if (result.left){ this.setleft(result.left); - }else { - // unknown json input + }; + if (result.cntl){ + this.cnt.left.avatar.html(result.cntl); + }; + if (result.cntr){ + this.cnt.right.avatar.html(result.cntr); }; }else{ // unknown non-json input