Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
woops forgot a file
  • Loading branch information
lauxley committed Oct 27, 2011
1 parent 5904e38 commit 756df73
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/index.html
Expand Up @@ -3,9 +3,9 @@
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script src="/socket.io/socket.io.js"></script>
<script src="lib/Three.js"></script>
<script src="js/Player.js"></script>
<script src="js/Game.js"></script>
<script src="js/Mesh.js"></script>
<script src="js/Player.js"></script>

<meta charset="utf-8">

Expand Down
43 changes: 43 additions & 0 deletions client/js/Game.js
@@ -0,0 +1,43 @@
var HOST = '192.168.0.10';
var PORT = 8000;

function Game() {

this.players = new players();

this.info = function(msg) {
console.log(msg);
};

this.move = function(x, y) {
socket.emit('move', '{"x":'+x+', "y":'+y+'}');
};

this.init = function() {
var socket = io.connect(HOST, {port:PORT});
var game = this;

socket.on('connect', function (data) {
game.info('connected!');
});

socket.on('welcome', function(data) {
game.info('I am '+data.id+' Spawn point: x='+data.x+' y='+data.y);
init();
game.players.makeMe(data);
});

socket.on('new_player', function(data) {
game.info('New player '+data.id+' Spawn point: x='+data.x+' y='+data.y);
game.players.makePlayerParticle(data);
});

socket.on('players', function (data) {
game.players.updateOtherParticles(data);
});

socket.on('this.info', function (data) {
game.info(data);
});
};
};
14 changes: 7 additions & 7 deletions client/js/Player.js
@@ -1,14 +1,14 @@
// initialisation des particules des joueurs
var players = {
particles : [],
me : null,
function players() {
this.particles = [],
this.me = null,

makeMe : function(data)
this.makeMe = function(data)
{
this.me = makeParticle(data);
},

makePlayerParticles : function(data)
this.makePlayerParticles = function(data)
{
for(var i = 0; i < data.length ; i++)
{
Expand All @@ -17,7 +17,7 @@ var players = {
},

// déplacement de la particule du joueur
moveMe : function (movingUp0, movingDown0, movingLeft0, movingRight0)
this.moveMe = function (movingUp0, movingDown0, movingLeft0, movingRight0)
{
if(movingUp0 == true && this.me.position.y < 780)
this.me.position.y += 10;
Expand All @@ -31,7 +31,7 @@ var players = {
},

// déplacement des autres particules
updateOtherParticles : function (data)
this.updateOtherParticles = function (data)
{
for(var i=0; i<data.length; i++)
{
Expand Down

0 comments on commit 756df73

Please sign in to comment.