new cool backgroud

This commit is contained in:
assada 2024-06-03 21:15:23 +03:00
parent b0256d7ae3
commit 2d7f65d7fb
Signed by: assada
GPG Key ID: D4860A938E541F06
5 changed files with 14 additions and 19 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

View File

@ -19,8 +19,8 @@ end
function scene:drawBackground() function scene:drawBackground()
local speed = 0.1 local speed = 0.1
if Ground.player ~= nil and Ground.player.isMovingRight() == true then if scene.ground ~= nil then
speed = 0.2 speed = scene.ground.moveSpeed * 0.4
end end
if scene.distance > 0 then if scene.distance > 0 then
@ -34,7 +34,7 @@ function scene:drawBackground()
end end
function scene:setValues() function scene:setValues()
self.bg = Graphics.image.new("assets/sprites/bgTest") self.bg = Graphics.image.new("assets/sprites/bg1")
scene.bgX = 0 scene.bgX = 0
scene.telemLostSound = playdate.sound.fileplayer.new("assets/audio/telemko") scene.telemLostSound = playdate.sound.fileplayer.new("assets/audio/telemko")
scene.telemLostSoundPlayed = false scene.telemLostSoundPlayed = false
@ -54,7 +54,7 @@ function scene:setValues()
scene.tank = nil scene.tank = nil
scene.distance = 900 scene.distance = 200
end end
function scene:init() function scene:init()
@ -115,11 +115,15 @@ function scene:update()
end end
if scene.distance > 0 then if scene.distance > 0 then
scene.distance = scene.distance - 1 scene.distance = scene.distance - scene.ground.moveSpeed
end end
if scene.distance < 850 and scene.tank == nil then if scene.distance < 0 then -- SHIT
scene.tank = Tank(500, 190, scene.player, scene.ground) scene.distance = 0
end
if scene.distance < 150 and scene.tank == nil then
scene.tank = Tank(480, 190, scene.ground)
scene:addSprite(scene.tank) -- Raw sprite scene:addSprite(scene.tank) -- Raw sprite
end end
@ -131,7 +135,7 @@ function scene:update()
local t = scene.player.getBat() / 10000 local t = scene.player.getBat() / 10000
local lerpBat = playdate.math.lerp(12.0, 16.8, t) local lerpBat = playdate.math.lerp(12.0, 16.8, t)
Noble.Text.draw(round(lerpBat) .. "v", 10, 210, Noble.Text.ALIGN_LEFT, false, font) Noble.Text.draw(round(lerpBat) .. "v", 10, 210, Noble.Text.ALIGN_LEFT, false, font)
Noble.Text.draw(scene.distance .. "m", 200, 40, Noble.Text.ALIGN_CENTER, false, font) Noble.Text.draw(math.round(scene.distance) .. "m", 200, 20, Noble.Text.ALIGN_CENTER, false, font)
end end
if scene.player.isDead() and not scene.telemLostSoundPlayed then if scene.player.isDead() and not scene.telemLostSoundPlayed then

View File

@ -2,7 +2,7 @@ Tank = {}
class("Tank").extends(Graphics.sprite) class("Tank").extends(Graphics.sprite)
function Tank:init(x, y, player, ground) function Tank:init(x, y, ground)
self.tankImage = Graphics.image.new("assets/sprites/tank") self.tankImage = Graphics.image.new("assets/sprites/tank")
self.tankImageD = Graphics.image.new("assets/sprites/tankD") self.tankImageD = Graphics.image.new("assets/sprites/tankD")
Tank.super.init(self) Tank.super.init(self)
@ -26,8 +26,6 @@ function Tank:init(x, y, player, ground)
}) })
-- Main properties -- Main properties
Tank.moveSpeed = 2
Tank.player = player
Tank.ground = ground Tank.ground = ground
self:fadein() self:fadein()
@ -49,12 +47,5 @@ function Tank:update()
return return
end end
-- Speedup when player is moving right self:moveTo(self.x - Tank.ground.moveSpeed, self.y)
if Tank.player.isMovingRight() == false then
Tank.moveSpeed = 0.2
else
Tank.moveSpeed = 1
end
self:moveTo(self.x - Tank.moveSpeed, self.y)
end end