/ld28

To get this branch, use:
bzr branch http://9ix.org/bzr/ld28

« back to all changes in this revision

Viewing changes to util.lua

  • Committer: Josh C
  • Date: 2013-12-14 02:57:47 UTC
  • Revision ID: josh@9ix.org-20131214025747-etw31g9vii33qvey
zoetrope 1.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
}