diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index c40f011..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..0d211b6 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +root = true + +[*] +indent_style = tab +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false + +[*.sh] +indent_style = space +indent_size = 4 diff --git a/.gitignore b/.gitignore index b205ba3..f826e9c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,14 @@ -builds/* +builds/ +source/assets/unused/ + +# OS +.DS_Store +Thumbs.db + +# IDE (machine-specific) +.vscode/settings.json + +# Editors +*.swp +*.swo +*~ diff --git a/.gitmodules b/.gitmodules index 0d31a0f..d58a343 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "Noble Engine"] - path = source/libraries/noble - url = https://github.com/NobleRobot/NobleEngine.git [submodule "source/libraries/noble"] path = source/libraries/noble url = https://github.com/NobleRobot/NobleEngine.git diff --git a/build_and_run.sh b/build_and_run.sh index eed4319..2890636 100755 --- a/build_and_run.sh +++ b/build_and_run.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -export PLAYDATE_SDK_PATH="/home/ut3usw/PlaydateSDK-2.5.0" +export PLAYDATE_SDK_PATH="${PLAYDATE_SDK_PATH:-/home/ut3usw/PlaydateSDK-2.5.0}" # Check for color by variable and tput command if [[ -z $NOCOLOR && -n $(command -v tput) ]]; then @@ -103,7 +103,7 @@ function make_build_dir() { function clean_build_dir() { if [[ -d "${BUILD_DIR}" ]]; then log "Cleaning build directory..." - rm -rfv "${BUILD_DIR}/*" + rm -rfv "${BUILD_DIR}"/* chk_err fi } diff --git a/build_and_run_mac.sh b/build_and_run_mac.sh index 304e721..cb85088 100755 --- a/build_and_run_mac.sh +++ b/build_and_run_mac.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -export PLAYDATE_SDK_PATH="/Users/oleksiiilienko/Developer/PlaydateSDK" +export PLAYDATE_SDK_PATH="${PLAYDATE_SDK_PATH:-/Users/oleksiiilienko/Developer/PlaydateSDK}" # Check for color by variable and tput command if [[ -z $NOCOLOR && -n $(command -v tput) ]]; then @@ -103,7 +103,7 @@ function make_build_dir() { function clean_build_dir() { if [[ -d "${BUILD_DIR}" ]]; then log "Cleaning build directory..." - rm -rfv "${BUILD_DIR}/*" + rm -rfv "${BUILD_DIR}"/* chk_err fi } diff --git a/source/assets/.DS_Store b/source/assets/.DS_Store deleted file mode 100644 index 0674314..0000000 Binary files a/source/assets/.DS_Store and /dev/null differ diff --git a/source/assets/unused/fonts/Mini Sans 2X-table-18-20.png b/source/assets/fonts/Mini Sans 2X-table-18-20.png similarity index 100% rename from source/assets/unused/fonts/Mini Sans 2X-table-18-20.png rename to source/assets/fonts/Mini Sans 2X-table-18-20.png diff --git a/source/assets/images/.DS_Store b/source/assets/images/.DS_Store deleted file mode 100644 index b5eb54d..0000000 Binary files a/source/assets/images/.DS_Store and /dev/null differ diff --git a/source/main.lua b/source/main.lua index 156c7b2..3037cdd 100644 --- a/source/main.lua +++ b/source/main.lua @@ -36,6 +36,17 @@ CollideGroups = { granade = 6 } +Tags = { + player = 1, + tank = 2, + ground = 3, + granade = 154, + ammoCrate = 155, +} + +SCREEN_W = 400 +SCREEN_H = 240 + Maps = { { id = 1, diff --git a/source/scenes/Game.lua b/source/scenes/Game.lua index b33ae4a..1ef98c6 100644 --- a/source/scenes/Game.lua +++ b/source/scenes/Game.lua @@ -142,7 +142,7 @@ function scene:update() Noble.GameData.set("money", Noble.GameData.get("money") + reward) message = "You did it! +$" .. reward end - c = notify(message, function() + local c = notify(message, function() Noble.transition(DroneCardSelector) c:remove() end) diff --git a/source/scenes/bomber/BomberScene.lua b/source/scenes/bomber/BomberScene.lua index e7bc11a..7452511 100644 --- a/source/scenes/bomber/BomberScene.lua +++ b/source/scenes/bomber/BomberScene.lua @@ -104,7 +104,6 @@ scene.inputHandler = { return end - print("AButtonDown") if not scene.grenadeCooldown then Granade(scene.crosshair.x, scene.crosshair.y) scene.grenadeCooldown = true @@ -144,13 +143,13 @@ end function scene:start() scene.super.start(self) self.optionsMenu:addMenuItem("Main Menu", function() Noble.transition(Menu) end) - Noble.showFPS = true + Noble.showFPS = false end function scene:hasActiveGrenades() local sprites = playdate.graphics.sprite.getAllSprites() for i = 1, #sprites do - if sprites[i]:getTag() == 154 then + if sprites[i]:getTag() == Tags.granade then return true end end diff --git a/source/scripts/bomber/ammoCrate.lua b/source/scripts/bomber/ammoCrate.lua index ee41193..bb6d681 100644 --- a/source/scripts/bomber/ammoCrate.lua +++ b/source/scripts/bomber/ammoCrate.lua @@ -11,7 +11,7 @@ function AmmoCrate:init(x, y) self:setGroups(CollideGroups.props) self:setCollidesWithGroups({ CollideGroups.granade }) self:setCollideRect(0, 0, self.crateSize, self.crateSize) - self:setTag(155) + self:setTag(Tags.ammoCrate) self.removed = false self.bonusGrenades = 3 @@ -30,7 +30,7 @@ function AmmoCrate:update() local _, _, collisions, count = self:checkCollisions(self.x, self.y) if count > 0 then for i, collision in ipairs(collisions) do - if collision.other:getTag() == 154 and collision.other.currentRadius <= 0.05 then + if collision.other:getTag() == Tags.granade and collision.other.currentRadius <= 0.05 then self:pickup() return end diff --git a/source/scripts/bomber/enemy.lua b/source/scripts/bomber/enemy.lua index ed9754c..e49c066 100644 --- a/source/scripts/bomber/enemy.lua +++ b/source/scripts/bomber/enemy.lua @@ -65,8 +65,7 @@ function Enemy:update() if numberOfCollisions > 0 then for i, collision in ipairs(collisions) do - if collision.other:getTag() == 154 and collision.other.currentRadius <= 0.05 and not self.isDying then - print("Collision with granade") + if collision.other:getTag() == Tags.granade and collision.other.currentRadius <= 0.05 and not self.isDying then self:setImage(self.deadImage) self.hitSound:play() self:applyExplosionForce(collision.other.x, collision.other.y) @@ -74,9 +73,8 @@ function Enemy:update() end end - if self.y > 240 + 10 then + if self.y > SCREEN_H + 10 then if not self.removed then - print("Removing enemy") self:remove() self:superRemove() self.removed = true diff --git a/source/scripts/bomber/granade.lua b/source/scripts/bomber/granade.lua index 9287a8d..d61c3c5 100644 --- a/source/scripts/bomber/granade.lua +++ b/source/scripts/bomber/granade.lua @@ -23,7 +23,7 @@ function Granade:init(x, y) self:setSize(size, size) self:moveTo(x, y) self:setZIndex(10) - self:setTag(154) + self:setTag(Tags.granade) self:setCenter(0.5, 0.5) self:setGroups(CollideGroups.granade) self:setCollidesWithGroups({ @@ -31,8 +31,6 @@ function Granade:init(x, y) }) self:setCollideRect(0, 0, self:getSize()) - print("Granade init") - print(self.x, self.y) self:add(x, y) self:markDirty() end @@ -56,7 +54,6 @@ function Granade:update() self.currentRadius = self.currentRadius - self.shrinkRate if self.currentRadius <= 0 then - print("Granade deactivated") self.isActive = false local particleB = ParticlePoly(self.x, self.y) particleB:setThickness(1) diff --git a/source/scripts/player.lua b/source/scripts/player.lua index 34b153c..4ef59bf 100644 --- a/source/scripts/player.lua +++ b/source/scripts/player.lua @@ -30,7 +30,7 @@ function Player:init(x, y) CollideGroups.wall }) self:setCollideRect(3, 19, 60, 33) - self:setTag(1) + self:setTag(Tags.player) -- Physics properties self.fallSpeed = 0.05 @@ -188,13 +188,13 @@ function Player:handleMovementAndCollisions() end end - if collisionTag == 3 then -- Ground + if collisionTag == Tags.ground then self:boom() return - elseif collisionTag == 154 then -- Baleba + elseif collisionTag == Tags.granade then self:boom(collisionObject) return - elseif collisionTag == 2 then -- Tank + elseif collisionTag == Tags.tank then self:boom() BigBoom() diff --git a/source/scripts/tankSprite.lua b/source/scripts/tankSprite.lua index 738992b..f2e1fb9 100644 --- a/source/scripts/tankSprite.lua +++ b/source/scripts/tankSprite.lua @@ -10,7 +10,7 @@ function Tank:init(x, y, ground) -- Collision properties self:setZIndex(ZIndex.enemy) - self:setTag(2) + self:setTag(Tags.tank) self:setCollideRect(4, 56, 147, 65) self:setGroups(CollideGroups.enemy) self:setCollidesWithGroups(