/ld28

To get this branch, use:
bzr branch /bzr/ld28

« back to all changes in this revision

Viewing changes to util.lua

  • Committer: Josh C
  • Date: 2013-12-14 20:49:59 UTC
  • Revision ID: josh@9ix.org-20131214204959-sbwlos88we9pckgo
... add the map.  and the extra code to work w/ it.

Show diffs side-by-side

added added

removed removed

 
1
util = {
 
2
   dim = function(dir)
 
3
      if dir == 'x' then
 
4
         return 'width'
 
5
      elseif dir == 'y' then
 
6
         return 'height'
 
7
      else
 
8
         if STRICT then error('dir '..dir) end
 
9
      end
 
10
   end,
 
11
   dirToXY = function(dir)
 
12
                if dir == 'up' or dir == 'down' then
 
13
                   return 'y'
 
14
                elseif dir == 'left' or dir == 'right' then
 
15
                   return 'x'
 
16
                else
 
17
                   error('bad direction')
 
18
                end
 
19
             end,
 
20
   dirToPosNeg = function(dir)
 
21
                    if dir == 'up' or dir == 'left' then
 
22
                       return -1
 
23
                    elseif dir == 'down' or dir == 'right' then
 
24
                       return 1
 
25
                    else
 
26
                       error('bad direction')
 
27
                    end
 
28
                 end
 
29
}