Refactored "add state" for entities and players

This commit is contained in:
Jeremiah Billmann
2013-07-14 14:29:09 -04:00
parent 5a778589ea
commit bbaf13baab
3 changed files with 22 additions and 11 deletions
+4
View File
@@ -9,6 +9,10 @@ function Entity (id) {
Entity.prototype = {
addState: function (state, executionTime) {
this.addHistory(state, executionTime);
this.sequence += 1;
},
addHistory: function (state, executionTime) {
var minTime, spliceTo = 0;
this.state = state;
this.stateHistory.push({ state: state, executionTime: executionTime });
+7 -1
View File
@@ -8,4 +8,10 @@ function Player (client) {
this.inputs = [];
}
Player.prototype = Object.create(entity.prototype);
Player.prototype = Object.create(entity.prototype);
Player.prototype.addState = function (state, executionTime) {
this.addHistory(state, executionTime);
this.sequence += this.inputs.length;
this.inputs = [];
};