diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..f7d03a9 Binary files /dev/null and b/.DS_Store differ diff --git a/.luarc.json b/.luarc.json index e54d37a..93b3337 100644 --- a/.luarc.json +++ b/.luarc.json @@ -29,6 +29,7 @@ "runtime.version": "Lua 5.4", "workspace.library": [ "/Users/oleksiiilienko/projects/playdate-luacats", - "/Users/oleksiiilienko/Documents/fpv2/source/libraries" + "/Users/oleksiiilienko/Documents/fpv2/source/libraries", + "/Users/oleksiiilienko/Documents/fpv2/source" ] } diff --git a/source/main.lua b/source/main.lua index f71332f..1616469 100644 --- a/source/main.lua +++ b/source/main.lua @@ -94,6 +94,8 @@ import "scripts/selectionSprite" import "scripts/DroneCard" import "scripts/pageSprite" import "scripts/MapCard" +import "scripts/bomber/movableCrosshair" +import "scripts/bomber/granade" import "scenes/BaseScene" import 'scenes/Assemble' @@ -101,6 +103,7 @@ import 'scenes/DroneCardSelector' import 'scenes/Menu' import 'scenes/Game' import 'scenes/MapSelector' +import 'scenes/bomber/BomberScene' Difficulty = { Easy = "Easy", @@ -126,7 +129,7 @@ DifficultySettings = { Noble.Settings.setup({ difficulty = Difficulty.Medium, music = true, - debug = true + debug = false }) Noble.GameData.setup({ @@ -141,4 +144,4 @@ playdate.display.setRefreshRate(50) Noble.showFPS = false -Noble.new(Menu) +Noble.new(BomberScene) diff --git a/source/scenes/bomber/BomberScene.lua b/source/scenes/bomber/BomberScene.lua new file mode 100644 index 0000000..c262ca0 --- /dev/null +++ b/source/scenes/bomber/BomberScene.lua @@ -0,0 +1,47 @@ +BomberScene = {} +class("BomberScene").extends(BaseScene) +local scene = BomberScene + +function scene:init() + scene.super.init(self) + scene.granade = nil +end + + +scene.inputHandler = { + upButtonHold = function() + scene.crosshair:moveUp() + end, + downButtonHold = function() + scene.crosshair:moveDown() + end, + leftButtonHold = function() + scene.crosshair:moveLeft() + end, + rightButtonHold = function() + scene.crosshair:moveRight() + end, + AButtonDown = function() + print("AButtonDown") + scene.granade = Granade(scene.crosshair.x, scene.crosshair.y) + end +} + +function scene:enter() + scene.super.enter(self) + Noble.Input.setHandler(scene.inputHandler) + scene.crosshair = MovableCrosshair(100, 100) +end + +function scene:start() + scene.super.start(self) +end + +function scene:update() + scene.super.update(self) + -- scene.crosshair:update() + + -- if scene.granade then + -- scene.granade:update() + -- end +end diff --git a/source/scripts/bomber/granade.lua b/source/scripts/bomber/granade.lua new file mode 100644 index 0000000..2c3f659 --- /dev/null +++ b/source/scripts/bomber/granade.lua @@ -0,0 +1,34 @@ +Granade = {} +class('Granade').extends(NobleSprite) + +function Granade:init(x, y) + Granade.super.init(self) + + self.initialRadius = 10 + self.currentRadius = self.initialRadius + self.shrinkRate = 0.2 + + self.isActive = true + + self:moveTo(x, y) + + print("Granade init") + print(self.x, self.y) +end + +function Granade:update() + if self.isActive then + self.currentRadius = self.currentRadius - self.shrinkRate + + if self.currentRadius <= 0 then + print("Granade deactivated") + self.isActive = false + self:remove() + end + end + self:draw() +end + +function Granade:draw() + playdate.graphics.fillCircleAtPoint(self.x, self.y, self.currentRadius) +end \ No newline at end of file diff --git a/source/scripts/bomber/movableCrosshair.lua b/source/scripts/bomber/movableCrosshair.lua new file mode 100644 index 0000000..eb15178 --- /dev/null +++ b/source/scripts/bomber/movableCrosshair.lua @@ -0,0 +1,76 @@ +MovableCrosshair = {} +class('MovableCrosshair').extends(NobleSprite) + +function MovableCrosshair:init() + MovableCrosshair.super.init(self) + + -- Parameters for crosshair + self.lineLength = 10 + self.gapSize = 3 + + -- Parameters for movement + self.baseX = 200 + self.baseY = 150 + self.moveRadius = 2 + self.moveSpeed = 2 + self.time = 0 +end + +function MovableCrosshair:update() + -- Update time + self.time = self.time + playdate.display.getRefreshRate() / 1000 + + -- Calculate new position with slight movement + local offsetX = math.sin(self.time) * self.moveRadius + local offsetY = math.cos(self.time * 1.3) * self.moveRadius + + self:moveTo(self.baseX + offsetX, self.baseY + offsetY) + + self:draw() +end + +function MovableCrosshair:draw() + -- Draw horizontal lines + playdate.graphics.drawLine( + self.x - self.lineLength - self.gapSize, self.y, + self.x - self.gapSize, self.y + ) + playdate.graphics.drawLine( + self.x + self.gapSize, self.y, + self.x + self.lineLength + self.gapSize, self.y + ) + + -- Draw vertical lines + playdate.graphics.drawLine( + self.x, self.y - self.lineLength - self.gapSize, + self.x, self.y - self.gapSize + ) + playdate.graphics.drawLine( + self.x, self.y + self.gapSize, + self.x, self.y + self.lineLength + self.gapSize + ) +end + +function MovableCrosshair:moveUp() + if self.baseY > 5 then + self.baseY = self.baseY - 1 + end +end + +function MovableCrosshair:moveDown() + if self.baseY < 235 then + self.baseY = self.baseY + 1 + end +end + +function MovableCrosshair:moveLeft() + if self.baseX > 5 then + self.baseX = self.baseX - 1 + end +end + +function MovableCrosshair:moveRight() + if self.baseX < 395 then + self.baseX = self.baseX + 1 + end +end \ No newline at end of file diff --git a/source/scripts/player.lua b/source/scripts/player.lua index 81bcefa..9e2b33f 100644 --- a/source/scripts/player.lua +++ b/source/scripts/player.lua @@ -192,9 +192,9 @@ function Player:handleMovementAndCollisions() self:boom() return elseif collisionTag == 154 then -- Baleba - if self.debug then - return - end + -- if self.debug then TODO: why debug always true? + -- return + -- end self:boom(collisionObject) return elseif collisionTag == 2 then -- Tank