summaryrefslogtreecommitdiff
path: root/server/Entities/Entity.js
blob: 04ea6b3d0f93b4efd6b3ff62cabb77ffd738131b (plain) (blame)
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
30
31
var initPack = { player: [], bullet: [] };
var removePack = { player: [], bullet: [] };

var Entity = function ()
{
    var self = {
        x: 250,
        y: 250,
        map: '002-1',
        speedX: 0,
        speedY: 0,
        id: "",
    }
    self.update = function ()
    {
        self.updatePosition();
    }
    self.updatePosition = function ()
    {
        self.x += self.speedX;
        self.y += self.speedY;
    }
    self.getDistance = function (pt)
    {
        return Math.sqrt(Math.pow(self.x - pt.x, 2)) + Math.pow(self.y - pt.y, 2);
    }
    return self;
}

module.exports = { Entity, initPack, removePack };