Permalink
Browse files

Replace undescore.js with prelude.ls

  • Loading branch information...
1 parent ae53767 commit f212f1d6a4d663451e2938db76c2e01f5dd2a06a @lessandro committed Nov 28, 2012
Showing with 22 additions and 17 deletions.
  1. +1 −1 .gitignore
  2. +1 −1 index.html
  3. +5 −0 lib/prelude.min.js
  4. +8 −6 src/_entity.ls
  5. +3 −5 src/input.ls
  6. +4 −4 src/level.ls
View
@@ -1,3 +1,3 @@
-*.js
+dave.js
copy
tmp
View
@@ -4,7 +4,7 @@
<meta charset="utf-8">
<title>get the trophy, go thru the door</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
- <script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.2/underscore-min.js"></script>
+ <script src="lib/prelude.min.js"></script>
<script src="dave.js"></script>
<script type="text/javascript">
$(Game.main);
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -19,10 +19,12 @@ class Entity
clipped: (direction) ->
tiles = @touching-tiles!
- map =
- \up : [tiles[0+0].tile, tiles[0+1].tile]
- \down : [tiles[2+0].tile, tiles[2+1].tile]
- \left : [tiles[0+0].tile, tiles[2+0].tile]
- \right : [tiles[0+1].tile, tiles[2+1].tile]
+ mapping =
+ \up : [0 1]
+ \down : [2 3]
+ \left : [0 2]
+ \right : [1 3]
- return _.any _.map map[direction], Tile.is-solid
+ tiles = [tiles[i].tile for i in mapping[direction]]
+
+ return any Tile.is-solid, tiles
View
@@ -9,14 +9,12 @@ class Input
->
@clear!
- handler = _.bind @handler, this
-
# assign handler
$ document.body
- .on \keydown, handler
- .on \keyup, handler
+ .on \keydown, @handler
+ .on \keyup, @handler
- handler: (e) ->
+ handler: (e) ~>
key = keymap[e.which]
return true unless key
View
@@ -91,13 +91,13 @@ class Level
@tiles[j][i] = ' '
tick: ->
- dead = []
+ alive = []
for entity in @entities
entity.tick()
- if entity.dead
- dead.push(entity)
+ if !entity.dead
+ alive.push(entity)
- @entities = _.difference @entities, dead
+ @entities = alive
draw: ->
w = 18 * Tile.size

0 comments on commit f212f1d

Please sign in to comment.