summaryrefslogtreecommitdiff
path: root/server/Entities/Entity.js
blob: d65492dc80b73c6c1f325f22a70c399914ead586 (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
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 };