-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
48 additions
and
47 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,3 @@ | ||
$ -> | ||
console.log 'script.coffee' | ||
|
||
window.requestAnimationFrame = | ||
window.requestAnimationFrame or | ||
window.mozRequestAnimationFrame or | ||
window.webkitRequestAnimationFrame or | ||
window.msRequestAnimationFrame; | ||
|
||
theGame = new tag() | ||
|
||
window.step = () -> | ||
theGame.draw() | ||
window.requestAnimationFrame(window.step) | ||
|
||
window.requestAnimationFrame(window.step) | ||
theGame.anim() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,44 @@ | ||
tag = () -> | ||
|
||
window.requestAnimationFrame = | ||
window.requestAnimationFrame or | ||
window.mozRequestAnimationFrame or | ||
window.webkitRequestAnimationFrame or | ||
window.msRequestAnimationFrame | ||
|
||
|
||
this.display = new display 1024, 768 | ||
tag = () -> | ||
this.display = new disp 1024, 768 | ||
this.ctx = this.display.ctx | ||
|
||
thisTag = this | ||
|
||
this.agents = [] | ||
|
||
for i in [0..1000] | ||
this.agents.push new agent( | ||
Math.random()*this.display.width, | ||
Math.random()*this.display.height, | ||
Math.random()*2*Math.PI, | ||
Math.random()*2 | ||
) | ||
agentX = Math.random()*this.display.width | ||
agentY = Math.random()*this.display.height | ||
agentHeading = Math.random()*2*Math.PI | ||
agentSpeed = Math.random()*5 | ||
this.agents.push new | ||
agent agentX, agentY, agentHeading, agentSpeed | ||
|
||
this.anim = () -> | ||
window.requestAnimationFrame thisTag.step | ||
|
||
this.updateAgents = (agents, width, height) -> | ||
for a in this.agents | ||
a.update(agents, width, height) | ||
a.update agents, width, height | ||
|
||
this.drawAgents = () -> | ||
for p in this.agents | ||
p.draw(this.ctx) | ||
for a in this.agents | ||
a.draw this.ctx | ||
|
||
this.draw = () -> | ||
this.display.clear() | ||
this.updateAgents(this.agents, this.display.width, this.display.height) | ||
this.updateAgents this.agents, this.display.width, this.display.height | ||
this.drawAgents() | ||
this.display.draw() | ||
|
||
this.step = () -> | ||
thisTag.draw() | ||
window.requestAnimationFrame thisTag.step | ||
|
||
this |