/traderous

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

« back to all changes in this revision

Viewing changes to player.lua

  • Committer: Josh C
  • Date: 2013-06-16 03:32:01 UTC
  • Revision ID: josh@9ix.org-20130616033201-91uqlfnqa6cgo989
make sure every planet trades something

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
local velLimit = 400
23
23
--local velLimit = 50
24
 
SpacePlayer = WrapTile:extend{
 
24
SpacePlayer = Tile:extend{
25
25
   image = 'data/ship.png',
26
26
   maxVelocity = {x=velLimit,y=velLimit},
27
27
   minVelocity = {x=-velLimit, y=-velLimit},
28
28
   lastFired = 0,
 
29
   money = 2000, -- what to use for money symbol? ✪ or ☥ or Ⓐ?
 
30
   goods = {},
29
31
   onNew = function(self)
30
32
              self.thrust = Tile:new{image = 'data/thrust.png'}
31
33
           end,
95
97
                        )
96
98
                     end
97
99
                  end
98
 
               end
 
100
               end,
 
101
   buy = function(self, good, price)
 
102
            if self.money >= price then
 
103
               self.goods[good] = (self.goods[good] or 0) + 1
 
104
               self.money = self.money - price
 
105
            end
 
106
         end,
 
107
   sell = function(self, good, price)
 
108
             if self.goods[good] and self.goods[good] > 0 then
 
109
                self.goods[good] = self.goods[good] - 1
 
110
                self.money = self.money + price
 
111
             end
 
112
          end
99
113
}
 
 
b'\\ No newline at end of file'