/ld27

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

« back to all changes in this revision

Viewing changes to zoetrope/sprites/tile.lua

  • Committer: Josh C
  • Date: 2014-07-05 00:05:23 UTC
  • Revision ID: josh@9ix.org-20140705000523-qxhxpi5ixst875zb
control by touch ("mouse")

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
                        self._quad = love.graphics.newQuad(self.imageOffset.x, self.imageOffset.y,
48
48
                                                                                           self.width, self.height,
49
49
                                                                                           self._imageObj:getWidth(), self._imageObj:getHeight())
50
 
                        self._imageObj:setWrap('repeat', 'repeat')
 
50
                        --self._imageObj:setWrap('repeat', 'repeat')
51
51
                        self._set.image = self.image
52
52
                        self._set.imageOffset.x = self.imageOffset.x
53
53
                        self._set.imageOffset.y = self.imageOffset.y
88
88
                -- draw the quad
89
89
                local scaleX = self.scale * self.distort.x
90
90
                local scaleY = self.scale * self.distort.y
 
91
                local origX = self.origin.x or (self.width / 2)
 
92
                local origY = self.origin.y or (self.height / 2)
91
93
 
92
94
                if self.flipX then scaleX = scaleX * -1 end
93
95
                if self.flipY then scaleY = scaleY * -1 end
94
96
 
95
97
    if map then
96
 
       batches = map.spriteBatches
97
 
 
98
 
       if not batches[self.image] then
99
 
          --batches:addBatch(self.image, self._imageObj)
100
 
          local maph, mapw = map:getMapSize()
101
 
          batches[self.image] = love.graphics.newSpriteBatch(self._imageObj, mapw * maph)
102
 
          print('adding new batch')
103
 
       end
104
 
 
105
 
       batches[self.image]:addq(self._quad, x + self.width / 2, y + self.height / 2, self.rotation, scaleX, scaleY, self.width / 2, self.height / 2)
 
98
      batches = map and map.spriteBatches
 
99
 
 
100
      if not batches[self.image] then
 
101
        --batches:addBatch(self.image, self._imageObj)
 
102
        local maph, mapw = map:getMapSize()
 
103
        batches[self.image] = love.graphics.newSpriteBatch(self._imageObj, mapw * maph)
 
104
        print('adding new batch')
 
105
      end
 
106
 
 
107
      batches[self.image]:add(self._quad, x + origX, y + origY,self.rotation,
 
108
                              scaleX, scaleY, origX, origY)
106
109
    else
107
 
 
108
 
       love.graphics.drawq(self._imageObj, self._quad, x + self.width / 2, y + self.height / 2, self.rotation,
109
 
                           scaleX, scaleY, self.width / 2, self.height / 2)
110
 
                end
111
 
 
 
110
      love.graphics.draw(self._imageObj, self._quad, x + origX, y + origY,
 
111
                         self.rotation, scaleX, scaleY, origX, origY)
 
112
    end
 
113
                
112
114
                -- reset color
113
115
                
114
116
                if colored then
117
119
        end,
118
120
 
119
121
        __tostring = function (self)
120
 
                local result = 'Tile (x: ' .. self.x .. ', y: ' .. self.y ..
121
 
                                           ', w: ' .. self.width .. ', h: ' .. self.height .. ', '
 
122
                local result = 'Tile (x: ' .. tostring(self.x) .. ', y: ' .. tostring(self.y) ..
 
123
                                           ', w: ' .. tostring(self.width) .. ', h: ' .. tostring(self.height) .. ', '
122
124
 
123
125
                result = result .. 'image \'' .. self.image .. '\', '
124
126