mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
added first damage and killing
This commit is contained in:
parent
2a4327c5cf
commit
f22e0dd53d
9 changed files with 124 additions and 52 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue