1spring = class:new() 2 3function spring:init(x, y) 4 self.cox = x 5 self.coy = y 6 7 --PHYSICS STUFF 8 self.x = x-1 9 self.y = y-31/16 10 self.width = 16/16 11 self.height = 31/16 12 self.static = true 13 self.active = true 14 15 self.drawable = false 16 17 self.timer = springtime 18 19 self.category = 19 20 21 self.mask = {true} 22 23 self.frame = 1 24end 25 26function spring:update(dt) 27 if self.timer < springtime then 28 self.timer = self.timer + dt 29 if self.timer > springtime then 30 self.timer = springtime 31 end 32 self.frame = math.ceil(self.timer/(springtime/3)+0.001)+1 33 if self.frame > 3 then 34 self.frame = 6-self.frame 35 end 36 end 37end 38 39function spring:draw() 40 love.graphics.drawq(springimg, springquads[spriteset][self.frame], math.floor((self.x-xscroll)*16*scale), (self.y*16-8)*scale, 0, scale, scale) 41end 42 43function spring:hit() 44 self.timer = 0 45end