Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Impact Game</title>
- <style type="text/css">
- html,body {
- background-color: #333;
- color: #fff;
- font-family: helvetica, arial, sans-serif;
- margin: 0;
- padding: 0;
- font-size: 12pt;
- }
- #canvas {
- position: absolute;
- left: 0;
- right: 0;
- top: 0;
- bottom: 0;
- margin: auto;
- }
- </style>
- <script type="text/javascript" src="https://cdn.socket.io/socket.io-1.0.6.js"></script>
- <script type="text/javascript" src="lib/impact/impact.js"></script>
- <script type="text/javascript" src="lib/game/main.js"></script>
- </head>
- <body>
- <script type="text/javascript">
- var players = [];
- var self;
- var sock = io.connect('http://localhost:3000');
- sock.on('addNetPlayer',function(x, y, index){
- console.log('addNetPlayer called');
- var newplayer = ig.game.spawnEntity(EntityNetPlayer,x,y);
- newplayer.id= index;
- players.push(newplayer);
- sock.emit('doYouKnowMe', self.id, self.pos.x, self.pos.y);
- console.log(x+' '+y+' '+' '+id);
- });
- sock.on('doYouKnowMe', function(id, x, y){
- console.log('doYouKnowMe called');
- var find = false;
- for(var i=0; i < players.length; i++)
- {
- if (players[i].id == id)
- {
- find = true;
- break;
- }
- }
- if (!find)
- {
- var newplayer = ig.game.spawnEntity(EntityNetPlayer,x,y);
- newplayer.id= id;
- players.push(newplayer);
- }
- });
- //why null ?
- var h = ig.game.spawnEntity(EntityHeart,100,100);
- //console.log(h);
- </script>
- <canvas id="canvas"></canvas>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement