Compare commits
3 Commits
apha-0.3
...
fae2abf94e
Author | SHA1 | Date | |
---|---|---|---|
fae2abf94e
|
|||
648e4a3dc4
|
|||
95b2c825db
|
@@ -28,7 +28,8 @@
|
|||||||
],
|
],
|
||||||
"runtime.version": "Lua 5.4",
|
"runtime.version": "Lua 5.4",
|
||||||
"workspace.library": [
|
"workspace.library": [
|
||||||
"/home/ut3usw/src/playdate-luacats",
|
"/Users/oleksiiilienko/projects/playdate-luacats",
|
||||||
"/home/ut3usw/Projects/VSCode-PlaydateTemplate/source/libraries"
|
"/Users/oleksiiilienko/Documents/fpv2/source/libraries",
|
||||||
|
"/Users/oleksiiilienko/Documents/fpv2/source"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
11
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "playdate",
|
||||||
|
"request": "launch",
|
||||||
|
"name": "Playdate: Debug",
|
||||||
|
"preLaunchTask": "${defaultBuildTask}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
4
.vscode/settings.json
vendored
@@ -5,4 +5,8 @@
|
|||||||
"Lua.runtime.nonstandardSymbol": ["+=", "-=", "*=", "/=", "//=", "%=", "<<=", ">>=", "&=", "|=", "^="],
|
"Lua.runtime.nonstandardSymbol": ["+=", "-=", "*=", "/=", "//=", "%=", "<<=", ">>=", "&=", "|=", "^="],
|
||||||
"Lua.workspace.library": ["$PLAYDATE_SDK_PATH/CoreLibs"],
|
"Lua.workspace.library": ["$PLAYDATE_SDK_PATH/CoreLibs"],
|
||||||
"Lua.workspace.preloadFileSize": 1000,
|
"Lua.workspace.preloadFileSize": 1000,
|
||||||
|
"playdate-debug.sdkPath": "/Users/oleksiiilienko/Developer/PlaydateSDK",
|
||||||
|
"playdate-debug.sourcePath": "/Users/oleksiiilienko/Documents/fpv2/source",
|
||||||
|
"playdate-debug.outputPath": "/Users/oleksiiilienko/Documents/fpv2/builds",
|
||||||
|
"playdate-debug.productName": "FPV Game"
|
||||||
}
|
}
|
32
.vscode/tasks.json
vendored
@@ -3,6 +3,26 @@
|
|||||||
// for the documentation about the tasks.json format
|
// for the documentation about the tasks.json format
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
|
{
|
||||||
|
"type": "pdc",
|
||||||
|
"problemMatcher": ["$pdc-lua", "$pdc-external"],
|
||||||
|
"label": "Playdate: Build"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "playdate-simulator",
|
||||||
|
"problemMatcher": ["$pdc-external"],
|
||||||
|
"label": "Playdate: Run"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Playdate: Build and Run",
|
||||||
|
"dependsOn": ["Playdate: Build", "Playdate: Run"],
|
||||||
|
"dependsOrder": "sequence",
|
||||||
|
"problemMatcher": [],
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"label": "Invoke Build and Run script",
|
"label": "Invoke Build and Run script",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
@@ -29,6 +49,12 @@
|
|||||||
"build"
|
"build"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"osx": {
|
||||||
|
"command": "${workspaceFolder}/build_and_run_mac.sh",
|
||||||
|
"args": [
|
||||||
|
"build"
|
||||||
|
]
|
||||||
|
},
|
||||||
"presentation": {
|
"presentation": {
|
||||||
"showReuseMessage": false,
|
"showReuseMessage": false,
|
||||||
"reveal": "always",
|
"reveal": "always",
|
||||||
@@ -62,6 +88,12 @@
|
|||||||
"run"
|
"run"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"osx": {
|
||||||
|
"command": "${workspaceFolder}/build_and_run_mac.sh",
|
||||||
|
"args": [
|
||||||
|
"run"
|
||||||
|
]
|
||||||
|
},
|
||||||
"presentation": {
|
"presentation": {
|
||||||
"showReuseMessage": false,
|
"showReuseMessage": false,
|
||||||
"reveal": "always",
|
"reveal": "always",
|
||||||
|
145
build_and_run_mac.sh
Executable file
@@ -0,0 +1,145 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
export PLAYDATE_SDK_PATH="/Users/oleksiiilienko/Developer/PlaydateSDK"
|
||||||
|
|
||||||
|
# Check for color by variable and tput command
|
||||||
|
if [[ -z $NOCOLOR && -n $(command -v tput) ]]; then
|
||||||
|
RED=$(tput setaf 1)
|
||||||
|
CYN=$(tput setaf 6)
|
||||||
|
YEL=$(tput setaf 3)
|
||||||
|
RST=$(tput sgr0)
|
||||||
|
fi
|
||||||
|
|
||||||
|
function display_help() {
|
||||||
|
printf "%s\n\n" "${0} build|run|-h|--help|"
|
||||||
|
printf "%-16s\n" "build: Builds the project and runs the Simulator"
|
||||||
|
printf "%-16s\n" "run : Skips building the project and runs the Simulator"
|
||||||
|
printf "\n"
|
||||||
|
printf "%s\n\n" "Set NOCOLOR=1 to disable terminal coloring"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# We don't need fancy flags/operators for two commands
|
||||||
|
case $1 in
|
||||||
|
"build")
|
||||||
|
BUILD=1
|
||||||
|
;;
|
||||||
|
"run")
|
||||||
|
BUILD=0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
display_help
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Set some paths
|
||||||
|
BUILD_DIR="./builds"
|
||||||
|
SOURCE_DIR="./source"
|
||||||
|
PDX_PATH="${BUILD_DIR}/$(basename $(pwd)).pdx"
|
||||||
|
|
||||||
|
# Logging functions
|
||||||
|
function log() {
|
||||||
|
printf "%s\n" "${CYN}>> $1${RST}"
|
||||||
|
}
|
||||||
|
function log_warn() {
|
||||||
|
printf "%s\n" "${YEL}>! $1${RST}"
|
||||||
|
}
|
||||||
|
function log_err() {
|
||||||
|
printf "%s\n >> %s\n" "${RED}!! ERROR !!" "$1${RST}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_pdxinfo() {
|
||||||
|
if [[ -f ./source/pdxinfo ]]; then
|
||||||
|
if grep "com.organization.package" ./source/pdxinfo 2>&1 >/dev/null; then
|
||||||
|
log_warn "PDXINFO NOTICE:"
|
||||||
|
log_warn "Don't forget to change your unique project info in 'source/pdxinfo': 'bundleID', 'name', 'author', 'description'."
|
||||||
|
log_warn "It's critical to change your game bundleID, so there will be no collisions with other games, installed via sideload."
|
||||||
|
log_warn "Read more about pdxinfo here: https://sdk.play.date/Inside%20Playdate.html#pdxinfo"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function chk_err() {
|
||||||
|
# Check for errors in last process and bail if needed
|
||||||
|
if [[ $? > 0 ]]; then
|
||||||
|
log_err "There was an issue with the previous command; exiting!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function check_close_sim() {
|
||||||
|
# Check if we have 'pidof'
|
||||||
|
PIDOF=$(command -v pidof2)
|
||||||
|
|
||||||
|
# Prefer 'pidof'; use ps if not
|
||||||
|
if [[ -n $PIDOF ]]; then
|
||||||
|
SIMPID=$($PIDOF "PlaydateSimulator")
|
||||||
|
if [[ -n $SIMPID ]]; then
|
||||||
|
log "Found existing Simulator, closing..."
|
||||||
|
kill -9 $SIMPID
|
||||||
|
chk_err
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
SIMPID=$(ps aux | grep PlaydateSimulator | grep -v grep | awk '{print $2}')
|
||||||
|
if [[ -n $SIMPID ]]; then
|
||||||
|
log "Found existing Simulator, closing..."
|
||||||
|
kill -9 $SIMPID
|
||||||
|
chk_err
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create build dir
|
||||||
|
function make_build_dir() {
|
||||||
|
if [[ ! -d "${BUILD_DIR}" ]]; then
|
||||||
|
log "Creating build directory..."
|
||||||
|
mkdir -p "${BUILD_DIR}"
|
||||||
|
chk_err
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Clean build dir
|
||||||
|
function clean_build_dir() {
|
||||||
|
if [[ -d "${BUILD_DIR}" ]]; then
|
||||||
|
log "Cleaning build directory..."
|
||||||
|
rm -rfv "${BUILD_DIR}/*"
|
||||||
|
chk_err
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Compile the PDX
|
||||||
|
function build_pdx() {
|
||||||
|
if [[ $BUILD == 1 ]]; then
|
||||||
|
log "Building PDX with 'pdc'..."
|
||||||
|
$PLAYDATE_SDK_PATH/bin/pdc -sdkpath "${PLAYDATE_SDK_PATH}" "${SOURCE_DIR}" "${PDX_PATH}"
|
||||||
|
chk_err
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run the PDX with Simulator
|
||||||
|
function run_pdx() {
|
||||||
|
if [[ -d "${PDX_PATH}" ]]; then
|
||||||
|
log "Running PDX with Simulator..."
|
||||||
|
open -a "$PLAYDATE_SDK_PATH/bin/Playdate Simulator.app" "${PDX_PATH}"
|
||||||
|
else
|
||||||
|
log_err "PDX doesn't exist! Please 'build' the project first!"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#### MAIN SCRIPT ####
|
||||||
|
if [[ $BUILD == 1 ]]; then
|
||||||
|
log "Attempting a build and run of PDX..."
|
||||||
|
make_build_dir
|
||||||
|
clean_build_dir
|
||||||
|
check_pdxinfo
|
||||||
|
build_pdx
|
||||||
|
check_close_sim
|
||||||
|
run_pdx
|
||||||
|
else
|
||||||
|
log "Attempting to run PDX: ${PDX_PATH}..."
|
||||||
|
check_close_sim
|
||||||
|
run_pdx
|
||||||
|
fi
|
||||||
|
|
BIN
source/.DS_Store
vendored
Normal file
BIN
source/assets/.DS_Store
vendored
Normal file
BIN
source/assets/audio/back.wav
Normal file
BIN
source/assets/audio/boom1.wav
Normal file
BIN
source/assets/audio/boom2.wav
Normal file
BIN
source/assets/audio/boom3.wav
Normal file
BIN
source/assets/audio/boom4.wav
Normal file
BIN
source/assets/bg_bomber.psd
Normal file
47
source/assets/fonts/Outfoxies.fnt
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
--metrics={"baseline":7,"xHeight":0,"capHeight":0,"pairs":{},"left":[],"right":[]}
|
||||||
|
datalen=1204
|
||||||
|
data=iVBORw0KGgoAAAANSUhEUgAAADgAAAAwCAYAAABE1blzAAAAAXNSR0IArs4c6QAAA0BJREFUaEPdWdtyqzAQa/7/o9uBqVMhpNUaCE17njr22uxVknMeHz//PuHv8eeD1tAG99TZ5eiwSfvjM2w3c176zxcop5XNchnbumQs62y/BDQccj7gGXc++f9Ag+EIZ55thnOpghiY647hOAaLa84/7jC+57mvLmDHuhXExLgKuQ5xgY47UwfYfVcddTFnWVW6qhSPuEsk2rnKsH/Kbr0/9bBrV25TlUG06VQAA+Nx6Z7fdUhnjhzCdVASMy1AegNU6juXoaj6+L9YSxlKVZrpgG7CqnZXc4yAtttXIFMNeYWCCUU7ASYhkVCYfd8oDRzsNkp9E75FMRIEVZCVeEj3t1EUCbSiBeY5ViUIGKxwVJCO6CsebKG0kldKWqUMqjlwEo0DTNzpFJHiUW7xJw9yxlW7pBnrnHEtunMMDF0gSSisd6oKYpvuhpY8vBJFXSW5OxxWSJ7tzEcH/a6yUUL71N3dCqjsJo5UgCWz/L1YfSO1sMKA1b+uFu1oQdUNqSIMXgn0+D70S9IME73KlBK+HZ7kCvLsnN1nlJa0pgJUQ8yc4wJkUKqUkso+82m3AywL/HYFZ75fKS2cwU3H3T2DSUi/bAYtCjUQzp11KOqo6aUoeopr3vlwJ5sO/RwPOrqoKnqY51KHVQFWYlZBNK8pRK1oqAIR9VpRL5CdtDwSIPMiU0hF+GjrzrmnU0qA3GcUrQg8IW63gq4zrli3FUzvPSWReAbVrB7lua4AcX495z1VRVWU17jtWFWoVnSasiMV8f6oqHBeuu8xbAPV4mnfzVLiza5/GwxwIPPO1Dbl21UVrNRMxaPYYmd40vLo7AzuUAp+NkTQ4TmsNOgV6Gln+ijKVXTCLdSduW6gXGk+t9mv4Fh9cKaCTn0ovqxQlYWF+hVguoLpUkcfjKDyZwTxX9qJhyuqcepoXXcz2MnoTIXTTCatiSDGyefgZYvOoGCaKcWDTM4OkNT8qrHg8xFFp7jlLxlXYvsoL6Uq3Jqfq2mCnXf8d1uQCmQcDDvkdK8IBRy3BYbtxwCgUCqhWGf/9uAQidwrWqGVI2qscIWktwbancEOj6mXydvNoKqCe3Gkl4gag1urp8j2dgde/cEvnycmPQiDA1YAAAAASUVORK5CYII=
|
||||||
|
width=8
|
||||||
|
height=8
|
||||||
|
|
||||||
|
tracking=1
|
||||||
|
|
||||||
|
0 8
|
||||||
|
1 8
|
||||||
|
2 8
|
||||||
|
3 8
|
||||||
|
4 8
|
||||||
|
5 8
|
||||||
|
6 8
|
||||||
|
7 8
|
||||||
|
8 8
|
||||||
|
9 8
|
||||||
|
space 8
|
||||||
|
<EFBFBD> 8
|
||||||
|
A 8
|
||||||
|
B 8
|
||||||
|
C 8
|
||||||
|
D 8
|
||||||
|
E 8
|
||||||
|
F 8
|
||||||
|
G 8
|
||||||
|
H 8
|
||||||
|
I 8
|
||||||
|
J 8
|
||||||
|
K 8
|
||||||
|
L 8
|
||||||
|
M 8
|
||||||
|
N 8
|
||||||
|
O 8
|
||||||
|
P 8
|
||||||
|
Q 8
|
||||||
|
R 8
|
||||||
|
S 8
|
||||||
|
T 8
|
||||||
|
U 8
|
||||||
|
V 8
|
||||||
|
W 8
|
||||||
|
X 8
|
||||||
|
Y 8
|
||||||
|
Z 8
|
||||||
|
|
BIN
source/assets/images/.DS_Store
vendored
Normal file
BIN
source/assets/images/bg_bomber33.png
Normal file
After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 3.8 KiB |
BIN
source/assets/images/maps/map_1.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
source/assets/images/maps/map_2.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
source/assets/sprites/bg2.png
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
source/assets/sprites/boomSplash1.png
Normal file
After Width: | Height: | Size: 297 B |
BIN
source/assets/sprites/boomSplash2.png
Normal file
After Width: | Height: | Size: 535 B |
BIN
source/assets/sprites/smallboom-table-400-240.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
@@ -20,7 +20,7 @@ function pdDialogue.wrap(lines, width, font)
|
|||||||
lines: an array of strings
|
lines: an array of strings
|
||||||
width: the maximum width of each line (in pixels)
|
width: the maximum width of each line (in pixels)
|
||||||
font: the font to use (optional, uses default font if not provided)
|
font: the font to use (optional, uses default font if not provided)
|
||||||
]] --
|
]]--
|
||||||
font = font or gfx.getFont()
|
font = font or gfx.getFont()
|
||||||
|
|
||||||
local result = {}
|
local result = {}
|
||||||
@@ -62,10 +62,10 @@ function pdDialogue.window(text, startIndex, height, font)
|
|||||||
startIndex: the row index to start the window
|
startIndex: the row index to start the window
|
||||||
height: the height (in pixels) of the window
|
height: the height (in pixels) of the window
|
||||||
font: the font to use (optional, uses default font if not provided)
|
font: the font to use (optional, uses default font if not provided)
|
||||||
]] --
|
]]--
|
||||||
font = font or gfx.getFont()
|
font = font or gfx.getFont()
|
||||||
|
|
||||||
local result = { text[start_index] }
|
local result = {text[start_index]}
|
||||||
local rows = pdDialogue.getRows(height, font) - 1
|
local rows = pdDialogue.getRows(height, font) - 1
|
||||||
|
|
||||||
for index = 1, rows do
|
for index = 1, rows do
|
||||||
@@ -85,7 +85,7 @@ function pdDialogue.paginate(lines, height, font)
|
|||||||
lines: array of strings (pre-wrapped)
|
lines: array of strings (pre-wrapped)
|
||||||
height: height to limit text (in pixels)
|
height: height to limit text (in pixels)
|
||||||
font: optional, will get current font if not provided
|
font: optional, will get current font if not provided
|
||||||
]] --
|
]]--
|
||||||
|
|
||||||
local result = {}
|
local result = {}
|
||||||
local currentLine = {}
|
local currentLine = {}
|
||||||
@@ -129,7 +129,7 @@ function pdDialogue.process(text, width, height, font)
|
|||||||
width: width to limit text (in pixels)
|
width: width to limit text (in pixels)
|
||||||
height: height to limit text (in pixels)
|
height: height to limit text (in pixels)
|
||||||
font: optional, will get current font if not provided
|
font: optional, will get current font if not provided
|
||||||
]] --
|
]]--
|
||||||
local lines = {}
|
local lines = {}
|
||||||
font = font or gfx.getFont()
|
font = font or gfx.getFont()
|
||||||
|
|
||||||
@@ -168,10 +168,10 @@ class("pdDialogueSprite").extends(gfx.sprite)
|
|||||||
function pdDialogueSprite:init(dialogue)
|
function pdDialogueSprite:init(dialogue)
|
||||||
--[[
|
--[[
|
||||||
dialogue: an instance of pdDialogueBox
|
dialogue: an instance of pdDialogueBox
|
||||||
]] --
|
]]--
|
||||||
pdDialogueSprite.super.init(self)
|
pdDialogueSprite.super.init(self)
|
||||||
self.image = gfx.image.new(dialogue.width, dialogue.height)
|
self.image = gfx.image.new(dialogue.width, dialogue.height)
|
||||||
self:setImage(self.image)
|
self:setImage(self.image)
|
||||||
self.dialogue = dialogue
|
self.dialogue = dialogue
|
||||||
-- Remove sprite when dialogue is closed
|
-- Remove sprite when dialogue is closed
|
||||||
local onClose = self.dialogue.onClose
|
local onClose = self.dialogue.onClose
|
||||||
@@ -182,22 +182,22 @@ function pdDialogueSprite:init(dialogue)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function pdDialogueSprite:add()
|
function pdDialogueSprite:add()
|
||||||
pdDialogueSprite.super.add(self)
|
pdDialogueSprite.super.add(self)
|
||||||
if not self.dialogue.enabled then
|
if not self.dialogue.enabled then
|
||||||
self.dialogue:enable()
|
self.dialogue:enable()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function pdDialogueSprite:update()
|
function pdDialogueSprite:update()
|
||||||
pdDialogueSprite.super.update(self)
|
pdDialogueSprite.super.update(self)
|
||||||
-- Redraw dialogue if it has changed (update returns true)
|
-- Redraw dialogue if it has changed (update returns true)
|
||||||
if self.dialogue:update() then
|
if self.dialogue:update() then
|
||||||
self.image:clear(gfx.kColorClear)
|
self.image:clear(gfx.kColorClear)
|
||||||
gfx.pushContext(self.image)
|
gfx.pushContext(self.image)
|
||||||
self.dialogue:draw(0, 0)
|
self.dialogue:draw(0, 0)
|
||||||
gfx.popContext()
|
gfx.popContext()
|
||||||
self:markDirty()
|
self:markDirty()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
----------------------------------------------------------------------------
|
----------------------------------------------------------------------------
|
||||||
@@ -206,11 +206,9 @@ end
|
|||||||
pdDialogueBox = {}
|
pdDialogueBox = {}
|
||||||
class("pdDialogueBox").extends()
|
class("pdDialogueBox").extends()
|
||||||
|
|
||||||
local ABTN = Graphics.image.new("assets/sprites/buttons/A")
|
|
||||||
|
|
||||||
function pdDialogueBox.buttonPrompt(x, y)
|
function pdDialogueBox.buttonPrompt(x, y)
|
||||||
gfx.setImageDrawMode(gfx.kDrawModeCopy)
|
gfx.setImageDrawMode(gfx.kDrawModeCopy)
|
||||||
ABTN:draw(x, y)
|
gfx.getSystemFont():drawText("Ⓐ", x, y)
|
||||||
end
|
end
|
||||||
|
|
||||||
function pdDialogueBox.arrowPrompt(x, y, color)
|
function pdDialogueBox.arrowPrompt(x, y, color)
|
||||||
@@ -228,7 +226,7 @@ function pdDialogueBox:init(text, width, height, font)
|
|||||||
width: width of dialogue box (in pixels)
|
width: width of dialogue box (in pixels)
|
||||||
height: height of dialogue box (in pixels)
|
height: height of dialogue box (in pixels)
|
||||||
font: font to use for drawing text
|
font: font to use for drawing text
|
||||||
]] --
|
]]--
|
||||||
|
|
||||||
pdDialogueBox.super.init(self)
|
pdDialogueBox.super.init(self)
|
||||||
self.speed = 0.5 -- char per frame
|
self.speed = 0.5 -- char per frame
|
||||||
@@ -250,17 +248,19 @@ function pdDialogueBox:asSprite()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function pdDialogueBox:getInputHandlers()
|
function pdDialogueBox:getInputHandlers()
|
||||||
|
local _speed = self:getSpeed()
|
||||||
return {
|
return {
|
||||||
AButtonDown = function()
|
AButtonDown = function()
|
||||||
self:setSpeed(2)
|
|
||||||
if self.dialogue_complete then
|
if self.dialogue_complete then
|
||||||
self:disable()
|
self:disable()
|
||||||
elseif self.line_complete then
|
elseif self.line_complete then
|
||||||
self:nextPage()
|
self:nextPage()
|
||||||
|
else
|
||||||
|
self:setSpeed(_speed * 2)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
AButtonUp = function()
|
AButtonUp = function()
|
||||||
self:setSpeed(0.5)
|
self:setSpeed(_speed)
|
||||||
end,
|
end,
|
||||||
BButtonDown = function()
|
BButtonDown = function()
|
||||||
if self.line_complete then
|
if self.line_complete then
|
||||||
@@ -406,6 +406,7 @@ function pdDialogueBox:nextPage()
|
|||||||
if self.currentPage + 1 <= #self.pages then
|
if self.currentPage + 1 <= #self.pages then
|
||||||
self.currentPage += 1
|
self.currentPage += 1
|
||||||
self:restartLine()
|
self:restartLine()
|
||||||
|
self:onNextPage()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -461,6 +462,10 @@ function pdDialogueBox:onPageComplete()
|
|||||||
-- Overrideable by user
|
-- Overrideable by user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function pdDialogueBox:onNextPage()
|
||||||
|
-- Overrideable by user
|
||||||
|
end
|
||||||
|
|
||||||
function pdDialogueBox:onDialogueComplete()
|
function pdDialogueBox:onDialogueComplete()
|
||||||
-- Overrideable by user
|
-- Overrideable by user
|
||||||
end
|
end
|
||||||
@@ -522,7 +527,7 @@ function pdPortraitDialogueBox:init(name, drawable, text, width, height, font)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
pdDialogueBox.init(self, text, width - self.portrait_width, height, font)
|
pdDialogueBox.init(self, text, width - self.portrait_width, height, font)
|
||||||
self:setAlignment(kTextAlignment.left)
|
self:setAlignment(kTextAlignment.left)
|
||||||
end
|
end
|
||||||
|
|
||||||
function pdPortraitDialogueBox:setAlignment(alignment)
|
function pdPortraitDialogueBox:setAlignment(alignment)
|
||||||
@@ -539,7 +544,7 @@ function pdPortraitDialogueBox:getAlignment()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function pdPortraitDialogueBox:draw(x, y)
|
function pdPortraitDialogueBox:draw(x, y)
|
||||||
local offset = self.alignment == kTextAlignment.left and self.portrait_width or 0
|
local offset = self.alignment == kTextAlignment.left and self.portrait_width or 0
|
||||||
pdPortraitDialogueBox.super.draw(self, x + offset, y)
|
pdPortraitDialogueBox.super.draw(self, x + offset, y)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -571,120 +576,123 @@ end
|
|||||||
----------------------------------------------------------------------------
|
----------------------------------------------------------------------------
|
||||||
-- #Section: dialogue box used in pdDialogue
|
-- #Section: dialogue box used in pdDialogue
|
||||||
----------------------------------------------------------------------------
|
----------------------------------------------------------------------------
|
||||||
pdDialogue.DialogueBox_x, pdDialogue.DialogueBox_y = 5, 186
|
pdDialogue.DialogueBox_x, pdDialogue.DialogueBox_y = 5, 186
|
||||||
pdDialogue.DialogueBox = pdDialogueBox(nil, 390, 48)
|
pdDialogue.DialogueBox = pdDialogueBox(nil, 390, 48)
|
||||||
pdDialogue.DialogueBox_Callbacks = {}
|
pdDialogue.DialogueBox_Callbacks = {}
|
||||||
pdDialogue.DialogueBox_Say_Default = nil
|
pdDialogue.DialogueBox_Say_Default = nil
|
||||||
pdDialogue.DialogueBox_Say_Nils = nil
|
pdDialogue.DialogueBox_Say_Nils = nil
|
||||||
pdDialogue.DialogueBox_KeyValueMap = {
|
pdDialogue.DialogueBox_KeyValueMap = {
|
||||||
width = {
|
width={
|
||||||
set = function(value) pdDialogue.DialogueBox:setWidth(value) end,
|
set=function(value) pdDialogue.DialogueBox:setWidth(value) end,
|
||||||
get = function() return pdDialogue.DialogueBox:getWidth() end
|
get=function() return pdDialogue.DialogueBox:getWidth() end
|
||||||
},
|
},
|
||||||
height = {
|
height={
|
||||||
set = function(value) pdDialogue.DialogueBox:setHeight(value) end,
|
set=function(value) pdDialogue.DialogueBox:setHeight(value) end,
|
||||||
get = function() return pdDialogue.DialogueBox:getHeight() end
|
get=function() return pdDialogue.DialogueBox:getHeight() end
|
||||||
},
|
},
|
||||||
x = {
|
x={
|
||||||
set = function(value) pdDialogue.DialogueBox_x = value end,
|
set=function(value) pdDialogue.DialogueBox_x = value end,
|
||||||
get = function() return pdDialogue.DialogueBox_x end
|
get=function() return pdDialogue.DialogueBox_x end
|
||||||
},
|
},
|
||||||
y = {
|
y={
|
||||||
set = function(value) pdDialogue.DialogueBox_y = value end,
|
set=function(value) pdDialogue.DialogueBox_y = value end,
|
||||||
get = function() return pdDialogue.DialogueBox_y end
|
get=function() return pdDialogue.DialogueBox_y end
|
||||||
},
|
},
|
||||||
padding = {
|
padding={
|
||||||
set = function(value) pdDialogue.DialogueBox:setPadding(value) end,
|
set=function(value) pdDialogue.DialogueBox:setPadding(value) end,
|
||||||
get = function() return pdDialogue.DialogueBox:getPadding() end
|
get=function() return pdDialogue.DialogueBox:getPadding() end
|
||||||
},
|
},
|
||||||
font = {
|
font={
|
||||||
set = function(value) pdDialogue.DialogueBox:setFont(value) end,
|
set=function(value) pdDialogue.DialogueBox:setFont(value) end,
|
||||||
get = function() return pdDialogue.DialogueBox:getFont() end
|
get=function() return pdDialogue.DialogueBox:getFont() end
|
||||||
},
|
},
|
||||||
fontFamily = {
|
fontFamily={
|
||||||
set = function(value) pdDialogue.DialogueBox.fontFamily = value end,
|
set=function(value) pdDialogue.DialogueBox.fontFamily = value end,
|
||||||
get = function() return pdDialogue.DialogueBox.fontFamily end
|
get=function() return pdDialogue.DialogueBox.fontFamily end
|
||||||
},
|
},
|
||||||
nineSlice = {
|
nineSlice={
|
||||||
set = function(value) pdDialogue.DialogueBox:setNineSlice(value) end,
|
set=function(value) pdDialogue.DialogueBox:setNineSlice(value) end,
|
||||||
get = function() return pdDialogue.DialogueBox:getNineSlice() end
|
get=function() return pdDialogue.DialogueBox:getNineSlice() end
|
||||||
},
|
},
|
||||||
speed = {
|
speed={
|
||||||
set = function(value) pdDialogue.DialogueBox:setSpeed(value) end,
|
set=function(value) pdDialogue.DialogueBox:setSpeed(value) end,
|
||||||
get = function() return pdDialogue.DialogueBox:getSpeed() end
|
get=function() return pdDialogue.DialogueBox:getSpeed() end
|
||||||
},
|
},
|
||||||
drawBackground = {
|
drawBackground={
|
||||||
set = function(func) pdDialogue.DialogueBox_Callbacks["drawBackground"] = func end,
|
set=function(func) pdDialogue.DialogueBox_Callbacks["drawBackground"] = func end,
|
||||||
get = function() return pdDialogue.DialogueBox_Callbacks["drawBackground"] end
|
get=function() return pdDialogue.DialogueBox_Callbacks["drawBackground"] end
|
||||||
},
|
},
|
||||||
drawText = {
|
drawText={
|
||||||
set = function(func) pdDialogue.DialogueBox_Callbacks["drawText"] = func end,
|
set=function(func) pdDialogue.DialogueBox_Callbacks["drawText"] = func end,
|
||||||
get = function() return pdDialogue.DialogueBox_Callbacks["drawText"] end
|
get=function() return pdDialogue.DialogueBox_Callbacks["drawText"] end
|
||||||
},
|
},
|
||||||
drawPrompt = {
|
drawPrompt={
|
||||||
set = function(func) pdDialogue.DialogueBox_Callbacks["drawPrompt"] = func end,
|
set=function(func) pdDialogue.DialogueBox_Callbacks["drawPrompt"] = func end,
|
||||||
get = function() return pdDialogue.DialogueBox_Callbacks["drawPrompt"] end
|
get=function() return pdDialogue.DialogueBox_Callbacks["drawPrompt"] end
|
||||||
},
|
},
|
||||||
onOpen = {
|
onOpen={
|
||||||
set = function(func) pdDialogue.DialogueBox_Callbacks["onOpen"] = func end,
|
set=function(func) pdDialogue.DialogueBox_Callbacks["onOpen"] = func end,
|
||||||
get = function() return pdDialogue.DialogueBox_Callbacks["onOpen"] end
|
get=function() return pdDialogue.DialogueBox_Callbacks["onOpen"] end
|
||||||
},
|
},
|
||||||
onPageComplete = {
|
onPageComplete={
|
||||||
set = function(func) pdDialogue.DialogueBox_Callbacks["onPageComplete"] = func end,
|
set=function(func) pdDialogue.DialogueBox_Callbacks["onPageComplete"] = func end,
|
||||||
get = function() return pdDialogue.DialogueBox_Callbacks["onPageComplete"] end
|
get=function() return pdDialogue.DialogueBox_Callbacks["onPageComplete"] end
|
||||||
},
|
},
|
||||||
onDialogueComplete = {
|
onNextPage={
|
||||||
set = function(func) pdDialogue.DialogueBox_Callbacks["onDialogueComplete"] = func end,
|
set=function(func) pdDialogue.DialogueBox_Callbacks["onNextPage"] = func end,
|
||||||
get = function() return pdDialogue.DialogueBox_Callbacks["onDialogueComplete"] end
|
get=function() return pdDialogue.DialogueBox_Callbacks["onNextPage"] end
|
||||||
},
|
},
|
||||||
onClose = {
|
onDialogueComplete={
|
||||||
set = function(func) pdDialogue.DialogueBox_Callbacks["onClose"] = func end,
|
set=function(func) pdDialogue.DialogueBox_Callbacks["onDialogueComplete"] = func end,
|
||||||
get = function() return pdDialogue.DialogueBox_Callbacks["onClose"] end
|
get=function() return pdDialogue.DialogueBox_Callbacks["onDialogueComplete"] end
|
||||||
|
},
|
||||||
|
onClose={
|
||||||
|
set=function(func) pdDialogue.DialogueBox_Callbacks["onClose"] = func end,
|
||||||
|
get=function() return pdDialogue.DialogueBox_Callbacks["onClose"] end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function pdDialogue.DialogueBox:drawBackground(x, y)
|
function pdDialogue.DialogueBox:drawBackground(x, y)
|
||||||
if pdDialogue.DialogueBox_Callbacks["drawBackground"] ~= nil then
|
if pdDialogue.DialogueBox_Callbacks["drawBackground"] ~= nil then
|
||||||
pdDialogue.DialogueBox_Callbacks["drawBackground"](dialogue, x, y)
|
pdDialogue.DialogueBox_Callbacks["drawBackground"](self, x, y)
|
||||||
else
|
else
|
||||||
pdDialogue.DialogueBox.super.drawBackground(self, x, y)
|
pdDialogue.DialogueBox.super.drawBackground(self, x, y)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
function pdDialogue.DialogueBox:drawText(x, y ,text)
|
||||||
function pdDialogue.DialogueBox:drawText(x, y, text)
|
|
||||||
if pdDialogue.DialogueBox_Callbacks["drawText"] ~= nil then
|
if pdDialogue.DialogueBox_Callbacks["drawText"] ~= nil then
|
||||||
pdDialogue.DialogueBox_Callbacks["drawText"](dialogue, x, y, text)
|
pdDialogue.DialogueBox_Callbacks["drawText"](self, x, y, text)
|
||||||
else
|
else
|
||||||
pdDialogue.DialogueBox.super.drawText(self, x, y, text)
|
pdDialogue.DialogueBox.super.drawText(self, x, y, text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function pdDialogue.DialogueBox:drawPrompt(x, y)
|
function pdDialogue.DialogueBox:drawPrompt(x, y)
|
||||||
if pdDialogue.DialogueBox_Callbacks["drawPrompt"] ~= nil then
|
if pdDialogue.DialogueBox_Callbacks["drawPrompt"] ~= nil then
|
||||||
pdDialogue.DialogueBox_Callbacks["drawPrompt"](dialogue, x, y)
|
pdDialogue.DialogueBox_Callbacks["drawPrompt"](self, x, y)
|
||||||
else
|
else
|
||||||
pdDialogue.DialogueBox.super.drawPrompt(self, x, y)
|
pdDialogue.DialogueBox.super.drawPrompt(self, x, y)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function pdDialogue.DialogueBox:onOpen()
|
function pdDialogue.DialogueBox:onOpen()
|
||||||
pd.inputHandlers.push(self:getInputHandlers(), true)
|
pd.inputHandlers.push(self:getInputHandlers(), true)
|
||||||
if pdDialogue.DialogueBox_Callbacks["onOpen"] ~= nil then
|
if pdDialogue.DialogueBox_Callbacks["onOpen"] ~= nil then
|
||||||
pdDialogue.DialogueBox_Callbacks["onOpen"]()
|
pdDialogue.DialogueBox_Callbacks["onOpen"]()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function pdDialogue.DialogueBox:onPageComplete()
|
function pdDialogue.DialogueBox:onPageComplete()
|
||||||
if pdDialogue.DialogueBox_Callbacks["onPageComplete"] ~= nil then
|
if pdDialogue.DialogueBox_Callbacks["onPageComplete"] ~= nil then
|
||||||
pdDialogue.DialogueBox_Callbacks["onPageComplete"]()
|
pdDialogue.DialogueBox_Callbacks["onPageComplete"]()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
function pdDialogue.DialogueBox:onNextPage()
|
||||||
|
if pdDialogue.DialogueBox_Callbacks["onNextPage"] ~= nil then
|
||||||
|
pdDialogue.DialogueBox_Callbacks["onNextPage"]()
|
||||||
|
end
|
||||||
|
end
|
||||||
function pdDialogue.DialogueBox:onDialogueComplete()
|
function pdDialogue.DialogueBox:onDialogueComplete()
|
||||||
if pdDialogue.DialogueBox_Callbacks["onDialogueComplete"] ~= nil then
|
if pdDialogue.DialogueBox_Callbacks["onDialogueComplete"] ~= nil then
|
||||||
pdDialogue.DialogueBox_Callbacks["onDialogueComplete"]()
|
pdDialogue.DialogueBox_Callbacks["onDialogueComplete"]()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function pdDialogue.DialogueBox:onClose()
|
function pdDialogue.DialogueBox:onClose()
|
||||||
-- Make a backup of the current onClose callback
|
-- Make a backup of the current onClose callback
|
||||||
local current = pdDialogue.DialogueBox_Callbacks["onClose"]
|
local current = pdDialogue.DialogueBox_Callbacks["onClose"]
|
||||||
@@ -738,7 +746,7 @@ function pdDialogue.say(text, config)
|
|||||||
--[[
|
--[[
|
||||||
text: string (can be multiline) to say
|
text: string (can be multiline) to say
|
||||||
config: optional table, will provide temporary overrides for this one dialogue box
|
config: optional table, will provide temporary overrides for this one dialogue box
|
||||||
]] --
|
]]--
|
||||||
if config ~= nil then
|
if config ~= nil then
|
||||||
pdDialogue.DialogueBox_Say_Default, pdDialogue.DialogueBox_Say_Nils = pdDialogue.setup(config)
|
pdDialogue.DialogueBox_Say_Default, pdDialogue.DialogueBox_Say_Nils = pdDialogue.setup(config)
|
||||||
end
|
end
|
||||||
|
@@ -569,7 +569,7 @@ function ParticlePixel:update()
|
|||||||
for part = 1, #self.particles, 1 do
|
for part = 1, #self.particles, 1 do
|
||||||
local pix = self.particles[part]
|
local pix = self.particles[part]
|
||||||
|
|
||||||
playdate.graphics.drawPixel(pix.x,pix.y,pix.size)
|
playdate.graphics.drawPixel(pix.x,pix.y)
|
||||||
|
|
||||||
pix.x += math.sin(math.rad(pix.dir)) * pix.speed
|
pix.x += math.sin(math.rad(pix.dir)) * pix.speed
|
||||||
pix.y -= math.cos(math.rad(pix.dir)) * pix.speed
|
pix.y -= math.cos(math.rad(pix.dir)) * pix.speed
|
||||||
|
@@ -34,9 +34,30 @@ CollideGroups = {
|
|||||||
wall = 5
|
wall = 5
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Maps = {
|
||||||
|
{
|
||||||
|
id = 1,
|
||||||
|
name = "Vovchansk",
|
||||||
|
description = "This is a map",
|
||||||
|
locked = false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id = 2,
|
||||||
|
name = "Mariupol",
|
||||||
|
description = "This is a map",
|
||||||
|
locked = false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Modes = {
|
||||||
|
fpv = "FPV",
|
||||||
|
bomber = "Bomber"
|
||||||
|
}
|
||||||
|
|
||||||
Drones = {
|
Drones = {
|
||||||
{
|
{
|
||||||
id = 1,
|
id = 1,
|
||||||
|
mode = Modes.fpv,
|
||||||
name = "Quad FPV",
|
name = "Quad FPV",
|
||||||
description =
|
description =
|
||||||
"This is a quadrocopter with a camera on it. It's a good drone for beginners. It's easy to control and has a good battery life.",
|
"This is a quadrocopter with a camera on it. It's a good drone for beginners. It's easy to control and has a good battery life.",
|
||||||
@@ -47,10 +68,11 @@ Drones = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
id = 2,
|
id = 2,
|
||||||
|
mode = Modes.bomber,
|
||||||
name = "Drone 2",
|
name = "Drone 2",
|
||||||
description = "This is a drone",
|
description = "This is a drone",
|
||||||
price = 200,
|
price = 200,
|
||||||
locked = true,
|
locked = false,
|
||||||
preview = nil,
|
preview = nil,
|
||||||
full = nil
|
full = nil
|
||||||
},
|
},
|
||||||
@@ -76,6 +98,7 @@ Drones = {
|
|||||||
|
|
||||||
import "scripts/player"
|
import "scripts/player"
|
||||||
import "scripts/bigBoomSprite"
|
import "scripts/bigBoomSprite"
|
||||||
|
import "scripts/bomber/boom"
|
||||||
import "scripts/groundSprite"
|
import "scripts/groundSprite"
|
||||||
import "scripts/balebaSprite"
|
import "scripts/balebaSprite"
|
||||||
import "scripts/dangerSprite"
|
import "scripts/dangerSprite"
|
||||||
@@ -84,12 +107,18 @@ import "scripts/progressBar"
|
|||||||
import "scripts/selectionSprite"
|
import "scripts/selectionSprite"
|
||||||
import "scripts/DroneCard"
|
import "scripts/DroneCard"
|
||||||
import "scripts/pageSprite"
|
import "scripts/pageSprite"
|
||||||
|
import "scripts/MapCard"
|
||||||
|
import "scripts/bomber/movableCrosshair"
|
||||||
|
import "scripts/bomber/granade"
|
||||||
|
import "scripts/bomber/explosionMark"
|
||||||
|
|
||||||
import "scenes/BaseScene"
|
import "scenes/BaseScene"
|
||||||
import 'scenes/Assemble'
|
import 'scenes/Assemble'
|
||||||
import 'scenes/DroneCardSelector'
|
import 'scenes/DroneCardSelector'
|
||||||
import 'scenes/Menu'
|
import 'scenes/Menu'
|
||||||
import 'scenes/Game'
|
import 'scenes/Game'
|
||||||
|
import 'scenes/MapSelector'
|
||||||
|
import 'scenes/bomber/BomberScene'
|
||||||
|
|
||||||
Difficulty = {
|
Difficulty = {
|
||||||
Easy = "Easy",
|
Easy = "Easy",
|
||||||
@@ -115,7 +144,7 @@ DifficultySettings = {
|
|||||||
Noble.Settings.setup({
|
Noble.Settings.setup({
|
||||||
difficulty = Difficulty.Medium,
|
difficulty = Difficulty.Medium,
|
||||||
music = true,
|
music = true,
|
||||||
debug = true
|
debug = false
|
||||||
})
|
})
|
||||||
|
|
||||||
Noble.GameData.setup({
|
Noble.GameData.setup({
|
||||||
@@ -130,4 +159,4 @@ playdate.display.setRefreshRate(50)
|
|||||||
|
|
||||||
Noble.showFPS = false
|
Noble.showFPS = false
|
||||||
|
|
||||||
Noble.new(Menu)
|
Noble.new(BomberScene)
|
||||||
|
@@ -2,7 +2,7 @@ name=FPV Game
|
|||||||
author=ut3usw
|
author=ut3usw
|
||||||
description=This is a FPV Game
|
description=This is a FPV Game
|
||||||
bundleID=guru.dead.fpv
|
bundleID=guru.dead.fpv
|
||||||
version=0.1.2
|
version=0.2.0
|
||||||
buildNumber=3
|
buildNumber=10
|
||||||
imagePath=assets/launcher/
|
imagePath=assets/launcher/
|
||||||
launchSoundPath=assets/launcher/sound.wav
|
launchSoundPath=assets/launcher/sound.wav
|
@@ -133,20 +133,19 @@ end
|
|||||||
function scene:start()
|
function scene:start()
|
||||||
scene.super.start(self)
|
scene.super.start(self)
|
||||||
|
|
||||||
|
|
||||||
self.optionsMenu:addMenuItem("Main Menu", function() Noble.transition(Menu) end)
|
self.optionsMenu:addMenuItem("Main Menu", function() Noble.transition(Menu) end)
|
||||||
Noble.showFPS = false
|
Noble.showFPS = false
|
||||||
|
if scene.musicEnabled then
|
||||||
|
scene.levelAudio:play(0)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function scene:enter()
|
function scene:enter()
|
||||||
scene.super.enter(self)
|
scene.super.enter(self)
|
||||||
|
|
||||||
scene.buttonTimeout = 100
|
scene.buttonTimeout = 100
|
||||||
|
|
||||||
Noble.Input.setHandler(scene.inputHandler)
|
Noble.Input.setHandler(scene.inputHandler)
|
||||||
|
|
||||||
if scene.musicEnabled then
|
|
||||||
scene.levelAudio:play(0)
|
|
||||||
end
|
|
||||||
local text =
|
local text =
|
||||||
[[The drone is assembled and operational. We are ready for the mission.
|
[[The drone is assembled and operational. We are ready for the mission.
|
||||||
|
|
||||||
@@ -226,6 +225,10 @@ function scene:update()
|
|||||||
self.tickTimer:remove()
|
self.tickTimer:remove()
|
||||||
screenShake(100, 5)
|
screenShake(100, 5)
|
||||||
Noble.Input.setEnabled(false)
|
Noble.Input.setEnabled(false)
|
||||||
|
playdate.timer.performAfterDelay(2500, function() -- Return to the start after failure
|
||||||
|
Noble.Input.setEnabled(true)
|
||||||
|
Noble.transition(DroneCardSelector, nil, Noble.Transition.SpotlightMask);
|
||||||
|
end)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@@ -10,9 +10,21 @@ scene.inputHandler = {
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
scene.menuConfirmSound:play(1)
|
scene.menuConfirmSound:play(1)
|
||||||
Noble.transition(Assemble)
|
mode = Drones[scene.menuIndex].mode
|
||||||
|
local soundTable = playdate.sound.playingSources()
|
||||||
|
for i=1, #soundTable do
|
||||||
|
soundTable[i]:stop()
|
||||||
|
end
|
||||||
|
if mode == Modes.bomber then
|
||||||
|
Noble.transition(BomberScene)
|
||||||
|
else
|
||||||
|
Noble.transition(Assemble)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
BButtonDown = function()
|
||||||
|
scene.menuBackSound:play(1)
|
||||||
|
Noble.transition(MapSelector)
|
||||||
end,
|
end,
|
||||||
BButtonDown = function() end,
|
|
||||||
downButtonDown = function()
|
downButtonDown = function()
|
||||||
end,
|
end,
|
||||||
leftButtonDown = function()
|
leftButtonDown = function()
|
||||||
@@ -41,7 +53,9 @@ function scene:setValues()
|
|||||||
self.menuIndex = 1
|
self.menuIndex = 1
|
||||||
|
|
||||||
self.aKey = Graphics.image.new("assets/sprites/buttons/A")
|
self.aKey = Graphics.image.new("assets/sprites/buttons/A")
|
||||||
|
self.bKey = Graphics.image.new("assets/sprites/buttons/B")
|
||||||
scene.menuConfirmSound = playdate.sound.fileplayer.new("assets/audio/confirm")
|
scene.menuConfirmSound = playdate.sound.fileplayer.new("assets/audio/confirm")
|
||||||
|
scene.menuBackSound = playdate.sound.fileplayer.new("assets/audio/back")
|
||||||
|
|
||||||
scene.menuSelSound = playdate.sound.fileplayer.new("assets/audio/menu_select")
|
scene.menuSelSound = playdate.sound.fileplayer.new("assets/audio/menu_select")
|
||||||
scene.menuSelSound:setVolume(0.5)
|
scene.menuSelSound:setVolume(0.5)
|
||||||
@@ -64,12 +78,10 @@ end
|
|||||||
|
|
||||||
function scene:enter()
|
function scene:enter()
|
||||||
scene.super.enter(self)
|
scene.super.enter(self)
|
||||||
scene.cards = {
|
scene.cards = {}
|
||||||
DroneCard(0, 0, Drones[1]),
|
for i = 1, #Drones do
|
||||||
DroneCard(0, 0, Drones[2]),
|
scene.cards[i] = DroneCard(0, 0, Drones[i])
|
||||||
DroneCard(0, 0, Drones[3]),
|
end
|
||||||
DroneCard(0, 0, Drones[4]),
|
|
||||||
}
|
|
||||||
scene.paginator = PageSprite(200, 207)
|
scene.paginator = PageSprite(200, 207)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -91,7 +103,7 @@ function scene:update()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local x = 0
|
local x = 0
|
||||||
for i = 1, 4 do
|
for i = 1, #scene.cards do
|
||||||
x = 29 + (339 + 16) * (i - 1)
|
x = 29 + (339 + 16) * (i - 1)
|
||||||
scene.cards[i]:moveTo(x + scene.currentX, 25)
|
scene.cards[i]:moveTo(x + scene.currentX, 25)
|
||||||
end
|
end
|
||||||
@@ -101,12 +113,15 @@ function scene:update()
|
|||||||
Noble.Text.draw("Assemble", 333, 210, Noble.Text.ALIGN_LEFT, false, fontMed)
|
Noble.Text.draw("Assemble", 333, 210, Noble.Text.ALIGN_LEFT, false, fontMed)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self.bKey:draw(15, 207 + dy)
|
||||||
|
Noble.Text.draw("Back", 33, 210, Noble.Text.ALIGN_LEFT, false, fontMed)
|
||||||
|
|
||||||
scene.paginator:moveTo(200, 207)
|
scene.paginator:moveTo(200, 207)
|
||||||
end
|
end
|
||||||
|
|
||||||
function scene:exit()
|
function scene:exit()
|
||||||
scene.super.exit(self)
|
scene.super.exit(self)
|
||||||
for i = 1, 4 do
|
for i = 1, #scene.cards do
|
||||||
scene.cards[i]:remove()
|
scene.cards[i]:remove()
|
||||||
end
|
end
|
||||||
Noble.showFPS = false
|
Noble.showFPS = false
|
||||||
|
123
source/scenes/MapSelector.lua
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
MapSelector = {}
|
||||||
|
class("MapSelector").extends(BaseScene)
|
||||||
|
local scene = MapSelector
|
||||||
|
local fontMed = Graphics.font.new('assets/fonts/onyx_9')
|
||||||
|
local fontBig = Graphics.font.new('assets/fonts/opal_12')
|
||||||
|
local elapsedTime = 0
|
||||||
|
|
||||||
|
function scene:init()
|
||||||
|
playdate.graphics.setImageDrawMode(playdate.graphics.kDrawModeXOR)
|
||||||
|
scene.super.init(self)
|
||||||
|
scene.menuIndex = 1
|
||||||
|
|
||||||
|
self.aKey = Graphics.image.new("assets/sprites/buttons/A")
|
||||||
|
self.bKey = Graphics.image.new("assets/sprites/buttons/B")
|
||||||
|
|
||||||
|
scene.menuConfirmSound = playdate.sound.fileplayer.new("assets/audio/confirm")
|
||||||
|
scene.menuBackSound = playdate.sound.fileplayer.new("assets/audio/back")
|
||||||
|
|
||||||
|
scene.menuSelSound = playdate.sound.fileplayer.new("assets/audio/menu_select")
|
||||||
|
scene.menuSelSound:setVolume(0.5)
|
||||||
|
|
||||||
|
scene.currentX = 0
|
||||||
|
scene.targetX = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function scene:start()
|
||||||
|
scene.super.start(self)
|
||||||
|
|
||||||
|
Noble.showFPS = false
|
||||||
|
|
||||||
|
self.optionsMenu:addMenuItem("Main Menu", function() Noble.transition(Menu) end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function scene:enter()
|
||||||
|
scene.super.enter(self)
|
||||||
|
scene.cards = {}
|
||||||
|
for i = 1, #Maps do
|
||||||
|
scene.cards[i] = MapCard(0, 0, Maps[i])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function scene:update()
|
||||||
|
scene.super.update(self)
|
||||||
|
elapsedTime = elapsedTime + 1 / playdate.display.getRefreshRate()
|
||||||
|
|
||||||
|
local dy = 2 * math.sin(20 * elapsedTime)
|
||||||
|
|
||||||
|
local speed = 40
|
||||||
|
if math.abs(scene.targetX - scene.currentX) < speed then
|
||||||
|
scene.currentX = scene.targetX
|
||||||
|
else
|
||||||
|
scene.currentX = scene.currentX + speed * ((scene.targetX > scene.currentX) and 1 or -1)
|
||||||
|
end
|
||||||
|
|
||||||
|
local x = 0
|
||||||
|
for i = 1, #scene.cards do
|
||||||
|
x = 400 * (i - 1)
|
||||||
|
scene.cards[i]:moveTo(x + scene.currentX, 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Bottom background
|
||||||
|
if Maps[scene.menuIndex].locked == false then
|
||||||
|
self.aKey:draw(315, 207 + dy)
|
||||||
|
Noble.Text.draw("Select", 333, 210, Noble.Text.ALIGN_LEFT, false, fontMed)
|
||||||
|
end
|
||||||
|
|
||||||
|
self.bKey:draw(15, 207 + dy)
|
||||||
|
Noble.Text.draw("Back", 33, 210, Noble.Text.ALIGN_LEFT, false, fontMed)
|
||||||
|
|
||||||
|
Noble.Text.draw(string.upper(Maps[scene.menuIndex].name), 200, 210, Noble.Text.ALIGN_CENTER, false, fontBig)
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function scene:exit()
|
||||||
|
scene.super.exit(self)
|
||||||
|
for i = 1, #scene.cards do
|
||||||
|
scene.cards[i]:remove()
|
||||||
|
end
|
||||||
|
Noble.showFPS = false
|
||||||
|
playdate.graphics.setImageDrawMode(playdate.graphics.kDrawModeXOR)
|
||||||
|
end
|
||||||
|
|
||||||
|
function scene:finish()
|
||||||
|
scene.super.finish(self)
|
||||||
|
for i = 1, #scene.cards do
|
||||||
|
scene.cards[i]:remove()
|
||||||
|
end
|
||||||
|
playdate.display.setScale(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
scene.inputHandler = {
|
||||||
|
AButtonDown = function()
|
||||||
|
if Maps[scene.menuIndex].locked then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
scene.menuConfirmSound:play(1)
|
||||||
|
Noble.transition(DroneCardSelector)
|
||||||
|
end,
|
||||||
|
BButtonDown = function()
|
||||||
|
scene.menuBackSound:play(1)
|
||||||
|
Noble.transition(Menu)
|
||||||
|
end,
|
||||||
|
leftButtonDown = function()
|
||||||
|
if scene.menuIndex <= 1 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
scene.menuSelSound:play(1)
|
||||||
|
scene.targetX = scene.targetX + 400
|
||||||
|
scene.menuIndex = scene.menuIndex - 1
|
||||||
|
end,
|
||||||
|
rightButtonDown = function()
|
||||||
|
if scene.menuIndex >= #Maps then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
scene.menuSelSound:play(1)
|
||||||
|
scene.targetX = scene.targetX - 400
|
||||||
|
scene.menuIndex = scene.menuIndex + 1
|
||||||
|
end,
|
||||||
|
upButtonDown = function()
|
||||||
|
end,
|
||||||
|
}
|
@@ -24,6 +24,10 @@ function scene:setValues()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function scene:init()
|
function scene:init()
|
||||||
|
local soundTable = playdate.sound.playingSources()
|
||||||
|
for i=1, #soundTable do
|
||||||
|
soundTable[i]:stop()
|
||||||
|
end
|
||||||
scene.super.init(self)
|
scene.super.init(self)
|
||||||
|
|
||||||
local menuSelSound = playdate.sound.fileplayer.new("assets/audio/menu_select")
|
local menuSelSound = playdate.sound.fileplayer.new("assets/audio/menu_select")
|
||||||
@@ -106,13 +110,13 @@ end
|
|||||||
|
|
||||||
function scene:exit()
|
function scene:exit()
|
||||||
scene.super.exit(self)
|
scene.super.exit(self)
|
||||||
scene.levelAudio:stop()
|
-- scene.levelAudio:stop()
|
||||||
self.sequence = Sequence.new():from(self.menuY):to(self.menuYTo, 0.5, Ease.inSine)
|
self.sequence = Sequence.new():from(self.menuY):to(self.menuYTo, 0.5, Ease.inSine)
|
||||||
self.sequence:start()
|
self.sequence:start()
|
||||||
end
|
end
|
||||||
|
|
||||||
function scene:setupMenu(__menu)
|
function scene:setupMenu(__menu)
|
||||||
__menu:addItem("Start", function() Noble.transition(DroneCardSelector, nil, Noble.Transition.DipToWhite) end)
|
__menu:addItem("Start", function() Noble.transition(MapSelector, nil, Noble.Transition.DipToWhite) end)
|
||||||
__menu:addItem("Tutorial", function()
|
__menu:addItem("Tutorial", function()
|
||||||
local debug = Noble.Settings.get("debug")
|
local debug = Noble.Settings.get("debug")
|
||||||
if debug then
|
if debug then
|
||||||
|
113
source/scenes/bomber/BomberScene.lua
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
BomberScene = {}
|
||||||
|
class("BomberScene").extends(BaseScene)
|
||||||
|
local scene = BomberScene
|
||||||
|
|
||||||
|
local font = Graphics.font.new('assets/fonts/Mini Sans 2X')
|
||||||
|
|
||||||
|
function scene:init()
|
||||||
|
scene.super.init(self)
|
||||||
|
|
||||||
|
self.bg = Graphics.image.new("assets/sprites/bg2")
|
||||||
|
self.bgY = 0
|
||||||
|
self.scrollSpeed = 0.6
|
||||||
|
|
||||||
|
scene.progressBar = ProgressBar(50, 210, 50, 5)
|
||||||
|
scene.progressBar:set(0)
|
||||||
|
scene.progressBar:setVisible(false)
|
||||||
|
|
||||||
|
scene.grenadeCooldown = false
|
||||||
|
scene.grenadeCooldownTimer = nil
|
||||||
|
scene.grenadeCooldownDuration = 100
|
||||||
|
scene.progressBarMax = 100
|
||||||
|
|
||||||
|
scene.availableGrenades = 8
|
||||||
|
|
||||||
|
BomberScene.instance = self
|
||||||
|
end
|
||||||
|
|
||||||
|
function scene:drawBackground()
|
||||||
|
self.bgY = self.bgY + self.scrollSpeed
|
||||||
|
|
||||||
|
if self.bgY >= 720 then
|
||||||
|
self.bgY = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
self.bg:draw(0, self.bgY - 720)
|
||||||
|
self.bg:draw(0, self.bgY)
|
||||||
|
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()
|
||||||
|
if scene.availableGrenades <= 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
print("AButtonDown")
|
||||||
|
if not scene.grenadeCooldown then
|
||||||
|
Granade(scene.crosshair.x, scene.crosshair.y)
|
||||||
|
scene.grenadeCooldown = true
|
||||||
|
|
||||||
|
scene.progressBar:set(0)
|
||||||
|
scene.progressBar:setVisible(true)
|
||||||
|
scene.availableGrenades = scene.availableGrenades - 1
|
||||||
|
|
||||||
|
scene.grenadeCooldownTimer = playdate.timer.new(scene.grenadeCooldownDuration, function()
|
||||||
|
scene.grenadeCooldown = false
|
||||||
|
scene.progressBar:setVisible(false)
|
||||||
|
end)
|
||||||
|
|
||||||
|
scene.grenadeCooldownTimer.updateCallback = function(timer)
|
||||||
|
local percentage = (scene.grenadeCooldownDuration - timer.timeLeft) / scene.grenadeCooldownDuration * scene.progressBarMax
|
||||||
|
scene.progressBar:set(percentage)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
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)
|
||||||
|
self.optionsMenu:addMenuItem("Main Menu", function() Noble.transition(Menu) end)
|
||||||
|
Noble.showFPS = true
|
||||||
|
end
|
||||||
|
|
||||||
|
function scene:update()
|
||||||
|
scene.super.update(self)
|
||||||
|
Noble.Text.draw(scene.availableGrenades .. "x", 10, 210, Noble.Text.ALIGN_LEFT, false, font)
|
||||||
|
|
||||||
|
if scene.availableGrenades <= 0 then
|
||||||
|
Noble.Text.draw("No grenades left", 200, 110, Noble.Text.ALIGN_CENTER, false, font)
|
||||||
|
scene.crosshair:setVisible(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
if playdate.isCrankDocked() then
|
||||||
|
Noble.Text.draw("Crank it to reload!", 200, 110, Noble.Text.ALIGN_CENTER, false, font)
|
||||||
|
playdate.ui.crankIndicator:draw()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- TODO: to reset grenades spin crank
|
||||||
|
-- TODO: random spawn of enemies
|
||||||
|
-- TODO: random spawn some decorations
|
||||||
|
-- TODO: add some music
|
||||||
|
-- TODO: add some sound effects
|
||||||
|
-- TODO: add clouds or smoke
|
||||||
|
-- TODO: random disactivate granades
|
11
source/scripts/MapCard.lua
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
local pd <const> = playdate
|
||||||
|
local gfx <const> = Graphics
|
||||||
|
|
||||||
|
class('MapCard').extends(gfx.sprite)
|
||||||
|
|
||||||
|
function MapCard:init(x, y, map)
|
||||||
|
self:setImage(gfx.image.new('assets/images/maps/map_' .. map.id .. '.png'))
|
||||||
|
self:setCenter(0, 0)
|
||||||
|
self:moveTo(x, y)
|
||||||
|
self:add()
|
||||||
|
end
|
28
source/scripts/bomber/boom.lua
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
SmallBoom = {}
|
||||||
|
class("SmallBoom").extends(AnimatedSprite)
|
||||||
|
|
||||||
|
local smallBoomImageTable = Graphics.imagetable.new("assets/sprites/smallboom")
|
||||||
|
|
||||||
|
function SmallBoom:init()
|
||||||
|
SmallBoom.super.init(self, smallBoomImageTable)
|
||||||
|
|
||||||
|
-- Animation properties
|
||||||
|
self:addState("play", 1, 3, { tickStep = 1, loop = 2 })
|
||||||
|
self:setDefaultState("play")
|
||||||
|
self:playAnimation()
|
||||||
|
self:setCenter(0, 0)
|
||||||
|
self:setSize(playdate.display.getSize())
|
||||||
|
self:setZIndex(ZIndex.flash)
|
||||||
|
|
||||||
|
self:moveTo(0, 0)
|
||||||
|
|
||||||
|
self:add()
|
||||||
|
end
|
||||||
|
|
||||||
|
function SmallBoom:update()
|
||||||
|
self:updateAnimation()
|
||||||
|
end
|
||||||
|
|
||||||
|
function SmallBoom:stopAnimation()
|
||||||
|
self:remove()
|
||||||
|
end
|
20
source/scripts/bomber/explosionMark.lua
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
ExplosionMark = {}
|
||||||
|
class('ExplosionMark').extends(NobleSprite)
|
||||||
|
|
||||||
|
function ExplosionMark:init(x, y)
|
||||||
|
ExplosionMark.super.init(self)
|
||||||
|
self.id = math.random(1, 2)
|
||||||
|
self.markImage = Graphics.image.new("assets/sprites/boomSplash" .. self.id) -- TODO: make it random
|
||||||
|
self:setImage(self.markImage)
|
||||||
|
self:moveTo(x, y)
|
||||||
|
self:setZIndex(5)
|
||||||
|
self:add(x, y)
|
||||||
|
end
|
||||||
|
|
||||||
|
function ExplosionMark:update()
|
||||||
|
self:moveBy(0, BomberScene.instance.scrollSpeed)
|
||||||
|
|
||||||
|
if self.y > 240 + 32 then
|
||||||
|
self:remove()
|
||||||
|
end
|
||||||
|
end
|
91
source/scripts/bomber/granade.lua
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
Granade = {}
|
||||||
|
class('Granade').extends(NobleSprite)
|
||||||
|
|
||||||
|
local function screenShake(shakeTime, shakeMagnitude)
|
||||||
|
local shakeTimer = playdate.timer.new(shakeTime, shakeMagnitude, 0)
|
||||||
|
shakeTimer.updateCallback = function(timer)
|
||||||
|
local magnitude = math.floor(timer.value)
|
||||||
|
local shakeX = math.random(-magnitude, magnitude)
|
||||||
|
local shakeY = math.random(-magnitude, magnitude)
|
||||||
|
playdate.display.setOffset(shakeX, shakeY)
|
||||||
|
end
|
||||||
|
shakeTimer.timerEndedCallback = function()
|
||||||
|
playdate.display.setOffset(0, 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Granade:init(x, y)
|
||||||
|
Granade.super.init(self)
|
||||||
|
|
||||||
|
self.initialRadius = 10
|
||||||
|
self.currentRadius = self.initialRadius
|
||||||
|
self.shrinkRate = 0.2
|
||||||
|
|
||||||
|
random = math.random(1, 4)
|
||||||
|
self.boomSound = playdate.sound.fileplayer.new("assets/audio/boom" .. random)
|
||||||
|
self.boomSound:setVolume(0.5)
|
||||||
|
|
||||||
|
self.isActive = true
|
||||||
|
-- Variables for random movement
|
||||||
|
self.randomMovementTimer = 0
|
||||||
|
self.randomXVelocity = 0
|
||||||
|
self.randomYVelocity = 0
|
||||||
|
|
||||||
|
local size = self.initialRadius * 2
|
||||||
|
self.spriteSize = size
|
||||||
|
self:setSize(size, size)
|
||||||
|
self:moveTo(x, y)
|
||||||
|
self:setCenter(0.5, 0.5)
|
||||||
|
|
||||||
|
print("Granade init")
|
||||||
|
print(self.x, self.y)
|
||||||
|
self:add(x, y)
|
||||||
|
self:markDirty()
|
||||||
|
end
|
||||||
|
|
||||||
|
function Granade:update()
|
||||||
|
if self.isActive then
|
||||||
|
if BomberScene.instance then
|
||||||
|
self:moveBy(0, BomberScene.instance.scrollSpeed - 0.2)
|
||||||
|
|
||||||
|
self.randomMovementTimer = self.randomMovementTimer + 1
|
||||||
|
|
||||||
|
if self.randomMovementTimer >= 10 then
|
||||||
|
self.randomMovementTimer = 0
|
||||||
|
self.randomXVelocity = math.random(-50, 50) / 100
|
||||||
|
self.randomYVelocity = math.random(-5, 10) / 100
|
||||||
|
end
|
||||||
|
|
||||||
|
self:moveBy(self.randomXVelocity, self.randomYVelocity)
|
||||||
|
end
|
||||||
|
|
||||||
|
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)
|
||||||
|
particleB:setAngular(-5, 5122)
|
||||||
|
particleB:setSize(1, 2)
|
||||||
|
particleB:setSpeed(1, 20)
|
||||||
|
particleB:setMode(Particles.modes.STAY)
|
||||||
|
particleB:setBounds(0, 0, 400, 240)
|
||||||
|
particleB:setColour(Graphics.kColorXOR)
|
||||||
|
particleB:add(20)
|
||||||
|
self.boomSound:play(1)
|
||||||
|
screenShake(1000, 5)
|
||||||
|
SmallBoom()
|
||||||
|
ExplosionMark(self.x, self.y)
|
||||||
|
|
||||||
|
self:remove()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self:markDirty()
|
||||||
|
end
|
||||||
|
|
||||||
|
function Granade:draw()
|
||||||
|
local centerX = self.spriteSize / 2
|
||||||
|
local centerY = self.spriteSize / 2
|
||||||
|
playdate.graphics.fillCircleAtPoint(centerX, centerY, self.currentRadius)
|
||||||
|
end
|
89
source/scripts/bomber/movableCrosshair.lua
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
MovableCrosshair = {}
|
||||||
|
class('MovableCrosshair').extends(playdate.graphics.sprite)
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
-- Calculate size based on crosshair dimensions
|
||||||
|
local totalSize = (self.lineLength + self.gapSize) * 2 + 10
|
||||||
|
self:setSize(totalSize, totalSize)
|
||||||
|
|
||||||
|
-- Set the drawing offset to middle of sprite
|
||||||
|
self.drawOffsetX = totalSize / 2
|
||||||
|
self.drawOffsetY = totalSize / 2
|
||||||
|
|
||||||
|
self:add(self.baseX, self.baseY)
|
||||||
|
self:setCenter(0.5, 0.5)
|
||||||
|
self:markDirty()
|
||||||
|
end
|
||||||
|
|
||||||
|
function MovableCrosshair:update()
|
||||||
|
MovableCrosshair.super.update(self)
|
||||||
|
self.time = self.time + playdate.display.getRefreshRate() / 1000
|
||||||
|
|
||||||
|
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:markDirty()
|
||||||
|
end
|
||||||
|
|
||||||
|
function MovableCrosshair:draw()
|
||||||
|
local centerX = self.drawOffsetX
|
||||||
|
local centerY = self.drawOffsetY
|
||||||
|
|
||||||
|
playdate.graphics.drawLine(
|
||||||
|
centerX - self.lineLength - self.gapSize, centerY,
|
||||||
|
centerX - self.gapSize, centerY
|
||||||
|
)
|
||||||
|
|
||||||
|
playdate.graphics.drawLine(
|
||||||
|
centerX + self.gapSize, centerY,
|
||||||
|
centerX + self.lineLength + self.gapSize, centerY
|
||||||
|
)
|
||||||
|
|
||||||
|
playdate.graphics.drawLine(
|
||||||
|
centerX, centerY - self.lineLength - self.gapSize,
|
||||||
|
centerX, centerY - self.gapSize
|
||||||
|
)
|
||||||
|
|
||||||
|
playdate.graphics.drawLine(
|
||||||
|
centerX, centerY + self.gapSize,
|
||||||
|
centerX, centerY + 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
|
@@ -192,9 +192,9 @@ function Player:handleMovementAndCollisions()
|
|||||||
self:boom()
|
self:boom()
|
||||||
return
|
return
|
||||||
elseif collisionTag == 154 then -- Baleba
|
elseif collisionTag == 154 then -- Baleba
|
||||||
if self.debug then
|
-- if self.debug then TODO: why debug always true?
|
||||||
return
|
-- return
|
||||||
end
|
-- end
|
||||||
self:boom(collisionObject)
|
self:boom(collisionObject)
|
||||||
return
|
return
|
||||||
elseif collisionTag == 2 then -- Tank
|
elseif collisionTag == 2 then -- Tank
|
||||||
|