- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
Latest commit
30 lines (26 loc) · 875 Bytes
/
Copy pathserver.js
File metadata and controls
30 lines (26 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
varexpress=require('express');
varapp=express();
varserver=require('http').Server(app);
vario=require('socket.io').listen(server);
varPlayer=require('./server/models/player/player')
varBundler=require('parcel-bundler');
varpath=require('path');
app.get('/',(req,res)=>{
res.sendFile(__dirname+'/client/index.html')
})
app.use('/client',express.static(__dirname+'/client'));
server.listen(8000,()=>{
console.log(`App now listening on port 8000`);
});
io.on('connect',(socket)=>{
socket.on('connect',(data)=>{
newPlayer(players.length+1,Math.random(0,5000),Math.random(0,5000),data.hero,0);
Player.onConnect(io,socket);
})
socket.on('move',(data)=>{
Player.onMove(data.targX,data.targY);
})
socket.on('disconnect',()=>{
Player.onDisconnect(io,socket);
})
})