Files
fpv/source/scripts/tankSprite.lua
assada 348bd4fe64 cleanup: QOL improvements — gitignore, Tags constants, remove debug artifacts
- Add .DS_Store, unused/, .vscode/settings.json to .gitignore
- Add .editorconfig (tabs for Lua, LF, UTF-8)
- Fix duplicate submodule entry in .gitmodules
- Add Tags table (player, tank, ground, granade, ammoCrate) — replace magic numbers
- Add SCREEN_W/SCREEN_H constants
- Fix leaked global variable `c` in Game.lua
- Remove Noble.showFPS = true from BomberScene
- Remove debug print() calls from granade, enemy, BomberScene
- Fix clean_build_dir glob bug in both build scripts
- Make PLAYDATE_SDK_PATH configurable via env var
2026-02-24 12:48:00 +01:00

45 lines
967 B
Lua

Tank = {}
class("Tank").extends(Graphics.sprite)
function Tank:init(x, y, ground)
local target = Targets[CurrentMission.targetIndex]
self.tankImage = Graphics.image.new(target.sprite)
self.tankImageD = Graphics.image.new(target.spriteD)
Tank.super.init(self)
-- Collision properties
self:setZIndex(ZIndex.enemy)
self:setTag(Tags.tank)
self:setCollideRect(4, 56, 147, 65)
self:setGroups(CollideGroups.enemy)
self:setCollidesWithGroups(
{
CollideGroups.player
})
-- Main properties
Tank.ground = ground
self:fadein()
self:moveTo(x, y)
end
function Tank:fadein()
self:setImage(self.tankImage)
end
function Tank:fadeout()
self:setImage(self.tankImageD)
end
function Tank:update()
if self.x <= 330 then
Tank.ground:setMoveSpeed(0)
return
end
self:moveTo(self.x - Tank.ground.moveSpeed, self.y)
end