NeutronLoved/objects/tutorial.lua

46 lines
1.1 KiB
Lua

local gen = {}
function gen:new(game,x,y)
local sprite = game:newImage("question.png")
local w = sprite:getWidth()
local h = sprite:getHeight()
local tut = game.objects.base:new(game,x-w/2,y-h/2,w,h)
tut.questionsprite = sprite
tut.closesprite = game:newImage("close.png")
tut.tutorialsprite = game:newImage("tutorial.png")
tut.sprite = sprite
tut.showing = false
tut.basedrawy = game.HEIGHT
tut.objectivedrawy = (game.HEIGHT-tut.tutorialsprite:getHeight())/2
tut.drawy = tut.basedrawy
tut.depth = 3
function tut:step(dt)
local obj = self.basedrawy
self.sprite = self.questionsprite
if self.showing then
self.sprite = self.closesprite
obj = self.objectivedrawy
end
self.drawy = self.drawy + (obj-self.drawy)*dt*5
end
function tut:MouseCallback(x,y,presses)
if self.rect:collidepoint(x,y) then self.showing = not self.showing end
end
function tut:draw()
local s = self.tutorialsprite
lg.draw(s,(self.game.WIDTH-s:getWidth())/2,self.drawy)
lg.draw(self.sprite,self.rect.x-self.game.camerax,self.rect.y-self.game.cameray)
end
return tut
end
return gen