tank
This commit is contained in:
parent
29a5ed2f62
commit
f19610e458
BIN
source/assets/sprites/old_player-table-64-64.png
Normal file
BIN
source/assets/sprites/old_player-table-64-64.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.6 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 8.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 4.1 KiB |
BIN
source/assets/sprites/tankD.png
Normal file
BIN
source/assets/sprites/tankD.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
@ -17,6 +17,7 @@ import "scripts/player"
|
|||||||
import "scripts/groundSprite"
|
import "scripts/groundSprite"
|
||||||
import "scripts/balebaSprite"
|
import "scripts/balebaSprite"
|
||||||
import "scripts/dangerSprite"
|
import "scripts/dangerSprite"
|
||||||
|
import "scripts/tankSprite"
|
||||||
|
|
||||||
import "scenes/BaseScene"
|
import "scenes/BaseScene"
|
||||||
import 'scenes/Menu'
|
import 'scenes/Menu'
|
||||||
@ -35,4 +36,4 @@ playdate.display.setRefreshRate(50)
|
|||||||
|
|
||||||
Noble.showFPS = true
|
Noble.showFPS = true
|
||||||
|
|
||||||
Noble.new(Menu)
|
Noble.new(Game)
|
@ -28,6 +28,8 @@ function scene:setValues()
|
|||||||
scene.t = playdate.timer.new(10000)
|
scene.t = playdate.timer.new(10000)
|
||||||
scene.t.repeats = true
|
scene.t.repeats = true
|
||||||
|
|
||||||
|
scene.tankTimer = playdate.timer.new(1000)
|
||||||
|
|
||||||
scene.fp = playdate.sound.fileplayer.new( "assets/audio/war" )
|
scene.fp = playdate.sound.fileplayer.new( "assets/audio/war" )
|
||||||
scene.fp:setVolume(0.7)
|
scene.fp:setVolume(0.7)
|
||||||
scene.hello = playdate.sound.fileplayer.new( "assets/audio/hello" )
|
scene.hello = playdate.sound.fileplayer.new( "assets/audio/hello" )
|
||||||
@ -68,7 +70,7 @@ function scene:enter()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local k = #scene.balebas+1
|
local k = #scene.balebas+1
|
||||||
scene.balebas[k] = scene:spawnBaleba()
|
--scene.balebas[k] = scene:spawnBaleba()
|
||||||
end
|
end
|
||||||
|
|
||||||
for i=1, 3 do
|
for i=1, 3 do
|
||||||
@ -80,6 +82,11 @@ function scene:enter()
|
|||||||
if musicEnabled then
|
if musicEnabled then
|
||||||
scene.fp:play(0)
|
scene.fp:play(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scene.tankTimer.timerEndedCallback = function()
|
||||||
|
scene.tank = Tank(550, 190, scene.player, scene.ground)
|
||||||
|
scene.tank:add()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function scene:update()
|
function scene:update()
|
||||||
@ -90,15 +97,13 @@ function scene:update()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if scene.player.isDead() then
|
if scene.player.isDead() and not scene.telemLostSoundPlayed then
|
||||||
if not scene.telemLostSoundPlayed then
|
|
||||||
scene.telemLostSound:play(1)
|
scene.telemLostSound:play(1)
|
||||||
scene.telemLostSoundPlayed = true
|
scene.telemLostSoundPlayed = true
|
||||||
screenShake(500, 5)
|
screenShake(500, 5)
|
||||||
end
|
|
||||||
|
|
||||||
scene:destroyPlayer()
|
|
||||||
local et = playdate.timer.new(2000)
|
local et = playdate.timer.new(6000)
|
||||||
et.timerEndedCallback = function()
|
et.timerEndedCallback = function()
|
||||||
Noble.transition(Menu)
|
Noble.transition(Menu)
|
||||||
end
|
end
|
||||||
@ -126,6 +131,9 @@ function scene:exit()
|
|||||||
scene.ground:remove()
|
scene.ground:remove()
|
||||||
scene.ground = nil
|
scene.ground = nil
|
||||||
|
|
||||||
|
scene.tank:remove()
|
||||||
|
scene.ground = nil
|
||||||
|
|
||||||
for i=1, #scene.balebas do
|
for i=1, #scene.balebas do
|
||||||
scene.balebas[i]:destroy()
|
scene.balebas[i]:destroy()
|
||||||
scene.balebas[i] = nil
|
scene.balebas[i] = nil
|
||||||
@ -139,6 +147,9 @@ function scene:exit()
|
|||||||
scene.t:remove()
|
scene.t:remove()
|
||||||
scene.t = nil
|
scene.t = nil
|
||||||
|
|
||||||
|
scene.tankTimer:remove()
|
||||||
|
scene.tankTimer = nil
|
||||||
|
|
||||||
|
|
||||||
Noble.showFPS = false
|
Noble.showFPS = false
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
Ground = {}
|
Ground = {}
|
||||||
class("Ground").extends(Graphics.sprite)
|
class("Ground").extends(Graphics.sprite)
|
||||||
|
|
||||||
local groundImage = playdate.graphics.image.new("assets/sprites/groundFin")
|
local groundImage = Graphics.image.new("assets/sprites/groundFin")
|
||||||
|
|
||||||
function Ground:init(x, y, player)
|
function Ground:init(x, y, player)
|
||||||
Ground.super.init(self, groundImage)
|
Ground.super.init(self, groundImage)
|
||||||
@ -24,6 +24,12 @@ function Ground:setMoveSpeed(speed)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Ground:update()
|
function Ground:update()
|
||||||
|
|
||||||
|
-- Stop ground
|
||||||
|
if Ground.moveSpeed == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
-- Speedup when player is moving right
|
-- Speedup when player is moving right
|
||||||
if Ground.player.isMovingRight() == false then
|
if Ground.player.isMovingRight() == false then
|
||||||
Ground.moveSpeed = 0.2
|
Ground.moveSpeed = 0.2
|
||||||
|
@ -99,6 +99,24 @@ function Player:changeToRunState(direction)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Player:boom(collisionObject)
|
||||||
|
Player.dead = true
|
||||||
|
self:changeState("boom")
|
||||||
|
|
||||||
|
local particleB = ParticlePoly(self.x, self.y)
|
||||||
|
particleB:setThickness(2)
|
||||||
|
particleB:setAngular(-15, 15)
|
||||||
|
particleB:setSize(1, 2)
|
||||||
|
particleB:setSpeed(1, 3)
|
||||||
|
particleB:setMode(Particles.modes.STAY)
|
||||||
|
particleB:setBounds(0, 0, 400, 240)
|
||||||
|
particleB:setColour(Graphics.kColorXOR)
|
||||||
|
particleB:add(20)
|
||||||
|
if collisionObject then
|
||||||
|
collisionObject:remove()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function Player:handleMovementAndCollisions()
|
function Player:handleMovementAndCollisions()
|
||||||
if Player.dead then
|
if Player.dead then
|
||||||
return
|
return
|
||||||
@ -134,23 +152,24 @@ function Player:handleMovementAndCollisions()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if collisionTag == 3 then -- Ground
|
if collisionTag == 3 then -- Ground
|
||||||
Player.dead = true
|
self:boom()
|
||||||
self:changeState("boom")
|
|
||||||
return
|
return
|
||||||
elseif collisionTag == 154 then -- Baleba
|
elseif collisionTag == 154 then -- Baleba
|
||||||
Player.dead = true
|
-- self:boom(collisionObject)
|
||||||
self:changeState("boom")
|
return
|
||||||
|
elseif collisionTag == 2 then -- Tank
|
||||||
|
self:boom()
|
||||||
|
|
||||||
local particleB = ParticlePoly(self.x, self.y)
|
local particleC = ParticlePoly(collisionObject.x, collisionObject.y)
|
||||||
particleB:setThickness(2)
|
particleC:setThickness(5)
|
||||||
particleB:setAngular(-15, 15)
|
particleC:setAngular(-15, 15)
|
||||||
particleB:setSize(1, 2)
|
particleC:setSize(1, 5)
|
||||||
particleB:setSpeed(1, 3)
|
particleC:setSpeed(1, 3)
|
||||||
particleB:setMode(Particles.modes.STAY)
|
particleC:setMode(Particles.modes.STAY)
|
||||||
particleB:setBounds(0, 0, 400, 240)
|
particleC:setBounds(0, 0, 400, 240)
|
||||||
particleB:setColour(Graphics.kColorXOR)
|
particleC:setColour(Graphics.kColorXOR)
|
||||||
particleB:add(20)
|
particleC:add(50)
|
||||||
collisionObject:remove()
|
collisionObject:fadeout()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
55
source/scripts/tankSprite.lua
Normal file
55
source/scripts/tankSprite.lua
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
Tank = {}
|
||||||
|
|
||||||
|
class("Tank").extends(Graphics.sprite)
|
||||||
|
|
||||||
|
function Tank:init(x, y, player, ground)
|
||||||
|
self.tankImage = Graphics.image.new("assets/sprites/tank")
|
||||||
|
self.tankImageD = Graphics.image.new("assets/sprites/tankD")
|
||||||
|
Tank.super.init(self)
|
||||||
|
|
||||||
|
local width, height = self.tankImage:getSize()
|
||||||
|
|
||||||
|
self.faded_image = Graphics.image.new(width, height, Graphics.kColorClear)
|
||||||
|
|
||||||
|
Graphics.pushContext(self.faded_image)
|
||||||
|
self.tankImageD:drawBlurred(0, 0, 2, 2, Graphics.image.kDitherTypeFloydSteinberg)
|
||||||
|
Graphics.popContext()
|
||||||
|
|
||||||
|
-- Collision properties
|
||||||
|
self:setZIndex(99)
|
||||||
|
self:setTag(2)
|
||||||
|
self:setCollideRect(4, 56, 147, 65)
|
||||||
|
|
||||||
|
-- Main properties
|
||||||
|
Tank.moveSpeed = 2
|
||||||
|
Tank.player = player
|
||||||
|
Tank.ground = ground
|
||||||
|
|
||||||
|
self:fadein()
|
||||||
|
|
||||||
|
self:moveTo(x, y)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Tank:fadein()
|
||||||
|
self:setImage(self.tankImage)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Tank:fadeout()
|
||||||
|
self:setImage(self.faded_image)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Tank:update()
|
||||||
|
if self.x <= 330 then
|
||||||
|
Tank.ground:setMoveSpeed(0)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Speedup when player is moving right
|
||||||
|
if Tank.player.isMovingRight() == false then
|
||||||
|
Tank.moveSpeed = 0.2
|
||||||
|
else
|
||||||
|
Tank.moveSpeed = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
self:moveTo(self.x-Tank.moveSpeed, self.y)
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user