diff options
author | Aki <nthirtyone@gmail.com> | 2017-01-20 14:24:50 +0100 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2017-01-20 14:24:50 +0100 |
commit | ff957be7d38a3143aa89a798184a975af00998bc (patch) | |
tree | b038c8d9acbdbfb4d1cabe0a3865501e1b1dd131 | |
parent | 444eaa53c31704186cf38dbadfab1a5f014b78b4 (diff) | |
download | roflnauts-ff957be7d38a3143aa89a798184a975af00998bc.zip roflnauts-ff957be7d38a3143aa89a798184a975af00998bc.tar.gz roflnauts-ff957be7d38a3143aa89a798184a975af00998bc.tar.bz2 |
Animated platform test for Abyss small
-rw-r--r-- | animated.lua | 6 | ||||
-rw-r--r-- | assets/platforms/alpha-small-1.png | bin | 351 -> 0 bytes | |||
-rw-r--r-- | assets/platforms/alpha-small.png | bin | 0 -> 821 bytes | |||
-rw-r--r-- | ground.lua | 3 | ||||
-rw-r--r-- | maps/alpha abyss.lua | 25 | ||||
-rw-r--r-- | world.lua | 6 |
6 files changed, 31 insertions, 9 deletions
diff --git a/animated.lua b/animated.lua index de16195..160ee44 100644 --- a/animated.lua +++ b/animated.lua @@ -27,8 +27,10 @@ end -- Sets new animations list. function Animated:setAnimationsList(t) - self.animations = t - self:setAnimation("default") + if t then + self.animations = t + self:setAnimation("default") + end end -- Sets current animation by table key. diff --git a/assets/platforms/alpha-small-1.png b/assets/platforms/alpha-small-1.png Binary files differdeleted file mode 100644 index b3f1a01..0000000 --- a/assets/platforms/alpha-small-1.png +++ /dev/null diff --git a/assets/platforms/alpha-small.png b/assets/platforms/alpha-small.png Binary files differnew file mode 100644 index 0000000..cce324f --- /dev/null +++ b/assets/platforms/alpha-small.png @@ -17,7 +17,7 @@ Ground.__index = Ground setmetatable(Ground, Animated) -- Constructor of `Ground` -function Ground:new (game, world, x, y, shape, sprite) +function Ground:new (game, world, x, y, shape, sprite, animations) local o = {} setmetatable(o, self) o.body = love.physics.newBody(world, x, y) @@ -40,6 +40,7 @@ function Ground:new (game, world, x, y, shape, sprite) end -- END HERE o:setSprite(love.graphics.newImage(sprite)) + o:setAnimationsList(animations) o.world = game return o end diff --git a/maps/alpha abyss.lua b/maps/alpha abyss.lua index a3b6153..2df6adc 100644 --- a/maps/alpha abyss.lua +++ b/maps/alpha abyss.lua @@ -1,4 +1,20 @@ -- The abyss of the alpha. +local animations_small = { + default = { + [1] = love.graphics.newQuad(0, 0, 60,20, 600,20), + [2] = love.graphics.newQuad(60, 0, 60,20, 600,20), + [3] = love.graphics.newQuad(120, 0, 60,20, 600,20), + [4] = love.graphics.newQuad(180, 0, 60,20, 600,20), + [5] = love.graphics.newQuad(240, 0, 60,20, 600,20), + [6] = love.graphics.newQuad(300, 0, 60,20, 600,20), + [7] = love.graphics.newQuad(360, 0, 60,20, 600,20), + [8] = love.graphics.newQuad(420, 0, 60,20, 600,20), + [9] = love.graphics.newQuad(480, 0, 60,20, 600,20), + [10] = love.graphics.newQuad(540, 0, 60,20, 600,20), + frames = 10, + repeated = true + } +} return { -- GENERAL name = "alpha abyss", @@ -30,19 +46,22 @@ return { x = -145, y = -50, shape = {0,0, 59,0, 59,19, 0,19}, - sprite = "assets/platforms/alpha-small-1.png" + sprite = "assets/platforms/alpha-small.png", + animations = animations_small }, { x = 85, y = -50, shape = {0,0, 59,0, 59,19, 0,19}, - sprite = "assets/platforms/alpha-small-1.png" + sprite = "assets/platforms/alpha-small.png", + animations = animations_small }, { x = -30, y = -80, shape = {0,0, 59,0, 59,19, 0,19}, - sprite = "assets/platforms/alpha-small-1.png" + sprite = "assets/platforms/alpha-small.png", + animations = animations_small } }, decorations = {} @@ -93,7 +93,7 @@ function World:loadMap(name) self.map = map() -- Platforms for _,platform in pairs(self.map.platforms) do - self:createPlatform(platform.x, platform.y, platform.shape, platform.sprite) + self:createPlatform(platform.x, platform.y, platform.shape, platform.sprite, platform.animations) end -- Decorations for _,decoration in pairs(self.map.decorations) do @@ -125,8 +125,8 @@ function World:getSpawnPosition() end -- Add new platform to the world -function World:createPlatform(x, y, polygon, sprite) - table.insert(self.Platforms, Ground:new(self, self.world, x, y, polygon, sprite)) +function World:createPlatform(x, y, polygon, sprite, animations) + table.insert(self.Platforms, Ground:new(self, self.world, x, y, polygon, sprite, animations)) end -- Add new naut to the world |