bg
This commit is contained in:
parent
9cd5c1bd81
commit
b0256d7ae3
BIN
source/assets/sprites/bgTest.png
Normal file
BIN
source/assets/sprites/bgTest.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
@ -3,6 +3,8 @@ import "CoreLibs/object"
|
||||
import "CoreLibs/sprites"
|
||||
import "CoreLibs/timer"
|
||||
import "CoreLibs/ui"
|
||||
import "CoreLibs/math"
|
||||
|
||||
|
||||
-- Libraries
|
||||
import 'libraries/noble/Noble'
|
||||
|
@ -17,9 +17,25 @@ local function screenShake(shakeTime, shakeMagnitude)
|
||||
end
|
||||
end
|
||||
|
||||
function scene:setValues()
|
||||
scene.background = Graphics.image.new("assets/sprites/bg")
|
||||
function scene:drawBackground()
|
||||
local speed = 0.1
|
||||
if Ground.player ~= nil and Ground.player.isMovingRight() == true then
|
||||
speed = 0.2
|
||||
end
|
||||
|
||||
if scene.distance > 0 then
|
||||
scene.bgX = scene.bgX - speed
|
||||
end
|
||||
|
||||
if scene.bgX <= -400 then
|
||||
scene.bgX = 0
|
||||
end
|
||||
self.bg:draw(scene.bgX or 0, 0)
|
||||
end
|
||||
|
||||
function scene:setValues()
|
||||
self.bg = Graphics.image.new("assets/sprites/bgTest")
|
||||
scene.bgX = 0
|
||||
scene.telemLostSound = playdate.sound.fileplayer.new("assets/audio/telemko")
|
||||
scene.telemLostSoundPlayed = false
|
||||
|
||||
@ -35,6 +51,10 @@ function scene:setValues()
|
||||
scene.levelAudio = playdate.sound.fileplayer.new("assets/audio/war")
|
||||
scene.levelAudio:setVolume(0.7)
|
||||
scene.helloAudio = playdate.sound.fileplayer.new("assets/audio/hello")
|
||||
|
||||
scene.tank = nil
|
||||
|
||||
scene.distance = 900
|
||||
end
|
||||
|
||||
function scene:init()
|
||||
@ -76,15 +96,15 @@ function scene:enter()
|
||||
scene:spawnBaleba()
|
||||
end
|
||||
|
||||
scene.helloAudio:play(1)
|
||||
--scene.helloAudio:play(1)
|
||||
if scene.musicEnabled then
|
||||
scene.levelAudio:play(0)
|
||||
--scene.levelAudio:play(0)
|
||||
end
|
||||
end
|
||||
|
||||
playdate.timer.performAfterDelay(1000, function()
|
||||
scene.tank = Tank(550, 190, scene.player, scene.ground)
|
||||
scene:addSprite(scene.tank) -- Raw sprite
|
||||
end)
|
||||
function round(number)
|
||||
local formatted = string.format("%.2f", number)
|
||||
return formatted
|
||||
end
|
||||
|
||||
function scene:update()
|
||||
@ -94,12 +114,24 @@ function scene:update()
|
||||
return
|
||||
end
|
||||
|
||||
if scene.distance > 0 then
|
||||
scene.distance = scene.distance - 1
|
||||
end
|
||||
|
||||
if scene.distance < 850 and scene.tank == nil then
|
||||
scene.tank = Tank(500, 190, scene.player, scene.ground)
|
||||
scene:addSprite(scene.tank) -- Raw sprite
|
||||
end
|
||||
|
||||
if scene.player.isDead() then
|
||||
if scene.resultShowed ~= true then
|
||||
Noble.Text.draw("Telemetry Lost", 200, 110, Noble.Text.ALIGN_CENTER, false, font)
|
||||
end
|
||||
else
|
||||
Noble.Text.draw("Bat: " .. math.floor(scene.player.getBat() / 100), 10, 215, Noble.Text.ALIGN_LEFT, false, font)
|
||||
local t = scene.player.getBat() / 10000
|
||||
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(scene.distance .. "m", 200, 40, Noble.Text.ALIGN_CENTER, false, font)
|
||||
end
|
||||
|
||||
if scene.player.isDead() and not scene.telemLostSoundPlayed then
|
||||
|
@ -49,7 +49,8 @@ function Player:init(x, y)
|
||||
self.touchingCeiling = false
|
||||
self.touchingWall = false
|
||||
Player.dead = false
|
||||
Player.bat = 10000
|
||||
Player.fullBat = 10000
|
||||
Player.bat = Player.fullBat
|
||||
Player.dischargeRate = 1
|
||||
Player.moveRight = false
|
||||
self.lastDirection = nil
|
||||
@ -172,7 +173,7 @@ function Player:handleMovementAndCollisions()
|
||||
self:boom()
|
||||
return
|
||||
elseif collisionTag == 154 then -- Baleba
|
||||
self:boom(collisionObject)
|
||||
--self:boom(collisionObject)
|
||||
return
|
||||
elseif collisionTag == 2 then -- Tank
|
||||
self:boom()
|
||||
|
Loading…
Reference in New Issue
Block a user