1faithplate = class:new() 2 3function faithplate:init(x, y, dir) 4 self.cox = x 5 self.coy = y 6 self.dir = dir 7 8 self.x = x-1 9 self.y = y-1 10 self.width = 2 11 self.height = 0.125 12 self.active = true 13 self.static = true 14 self.category = 26 15 16 self.mask = {true} 17 18 self.animationtimer = 1 19 20 self.includetable = {"player", "box", "goomba"} 21end 22 23function faithplate:update(dt) 24 if self.animationtimer < 1 then 25 self.animationtimer = self.animationtimer + dt / faithplatetime 26 end 27 28 local intable = checkrect(self.x+.5, self.y-0.125, 1, 0.125, self.includetable) 29 30 for i = 1, #intable, 2 do 31 if self.dir == "up" then 32 objects[intable[i]][intable[i+1]].speedy = -40 33 elseif self.dir == "right" then 34 objects[intable[i]][intable[i+1]].speedy = -30 35 objects[intable[i]][intable[i+1]].speedx = 30 36 elseif self.dir == "left" then 37 objects[intable[i]][intable[i+1]].speedy = -30 38 objects[intable[i]][intable[i+1]].speedx = -30 39 end 40 41 if objects[intable[i]][intable[i+1]].faithplate then 42 objects[intable[i]][intable[i+1]]:faithplate(self.dir) 43 end 44 45 self.animationtimer = 0 46 end 47end 48 49function faithplate:draw() 50 love.graphics.setScissor(math.floor((self.cox-1-xscroll)*16*scale), (self.coy-4)*16*scale, 32*scale, (2.5+2/16)*16*scale) 51 52 love.graphics.setColor(unpack(backgroundcolor[background])) 53 love.graphics.rectangle("fill", math.floor((self.cox-1-xscroll)*16*scale), (self.coy-1.5)*16*scale, 32*scale, 2*scale) 54 love.graphics.setColor(255, 255, 255) 55 56 if self.animationtimer < 1 then 57 if self.dir == "right" then 58 local rot = 0 59 if self.animationtimer < 0.1 then 60 rot = math.pi/4*(self.animationtimer/0.1) 61 elseif self.animationtimer < 0.3 then 62 rot = math.pi/4 63 else 64 rot = math.pi/4*(1 - (self.animationtimer-0.3)/0.7) 65 end 66 67 love.graphics.draw(faithplateplateimg, math.floor((self.cox+1-xscroll)*16*scale), (self.coy-1.5)*16*scale, rot, scale, scale, 32) 68 elseif self.dir == "left" then 69 local rot = 0 70 if self.animationtimer < 0.1 then 71 rot = math.pi/4*(self.animationtimer/0.1) 72 elseif self.animationtimer < 0.3 then 73 rot = math.pi/4 74 else 75 rot = math.pi/4*(1 - (self.animationtimer-0.3)/0.7) 76 end 77 78 love.graphics.draw(faithplateplateimg, math.floor((self.cox-1-xscroll)*16*scale), (self.coy-1.5)*16*scale, -rot, -scale, scale, 32) 79 elseif self.dir == "up" then 80 local ymod = 0 81 if self.animationtimer < 0.1 then 82 ymod = .5*(self.animationtimer/0.1) 83 elseif self.animationtimer < 0.3 then 84 ymod = .5 85 else 86 ymod = .5*(1 - (self.animationtimer-0.3)/0.7) 87 end 88 89 love.graphics.draw(faithplateplateimg, math.floor((self.cox-1-xscroll)*16*scale), (self.coy-1.5-ymod)*16*scale, 0, scale, scale) 90 end 91 else 92 if self.dir ~= "left" then 93 love.graphics.draw(faithplateplateimg, math.floor((self.cox-1-xscroll)*16*scale), (self.coy-1.5)*16*scale, 0, scale, scale) 94 else 95 love.graphics.draw(faithplateplateimg, math.floor((self.cox+1-xscroll)*16*scale), (self.coy-1.5)*16*scale, 0, -scale, scale) 96 end 97 end 98 99 love.graphics.setScissor() 100end