diff --git a/front end/index.html b/front end/index.html index 9e440b7..8bc993c 100644 --- a/front end/index.html +++ b/front end/index.html @@ -36,12 +36,14 @@ var players = {}; - var bullets = {}; + var blocks = {}; socket.on("connected", function(data) { - players = data.player; - bullets = data.bullet; + console.log("got message connected"); + console.log(data); + players = data.players; + blocks = data.blocks; }); socket.on("update",function(data) @@ -56,6 +58,7 @@ function doKeyDown(e) { + console.log("key down"); socket.emit("keyUp",{"direction":e.keyCode}); } @@ -64,12 +67,12 @@ context.fillStyle = "#000000"; context.fillRect(0, 0, width, height); - for(var i = 0; i< bullets.length; i++) + for(var i = 0; i< blocks.length; i++) { if(bullets[i] != -1) { context.fillStyle = "rgba(255, 0, 199, 1)"; //pink - context.fillRect(bullets[i].x, bullets[i].y, 10,10); + context.fillRect(blocks[i].x, blocks[i].y, 10,10); } } diff --git a/front end/singlePlayer.html b/front end/singlePlayer.html index 6faf3c3..98dd3d6 100644 --- a/front end/singlePlayer.html +++ b/front end/singlePlayer.html @@ -1,5 +1,4 @@ - - + diff --git a/server/server.js b/server/server.js index 11bed20..9098701 100644 --- a/server/server.js +++ b/server/server.js @@ -5,19 +5,51 @@ * 2-22-18 */ -const app = require('express')(); -const http = require('http').Server(app); -const io = require('socket.io')(http); +var app = require('express')(); +var http = require('http').Server(app); +var io = require('socket.io')(http); -const PORT = 3000; +var PORT = 3000; -var players +var players = {}; -io.on('connection', function(socket) +var blocks = []; + + +var Player = function() { }; +io.on('connection', function(socket) +{ + var p = new Player(); + + console.log("user connected"); + + var initialState = new Object(); + initialState.players = players; + initialState.blocks = blocks; + + socket.emit('connected', initialState); + + socket.on('move', function(data) + { + + }); + + socket.on('shoot', function(data) + { + + }); + + socket.on('disconnect', function() + { + console.log("user disconnected"); + }) + +}); + http.listen(PORT, function() { console.log('listening on *:3000');