Created
February 23, 2012 01:09
-
-
Save kevinmeziere/1888928 to your computer and use it in GitHub Desktop.
Wednesday File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function gameLoop(willRun){ | |
var i = 0; | |
while(i < 5){ | |
console.log("looping in gameLoop"); | |
for(var event in pendingEvents){ | |
var curEvent = pendingEvents[event]; | |
curEvent.call(curEvent.arguments[0]); | |
} | |
pendingEvents = null; | |
pendingEvents = []; | |
if(i == 2){ | |
var args = ["steve"]; | |
var tmp = new pendingEventType(hello, args); | |
pendingEvents.push(tmp); | |
} | |
i++; | |
} | |
} | |
var pendingEvents = []; | |
function pendingEventType(functionToCall, arrayOfArgs){ | |
this.call = functionToCall; | |
this.arguments = arrayOfArgs; | |
} | |
pendingEventType.prototype = { | |
call: null, | |
arguments: [] | |
} | |
function hello(name){ | |
console.log("Hello " + name); | |
} | |
function monster(name, furColor) { | |
this.name = name; | |
this.color = furColor; | |
} | |
monster.prototype = { | |
eyes: 2, | |
feet: 2, | |
mouth: "full", | |
hands: 2, | |
name: null, | |
color: null, | |
fur: true, | |
_health:100, | |
_healthChangeMultiplier:0, | |
health : function(value){ | |
if(value){ | |
if(value > 0 && value <=100) | |
_health = value; | |
} | |
else | |
return_health; | |
} | |
}; | |
/*** cookieMonster Prototype ***/ | |
function cookieMonster(name, furColor, addiction) { | |
monster.call(this, name, furColor); | |
this.addictedTo = addiction; | |
} | |
cookieMonster.prototype = new monster(); | |
cookieMonster.prototype.addictedTo = null; | |
cookieMonster.prototype._guns = 0; | |
cookieMonster.prototype.guns = function(value){ | |
if(value){ | |
if(value >= 0 && value <=10){ | |
this._guns = value; | |
} | |
} | |
}; | |
/*** elmoMonster Prototype ***/ | |
function elmoMonster(name, cash){ | |
this.name = name; | |
this.color = "red"; | |
this.cashOnHand = cash; | |
this.knifeCount = knifes | |
} | |
elmoMonster.protoype = new monster(); | |
elmoMonster.protoype.cashOnHand = 0; | |
elmoMonster.protoype._knives = 0; | |
elmoMonster.prototype.knives = function(value){ | |
if(value){ | |
if(value >= 0 && value <=10){ | |
this._knives = value; | |
} | |
} | |
else{ | |
return this._knives; | |
} | |
}; | |
elmoMonster.prototype.throwKnife = function(){ | |
this.knives(this.knives()-1); | |
//event for knife thrown | |
}; | |
gameLoop(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment