Advertisement
papyhardcore

index.html

Aug 7th, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.36 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <title>Impact Game</title>
  5.         <style type="text/css">
  6.             html,body {
  7.                 background-color: #333;
  8.                 color: #fff;
  9.                 font-family: helvetica, arial, sans-serif;
  10.                 margin: 0;
  11.                 padding: 0;
  12.                 font-size: 12pt;
  13.             }
  14.  
  15.             #canvas {
  16.                 position: absolute;
  17.                 left: 0;
  18.                 right: 0;
  19.                 top: 0;
  20.                 bottom: 0;
  21.                 margin: auto;
  22.             }
  23.         </style>
  24.         <script type="text/javascript" src="https://cdn.socket.io/socket.io-1.0.6.js"></script>
  25.         <script type="text/javascript" src="lib/impact/impact.js"></script>
  26.         <script type="text/javascript" src="lib/game/main.js"></script>
  27.  
  28.     </head>
  29.     <body>
  30.         <script type="text/javascript">
  31.             var players = [];
  32.  
  33.             var self;
  34.            
  35.             var window.sock = io.connect('http://localhost:3000');            
  36.  
  37.            
  38.            
  39.             window.sock.on('addNetPlayer',function(x, y, index){
  40.                console.log('addNetPlayer called');
  41.                
  42.                var newplayer = ig.game.spawnEntity(EntityNetPlayer,x,y);
  43.                newplayer.id= index;
  44.  
  45.                players.push(newplayer);
  46.  
  47.                window.sock.emit('doYouKnowMe', self.id, self.pos.x, self.pos.y);
  48.  
  49.                console.log(x+' '+y+' '+' '+id);
  50.             });
  51.  
  52.             window.sock.on('doYouKnowMe', function(id, x, y){
  53.                 console.log('doYouKnowMe called');
  54.                 var find = false;
  55.                 for(var i=0; i < players.length; i++)
  56.                {
  57.                    if (players[i].id == id)
  58.                    {
  59.                        find = true;
  60.                        break;
  61.                    }
  62.                }
  63.                if (!find)
  64.                {
  65.                    var newplayer = ig.game.spawnEntity(EntityNetPlayer,x,y);
  66.                    newplayer.id= id;
  67.                    
  68.                    players.push(newplayer);
  69.                }
  70.            });
  71.  
  72.            //why null ?
  73.            var h = ig.game.spawnEntity(EntityHeart,100,100);
  74.            //console.log(h);
  75.  
  76.  
  77.        </script>
  78.         <canvas id="canvas"></canvas>
  79.  
  80.     </body>
  81. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement