mirror of
https://github.com/ctruLua/ctruLua.git
synced 2025-10-27 16:39:29 +00:00
Changed spaces to tabs, Fixed a potential bug, Removed debug stuff
This commit is contained in:
parent
a4a6e09d74
commit
e8471ce6e6
1 changed files with 18 additions and 19 deletions
|
|
@ -4,31 +4,30 @@ local mod = {}
|
|||
|
||||
-- Module functions
|
||||
local function getBox(tx, ty, i, sx, sy)
|
||||
--i = i - 1
|
||||
x = (i%tx)
|
||||
y = math.floor(i/tx)
|
||||
x = (i%tx)
|
||||
y = math.floor(i/tx)
|
||||
|
||||
return (x*sx), (y*sy)
|
||||
end
|
||||
|
||||
-- Sprite object methods
|
||||
local function draw(self, x, y, rad)
|
||||
if not self.animations[self.currentAnimation] then return 0 end
|
||||
local frame = self.animations[self.currentAnimation].animation[self.currentFrame]
|
||||
local tsx, tsy = self.texture:getSize()
|
||||
|
||||
local sx, sy = getBox(tsx, tsy, frame, self.frameSizeX, self.frameSizeY)
|
||||
gfx.text(200, 200, sx.."/"..sy)
|
||||
self.texture:drawPart(x, y, sx, sy, self.frameSizeX, self.frameSizeY, rad)
|
||||
if not self.animations[self.currentAnimation] then return 0 end
|
||||
|
||||
if (ctr.time()-self.frameTimer) >= self.animations[self.currentAnimation].delay then
|
||||
self.currentFrame = (self.currentFrame+1)
|
||||
self.frameTimer = ctr.time()
|
||||
if self.currentFrame > #self.animations[self.currentAnimation].animation then
|
||||
self.currentFrame = 1
|
||||
end
|
||||
self.currentFrame = (self.currentFrame+1)
|
||||
self.frameTimer = ctr.time()
|
||||
if self.currentFrame > #self.animations[self.currentAnimation].animation then
|
||||
self.currentFrame = 1
|
||||
end
|
||||
end
|
||||
|
||||
local frame = self.animations[self.currentAnimation].animation[self.currentFrame]
|
||||
local tsx, tsy = self.texture:getSize()
|
||||
|
||||
local sx, sy = getBox(tsx, tsy, frame, self.frameSizeX, self.frameSizeY)
|
||||
self.texture:drawPart(x, y, sx, sy, self.frameSizeX, self.frameSizeY, rad)
|
||||
|
||||
return frame
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue