added first damage and killing

This commit is contained in:
Jeena 2014-01-21 03:14:50 +01:00
parent 2a4327c5cf
commit f22e0dd53d
9 changed files with 124 additions and 52 deletions

View file

@ -1,12 +1,19 @@
define([
"Game/" + GLOBALS.context + "/GameObjects/Doll",
"Game/Config/Settings"
"Game/Config/Settings",
"Lib/Utilities/NotificationCenter"
],
function (Doll, Settings) {
function (Doll, Settings, NotificationCenter) {
function Player (id, physicsEngine) {
this.stats = {
health: 100,
deaths: 0,
kills: 0
}
this.physicsEngine = physicsEngine;
this.playerController = null;
this.doll;
@ -20,6 +27,9 @@ function (Doll, Settings) {
};
Player.prototype.spawn = function (x, y) {
if(this.doll) {
this.doll.destroy();
}
this.doll = new Doll(this.physicsEngine, "doll-" + this.id, this);
this.doll.spawn(x, y);
this.isSpawned = true;
@ -64,6 +74,10 @@ function (Doll, Settings) {
this.holdingItem = null;
};
Player.prototype.kill = function(killedBy) {
NotificationCenter.trigger("player/killed", this);
};
Player.prototype.update = function () {
if(this.doll) {