-
-# local no_spaces = ldoc.no_spaces
-# local use_li = ldoc.use_li
-# local display_name = ldoc.display_name
-# local iter = ldoc.modules.iter
-# local function M(txt,item) return ldoc.markup(txt,item,ldoc.plain) end
-# --local nowrap = ldoc.wrap and '' or 'nowrap'
-
-
-
-
-
-# --------- contents of module -------------
-# if module and not ldoc.no_summary and #module.items > 0 then
-
-
$(module.name)
-
-# for kind, items in module.kinds() do
-# kind = kind:gsub("modules.", ""):gsub(" Functions", ""):gsub("%.", "\u{200B}.")
-
$(kind)
-
-# for item in items() do
-# local subName = item.name
-# if (item.name:sub(1, #module.name) == module.name) then
-# subName = item.name:sub(#module.name+1, #item.name)
-# elseif (module.name == "Noble") then
-# subName = "." .. item.name
-# end
-
-
-# if ldoc.body then -- verbatim HTML as contents; 'non-code' entries
- $(ldoc.body)
-# elseif module then -- module documentation
-
$(module.name)
-
$(M(module.summary,module))
-
$(M(module.description,module))
-# if module.tags.include then
- $(M(ldoc.include_file(module.tags.include)))
-# end
-# if module.see then
-# local li,il = use_li(module.see)
-
See
-
-# for see in iter(module.see) do
- $(li)$(see.label)$(il)
-# end
-
-# end
-# if module.usage then
-# local li,il = use_li(module.usage)
-
Usage
-# for usage in iter(module.usage) do
-
$(ldoc.escape(usage))
-# end
-# end
-# if module.info then
-
Info
-
-# for tag, value in module.info:iter() do
-
$(tag): $(M(value,module))
-# end
-
-# end
-
-
-
-# --- currently works for both Functions and Tables. The params field either contains
-# --- function parameters or table fields.
-# local show_return = not ldoc.no_return_or_parms
-# local show_parms = show_return
-# for kind, items in module.kinds() do
-# local kitem = module.kinds:get_item(kind)
-# local has_description = kitem and ldoc.descript(kitem) ~= ""
-# kind = kind:gsub("modules.", ""):gsub(" Functions", "")
-
$(kind)
-
-# if kitem then
-# if has_description then
-
- $(M(ldoc.descript(kitem),kitem))
-
-# end
-# if kitem.usage then
-
Usage
-
$(ldoc.prettify(kitem.usage[1]))
-# end
-# end
-
-# for item in items() do
-
-
- $(display_name(item))
-# if ldoc.prettify_files and ldoc.is_file_prettified[item.module.file.filename] then
- line $(item.lineno)
-# end
-
-
- $(M(ldoc.descript(item),item))
-# if ldoc.custom_tags then
-# for custom in iter(ldoc.custom_tags) do
-# local tag = item.tags[custom[1]]
-# if tag and not custom.hidden then
-# local li,il = use_li(tag)
-
$(custom.title or custom[1])
-
-# for value in iter(tag) do
- $(li)$(custom.format and custom.format(value) or M(value))$(il)
-# end
-# end
-
-# end
-# end
-
-# if show_parms and item.params and #item.params > 0 then
-# local subnames = module.kinds:type_of(item).subnames
-# if subnames then
-
$(subnames)
-# end
-
-# for parm in iter(item.params) do
-# local param,sublist = item:subparam(parm)
-# if sublist then
-
$(sublist)$(M(item.params.map[sublist],item))
-
-# end
-# for p in iter(param) do
-# local name,tp,def = item:display_name_of(p), ldoc.typename(item:type_of_param(p)), item:default_of_param(p)
-
$(name)
-# if tp ~= '' then
- $(tp)
-# end
-# if def == true then
- (optional)
-# elseif def then
- = $(def) (default)
-# end
-# if item:readonly(p) then
- readonly
-# end
-
- $(M(item.params.map[p],item))
-
-# end
-# if sublist then
-
-
-# end
-# end
-
-# end
-
-# if show_return and item.retgroups then local groups = item.retgroups
-
Returns
-# for i,group in ldoc.ipairs(groups) do local li,il = use_li(group)
-
-# for r in group:iter() do local type, ctypes = item:return_type(r); local rt = ldoc.typename(type)
- $(li)
-# if rt ~= '' then
- $(rt)
-# end
- $(M(r.text,item))$(il)
-# if ctypes then
-
Do not copy this file as a template for your scenes. Instead, your scenes will extend this class.
- See templates/SceneTemplate.lua for a blank scene that you can copy and modify for your own scenes.
- If you are using NobleEngine-ProjectTemplate,
- see scenes/ExampleScene.lua for an implementation example.
-
Usage
-
YourSceneName = {}
-class("YourSceneName").extends(NobleScene)
-local scene = YourSceneName
-
-
-
-
-
Properties
-
-
-
-
- noblescene.name
-
-
- The name of this scene. Optional.
- If you do not set this value, it will take on the scene's className.
-
-
-
-
-
-
-
-
-
- noblescene.backgroundColor
-
-
- This is the background color of this scene.
-
-
-
-
-
-
-
-
-
Tables
-
-
-
-
- noblescene.inputHandler
-
-
- All scenes have a default inputHandler which is made active when the scene starts.
- If you do not define your scene's inputHandler, it is nil and input is disabled when this scene
- starts.
-
-
-
-
-
- Use this to add sprites to your scene instead of playdate.graphics.sprite:add().
-
-
If your sprite is a NobleSprite, using NobleSprite:add() will also call this method.
-
-
Sprites added with this method that are tracked by the scene. Any not manually removed before transitioning to another scene are automatically removed in finish.
-
-
Parameters
-
-
__sprite
- playdate.graphics.sprite
-
- The sprite to add to the scene.
-
- Implement this in your scene if you have code to run when your scene's object is created.
-
-
-
-
-
-
Usage
-
function YourSceneName:init()
- YourSceneName.super.init(self)
- --[Your code here]--
-end
-
-
-
-
- noblescene:enter()
-
-
- Implement if you want to run code as the transition to this scene begins, such as UI animation, triggers, etc.
-
-
-
-
-
-
Usage
-
function YourSceneName:enter()
- YourSceneName.super.enter(self)
- --[Your code here]--
-end
-
-
-
-
- noblescene:start()
-
-
- Implement if you have code to run once the transition to this scene is complete. This method signifies the full activation of a scene. If this scene's inputHandler is defined, it is enabled now.
-
-
-
-
-
function YourSceneName:start()
- YourSceneName.super.start(self)
- --[Your code here]--
-end
-
-
-
-
- noblescene:update()
-
-
- Implement to run scene-specific code on every frame while this scene is active.
- NOTE: you may use coroutine.yield() here, because it only runs inside of playdate.update(), which is a coroutine.
-
-
-
-
-
-
Usage
-
function YourSceneName:update()
- YourSceneName.super.update(self)
- --[Your code here]--
-end
- Implement this function to draw background visual elements in your scene.
- This runs when the engine need to redraw a background area.
- By default it runs every frame and fills the background with self.backgroundColor. All arguments are optional.
- Use Graphics.sprite.setAlwaysRedraw(false) after Noble.new() to optimize partial redraw.
-
-
- Implement this in your scene if you have "goodbye" code to run when a transition to another scene
- begins, such as UI animation, saving to disk, etc.
-
-
-
-
-
-
Usage
-
function YourSceneName:exit()
- YourSceneName.super.exit(self)
- --[Your code here]--
-end
-
-
-
-
- noblescene:finish()
-
-
- Implement this in your scene if you have code to run when a transition to another scene
- is complete, such as resetting variables.
-
-
-
-
-
-
Usage
-
function YourSceneName:finish()
- YourSceneName.super.finish(self)
- --[Your code here]--
-end
-
-
-
-
- noblescene:pause()
-
-
- pause() / resume()
-
-
Implement one or both of these in your scene if you want something to happen when the game is paused/unpaused
- by the system. The Playdate SDK does not require you to write pause logic, but these are useful if you want a
- custom menu image (see Playdate SDK for more details), want to obscure game elements to prevent players from
- cheating in a time-sensitive game, want to count the number of times the player pauses the game, etc.
-
-
-
-
-
-
Usage
-
function YourSceneName:pause()
- YourSceneName.super.pause(self)
- --[Your code here]--
-end
-
-
-
-
- noblescene:resume()
-
-
-
-
-
-
-
-
-
Usage
-
function YourSceneName:resume()
- YourSceneName.super.resume(self)
- --[Your code here]--
-end
- Do not call an "init" method directly. Use NobleSprite() (see usage examples).
-
-
Parameters
-
-
__view
- string
- (optional)
-
- This can be: the path to an image or spritesheet image file, an image object (Graphics.image) or an animation object (Noble.Animation)
-
-
__viewIsSpritesheet
- boolean
- = false (default)
-
- Set this to true to indicate that __view is a spritesheet. Will only be considered if __view is a string path to an image.
-
-
__singleState
- boolean
- = false (default)
-
- If this sprite has just one animation, set this to true. It saves you from having to use Noble.Animation.addState()
-
-
__singleStateLoop
- boolean
- = true (default)
-
- If using a single state animation, should it loop?
-
-- Provide a spritesheet image file to create a new Noble.Animation for a NobleSprite's view.
-myNobleSprite = NobleSprite("path/to/spritesheet", true)
-
-- Provide an image file to create a new Graphics.image for a NobleSprite's view.
-myNobleSprite = NobleSprite("path/to/image")
-
-- Use an existing Noble.Animation for a NobleSprite's view.
-local myAnimation = Noble.Animation.new("path/to/spritesheet")
- myAnimation:addState("default", 1, animation.imageTable:getLength(), nil, true)
-myNobleSprite = NobleSprite(myAnimation)
-
-- Use an existing Graphics.image object for a NobleSprite's view.
-local myImage = Graphics.image.new("path/to/image")
-myNobleSprite = NobleSprite(myImage)
- This will enable the update loop for this NobleSprite, which also causes its Noble.Animation to play.
-
-
-
-
-
-
-
-
-
- noblesprite:pause()
-
-
- This will disable the update loop for this NobleSprite, which also causes its Noble.Animation to pause.
-
-
-
-
-
-
-
-
-
- noblesprite:stop()
-
-
- This will disable the update loop for this NobleSprite, and also reset its Noble.Animation (if it exists) to the first frame of its current state.
-
-
-
-
-
-
-
-
-
- noblesprite:add(__x, __y)
-
-
- Use this to add this NobleSprite to your scene. This replaces playdate.graphics.sprite:add() to allow NobleSprites to be tracked by the current NobleScene.
-
-
To add a playdate.graphics.sprite to a scene, use NobleScene:addSprite(__sprite).
-
-
- Use this to remove this NobleSprite from your scene. This replaces playdate.graphics.sprite:remove() to allow NobleSprites to be tracked by the current NobleScene.
-
-
To remove a playdate.graphics.sprite from a scene, use NobleScene:removeSprite(__sprite).
-
-
-
-
-
---
--- SceneTemplate.lua
---
--- Use this as a starting point for your game's scenes.
--- Copy this file to your root "scenes" directory,
--- and rename it.
---
-
--- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
--- !!! Rename "SceneTemplate" to your scene's name in these first three lines. !!!
--- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-SceneTemplate = {}
-class("SceneTemplate").extends(NobleScene)
-local scene = SceneTemplate
-
--- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
--- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
--- It is recommended that you declare, but don't yet define,
--- your scene-specific varibles and methods here. Use "local" where possible.
---
--- local variable1 = nil -- local variable
--- scene.variable2 = nil -- Scene variable.
--- When accessed outside this file use SceneTemplate.variable2.
--- ...
---
-
--- This is the background color of this scene.
-scene.backgroundColor = Graphics.kColorWhite
-
--- This runs when your scene's object is created, which is the
--- first thing that happens when transitining away from another scene.
-function scene:init()
- scene.super.init(self)
-
- -- variable1 = 100
--- SceneTemplate.variable2 = "string"
--- ...
-
- -- Your code here
-end
-
--- When transitioning from another scene, this runs as soon as this
--- scene needs to be visible (this moment depends on which transition type is used).
-function scene:enter()
- scene.super.enter(self)
- -- Your code here
-end
-
--- This runs once a transition from another scene is complete.
-function scene:start()
- scene.super.start(self)
- -- Your code here
-end
-
--- This runs once per frame.
-function scene:update()
- scene.super.update(self)
- -- Your code here
-end
-
--- This runs once per frame, and is meant for drawing code.
-function scene:drawBackground()
- scene.super.drawBackground(self)
- -- Your code here
-end
-
--- This runs as as soon as a transition to another scene begins.
-function scene:exit()
- scene.super.exit(self)
- -- Your code here
-end
-
--- This runs once a transition to another scene completes.
-function scene:finish()
- scene.super.finish(self)
- -- Your code here
-end
-
-function scene:pause()
- scene.super.pause(self)
- -- Your code here
-end
-function scene:resume()
- scene.super.resume(self)
- -- Your code here
-end
-
--- Define the inputHander for this scene here, or use a previously defined inputHandler.
-
--- scene.inputHandler = someOtherInputHandler
--- OR
-scene.inputHandler = {
-
- -- A button
---
- AButtonDown = function() -- Runs once when button is pressed.
--- Your code here
-end,
- AButtonHold = function() -- Runs every frame while the player is holding button down.
--- Your code here
-end,
- AButtonHeld = function() -- Runs after button is held for 1 second.
--- Your code here
-end,
- AButtonUp = function() -- Runs once when button is released.
--- Your code here
-end,
-
- -- B button
---
- BButtonDown = function()
- -- Your code here
-end,
- BButtonHeld = function()
- -- Your code here
-end,
- BButtonHold = function()
- -- Your code here
-end,
- BButtonUp = function()
- -- Your code here
-end,
-
- -- D-pad left
---
- leftButtonDown = function()
- -- Your code here
-end,
- leftButtonHold = function()
- -- Your code here
-end,
- leftButtonUp = function()
- -- Your code here
-end,
-
- -- D-pad right
---
- rightButtonDown = function()
- -- Your code here
-end,
- rightButtonHold = function()
- -- Your code here
-end,
- rightButtonUp = function()
- -- Your code here
-end,
-
- -- D-pad up
---
- upButtonDown = function()
- -- Your code here
-end,
- upButtonHold = function()
- -- Your code here
-end,
- upButtonUp = function()
- -- Your code here
-end,
-
- -- D-pad down
---
- downButtonDown = function()
- -- Your code here
-end,
- downButtonHold = function()
- -- Your code here
-end,
- downButtonUp = function()
- -- Your code here
-end,
-
- -- Crank
---
- cranked = function(change, acceleratedChange) -- Runs when the crank is rotated. See Playdate SDK documentation for details.
--- Your code here
-end,
- crankDocked = function() -- Runs once when when crank is docked.
--- Your code here
-end,
- crankUndocked = function() -- Runs once when when crank is undocked.
--- Your code here
-end
-}
Extensions to playdate.easingFunctions, aliased as Ease in Noble Engine.
-
See the Playdate SDK for a list of easing functions.
-
-
-
-
Functions
-
-
-
-
- enter(__easingFunction)
-
-
- Returns the first half of an "inOut" or "outIn" easing function.
- Returns nil for any easing function that isn't in the form of Ease.inOutXxxx or Ease.outInXxxx. Ease.linear returns itself.
-
-
- Returns the second half of an "inOut" or "outIn" easing function.
- Returns nil for any easing function that isn't in the form of Ease.inOutXxxx or Ease.outInXxxx. Ease.linear returns itself.
-
-
- Returns the reverse function of the provided function.
- Returns nil for any easing function that isn't in the form of Ease.inXxxx or Ease.outXxxx. Ease.linear returns itself.
-
-
Ideal for use with NobleSprite objects. Suitable for other uses as well.
-
-
-
-
Setup
-
-
-
-
- Noble.Animation.new(__view)
-
-
- Create a new animation "state machine". This function is called automatically when creating a new NobleSprite.
-
-
Parameters
-
-
__view
- string
-
- This can be: the path to a spritesheet image file or an image table object (Graphics.imagetable). See Playdate SDK docs for imagetable file naming conventions.
-
- Add an animation state. The first state added will be the default set for this animation.
-
-
NOTE: Added states are first-degree member objects of your Noble.Animation object, so do not use names of already existing methods/properties ("current", "draw", etc.).
-
-
Parameters
-
-
__name
- string
-
- The name of the animation, this is also used as the key for the animation.
-
-
__startFrame
- integer
-
- This is the first frame of this animation in the imagetable/spritesheet
-
-
__endFrame
- integer
-
- This is the final frame of this animation in the imagetable/spritesheet
-
-
__next
- string
-
- By default, animation states will loop, but if you want to sequence an animation, enter the name of the next state here.
-
-
__loop
- boolean
- = true (default)
-
- If you want a state to "freeze" on its final frame, instead of looping, enter false here.
-
-
__onComplete
-
- This function will run when this animation is complete. Be careful when using this on a looping animation!
-
-
__frameDuration
- integer
- = 1 (default)
-
- This is the number of ticks between each frame in this animation. If not specified, it will be set to 1.
-
-
-
-
-
-
-
Usage
-
-- You can reference an animation's state's properties using bog-standard lua syntax:
-
-animation.idle.startFrame -- 30
-animation.walk.endFrame -- 65
-animation.["walk"].endFrame -- 65
-animation.jump.name -- "jump"
-animation.["jump"].next-- "float"
-animation.idle.next-- nil
-
-
-
-
Properties
-
-
-
-
- animation.current
-
-
- The currently set animation state.
-
-
This is intended as read-only. You should not modify this property directly.
-
-
-
-
-
- Sets the current animation state. This can be run in a object's update method because it only changes the animation state if the new state is different from the current one.
-
-
Parameters
-
-
__animationState
- string or Noble.Animation
-
- The name of the animation to set. You can pass the name of the state, or the object itself.
-
-
__continuous
- boolean
- = false (default)
-
- Set to true if your new state's frames line up with the previous one's, i.e.: two walk cycles but one is wearing a cute hat!
-
-
__unlessThisState
- string or Noble.Animation
-
- If this state is the current state, do not set the new one.
-
When attached to a NobleSprite, this is called by NobleSprite:draw() when added to a scene. For non-NobleSprite sprites, put this method inside your sprite's draw() method, or inside NobleScene:update.
-
-
Parameters
-
-
__x
- number
- = 0 (default)
-
-
-
-
-
-
__y
- number
- = 0 (default)
-
-
-
-
-
-
__advance
- boolean
- = true (default)
-
- Advances to the next frame after drawing this one. Noble.Animation is frame-based, not "delta time"-based, so its speed is dependent on your game's framerate.
-
-
-
-
-
-
-
Usage
-
function MySprite:draw()
- animation:draw()
-end
-
function MyScene:update()
- animation:draw(100,100)
-end
- Sometimes, you just want to draw a specific frame.
- Use this for objects or sprites that you want to control outside of update loops, such as score counters, flipbook-style objects that respond to player input, etc.
-
-
Parameters
-
-
__frameNumber
- integer
-
- The frame to draw from the current state. This is not an imagetable index. Entering 1 will draw the selected state's startFrame.
-
-
__stateName
- string
- = self.currentName (default)
-
- The specific state to pull the __frameNumber from.
-
-
__x
- number
- = 0 (default)
-
-
-
-
-
-
__y
- number
- = 0 (default)
-
-
-
-
-
-
__direction
- = self.direction (default)
-
- Override the current direction.
-
-
-
-
-
-
-
-
-
-
Constants
-
-
-
-
- Noble.Animation.DIRECTION_RIGHT
-
-
- A re-contextualized instance of playdate.graphics.kImageUnflipped
-
-
-
-
-
-
-
-
-
- Noble.Animation.DIRECTION_LEFT
-
-
- A re-contextualized instance of playdate.graphics.kImageFlippedX
-
-
-
-
-
-
-
Noble Engine overrides/supersedes some Playdate SDK behavior. A "bonk" is what happens when your game breaks the engine.
-
-
Most bonks will throw during normal operation, but others ("debug bonks") introduce some execution overhead so are not
- checked by default.
-
-
-
-
Functions
-
-
-
-
- Noble.Bonk.startCheckingDebugBonks()
-
-
- Begin checking for debug bonks, on every frame. This introduces needless overhead, so don't do it in a release build.
- You can only run this if you ran previously Noble.new() with __enableDebugBonkChecking as true, which you should also not do in a release build.
-
-
-
-
-
- Sets up the GameDatas (save slots) for your game, and/or loads any existing GameDatas from disk.
- You can only run this once, ideally in your main.lua before you load your first scene.
-
-
Parameters
-
-
__keyValuePairs
- table
-
- All the data items for a saved game, and their default values, as key/value pairs. NOTE: Do not use "nil" as a value.
-
-
__numberOfSlots
- integer
- = 1 (default)
-
- If you want multiple save slots, enter an integer here. You can add additional slots later.
-
-
__saveToDisk
- boolean
- = true (default)
-
- Saves your default values immediately to disk.
-
-
__modifyExistingOnKeyChange
- boolean
- = true (default)
-
- Updates the existing gameData objects on disk if you make changes to your keys (not values) during development or when updating your game.
-
__dataItemName
- string
-
- The name of the data item.
-
-
__value
- any
-
- The data item's new value
-
-
__gameDataSlot
- integer
- (optional)
-
- If set, uses a specific GameData slot. If not, uses the most recently touched GameData slot.
-
-
__saveToDisk
- boolean
- = true (default)
-
- Saves to disk immediately. Set to false if you prefer to manually save (via a checkpoint or menu).
-
-
__updateTimestamp
- boolean
- = true (default)
-
- Sets the timestamp of this GameData to the current time. Leave false to retain existing timestamp.
-
- Reset a GameData item to its default value, defined in setup.
-
-
Parameters
-
-
__dataItemName
- string
-
- The name of the data item.
-
-
__gameDataSlot
- integer
- (optional)
-
- If set, uses a specific GameData slot. If not, uses the most recently touched GameData slot.
-
-
__saveToDisk
- boolean
- = true (default)
-
- Saves to disk immediately. Set to false if you prefer to manually save (via a checkpoint or menu).
-
-
__updateTimestamp
- boolean
- = true (default)
-
- Resets the timestamp of this GameData to the current time. Leave false to retain existing timestamp.
-
- Reset all values in a GameData slot to the default values, defined in setup.
-
-
Parameters
-
-
__gameDataSlot
- integer
- (optional)
-
- If set, uses a specific GameData slot. If not, uses the most recently touched GameData slot.
-
-
__saveToDisk
- boolean
- = true (default)
-
- Saves to disk immediately. Set to false if you prefer to manually save (via a checkpoint or menu).
-
-
__updateTimestamp
- boolean
- = true (default)
-
- Resets the timestamp of this GameData to the current time. Leave false to retain existing timestamp.
-
- Deletes a GameData from disk if its save slot is greater than the default number established in setup.
- Otherwise, resets all data items to default values using resetAll.
-
-
Generally, you won't need this unless you've added save slots using addSlot. In other cases, use resetAll.
-
-
Parameters
-
-
__gameDataSlot
- integer
-
- The slot holding the GameData to delete. Unlike other methods that take this argument, this is not optional.
-
-
__collapseGameDatas
- boolean
- = true (default)
-
- Re-sorts the gameDatas table (and renames existing JSON files on disk) to fill the gap left by the deleted GameData.
-
- Deletes all GameDatas from disk, except for the number specified in setup, which are reset to default values.
- Use this to clear all data as if you were running setup again.
- Generally, you don't need this unless you've added save slots using addSlot. In other cases, use resetAll on each slot.
-
-
-
-
-
- Returns the timestamp of the requested GameData, as a tuple (local time, GMT time). The timestamp is updated
- See Playdate SDK for details on how a time object is formatted. NOTE: Timestamps are stored internally in GMT.
-
-
Parameters
-
-
__gameDataSlot
- integer
-
- The GameData slot to get the timestamp of. Unlike other methods that take this argument, this is not optional.
-
-
-
-
Returns
-
-
- table
- Local time
-
- table
- GMT time
-
-
-
-
-
Usage
-
Noble.GameData.getTimestamp(1)
-
-
-
-
- Noble.GameData.getNumberOfSlots()
-
-
- Returns the current number of GameData slots.
-
-
-
Returns
-
-
- int
-
-
-
-
-
-
-
-
-
-
-
- Noble.GameData.getCurrentSlot()
-
-
- Returns the number of the current GameData slot.
-
-
-
Returns
-
-
- int
-
-
-
-
-
-
-
-
-
-
-
- Noble.GameData.save([__gameDataSlot])
-
-
- Saves a single GameData to disk. If you want to save all GameDatas, use saveAll instead.
-
-
Parameters
-
-
__gameDataSlot
- integer
- (optional)
-
- If set, uses a specific GameData slot. If not, uses the most recently touched GameData slot.
-
A complete encapsulation of the Playdate's input system.
-
The Playdate SDK gives developers multiple ways to manage input. Noble Engine's approach revolves around the SDK's "inputHandlers," extending them to include additional input methods, and pull in other hardware functions that the SDK puts elsewhere. See usage below for the full list of supported methods.
-
By default, Noble Engine assumes each scene will have an inputManager assigned to it. So, for example, you can define one inputManager for menu screens and another for gameplay scenes in your main.lua, and then in each scene, set which one that scene uses. You can instead define a unique inputHandler in each scene.
-
You may also create and manage inputManagers within and outside of scenes. When a NobleScene is loaded, its inputHandler will become active, thus, inputHandlers do not carry across scenes, and all input is suspended during scene transitions. An advanced use-case is to leave a scene's inputHandler as nil, and manage it separately.
-
NOTE: While the Playdate SDK allows you to stack as many inputHandlers as you want, Noble Engine assumes only one active inputHandler at a time. You may still manually call playdate.inputHandlers.push() and playdate.inputHandlers.pop() yourself, but Noble Engine will not know about it and it may cause unexpected behavior.
-
In addition, you may directly query button status using the SDK's methods for that, but it is not advised to use that as the primary way to manage input for Noble Engine projects, because much of Noble.Input's functionality will not apply.
- Enable and disable user input without dealing with inputHanders.
- The Playdate SDK requires removing all inputHanders to halt user input, so while the currentHandler is cleared when false is passed to this method,
- it is cached so it can be later re-enabled by passing true it.
-
-
Parameters
-
-
__value
- boolean
-
- Set to false to halt input. Set to true to resume accepting input.
-
- Enable/disable on-screen system crank indicator.
-
-
NOTE: The indicator will only ever show if the crank is docked, unless __evenWhenUndocked is true.
-
-
Parameters
-
-
__active
- boolean
-
- Set true to start showing the on-screen crank indicator. Set false to stop showing it.
-
-
__evenWhenUndocked
- boolean
- = false (default)
-
- Set true to show the crank indicator even if the crank is already undocked (__active must also be true).
-
-
-
-
-
-
-
-
-
-
- Noble.Input.getCrankIndicatorStatus()
-
-
- Checks whether the system crank indicator status. Returns a tuple.
-
-
-
Returns
-
-
- bool
- Is the crank indicator active?
-
- bool
- Is the crank indicator being forced when active, even when the crank is undocked?
- Checks the current display orientation of the device. Returns a tuple.
- If the accelerometer is not currently enabled, this method will turn it on, return current values, and then turn it off.
- If you are trying to get raw accelerometer values rather than the display orientation, you may want to use playdate.readAccelerometer() instead.
-
-
Parameters
-
-
__getStoredValues
- boolean
- = false (default)
-
- If true, this method will simply return the most recently stored values, rather than use the accelerometer to check for new ones.
-
-
-
-
Returns
-
-
- str
- The named orientation of the device (a pseudo enum Noble.Input.ORIENTATION_XX)
-
- list
- Accelerometer values, where list[1] is x, list[2] is y and list[3] is z
- A set of constants referencing device inputs, stored as strings. Can be used for querying button input,
- but are mainly for on-screen prompts or other elements where a string literal is useful, such as a filename, GameData value, or localization key.
- For faster performance, use the ones that exist in the Playdate SDK (i.e.: playdate.kButtonA), which are stored as binary numbers.
-
__nameOrKey
- string
-
- The name of this menu item. It can be a display name or a localization key. Must be unique.
-
-
__clickHandler
- function
- (optional)
-
- The function that runs when this menu item is "clicked."
-
-
__position
- integer
- (optional)
-
- Insert the item at a specific position. If not set, adds to the end of the list.
-
-
__displayName
- string
- (optional)
-
- You can create an optional, separate display name for this item. You can add or change this at runtime via setItemDisplayName.
-
-
__displayNameIsALocalizationKey
- boolean
- = false (default)
-
- If true, will treat the __displayName as a localization key. This is separate from this menu's localized value.
-
__menuItem
- int or string
- = #menu.itemNames (default)
-
- The menu item to remove. You can enter either the item's name/key or it's position. If left blank, removes the last item.
-
_
- integer
-
- The width of the widest menu item plus the menu's horizontal padding.
-
-
This is meant as a read-only value. Do not modify it directly.
-
-
-
-
-
-
-
-
-
-
Methods
-
-
-
-
- menu:activate()
-
-
- Activate this menu.
- This selects the most recently selected menu item (or the first item if none have been previously selected), and enables this menu's selectPrevious, selectNext, and click methods.
-
-
-
-
-
-
Usage
-
local menu = Noble.Menu.new(false)
-menu:activate()
-
-
-
-
- menu:deactivate()
-
-
- Deactivate this menu.
- This deselects all menu items, and disables this menu's selectPrevious, selectNext, and click methods.
-
-
-
-
-
-
Usage
-
local menu = Noble.Menu.new(true)
-menu:deactivate()
-
-
-
-
- menu:isActive()
-
-
- Check to see if this menu is currently active.
-
-
-
If a menu item does not have a display name, then the __nameOrKey (or its localized string) will be returned instead. This method is used internally when draw is called.
-
-
If this menu's localized value is true, a returned __nameOrKey will always be localized, but a returned display name is only localized if the __displayNameIsALocalizationKey argument was set to true when the display name was added.
-
-
Parameters
-
-
__itemName
- string
-
- The menu item you want the display name of.
-
- When you add a menu item, you can give it a display name that's different from it's actual name. This method adds or changes the display name of a menu item.
-
-
Parameters
-
-
__itemName
- string
-
- The menu item name (or key if this menu uses localization keys).
-
-
__displayName
- string
-
- The display name.
-
-
__displayNameIsALocalizationKey
- boolean
- = false (default)
-
- Set to use to indicate that this display name is a localization key. This setting is separate from localized
-
- A string "array" of menu item strings/keys.
- You cannot add or remove menu items by modifying this table.
- It is meant as a read-only table, provided for convenience when iterating, etc. Modifying its values may break other methods.
-
-
-
-
-
for i = 1, #menu.itemNames, 1do
- menu.clickHandlers[menu.itemNames[i]] = nil-- Clears all click handlers, for some reason.
-end
-
-
-
-
- menu.clickHandlers
-
-
- A table of functions associated with menu items. Items are a defined when calling addItem, but their associated functions may be modified afterward.
-
-
You cannot add or remove menu items by modifying this table.
-
-
-
-
-
local menu = Noble.Menu.new(true)
-menu.addItem("Play Game")
-menu.addItem("Options")
-
-menu.clickHandlers["Play Game"] = function() TitleScreen:playGame() end
-menu.clickHandlers["Options"] = function() Noble.transition(OptionsScreen) end
-
local menu = Noble.Menu.new(true)
-menu.addItem("Play Game")
-menu.addItem("Options")
-
-menu.clickHandlers = {
- ["Play Game"] = function TitleScreen:playGame() end,
- ["Options"] = function() Noble.transition(OptionsScreen) end
-}
-
-
-
-
- menu.itemPositions
-
-
- A key/value table of menu item indices.
-
-
This is meant as a read-only table, provided for convenience. Modifying its values will break other methods.
-
-
-
-
-
-
- A key/value table of pixel widths for each menu item, based on its text. Useful for animation, layout, etc.
-
-
This is meant as a read-only table, provided for convenience. Modifying its values will break other methods.
-
-
-
-
-
-
Usage
-
local playGameMenuItemWidth = menu.itemWidths["Play Game"]
-
-
-
-
Drawing
-
-
-
-
- menu:draw(__x, __y)
-
-
- Draw's this menu to the screen. You may call this manually, but ideally, you will put it in in your scene's update or drawBackground method.
-
-
Parameters
-
-
__x
-
-
-
-
-
-
__y
-
-
-
-
-
-
-
-
-
-
-
Usage
-
function YourScene:update()
- YourScene.super.update(self)
- menu:draw(50, 100)
-end
-
-
-
-
- menu:drawItem(__x, __y, __itemIndex)
-
-
- This method is called for every non-selected item when draw is called. You shouldn't call this directly, but you may re-implement it if you wish.
-
-
- Sets up the settings for your game. You can only run this once, and you must run it before using other Noble.Settings functions. It is recommended to place it in your main.lua, before Noble.new().
-
-
NOTE: You will not be able to add new keys via the Noble.Settings.set method. This means you need to specify the keys and default values of all of the settings in your game at setup.
- If you need to add keys that are not known during setup, it is probably not a setting and you should consider using Noble.GameData instead.
-
-
Parameters
-
-
__keyValuePairs
- table
-
- table. Your game's settings, and thier default values, as key/value pairs. NOTE: Do not use "nil" as a value.
-
-
__saveToDisk
- boolean
- = true (default)
-
- Saves your default values immediatly to disk.
-
-
__modifyExistingOnKeyChange
- boolean
- = true (default)
-
- Updates the existing settings object on disk if you make changes to your settings keys (not values) during development or when updating your game.
-
-
-
-
-
-
-
Usage
-
Noble.Settings.setup({
- difficulty = "normal",
- music = true,
- sfx = true,
- players = 2,
- highScore = 0-- You can store persistant stats here, too!
-})
-
-
-
-
- Noble.Settings.get(__settingName)
-
-
- Get the value of a setting.
-
-
Parameters
-
-
__settingName
- string
-
- The name of the setting.
-
-
-
-
Returns
-
-
- any
- The value of the requested setting.
-
-
-
-
- Resets the value of multiple settings to thier default value defined in setup(). This is useful if you are storing persistant stats like high scores in Settings and want the player to be able to reset them seperately.
-
-
Parameters
-
-
__settingNames
- table
-
- The names of the settings, in an array-style table.
-
-
__saveToDisk
- boolean
- = true (default)
-
- Saves to disk immediately. Set to false if you prefer to manually save (via a confirm button, etc).
-
- Saves settings to disk.
- You don't need to call this unless you set __saveToDisk as false when setting or resetting a setting (say that five times fast!).
-
-
-
-
-
- Use this to modify multiple default properties of a transition. Having default properties avoids having to set them every time a transition is called.
- Properties added here are merged with the existing default properties table. Overwrites only happen when a new value is set.
-
-
- Do not call this directly. Implement this in a custom transition in order to set properties from user arguments given in Noble.transition(). See existing transitions for implementation examples.
-
-
- Do not call this directly. Implement this in a custom transition in order to run custom code when the transition starts. Default transitions in Noble Engine do not use this.
-
-
-
-
-
-
-
-
-
- Noble.Transition:onMidpoint()
-
-
- Do not call this directly. Implement this in a custom transition in order to run custom code when the transition reaches its midpoint. Default transitions in Noble Engine do not use this.
-
-
-
-
-
-
-
-
-
- Noble.Transition:onHoldTimeElapsed()
-
-
- Do not call this directly. Implement this in a custom transition in order to run custom code when the transition's hold time has elapsed. Default transitions in Noble Engine do not use this.
-
-
-
-
-
-
-
-
-
- Noble.Transition:onComplete()
-
-
- Do not call this directly. Implement this in a custom transition in order to run custom code when the transition completes. Default transitions in Noble Engine do not use this.
-
-
-
-
-
-
-
-
-
- Noble.Transition:draw()
-
-
- Do not call this directly. Implement this in a custom transition to draw the transition. This runs once per frame while the transition is running. See existing transitions for implementation examples.
-
-
-
-
-
-
-
-
-
Tables
-
-
-
-
- Noble.Transition.defaultProperties
-
-
- A transition may have unique properties that can be set by the user when invoked. This table holds the default values for those properties.
-
-
-
-
-
- A transition type where no time at all passes between scenes.
-
-
-
-
-
See
-
-
-
-
-
-
-
- Noble.Transition.Type.COVER
-
-
- A transition type that has an "Enter" phase and an "Exit" phase. The new scene does not become active until the Enter phase is complete. A "holdTime" value determines how long to wait after the Enter phase completes before starting the Exit phase.
-
-
-
-
-
See
-
-
-
-
-
-
-
- Noble.Transition.Type.MIX
-
-
- A transition type that takes a screenshot of the exiting scene and activates the new scene before beginning the transition, allowing for both scenes to appear to be visible during the transition.
-
-
-
-
-
- A wipe transition using an animated mask in the form of an imagetable.
-
-
Fields
-
-
imagetable
- Graphics.imagetable
-
-
-
-
-
-
reverse
- boolean
- = false (default)
-
- Set true to play the imagetable's frames in reverse order.
-
-
flipX
- boolean
- = false (default)
-
-
-
-
-
-
flipY
- boolean
- = false (default)
-
-
-
-
-
-
rotate
- boolean
- = false (default)
-
- Set as true to rotate the image 180-degrees
-
-
hasTransparency
- boolean
- = true (default)
-
- Set as true if the imagetable asset has transparent pixels. Set as false if the image uses white pixels for transparency.
-
-
invert
- boolean
- = false (default)
-
- Set as true to invert the image mask.
-
- The previous scene slides off the right side of the screen, revealing the next scene.
- NOTE: The x, y, and rotation properties are locked.
-
-
-
-
-
- The next scene slides onto the screen from the bottom, covering up the previous scene.
- NOTE: The x, y, and rotation properties are locked.
-
-
-
-
-
- Engine initialization. Run this once in your main.lua file to begin your game.
-
-
Parameters
-
-
StartingScene
- NobleScene
-
- This is the scene your game begins with, such as a title screen, loading screen, splash screen, etc. NOTE: Pass the scene's class name, not an instance of the scene.
-
-
__launcherTransitionDuration
- number
- = 0 (default)
-
- If you want to transition from the final frame of your launch image sequence, enter a duration in seconds here.
-
-
__launcherTransition
- Noble.Transition
- = Noble.Transition.DipToBlack (default)
-
- If a transition duration is set, use this transition type.
-
-
__launcherTransitionProperties
- table
- = {} (default)
-
- Provide a table of properties to apply to the launcher transition. See the documentation for the transition you're using for a list of available properties.
-
-
__configuration
- table
- = {} (default)
-
- Provide a table of Noble Engine configuration values. This will run Noble.setConfig for you at launch.
-
- Optionally customize miscellaneous Noble Engine configuration options / default values. You may run this method to change these values during runtime.
-
-
Parameters
-
-
__configuration
- table
-
- This is a table with your configuration values in it.
-
- Transition to a new scene (at the end of this frame).
- This method will create a new scene, mark the previous one for garbage collection, and animate between them.
- Additional calls to this method within the same frame (before the already-called transition begins), will override previous calls. Any calls to this method once a transition begins will be ignored until the transition completes.
-
-
Parameters
-
-
NewScene
- NobleScene
-
- The scene to transition to. Pass the scene's class, not an instance of the scene. You always transition from Noble.currentScene
-
-
__duration
- number
- = 1.5 (default)
-
- The length of the transition, in seconds.
-
-
__transition
- Noble.Transition
- = Noble.TransitionType.DIP_TO_BLACK (default)
-
- If a transition duration is set, use this transition type. If not set, it will use the value of configuration.defaultTransition.
-
-
__transitionProperties
- table
- = {} (default)
-
- A table consisting of properties for this transition. Properties not set here will use values that transition's defaultProperties table.
-
- Check to see if the game is transitioning between scenes.
- Useful to control game logic that lives outside of a scene's update() method.
-
-
-
Returns
-
-
- bool
-
-
-
-
-
-
-
-
-
-
-
Tables
-
-
-
-
- configuration
-
-
- Miscellaneous Noble Engine configuration options / default values.
- This table cannot be edited directly. Use Noble.getConfig and Noble.setConfig.
-
-
Fields
-
-
defaultTransition
- Noble.Transition
- = Noble.Transition.DipToBlack (default)
-
- When running Noble.transition if the transition is unspecified, it will use this one.
-
-
defaultTransitionDuration
- number
- = 1.5 (default)
-
- When running Noble.transition if the scene transition duration is unspecified, it will take this long in seconds.
-
-
enableDebugBonkChecking
- boolean
- = false (default)
-
- Noble Engine-specific errors are called "Bonks." You can set this to true during development in order to check for more of them. However, it uses resources, so you will probably want to turn it off before release.
-
-
alwaysRedraw
- boolean
- = true (default)
-
- This sets the Playdate SDK method playdate.graphics.sprite.setAlwaysRedraw. See the Playdate SDK for details on how this function works, and the reasons you might want to set it as true or false for your project.
-
By default, Noble Engine assumes each scene will have an inputManager assigned to it. So, for example, you can define one inputManager for menu screens and another for gameplay scenes in your `main.lua`, and then in each scene, set which one that scene uses. You can instead define a unique inputHandler in each scene.
---
You may also create and manage inputManagers within and outside of scenes. When a NobleScene is loaded, its inputHandler will become active, thus, inputHandlers do not carry across scenes, and all input is suspended during scene transitions. An advanced use-case is to leave a scene's inputHandler as nil, and manage it separately.
---
NOTE: While the Playdate SDK allows you to stack as many inputHandlers as you want, Noble Engine assumes only one active inputHandler at a time. You may still manually call `playdate.inputHandlers.push()` and `playdate.inputHandlers.pop()` yourself, but Noble Engine will not know about it and it may cause unexpected behavior.
---
In addition, you may directly query button status using the SDK's methods for that, but it is not advised to use that as the primary way to manage input for Noble Engine projects, because much of Noble.Input's functionality will not apply.
--- @module Noble.Input
--- @usage
--- local myInputHandler = {
--- AButtonDown = function() end, -- Fires once when button is pressed down.
--- AButtonHold = function() end, -- Fires each frame while a button is held (Noble Engine implementation).
--- AButtonHeld = function() end, -- Fires once after button is held for 1 second (available for A and B).
--- AButtonUp = function() end, -- Fires once when button is released.
--- BButtonDown = function() end,
--- BButtonHold = function() end,
--- BButtonHeld = function() end,
--- BButtonUp = function() end,
--- downButtonDown = function() end,
--- downButtonHold = function() end,
--- downButtonUp = function() end,
--- leftButtonDown = function() end,
--- leftButtonHold = function() end,
--- leftButtonUp = function() end,
--- rightButtonDown = function() end,
--- rightButtonHold = function() end,
--- rightButtonUp = function() end,
--- upButtonDown = function() end,
--- upButtonHold = function() end
--- upButtonUp = function() end,
---
--- cranked = function(change, acceleratedChange) end, -- See Playdate SDK.
--- crankDocked = function() end, -- Noble Engine implementation.
--- crankUndocked = function() end, -- Noble Engine implementation.
---
--- orientationChanged = function() end -- Noble Engine implementation.
--- }
--- @see NobleScene.inputHandler
---
-Noble.Input = {}
-
-local currentHandler = {}
-
---- Get the currently active input handler. Returns nil if none are active.
--- @treturn table A table of callbacks which handle input events.
--- @see NobleScene.inputHandler
-function Noble.Input.getHandler()
- return currentHandler
-end
-
---- Use this to change the active inputHandler.
---
Enter `nil` to disable input. Use @{setEnabled} to disable/enable input without losing track of the current inputHandler.
--- @tparam[opt=nil] table __inputHandler A table of callbacks which handle input events.
--- @see NobleScene.inputHandler
--- @see clearHandler
--- @see setEnabled
-function Noble.Input.setHandler(__inputHandler)
- if (currentHandler ~= nil) then
- playdate.inputHandlers.pop()
- end
-
- if (__inputHandler == nil) then
- currentHandler = nil
- else
- currentHandler = __inputHandler
- playdate.inputHandlers.push(__inputHandler, true) -- The Playdate SDK allows for multiple inputHandlers to mix and match methods. Noble Engine removes this functionality.
- end
-end
-
---- A helper function that calls Noble.Input.setHandler() with no argument.
--- @see setHandler
-function Noble.Input.clearHandler()
- Noble.Input.setHandler()
-end
-
-local cachedInputHandler = nil
-
---- Enable and disable user input without dealing with inputHanders.
--- The Playdate SDK requires removing all inputHanders to halt user input, so while the currentHandler is cleared when `false` is passed to this method,
--- it is cached so it can be later re-enabled by passing `true` it.
--- @bool __value Set to false to halt input. Set to true to resume accepting input.
--- @see getHandler
--- @see clearHandler
-function Noble.Input.setEnabled(__value)
- local value = Utilities.handleOptionalBoolean(__value, true)
- if (value == true) then
- Noble.Input.setHandler(cachedInputHandler or currentHandler)
- cachedInputHandler = nil
- else
- cachedInputHandler = currentHandler
- Noble.Input.clearHandler()
- end
-end
-
---- Checks to see that there is an active inputHandler
--- @treturn bool Returns true if the input system is enabled. Returns false if `setEnabled(false)` was used, or if currentHandler is `nil`.
-function Noble.Input.getEnabled()
- return cachedInputHandler == nil
-end
-
-local crankIndicatorActive = false
-local crankIndicatorForced = false
-
---- Enable/disable on-screen system crank indicator.
---
--- NOTE: The indicator will only ever show if the crank is docked, unless `__evenWhenUndocked` is true.
--- @bool __active Set true to start showing the on-screen crank indicator. Set false to stop showing it.
--- @bool[opt=false] __evenWhenUndocked Set true to show the crank indicator even if the crank is already undocked (`__active` must also be true).
-function Noble.Input.setCrankIndicatorStatus(__active, __evenWhenUndocked)
- if (__active) then
- UI.crankIndicator:start()
- end
- crankIndicatorActive = __active
- crankIndicatorForced = Utilities.handleOptionalBoolean(__evenWhenUndocked, false)
-end
-
---- Checks whether the system crank indicator status. Returns a tuple.
---
--- @treturn bool Is the crank indicator active?
--- @treturn bool Is the crank indicator being forced when active, even when the crank is undocked?
--- @see setCrankIndicatorStatus
-function Noble.Input.getCrankIndicatorStatus()
- return crankIndicatorActive, crankIndicatorForced
-end
-
--- Noble Engine defines extra "buttonHold" methods that run every frame that a button is held down, but to implement them, we need to do some magic.
-local buttonHoldBufferAmount = 3 -- This is how many frames to wait before the engine determines that a button is being held down. Using !buttonJustPressed() provides only 1 frame, which isn't enough.
-
-local AButtonHoldBufferCount = 0
-local BButtonHoldBufferCount = 0
-local upButtonHoldBufferCount = 0
-local downButtonHoldBufferCount = 0
-local leftButtonHoldBufferCount = 0
-local rightButtonHoldBufferCount = 0
-
--- Store the latest orientation in order to know when to run the orientationChanged callback
-local orientation = nil
-local accelerometerValues = nil
-
---- Checks the current display orientation of the device. Returns a tuple.
--- If the accelerometer is not currently enabled, this method will turn it on, return current values, and then turn it off.
--- If you are trying to get raw accelerometer values rather than the display orientation, you may want to use `playdate.readAccelerometer()` instead.
--- @bool[opt=false] __getStoredValues If true, this method will simply return the most recently stored values, rather than use the accelerometer to check for new ones.
--- @treturn str The named orientation of the device (a pseudo enum Noble.Input.ORIENTATION_XX)
--- @treturn list Accelerometer values, where list[1] is x, list[2] is y and list[3] is z
--- @see Noble.Input.ORIENTATION_UP
--- @see Noble.Input.ORIENTATION_DOWN
--- @see Noble.Input.ORIENTATION_LEFT
--- @see Noble.Input.ORIENTATION_RIGHT
-function Noble.Input.getOrientation(__getStoredValues)
-
- local getStoredValues = Utilities.handleOptionalBoolean(__getStoredValues, false)
- if (not getStoredValues) then
-
- local turnOffAfterUse = false
- if (not playdate.accelerometerIsRunning()) then
- playdate.startAccelerometer()
- turnOffAfterUse = true
- end
-
- local x, y, z = playdate.readAccelerometer()
-
- if (turnOffAfterUse) then
- playdate.stopAccelerometer()
- end
-
- local newOrientation = nil
-
- if (x <= -0.7) then
- newOrientation = Noble.Input.ORIENTATION_LEFT
- elseif (x >= 0.7) then
- newOrientation = Noble.Input.ORIENTATION_RIGHT
- elseif (y <= -0.3) then
- newOrientation = Noble.Input.ORIENTATION_DOWN
- else
- newOrientation = Noble.Input.ORIENTATION_UP
- end
-
- accelerometerValues = {x, y, z}
-
- if (newOrientation ~= orientation) then
- if (currentHandler.orientationChanged ~= nil) then
- currentHandler.orientationChanged(orientation, accelerometerValues)
- end
- orientation = newOrientation
- end
- end
-
- return orientation, accelerometerValues
-
-end
-
--- Do not call this method directly, or modify it, thanks. :-)
-function Noble.Input.update()
-
- if (currentHandler == nil) then return end
-
- if (currentHandler.AButtonHold ~= nil) then
- if (playdate.buttonIsPressed(playdate.kButtonA)) then
- if (AButtonHoldBufferCount >= buttonHoldBufferAmount) then currentHandler.AButtonHold(AButtonHoldBufferCount) end -- Execute!
- AButtonHoldBufferCount = AButtonHoldBufferCount + 1 -- Wait another frame!
- end
- if (playdate.buttonJustReleased(playdate.kButtonA)) then AButtonHoldBufferCount = 0 end -- Reset!
- end
- if (currentHandler.BButtonHold ~= nil) then
- if (playdate.buttonIsPressed(playdate.kButtonB)) then
- if (BButtonHoldBufferCount >= buttonHoldBufferAmount) then currentHandler.BButtonHold(BButtonHoldBufferCount) end
- BButtonHoldBufferCount = BButtonHoldBufferCount + 1
- end
- if (playdate.buttonJustReleased(playdate.kButtonB)) then BButtonHoldBufferCount = 0 end
- end
- if (currentHandler.upButtonHold ~= nil) then
- if (playdate.buttonIsPressed(playdate.kButtonUp)) then
- if (upButtonHoldBufferCount >= buttonHoldBufferAmount) then currentHandler.upButtonHold(upButtonHoldBufferCount) end
- upButtonHoldBufferCount = upButtonHoldBufferCount + 1
- end
- if (playdate.buttonJustReleased(playdate.kButtonUp)) then upButtonHoldBufferCount = 0 end
- end
- if (currentHandler.downButtonHold ~= nil) then
- if (playdate.buttonIsPressed(playdate.kButtonDown)) then
- if (downButtonHoldBufferCount >= buttonHoldBufferAmount) then currentHandler.downButtonHold(downButtonHoldBufferCount) end
- downButtonHoldBufferCount = downButtonHoldBufferCount + 1
- end
- if (playdate.buttonJustReleased(playdate.kButtonDown)) then downButtonHoldBufferCount = 0 end
- end
- if (currentHandler.leftButtonHold ~= nil) then
- if (playdate.buttonIsPressed(playdate.kButtonLeft)) then
- if (leftButtonHoldBufferCount >= buttonHoldBufferAmount) then currentHandler.leftButtonHold(leftButtonHoldBufferCount) end
- leftButtonHoldBufferCount = leftButtonHoldBufferCount + 1
- end
- if (playdate.buttonJustReleased(playdate.kButtonLeft)) then leftButtonHoldBufferCount = 0 end
- end
- if (currentHandler.rightButtonHold ~= nil) then
- if (playdate.buttonIsPressed(playdate.kButtonRight)) then
- if (rightButtonHoldBufferCount >= buttonHoldBufferAmount) then currentHandler.rightButtonHold(rightButtonHoldBufferCount) end
- rightButtonHoldBufferCount = rightButtonHoldBufferCount + 1
- end
- if (playdate.buttonJustReleased(playdate.kButtonRight)) then rightButtonHoldBufferCount = 0 end
- end
- if (playdate.accelerometerIsRunning()) then
- Noble.Input.getOrientation()
- end
-end
-
--- Do not call this method directly, or modify it, thanks. :-)
-function playdate.crankDocked()
- if (currentHandler ~= nil and currentHandler.crankDocked ~= nil and Noble.Input.getEnabled() == true) then
- currentHandler.crankDocked()
- end
-end
-
--- Do not call this method directly, or modify it, thanks. :-)
-function playdate.crankUndocked()
- if (currentHandler ~= nil and currentHandler.crankUndocked ~= nil and Noble.Input.getEnabled() == true) then
- currentHandler.crankUndocked()
- end
-end
-
---- Constants
--- . A set of constants referencing device inputs, stored as strings. Can be used for querying button input,
--- but are mainly for on-screen prompts or other elements where a string literal is useful, such as a filename, GameData value, or localization key.
--- For faster performance, use the ones that exist in the Playdate SDK (i.e.: `playdate.kButtonA`), which are stored as binary numbers.
--- @usage
--- function newPrompt(__input, __promptString)
--- -- ...
--- local icon = Graphics.image.new("assets/images/UI/Icon_" .. __input)
--- -- ...
--- end
---
--- promptMove = newPrompt(Noble.Input.DPAD_HORIZONTAL, "Move!") -- assets/images/UI/Icon_dPadHorizontal.png"
--- promptJump = newPrompt(Noble.Input.BUTTON_A, "Jump!") -- assets/images/UI/Icon_buttonA.png"
--- promptCharge = newPrompt(Noble.Input.CRANK_FORWARD, "Charge the battery!") -- assets/images/UI/Icon_crankForward.png"
--- @section constants
-
---- `"buttonA"`
-Noble.Input.BUTTON_A = "buttonA"
---- `"buttonB"`
-Noble.Input.BUTTON_B = "buttonB"
---- The system menu button.
---
--- `"buttonMenu"`
-Noble.Input.BUTTON_MENU = "buttonMenu"
-
---- Referencing the D-pad component itself, rather than an input.
---
--- `"dPad"`
-Noble.Input.DPAD = "dPad"
---- Referencing the left and right input D-pad inputs.
---
--- `"dPadHorizontal"`
-Noble.Input.DPAD_HORIZONTAL = "dPadHorizontal"
---- Referencing the up and down input D-pad inputs.
---
--- `"dPadVertical"`
-Noble.Input.DPAD_VERTICAL = "dPadVertical"
---- `"dPadUp"`
-Noble.Input.DPAD_UP = "dPadUp"
---- `"dPadDown"`
-Noble.Input.DPAD_DOWN = "dPadDown"
---- `"dPadLeft"`
-Noble.Input.DPAD_LEFT = "dPadLeft"
---- `"dPadRight"`
-Noble.Input.DPAD_RIGHT = "dPadRight"
-
---- Referencing the crank component itself, rather than an input.
---
--- `"crank"`
-Noble.Input.CRANK = "crank"
---- AKA: Clockwise. See Playdate SDK.
---
--- `"crankForward"`
-Noble.Input.CRANK_FORWARD = "crankForward"
---- AKA: Anticlockwise. See Playdate SDK.
---
--- `"crankReverse"`
-Noble.Input.CRANK_REVERSE = "crankReverse"
---- Referencing the action of docking the crank.
---
--- `"crankDock"`
-Noble.Input.CRANK_DOCK = "crankDock"
---- Referencing the action of undocking the crank.
---
--- `"crankUndock"`
-Noble.Input.CRANK_UNDOCK = "crankUndock"
-
---- Referencing the display orientations.
---
--- `"orientationUp"`
-Noble.Input.ORIENTATION_UP = "orientationUp"
--- `"orientationDown"`
-Noble.Input.ORIENTATION_DOWN = "orientationDown"
--- `"orientationLeft"`
-Noble.Input.ORIENTATION_LEFT = "orientationLeft"
--- `"orientationRight"`
-Noble.Input.ORIENTATION_RIGHT = "orientationRight"
\ No newline at end of file
diff --git a/source/libraries/noble/modules/Noble.Menu.lua b/source/libraries/noble/modules/Noble.Menu.lua
deleted file mode 100644
index 00781cf..0000000
--- a/source/libraries/noble/modules/Noble.Menu.lua
+++ /dev/null
@@ -1,570 +0,0 @@
---- An extended implementation of `playdate.ui.gridview`, meant for 1-dimensional, single-screen text menus.
--- @module Noble.Menu
---
-Noble.Menu = {}
-
---- Setup
--- @section setup
-
---- Create a new menu object.
--- @bool[opt=true] __activate @{activate|Activate} this menu upon creation.
--- @param[opt=Noble.Text.ALIGN_LEFT] __alignment The text alignment of menu items.
--- @bool[opt=false] __localized If true, menu item names are localization keys rather than display names.
--- @param[opt=Graphics.kColorBlack] __color The color of menu item text. The selected highlight will be the inverse color.
--- @int[opt=2] __padding Cell padding for menu items.
--- @int[opt] __horizontalPadding Use this to override horizontal padding, useful for certain fonts. If nil, uses __padding.
--- @int[opt=2] __margin Spacing between menu items.
--- @param[opt=Noble.Text.getCurrentFont()] __font If nil, uses current set font.
--- @int[opt=__font:getHeight()/4] __selectedCornerRadius Sets rounded corners for a selected menu item.
--- @int[opt=1] __selectedOutlineThickness Sets the outline thickness for selected items.
--- @return `menu`, a new menu item.
--- @usage
--- local menu = Noble.Menu.new(
--- true,
--- Noble.Text.ALIGN_CENTER,
--- false,
--- Graphics.kColorWhite,
--- 4, 6,
--- Noble.Text.large,
--- nil, 3
--- )
--- menu:addItem("Play Game", function() TitleScreen:playGame() end)
--- menu:addItem("Options", function() Noble.transition(OptionsScreen) end)
--- menu:addItem("Credits", function() Noble.transition(CreditsScreen) end)
--- @see addItem
-function Noble.Menu.new(__activate, __alignment, __localized, __color, __padding, __horizontalPadding, __margin, __font, __selectedCornerRadius, __selectedOutlineThickness)
-
- -- Prep for creating the gridview object
- local paddingLocal = __padding or 2
- local fontLocal = __font or Noble.Text.getCurrentFont()
- local textHeightLocal = fontLocal:getHeight()
-
- -- Create gridview object
- local menu = UI.gridview.new(0, textHeightLocal + paddingLocal)
-
- --- Properties
- --@section properties
-
- menu.alignment = __alignment or Noble.Text.ALIGN_LEFT
-
- --- @bool[opt=false] _ Indicates whether this menu's item names are treated as localization keys.
- menu.localized = Utilities.handleOptionalBoolean(__localized, false)
- menu.textHeight = textHeightLocal
- menu.padding = paddingLocal
- menu.horizontalPadding = __horizontalPadding or menu.padding
- menu.margin = __margin or 2
- menu.font = fontLocal
- menu.selectedCornerRadius = __selectedCornerRadius or textHeightLocal/4
- menu.selectedOutlineThickness = __selectedOutlineThickness or 1
-
- -- Local cleanup. We don't need these anymore.
- paddingLocal = nil
- fontLocal = nil
- textHeightLocal = nil
-
- -- Colors
- menu.color = __color or Graphics.kColorBlack -- TO-DO allow for copy fill mode instead of color.
- menu.fillMode = Graphics.kDrawModeFillBlack
- menu.otherColor = Graphics.kColorWhite
- menu.otherFillMode = Graphics.kDrawModeFillWhite
- if (menu.color == Graphics.kColorWhite) then
- menu.fillMode = Graphics.kDrawModeFillWhite
- menu.otherColor = Graphics.kColorBlack
- menu.otherFillMode = Graphics.kDrawModeFillBlack
- end
-
- -- Gridview properties
- menu:setNumberOfColumns(1)
- menu:setCellPadding(0, 0, 0, 0)
- menu.changeRowOnColumnWrap = false
-
- --- Tables
- --@section tables
-
- --- A string "array" of menu item strings/keys.
- -- You cannot add or remove menu items by modifying this table.
- -- It is meant as a read-only table, provided for convenience when iterating, etc. Modifying its values may break other methods.
- -- @usage
- -- for i = 1, #menu.itemNames, 1 do
- -- menu.clickHandlers[menu.itemNames[i]] = nil -- Clears all click handlers, for some reason.
- -- end
- -- @see addItem
- menu.itemNames = {}
-
- -- This is an internal table. Modifying its may break other methods.
- menu.displayNames = {}
-
- -- This is an internal table. Modifying its may break other methods.
- menu.displayNamesAreLocalized = {}
-
- --- A table of functions associated with menu items. Items are a defined when calling @{addItem|addItem}, but their associated functions may be modified afterward.
- --
- -- You cannot add or remove menu items by modifying this table.
- -- @usage
- -- local menu = Noble.Menu.new(true)
- -- menu.addItem("Play Game")
- -- menu.addItem("Options")
- --
- -- menu.clickHandlers["Play Game"] = function() TitleScreen:playGame() end
- -- menu.clickHandlers["Options"] = function() Noble.transition(OptionsScreen) end
- -- @usage
- -- local menu = Noble.Menu.new(true)
- -- menu.addItem("Play Game")
- -- menu.addItem("Options")
- --
- -- menu.clickHandlers = {
- -- ["Play Game"] = function TitleScreen:playGame() end,
- -- ["Options"] = function() Noble.transition(OptionsScreen) end
- -- }
- -- @see addItem
- -- @see removeItem
- menu.clickHandlers = {}
-
- --- A key/value table of menu item indices.
- --
- -- This is meant as a read-only table, provided for convenience. Modifying its values will break other methods.
- -- @usage
- -- menu.itemPositions["Play Game"] -- 1
- -- menu.itemPositions["Options"] -- 2
- menu.itemPositions = {}
-
- --- A key/value table of pixel widths for each menu item, based on its text. Useful for animation, layout, etc.
- --
- -- This is meant as a read-only table, provided for convenience. Modifying its values will break other methods.
- -- @usage local playGameMenuItemWidth = menu.itemWidths["Play Game"]
- menu.itemWidths = {}
-
- --- Properties
- -- @section properties
-
- --- @int _
- -- The current menu item's index.
- --
- -- This is meant as a read-only value. Do not modify it directly.
- -- @see select
- menu.currentItemNumber = 1
-
- --- @string _
- -- The current menu item's name.
- --
- -- This is meant as a read-only value. Do not modify it directly.
- -- @see select
- menu.currentItemName = menu.itemNames[1]
-
-
- --- @int _
- -- The width of the widest menu item plus the menu's horizontal padding.
- --
- -- This is meant as a read-only value. Do not modify it directly.
- menu.width = 0
-
- --- Setup
- -- @section setup
-
- --- Adds a item to this menu.
- -- @string __nameOrKey The name of this menu item. It can be a display name or a localization key. Must be unique.
- -- @tparam[opt] function __clickHandler The function that runs when this menu item is "clicked."
- -- @int[opt] __position Insert the item at a specific position. If not set, adds to the end of the list.
- -- @string[opt] __displayName You can create an optional, separate display name for this item. You can add or change this at runtime via @{setItemDisplayName|setItemDisplayName}.
- -- @bool[opt=false] __displayNameIsALocalizationKey If true, will treat the `__displayName` as a localization key. This is separate from this menu's @{localized|localized} value.
- -- @see new
- -- @see removeItem
- -- @see setItemDisplayName
- function menu:addItem(__nameOrKey, __clickHandler, __position, __displayName, __displayNameIsALocalizationKey)
- local clickHandler = __clickHandler or function () print("Menu item \"" .. __nameOrKey .. "\" clicked!") end
- if (__position ~= nil) then
- if (__position <= 0 or __position > #self.itemNames) then error("BONK: Menu item out of range.", 3) return end
- table.insert(self.itemNames, __position, __nameOrKey)
- for key, value in pairs(self.itemPositions) do
- if (value >= __position) then
- self.itemPositions[key] = self.itemPositions[key] + 1
- end
- end
- self.itemPositions[__nameOrKey] = __position
- else
- table.insert(self.itemNames, __nameOrKey)
- self.itemPositions[__nameOrKey] = #self.itemNames
- end
-
- self.clickHandlers[__nameOrKey] = clickHandler
-
- -- Item name
- local nameOrKey
- if (self.localized) then
- nameOrKey = Graphics.getLocalizedText(__nameOrKey)
- else
- nameOrKey = __nameOrKey
- end
-
- -- Display name
- local displayName = nil
- if (__displayName ~= nil) then
- if (__displayNameIsALocalizationKey == true) then
- displayName = Graphics.getLocalizedText(__displayName)
- else
- displayName = __displayName
- end
- self.displayNames[__nameOrKey] = displayName
- end
-
- if (displayName == nil) then
- self:updateWidths(__nameOrKey, nameOrKey)
- else
- self:updateWidths(__nameOrKey, displayName)
- end
-
- self:setNumberOfRows(#self.itemNames)
-
- end
-
- -- Internal method.
- function menu:updateWidths(__nameOrKey, __string)
-
- if (__string == nil) then
- __string = __nameOrKey
- end
-
- -- Item width
- self.itemWidths[__nameOrKey] = self.font:getTextWidth(__string)
-
- -- Menu width
- local width = 0
- for _, value in pairs(self.itemWidths) do
- if value > width then width = value end
- end
- self.width = width + (self.horizontalPadding * 2) + (self.selectedOutlineThickness * 2)
- end
-
- --- Removes a item from this menu.
- -- @tparam[opt=#menu.itemNames] int|string __menuItem The menu item to remove. You can enter either the item's name/key or it's position. If left blank, removes the last item.
- -- @see addItem
- function menu:removeItem(__menuItem)
- local itemString = nil
- local itemPosition = nil
-
- if (__menuItem == nil) then
- __menuItem = #self.itemNames
- end
-
- if (type(__menuItem) == "number") then
- if (__menuItem <= 0 or __menuItem > #self.itemNames) then error("BONK: Menu item out of range.", 3) return end
- itemString = self.itemNames[__menuItem]
- itemPosition = __menuItem
- elseif (type(__menuItem) == "string") then
- itemString = __menuItem
- itemPosition = self.itemPositions[__menuItem]
- if (itemPosition == nil) then error("BONK: Menu item not found.", 3) return end
- end
-
- for key, value in pairs(self.itemPositions) do
- if (value > itemPosition) then
- self.itemPositions[key] = self.itemPositions[key] - 1
- end
- end
-
- table.remove(self.itemNames, itemPosition)
- self.itemPositions[itemString] = nil
- self.clickHandlers[itemString] = nil
- self.itemWidths[itemString] = nil
- self.displayNames[itemString] = nil
- self.displayNamesAreLocalized[itemString] = nil
-
- -- In case the current item is selected.
- if (self.currentItemNumber == itemPosition and self.currentItemNumber ~= 1) then
- self:select(self.currentItemNumber - 1, true)
- if (self.isActive() == false) then
- self:setSelectedRow(0)
- end
- end
-
- self:setNumberOfRows(#self.itemNames)
-
- -- Update width
- local width = 0
- for _, value in pairs(self.itemWidths) do
- if value > width then width = value end
- end
- self.width = width + (self.horizontalPadding * 2) + (self.selectedOutlineThickness * 2)
-
- end
-
- --
-
- local active = Utilities.handleOptionalBoolean(__activate, true)
- if (active) then
- menu.currentItemNumber = 1
- menu.currentItemName = menu.itemNames[1]
- menu:setSelectedRow(1)
- else
- menu:setSelectedRow(0)
- end
-
- --- Methods
- --@section methods
-
- --- Activate this menu.
- -- This selects the most recently selected menu item (or the first item if none have been previously selected), and enables this menu's @{selectPrevious|selectPrevious}, @{selectNext|selectNext}, and @{click|click} methods.
- -- @usage
- -- local menu = Noble.Menu.new(false)
- -- menu:activate()
- function menu:activate()
- active = true
- self:select(self.currentItemNumber)
- end
- --- Deactivate this menu.
- -- This deselects all menu items, and disables this menu's @{selectPrevious|selectPrevious}, @{selectNext|selectNext}, and @{click|click} methods.
- -- @usage
- -- local menu = Noble.Menu.new(true)
- -- menu:deactivate()
- function menu:deactivate()
- self:setSelectedRow(0)
- active = false
- end
- --- Check to see if this menu is currently active.
- -- @treturn bool
- function menu:isActive()
- return active
- end
-
- --- Selects the previous item in this menu. This menu must be active.
- -- @bool[opt=false] __force Force this method to run, even if this menu is not active.
- -- @bool[opt=true] __wrapSelection Selects the final menu item if the first menu item is currently selected.
- -- @see activate
- -- @usage
- -- TitleScreen.inputHandler.upButtonDown = function()
- -- menu:selectPrevious()
- -- end
- function menu:selectPrevious(__force, __wrapSelection)
- if (self:isActive() or __force) then
- local wrapSelection = Utilities.handleOptionalBoolean(__wrapSelection, true)
- self:selectPreviousRow(wrapSelection, false, false)
- local _, row, _ = self:getSelection()
- self.currentItemNumber = row
- self.currentItemName = self.itemNames[row]
- end
- end
- --- Selects the next previous item in this menu. This menu must be active.
- -- @bool[opt=false] __force Force this method to run, even if this menu is not active.
- -- @bool[opt=true] __wrapSelection Selects the first menu item if the final menu item is currently selected.
- -- @see activate
- -- @usage
- -- TitleScreen.inputHandler.downButtonDown = function()
- -- menu:selectNext()
- -- end
- function menu:selectNext(__force, __wrapSelection)
- if (self:isActive() or __force) then
- local wrapSelection = Utilities.handleOptionalBoolean(__wrapSelection, true)
- self:selectNextRow(wrapSelection, false, false)
- local _, row, _ = self:getSelection()
- self.currentItemNumber = row
- self.currentItemName = self.itemNames[row]
- end
- end
-
- --- Selects a specific item in this menu, either by it's index, or it's name. This menu must be active.
- -- @tparam int|string __menuItem The menu item to select. You can enter the item's number or it's name/key.
- -- @bool[opt=false] __force Force this method to run, even if this menu is not active.
- -- @see activate
- -- @usage
- -- function resetMenu()
- -- menu:select(1, true)
- -- menu:deactivate()
- -- end
- -- @usage
- -- function resetMenu()
- -- menu:select("Play Game", true)
- -- menu:deactivate()
- -- end
- function menu:select(__menuItem, __force)
- if (self:isActive() or __force) then
- if (type(__menuItem) == 'number') then
- if (__menuItem < 1) then
- error("BONK: _menuItem must be a number greater than 0 (or a string).")
- end
- self:setSelectedRow(__menuItem)
- elseif (type(__menuItem) == 'string') then
- self:setSelectedRow(self.itemPositions[__menuItem])
- else
- error("BONK: _menuItem must be a number or string, silly.")
- end
- local _, row, _ = self:getSelection()
- self.currentItemNumber = row
- self.currentItemName = self.itemNames[row]
- end
- end
-
- --- Runs the function associated with the currently selected menu item. This menu must be active.
- -- @bool[opt=false] __force Force this method to run, even if this menu is not active.
- -- @see activate
- -- @usage
- -- TitleScreen.inputHandler.AButtonDown = function()
- -- menu:click()
- -- end
- function menu:click(__force)
- if ((self:isActive() or __force) and self.clickHandlers[self.currentItemName] ~= nil) then
- self.clickHandlers[self.currentItemName]()
- end
- end
-
- --- Gets the display name of a menu item.
- --
- -- If a menu item does not have a display name, then the `__nameOrKey` (or its localized string) will be returned instead. This method is used internally when @{draw|draw} is called.
- --
- -- If this menu's `localized` value is true, a returned `__nameOrKey` will always be localized, but a returned display name is only localized if the `__displayNameIsALocalizationKey` argument was set to `true` when the display name was added.
- -- @string __itemName The menu item you want the display name of.
- -- @treturn string
- -- @see addItem
- -- @see setItemDisplayName
- function menu:getItemDisplayName(__itemName)
- if (self.displayNames[__itemName] == nil) then
- -- No display name.
- if (self.localized) then
- return Graphics.getLocalizedText(__itemName)
- else
- return __itemName
- end
- else
- -- Has display name.
- if (self.displayNamesAreLocalized[__itemName] == true) then
- return Graphics.getLocalizedText(self.displayNames[__itemName])
- else
- return self.displayNames[__itemName]
- end
- end
- end
-
- --- When you add a menu item, you can give it a display name that's different from it's actual name. This method adds or changes the display name of a menu item.
- -- @string __itemName The menu item name (or key if this menu uses localization keys).
- -- @string __displayName The display name.
- -- @bool[opt=false] __displayNameIsALocalizationKey Set to use to indicate that this display name is a localization key. This setting is separate from @{localized|localized}
- -- @usage
- -- function changeDifficultyLevel(__level)
- -- menu:setItemDisplayName("Difficulty", "Difficulty: " .. __level)
- -- end
- function menu:setItemDisplayName(__itemName, __displayName, __displayNameIsALocalizationKey)
- self.displayNames[__itemName] = __displayName
- self.displayNamesAreLocalized[__itemName] = Utilities.handleOptionalBoolean(__displayNameIsALocalizationKey, false)
-
- local displayName
- if (__displayNameIsALocalizationKey == true) then
- displayName = Graphics.getLocalizedText(__displayName)
- else
- displayName = __displayName
- end
-
- -- If we're "resetting" the display name by setting it to nil, then use __nameOrKey instead (checking for localization before calling updateWidths)
- if (displayName == nil) then
- if (self.localized) then
- displayName = Graphics.getLocalizedText(__itemName)
- else
- displayName = __itemName
- end
- end
-
- self:updateWidths(__itemName, displayName)
- end
-
- --- Drawing
- --@section drawing
-
- --- Draw's this menu to the screen. You may call this manually, but ideally, you will put it in in your scene's @{NobleScene:update|update} or @{NobleScene:drawBackground|drawBackground} method.
- -- @usage
- -- function YourScene:update()
- -- YourScene.super.update(self)
- -- menu:draw(50, 100)
- -- end
- function menu:draw(__x, __y)
- local xAdjustment = 0
- if (self.alignment == Noble.Text.ALIGN_CENTER) then
- xAdjustment = self.width/2
- elseif (self.alignment == Noble.Text.ALIGN_RIGHT) then
- xAdjustment = self.width
- end
- self:drawInRect(__x - xAdjustment, __y, self.width, ((self.textHeight + self.padding + self.margin) * #self.itemNames) + (self.selectedOutlineThickness * 2) - self.margin)
- end
-
- --- This method is called for every non-selected item when @{draw|draw} is called. You shouldn't call this directly, but you may re-implement it if you wish.
- -- @usage
- -- -- This is the default implementation for this method.
- -- function menu:drawItem(__x, __y, __itemIndex)
- -- Graphics.setImageDrawMode(self.fillMode)
- -- local xAdjustment = 0
- -- if (self.alignment == Noble.Text.ALIGN_CENTER) then
- -- xAdjustment = self.width/2 - self.horizontalPadding/2
- -- elseif (self.alignment == Noble.Text.ALIGN_RIGHT) then
- -- xAdjustment = self.width - self.horizontalPadding
- -- end
- -- Noble.Text.draw(self.itemNames[__itemIndex], __x + self.horizontalPadding/2 + xAdjustment, __y + self.padding/2, self.alignment, self.localized, self.font)
- -- end
- -- @see Noble.Text.draw
- function menu:drawItem(__x, __y, __itemIndex)
- Graphics.setImageDrawMode(self.fillMode)
- local xAdjustment = self.selectedOutlineThickness
- if (self.alignment == Noble.Text.ALIGN_CENTER) then
- xAdjustment = self.width/2 - self.horizontalPadding/2
- elseif (self.alignment == Noble.Text.ALIGN_RIGHT) then
- xAdjustment = self.width - self.horizontalPadding - self.selectedOutlineThickness
- end
- Noble.Text.draw(
- self:getItemDisplayName(self.itemNames[__itemIndex]),
- __x + self.horizontalPadding/2 + xAdjustment, __y + self.padding/2 + self.selectedOutlineThickness + (self.margin * (__itemIndex -1)),
- self.alignment, false, self.font
- )
- end
-
- --- This method is called for every selected item when @{draw|draw} is called. You shouldn't call this directly, but you may re-implement it if you wish.
- -- @usage
- -- -- This is the default implementation for this method.
- -- function menu:drawSelectedItem(__x, __y, __itemIndex)
- -- local xAdjustmentText = 0
- -- local xAdjustmentRect = 0
- -- if (self.alignment == Noble.Text.ALIGN_CENTER) then
- -- xAdjustmentText = self.width/2 - self.horizontalPadding/2
- -- xAdjustmentRect = self.width/2 - self.itemWidths[self.itemNames[__itemIndex]]/2 - self.horizontalPadding/2
- -- elseif (self.alignment == Noble.Text.ALIGN_RIGHT) then
- -- xAdjustmentText = self.width - self.horizontalPadding
- -- xAdjustmentRect = self.width - self.itemWidths[self.itemNames[__itemIndex]] - self.horizontalPadding
- -- end
- -- Graphics.setColor(self.color)
- -- Graphics.fillRoundRect(__x + xAdjustmentRect, __y, self.itemWidths[self.itemNames[__itemIndex]]+self.horizontalPadding, self.textHeight+self.padding, self.selectedCornerRadius)
- -- Graphics.setColor(self.otherColor)
- -- Graphics.setLineWidth(self.selectedOutlineThickness)
- -- Graphics.drawRoundRect(__x + xAdjustmentRect, __y, self.itemWidths[self.itemNames[__itemIndex]]+self.horizontalPadding, self.textHeight+self.padding, self.selectedCornerRadius)
- -- Graphics.setImageDrawMode(self.otherFillMode)
- -- Noble.Text.draw(self.itemNames[__itemIndex], __x + self.horizontalPadding/2 + xAdjustmentText, __y+self.padding/2, self.alignment, self.localized, self.font)
- -- end
- -- @see Noble.Text.draw
- function menu:drawSelectedItem(__x, __y, __itemIndex)
- local xAdjustmentText = self.selectedOutlineThickness
- local xAdjustmentRect = self.selectedOutlineThickness
- if (self.alignment == Noble.Text.ALIGN_CENTER) then
- xAdjustmentText = self.width/2 - self.horizontalPadding/2
- xAdjustmentRect = self.width/2 - self.itemWidths[self.itemNames[__itemIndex]]/2 - self.horizontalPadding/2
- elseif (self.alignment == Noble.Text.ALIGN_RIGHT) then
- xAdjustmentText = self.width - self.horizontalPadding - self.selectedOutlineThickness
- xAdjustmentRect = self.width - self.itemWidths[self.itemNames[__itemIndex]] - self.horizontalPadding - self.selectedOutlineThickness
- end
- Graphics.setColor(self.color)
- Graphics.fillRoundRect(__x + xAdjustmentRect, __y + self.selectedOutlineThickness + (self.margin * (__itemIndex -1)), self.itemWidths[self.itemNames[__itemIndex]]+self.horizontalPadding, self.textHeight+self.padding, self.selectedCornerRadius)
- Graphics.setColor(self.otherColor)
- Graphics.setLineWidth(self.selectedOutlineThickness)
- Graphics.drawRoundRect(__x + xAdjustmentRect, __y + self.selectedOutlineThickness + (self.margin * (__itemIndex -1)), self.itemWidths[self.itemNames[__itemIndex]]+self.horizontalPadding, self.textHeight+self.padding, self.selectedCornerRadius)
- Graphics.setImageDrawMode(self.otherFillMode)
- Noble.Text.draw(
- self:getItemDisplayName(self.itemNames[__itemIndex]),
- __x + self.horizontalPadding/2 + xAdjustmentText, __y + self.padding/2 + self.selectedOutlineThickness + (self.margin * (__itemIndex -1)),
- self.alignment, false, self.font
- )
- end
-
- -- Don't call or modify this function.
- function menu:drawCell(_, row, _, selected, x, y, width, height)
- if selected then
- self:drawSelectedItem(x, y, row)
- else
- self:drawItem(x, y, row)
- end
- end
-
- return menu
-end
diff --git a/source/libraries/noble/modules/Noble.Settings.lua b/source/libraries/noble/modules/Noble.Settings.lua
deleted file mode 100644
index fa69a91..0000000
--- a/source/libraries/noble/modules/Noble.Settings.lua
+++ /dev/null
@@ -1,158 +0,0 @@
---- Operations for game settings / stats.
--- @module Noble.Settings
---
-Noble.Settings = {} -- This is the "class" that holds methods.
-local settings = nil -- This is the actual settings object. We keep it local to avoid direct tampering.
-local settingsDefault = nil -- We keep track of default values so they can be reset.
-
-local function keyChange(__dataDefault, __data)
- local defaultKeys = {}
- local keys = {}
- for key, value in pairs(__dataDefault) do table.insert(defaultKeys, key) end
- for key, value in pairs(__data) do table.insert(keys, key) end
- for i = 1, #keys, 1 do
- if (defaultKeys[i] ~= keys[i]) then return true end
- end
- return false
-end
-
-local function settingExists(__key)
- -- Check for valid data item.
- for key, value in pairs(settings) do
- if __key == key then
- return true
- end
- end
- error("BONK: Setting \'" .. __key .. "\' does not exist. Maybe you spellet ti wronlgly.", 3)
- return false
-end
-
-local settingsHaveBeenSetup = false
-
---- Sets up the settings for your game. You can only run this once, and you must run it before using other `Noble.Settings` functions. It is recommended to place it in your main.lua, before `Noble.new()`.
---
--- NOTE: You will *not* be able to add new keys via the `Noble.Settings.set` method. This means you need to specify the keys and default values of all of the settings in your game at setup.
--- If you need to add keys that are not known during setup, it is probably not a setting and you should consider using `Noble.GameData` instead.
--- @tparam table __keyValuePairs table. Your game's settings, and thier default values, as key/value pairs. NOTE: Do not use "nil" as a value.
--- @bool[opt=true] __saveToDisk Saves your default values immediatly to disk.
--- @bool[opt=true] __modifyExistingOnKeyChange Updates the existing settings object on disk if you make changes to your settings keys (not values) during development or when updating your game.
--- @usage
--- Noble.Settings.setup({
--- difficulty = "normal",
--- music = true,
--- sfx = true,
--- players = 2,
--- highScore = 0 -- You can store persistant stats here, too!
--- })
-function Noble.Settings.setup(__keyValuePairs, __saveToDisk, __modifyExistingOnKeyChange)
- if (settingsHaveBeenSetup) then
- error("BONK: You can only run Noble.Settings.setup() once.")
- return
- else
- settingsHaveBeenSetup = true
- end
-
- -- Prevent using the setup() method if there are no settings to register
- if (__keyValuePairs == nil or table.getSize(__keyValuePairs) == 0) then
- error("BONK: Do not use Noble.Settings.setup if you do not have any settings to register. New settings cannot be added via Noble.Settings.set and must be all declared upfront in the Noble.Settings.setup method.")
- return
- end
-
- local saveToDisk = Utilities.handleOptionalBoolean(__saveToDisk, true)
- local modifyExistingOnKeyChange = Utilities.handleOptionalBoolean(__modifyExistingOnKeyChange, true)
- settingsDefault = __keyValuePairs
-
- -- Get existing settings from disk, if any.
- settings = Datastore.read("Settings")
-
- if (settings == nil) then
- -- No settings on disk, so we create a new settings object using default values.
- settings = table.deepcopy(settingsDefault)
- elseif (modifyExistingOnKeyChange and keyChange(settingsDefault, settings)) then
- -- Found settings on disk, but key changes have been made...
- -- ...so we start with a new default settings object...
- local existingSettings = table.deepcopy(settings)
- settings = table.deepcopy(settingsDefault)
- for key, value in pairs(settings) do
- -- ...then copy settings with unchanged keys to the new settings object,
- -- naturally discarding keys that don't exist anymore.
- if (existingSettings[key] ~= nil) then settings[key] = existingSettings[key] end
- end
-
- end
-
- if (saveToDisk) then
- Noble.Settings.save()
- end
-end
-
---- Get the value of a setting.
--- @string __settingName The name of the setting.
--- @treturn any The value of the requested setting.
--- @see set
-function Noble.Settings.get(__settingName)
- if (settingExists(__settingName)) then
- return settings[__settingName]
- end
-end
-
---- Set the value of a setting.
---
--- NOTE: If __settingName is not a key in the __keyValuePairs dictionary given to the `setup` method it will not be added to the Settings.
--- @string __settingName The name of the setting.
--- @tparam any __value The setting's new value
--- @bool[opt=true] __saveToDisk Saves to disk immediately. Set to false if you prefer to manually save (via a confirm button, etc).
--- @see setup
--- @see get
--- @see save
-function Noble.Settings.set(__settingName, __value, __saveToDisk)
- if (settingExists(__settingName)) then
- settings[__settingName] = __value
- local saveToDisk = Utilities.handleOptionalBoolean(__saveToDisk, true)
- if (saveToDisk) then Noble.Settings.save() end
- end
-end
-
---- Resets the value of a setting to its default value defined in `setup()`.
--- @string __settingName The name of the setting.
--- @bool[opt=true] __saveToDisk Saves to disk immediately. Set to false if you prefer to manually save (via a confirm button, etc).
--- @see resetSome
--- @see resetAll
--- @see save
-function Noble.Settings.reset(__settingName, __saveToDisk)
- if (settingExists(__settingName)) then
- settings[__settingName] = settingsDefault[__settingName]
- local saveToDisk = Utilities.handleOptionalBoolean(__saveToDisk, true)
- if (saveToDisk) then Noble.Settings.save() end
- end
-end
-
---- Resets the value of multiple settings to thier default value defined in `setup()`. This is useful if you are storing persistant stats like high scores in `Settings` and want the player to be able to reset them seperately.
--- @tparam table __settingNames The names of the settings, in an array-style table.
--- @bool[opt=true] __saveToDisk Saves to disk immediately. Set to false if you prefer to manually save (via a confirm button, etc).
--- @see resetAll
--- @see save
-function Noble.Settings.resetSome(__settingNames, __saveToDisk)
- for i = 1, #__settingNames, 1 do
- Noble.Settings.reset(__settingNames[i], __saveToDisk)
- end
-end
-
---- Resets all settings to thier default values defined in `setup()`.
--- @bool[opt=true] __saveToDisk Saves to disk immediately. Set to false if you prefer to manually save (via a confirm button, etc).
--- @see resetSome
--- @see save
-function Noble.Settings.resetAll(__saveToDisk)
- settings = table.deepcopy(settingsDefault)
- local saveToDisk = Utilities.handleOptionalBoolean(__saveToDisk, true)
- if (saveToDisk) then Noble.Settings.save() end
-end
-
---- Saves settings to disk.
--- You don't need to call this unless you set `__saveToDisk` as false when setting or resetting a setting (say that five times fast!).
--- @see set
--- @see reset
--- @see resetAll
-function Noble.Settings.save()
- Datastore.write(settings, "Settings")
-end
diff --git a/source/libraries/noble/modules/Noble.Text.lua b/source/libraries/noble/modules/Noble.Text.lua
deleted file mode 100644
index f910c95..0000000
--- a/source/libraries/noble/modules/Noble.Text.lua
+++ /dev/null
@@ -1,74 +0,0 @@
---- Text and font handling.
--- @module Noble.Text
-Noble.Text = {}
-
---- Fonts
---
--- You can use these fonts in your project, or override them with your own if you wish.
--- @section fonts
--- @usage
--- Noble.Text.FONT_SMALL = Graphics.font.new("assets/fonts/MySmallFont")
--- Noble.Text.setFont(Noble.Text.FONT_SMALL)
-
---- The Playdate system font.
-Noble.Text.FONT_SYSTEM = Graphics.getSystemFont()
---- Noble Sans: A sans-serif 8×9 font, with English and Japanese-Kana character sets.
-Noble.Text.FONT_SMALL = Graphics.font.new("libraries/noble/assets/fonts/NobleSans")
---- Noble Slab: (This font is not ready yet!)
-Noble.Text.FONT_MEDIUM = Graphics.font.new("libraries/noble/assets/fonts/NobleSlab")
---- Satchel Roughed: A sans-serif 17×14 rounded font, with an English character set.
-Noble.Text.FONT_LARGE = Graphics.font.new("libraries/noble/assets/fonts/SatchelRoughed")
-
---- Constants
---@section constants
-
---- An alternate way to call Playdate SDK's `kTextAlignment.left`
-Noble.Text.ALIGN_LEFT = kTextAlignment.left
---- An alternate way to call Playdate SDK's `kTextAlignment.right`
-Noble.Text.ALIGN_RIGHT = kTextAlignment.right
---- An alternate way to call Playdate SDK's `kTextAlignment.center`
-Noble.Text.ALIGN_CENTER = kTextAlignment.center
-
-local currentFont = Noble.Text.FONT_SYSTEM
-
-
---- Functions
---@section functions
-
----
--- @return The currently set font.
-function Noble.Text.getCurrentFont()
- return currentFont
-end
-
---- Set the current font
--- @param __font any
--- @param __variant any
-function Noble.Text.setFont(__font, __variant)
- currentFont = __font
- local variant = __variant or Graphics.font.kVariantNormal
- Graphics.setFont(__font, variant)
-end
-
---- Abstracts multiple `playdate.text` drawing functions into one.
--- @string __string Display text or localization key.
--- @number __x
--- @number __y
--- @param[opt=Noble.Text.ALIGN_LEFT] __alignment Left, right, or center!
--- @bool[opt=false] __localized If true, `__string` is a localization key rather than display text.
--- @param[opt=Noble.Text.getCurrentFont()] __font A font to use. If not set, the `currentFont` is used. If set, the `currentFont` is not updated.
-function Noble.Text.draw(__string, __x, __y, __alignment, __localized, __font)
- local alignment = __alignment or Noble.Text.ALIGN_LEFT
- local localized = Utilities.handleOptionalBoolean(__localized, false)
- local string = __string or ""
-
- if (__font ~= nil) then Graphics.setFont(__font) end -- Temporary font
-
- if (localized) then
- Graphics.drawLocalizedTextAligned(string, __x, __y, alignment)
- else
- Graphics.drawTextAligned(string, __x, __y, alignment)
- end
-
- if (__font ~= nil) then Graphics.setFont(currentFont) end -- Reset
-end
diff --git a/source/libraries/noble/modules/Noble.Transition.lua b/source/libraries/noble/modules/Noble.Transition.lua
deleted file mode 100644
index 728811e..0000000
--- a/source/libraries/noble/modules/Noble.Transition.lua
+++ /dev/null
@@ -1,208 +0,0 @@
---- An abstract class from which transition types are extended.
--- @module Noble.Transition
-
-Noble.Transition = {}
-class("Transition", nil, Noble).extends()
-
-Noble.Transition.Type = {}
-
---- A transition type where no time at all passes between scenes.
--- @see Noble.Transition.Cut
-Noble.Transition.Type.CUT = "Cut"
-
---- A transition type that has an "Enter" phase and an "Exit" phase. The new scene does not become active until the Enter phase is complete. A "holdTime" value determines how long to wait after the Enter phase completes before starting the Exit phase.
--- @see Noble.Transition.Dip
--- @see Noble.Transition.Imagetable
--- @see Noble.Transition.Spotlight
-Noble.Transition.Type.COVER = "Cover"
-
---- A transition type that takes a screenshot of the exiting scene and activates the new scene before beginning the transition, allowing for both scenes to appear to be visible during the transition.
--- @see Noble.Transition.CrossDissolve
--- @see Noble.Transition.SlideOff
--- @see Noble.Transition.ImagetableMask
-Noble.Transition.Type.MIX = "Mix"
-
---- A transition may have unique properties that can be set by the user when invoked. This table holds the default values for those properties.
--- @see setDefaultProperties
-Noble.Transition.defaultProperties = {}
-
-function Noble.Transition:init(__duration, __arguments)
-
- self.duration = __duration or Noble.getConfig().defaultTransitionDuration
-
- self.durationEnter = __arguments.durationEnter or self.duration/2
- self.durationExit = __arguments.durationExit or self.duration/2
-
- if (__arguments.durationEnter and not __arguments.durationExit) then
- warn("Soft-BONK: You've specified 'durationEnter' but not 'durationExit' for this transition. Thus, 'durationExit' will be half the value of 'duration'. Did you intend to do that?")
- elseif (__arguments.durationExit and not __arguments.durationEnter) then
- warn("Soft-BONK: You've specified 'durationExit' but not 'durationEnter' for this transition. Thus, 'durationEnter' will be half the value of 'duration'. Did you intend to do that?")
- end
-
- self.sequence = nil
-
- self._captureScreenshotsDuringTransition = self._captureScreenshotsDuringTransition or false
-
- self.midpointReached = false
- self.holdTimeElapsed = false
-
- self.drawMode = self.drawMode or __arguments.drawMode or Graphics.kDrawModeCopy
-
- self.holdTime = self.holdTime or __arguments.holdTime or self.defaultProperties.holdTime or 0
-
- if (self._type == Noble.Transition.Type.MIX) then
-
- self._sequenceStartValue = self._sequenceStartValue or 0
- self._sequenceCompleteValue = self._sequenceCompleteValue or 1
-
- self.ease = self.ease or __arguments.ease or self.defaultProperties.ease or Ease.linear
- if ((__arguments.easeEnter or __arguments.easeExit) ~= nil) then
- warn("BONK: You've specified an 'easeEnter' and/or 'easeExit' argument for a transition of type 'Noble.Transition.Type.MIX'. This will have no effect. Use 'ease' instead, or specify a transition of type 'Noble.Transition.Type.COVER'.")
- end
-
- self.oldSceneScreenshot = Utilities.screenshot()
-
- elseif (self._type == Noble.Transition.Type.COVER) then
-
- self._sequenceStartValue = self._sequenceStartValue or 0
- self._sequenceMidpointValue = self._sequenceMidpointValue or 1
- self._sequenceResumeValue = self._sequenceResumeValue or 1
- self._sequenceCompleteValue = self._sequenceCompleteValue or 0
-
- local ease = self.ease or __arguments.ease or self.defaultProperties.ease or Ease.linear
- if (ease) then
- self.easeEnter = self.easeEnter or self.defaultProperties.easeEnter or Ease.enter(ease) or ease
- self.easeExit = self.easeExit or self.defaultProperties.easeExit or Ease.exit(ease) or ease
- if (Ease.enter(ease) == nil or Ease.exit(ease) == nil) then
- warn("Soft-BONK: You've specified an 'ease' value for a transition of type 'Noble.Transition.Type.COVER' that isn't in the form of 'Ease.inOutXxxx' or an 'Ease.outInXxxx'. As a result, this value will be used for both 'easeEnter' and 'easeExit'. Did you mean to do that?")
- end
- else
- self.easeEnter = self.easeEnter or __arguments.easeEnter or self.defaultProperties.easeEnter or self.easeEnter or Ease.linear
- self.easeExit = self.easeExit or __arguments.easeExit or self.defaultProperties.easeExit or self.easeExit or Ease.linear
- end
-
- end
-
- self:setProperties(__arguments)
-
-end
-
---- Use this to modify multiple default properties of a transition. Having default properties avoids having to set them every time a transition is called.
--- Properties added here are merged with the existing default properties table. Overwrites only happen when a new value is set.
--- @usage
--- Noble.Transition.setDefaultProperties(Noble.Transition.CrossDissolve, {
--- dither = Graphics.image.kDitherTypeDiagonalLine
--- ease = Ease.outQuint
--- })
--- Noble.Transition.setDefaultProperties(Noble.Transition.SpotlightMask, {
--- x = 325,
--- y = 95,
--- invert = true
--- })
--- @see defaultProperties
-function Noble.Transition.setDefaultProperties(__transition, __properties)
- table.merge(__transition.defaultProperties, __properties)
-end
-
-function Noble.Transition:execute()
-
- local onStart = function()
- Noble.transitionStartHandler()
- self:onStart() -- If this transition has any custom code to run here, run it.
- end
-
- local onMidpoint = function()
- Noble.transitionMidpointHandler()
- self.midpointReached = true
- self:onMidpoint() -- If this transition has any custom code to run here, run it.
- end
-
- local onHoldTimeElapsed = function()
- self.holdTimeElapsed = true
- self:onHoldTimeElapsed()
- end
-
- local onComplete = function()
- self:onComplete() -- If this transition has any custom code to run here, run it.
- Noble.transitionCompleteHandler()
- end
-
- local type = self._type
- local holdTime = self.holdTime
-
- if (type == Noble.Transition.Type.CUT) then
- onStart()
- onMidpoint()
- onHoldTimeElapsed()
- onComplete()
- elseif (type == Noble.Transition.Type.COVER) then
- onStart()
- self.sequence = Sequence.new()
- :from(self._sequenceStartValue)
- :to(self._sequenceMidpointValue, self.durationEnter-(holdTime/2), self.easeEnter)
- :callback(onMidpoint)
- :sleep(holdTime)
- :callback(onHoldTimeElapsed)
- :to(self._sequenceResumeValue, 0)
- :to(self._sequenceCompleteValue, self.durationExit-(holdTime/2), self.easeExit)
- :callback(onComplete)
- :start()
- elseif (type == Noble.Transition.Type.MIX) then
- onStart()
- onMidpoint()
- onHoldTimeElapsed()
- self.sequence = Sequence.new()
- :from(self._sequenceStartValue)
- :to(self._sequenceCompleteValue, self.duration, self.ease)
- :callback(onComplete)
- :start()
- end
-
-end
-
---- *Do not call this directly.* Implement this in a custom transition in order to set properties from user arguments given in `Noble.transition()`. See existing transitions for implementation examples.
--- @see Noble.transition
-function Noble.Transition:setProperties(__arguments) end
-
---- *Do not call this directly.* Implement this in a custom transition in order to run custom code when the transition starts. Default transitions in Noble Engine do not use this.
-function Noble.Transition:onStart() end
-
---- *Do not call this directly.* Implement this in a custom transition in order to run custom code when the transition reaches its midpoint. Default transitions in Noble Engine do not use this.
-function Noble.Transition:onMidpoint() end
-
---- *Do not call this directly.* Implement this in a custom transition in order to run custom code when the transition's hold time has elapsed. Default transitions in Noble Engine do not use this.
-function Noble.Transition:onHoldTimeElapsed() end
-
---- *Do not call this directly.* Implement this in a custom transition in order to run custom code when the transition completes. Default transitions in Noble Engine do not use this.
-function Noble.Transition:onComplete() end
-
---- *Do not call this directly.* Implement this in a custom transition to draw the transition. This runs once per frame while the transition is running. See existing transitions for implementation examples.
-function Noble.Transition:draw() end
-
-
--- Noble Engine built-in transitions.
-import 'libraries/noble/modules/Noble.Transition/Cut.lua'
---
-import 'libraries/noble/modules/Noble.Transition/CrossDissolve.lua'
-import 'libraries/noble/modules/Noble.Transition/Dip.lua'
-import 'libraries/noble/modules/Noble.Transition/DipToBlack.lua'
-import 'libraries/noble/modules/Noble.Transition/DipToWhite.lua'
---
-import 'libraries/noble/modules/Noble.Transition/Imagetable.lua'
-import 'libraries/noble/modules/Noble.Transition/ImagetableMask.lua'
-import 'libraries/noble/modules/Noble.Transition/Spotlight.lua'
-import 'libraries/noble/modules/Noble.Transition/SpotlightMask.lua'
---
-import 'libraries/noble/modules/Noble.Transition/SlideOff.lua'
-import 'libraries/noble/modules/Noble.Transition/SlideOffLeft.lua'
-import 'libraries/noble/modules/Noble.Transition/SlideOffRight.lua'
-import 'libraries/noble/modules/Noble.Transition/SlideOffUp.lua'
-import 'libraries/noble/modules/Noble.Transition/SlideOffDown.lua'
-import 'libraries/noble/modules/Noble.Transition/SlideOn.lua'
-import 'libraries/noble/modules/Noble.Transition/SlideOnLeft.lua'
-import 'libraries/noble/modules/Noble.Transition/SlideOnRight.lua'
-import 'libraries/noble/modules/Noble.Transition/SlideOnUp.lua'
-import 'libraries/noble/modules/Noble.Transition/SlideOnDown.lua'
---
-import 'libraries/noble/modules/Noble.Transition/MetroNexus.lua'
-import 'libraries/noble/modules/Noble.Transition/WidgetSatchel.lua'
\ No newline at end of file
diff --git a/source/libraries/noble/modules/Noble.Transition/CrossDissolve.lua b/source/libraries/noble/modules/Noble.Transition/CrossDissolve.lua
deleted file mode 100644
index b89a5c0..0000000
--- a/source/libraries/noble/modules/Noble.Transition/CrossDissolve.lua
+++ /dev/null
@@ -1,26 +0,0 @@
----
--- @submodule Noble.Transition
-
-class("CrossDissolve", nil, Noble.Transition).extends(Noble.Transition)
-local transition = Noble.Transition.CrossDissolve
-transition.name = "Cross Dissolve"
-
--- Type
-transition._type = Noble.Transition.Type.MIX
-
---- A simple cross-fade.
--- @table Noble.Transition.CrossDissolve.defaultProperties
--- @tparam[opt=Ease.outCubic] Ease ease
--- @tparam[opt=Graphics.image.kDitherTypeBayer4x4] Graphics.image.kDither dither
-transition.defaultProperties = {
- ease = Ease.outCubic,
- dither = Graphics.image.kDitherTypeBayer4x4
-}
-
-function transition:setProperties(__properties)
- self.dither = __properties.dither or self.defaultProperties.dither
-end
-
-function transition:draw()
- self.oldSceneScreenshot:drawFaded(0, 0, 1 - self.sequence:get(), self.dither)
-end
\ No newline at end of file
diff --git a/source/libraries/noble/modules/Noble.Transition/Cut.lua b/source/libraries/noble/modules/Noble.Transition/Cut.lua
deleted file mode 100644
index 0413b81..0000000
--- a/source/libraries/noble/modules/Noble.Transition/Cut.lua
+++ /dev/null
@@ -1,13 +0,0 @@
----
--- @submodule Noble.Transition
-
-class("Cut", nil, Noble.Transition).extends(Noble.Transition)
-local transition = Noble.Transition.Cut
-transition.name = "Cut"
-
--- Properties
-transition._type = Noble.Transition.Type.CUT
-
---- An all-time classic.
--- This transition has no properties.
--- @table Noble.Transition.Cut.defaultProperties
\ No newline at end of file
diff --git a/source/libraries/noble/modules/Noble.Transition/Dip.lua b/source/libraries/noble/modules/Noble.Transition/Dip.lua
deleted file mode 100644
index 367313b..0000000
--- a/source/libraries/noble/modules/Noble.Transition/Dip.lua
+++ /dev/null
@@ -1,37 +0,0 @@
----
--- @submodule Noble.Transition
-
-class("Dip", nil, Noble.Transition).extends(Noble.Transition)
-local transition = Noble.Transition.Dip
-transition.name = "Dip"
-
--- Type
-transition._type = Noble.Transition.Type.COVER
-
---- Fade to an image, then to the next scene.
--- @table Noble.Transition.Dip.defaultProperties
--- @number[opt=0.25] holdTime
--- @tparam Graphics.image panelImage
--- @tparam[opt=Graphics.image.kDitherTypeBayer4x4] Graphics.image.kDither dither
--- @tparam[opt=Ease.outInQuad] Ease ease
--- @number[opt=0] x
--- @number[opt=0] y
-transition.defaultProperties = {
- holdTime = 0.25,
- ease = Ease.outInQuad,
- dither = Graphics.image.kDitherTypeBayer4x4,
- panelImage = nil,
- x = 0,
- y = 0
-}
-
-function transition:setProperties(__arguments)
- self.dither = __arguments.dither or self.defaultProperties.dither
- self.panelImage = __arguments.panelImage or self.defaultProperties.panelImage
- self.x = __arguments.x or self.defaultProperties.x
- self.y = __arguments.y or self.defaultProperties.y
-end
-
-function transition:draw()
- self.panelImage:drawFaded(self.x, self.y, self.sequence:get(), self.dither)
-end
\ No newline at end of file
diff --git a/source/libraries/noble/modules/Noble.Transition/DipToBlack.lua b/source/libraries/noble/modules/Noble.Transition/DipToBlack.lua
deleted file mode 100644
index 9b3d0be..0000000
--- a/source/libraries/noble/modules/Noble.Transition/DipToBlack.lua
+++ /dev/null
@@ -1,19 +0,0 @@
----
--- @submodule Noble.Transition
-
-class("DipToBlack", nil, Noble.Transition).extends(Noble.Transition.Dip)
-local transition = Noble.Transition.DipToBlack
-transition.name = "Dip to Black"
-
---- Fade to black, then to the next scene.
--- NOTE: The `panelImage` property is locked.
--- @see Noble.Transition.Dip.defaultProperties
--- @table Noble.Transition.DipToBlack.defaultProperties
-
-transition.panelImage = Graphics.image.new(400, 240, Graphics.kColorBlack)
-
-function transition:setCustomArguments(__arguments)
- transition.super.setCustomArguments(self, __arguments)
- self.x = 0
- self.y = 0
-end
\ No newline at end of file
diff --git a/source/libraries/noble/modules/Noble.Transition/DipToWhite.lua b/source/libraries/noble/modules/Noble.Transition/DipToWhite.lua
deleted file mode 100644
index fc101ac..0000000
--- a/source/libraries/noble/modules/Noble.Transition/DipToWhite.lua
+++ /dev/null
@@ -1,19 +0,0 @@
----
--- @submodule Noble.Transition
-
-class("DipToWhite", nil, Noble.Transition).extends(Noble.Transition.Dip)
-local transition = Noble.Transition.DipToWhite
-transition.name = "Dip to White"
-
---- Fade to white, then to the next scene.
--- NOTE: The `panelImage` property is locked.
--- @see Noble.Transition.Dip.defaultProperties
--- @table Noble.Transition.DipToWhite.defaultProperties
-
-transition.panelImage = Graphics.image.new(400, 240, Graphics.kColorWhite)
-
-function transition:setCustomArguments(__arguments)
- transition.super.setCustomArguments(self, __arguments)
- self.x = 0
- self.y = 0
-end
\ No newline at end of file
diff --git a/source/libraries/noble/modules/Noble.Transition/Imagetable.lua b/source/libraries/noble/modules/Noble.Transition/Imagetable.lua
deleted file mode 100644
index 64c402a..0000000
--- a/source/libraries/noble/modules/Noble.Transition/Imagetable.lua
+++ /dev/null
@@ -1,131 +0,0 @@
----
--- @submodule Noble.Transition
-
-class("Imagetable", nil, Noble.Transition).extends(Noble.Transition)
-local transition = Noble.Transition.Imagetable
-transition.name = "Imagetable"
-
--- Type
-transition._type = Noble.Transition.Type.COVER
-
--- Overrides
-transition.easeEnter = Ease.linear
-transition.easeExit = Ease.linear
-
---- A dip-style transition using one or two imagetables.
--- @see Noble.Transition.ImagetableMask.defaultProperties
--- @table Noble.Transition.Imagetable.defaultProperties
--- @number[opt=0] holdTime
--- @tparam Graphics.imagetable imagetable
--- @bool[opt=false] reverse
--- @bool[opt=false] flipX
--- @bool[opt=false] flipY
--- @bool[opt=false] rotate
--- @tparam Graphics.imagetable imagetableEnter
--- @bool[opt=nil] reverseEnter
--- @bool[opt=nil] flipXEnter
--- @bool[opt=nil] flipYEnter
--- @bool[opt=nil] rotateEnter
--- @tparam Graphics.imagetable imagetableExit
--- @bool[opt=nil] reverseExit
--- @bool[opt=nil] flipXExit
--- @bool[opt=nil] flipYExit
--- @bool[opt=nil] rotateExit
-transition.defaultProperties = {
- holdTime = 0,
- imagetable = nil,
- imagetableEnter = Graphics.imagetable.new("libraries/noble/assets/images/BoltTransitionEnter"),
- imagetableExit = Graphics.imagetable.new("libraries/noble/assets/images/BoltTransitionExit"),
- reverse = false,
- reverseEnter = nil,
- reverseExit = nil,
- flipX = false,
- flipY = false,
- flipXEnter = nil,
- flipYEnter = nil,
- flipXExit = nil,
- flipYExit = nil,
- rotate = false,
- rotateEnter = nil,
- rotateExit = nil,
-}
-
-function transition:setProperties(__properties)
-
- self.imagetable = __properties.imagetable or self.defaultProperties.imagetable
- self.imagetableEnter = __properties.imagetableEnter or self.defaultProperties.imagetableEnter or self.imagetable
- self.imagetableExit = __properties.imagetableExit or self.defaultProperties.imagetableExit or self.imagetable
-
- self.reverse = __properties.reverse or self.defaultProperties.reverse
- self.reverseEnter = __properties.reverseEnter or self.defaultProperties.reverseEnter or self.reverse
- self.reverseExit = __properties.reverseExit or self.defaultProperties.reverseExit or self.reverse
-
- self.flipX = __properties.flipX or self.defaultProperties.flipX
- self.flipY = __properties.flipY or self.defaultProperties.flipY
- self.flipXEnter = __properties.flipXEnter or self.defaultProperties.flipXEnter or self.flipX
- self.flipYEnter = __properties.flipYEnter or self.defaultProperties.flipYEnter or self.flipY
- self.flipXExit = __properties.flipXExit or self.defaultProperties.flipXExit or self.flipX
- self.flipYExit = __properties.flipYExit or self.defaultProperties.flipYExit or self.flipY
-
- self.rotate = __properties.rotate or self.defaultProperties.rotate
- self.rotateEnter = __properties.rotateEnter or self.defaultProperties.rotateEnter or self.rotate
- self.rotateExit = __properties.rotateExit or self.defaultProperties.rotateExit or self.rotate
-
- -- "Private" variables
- self._frameCountEnter = self.imagetableEnter and #self.imagetableEnter or 0
- self._frameCountExit = self.imagetableExit and #self.imagetableExit or 0
-
- self._flipValueEnter = Noble.Transition.Imagetable.getFlipValue(self.rotateEnter, self.flipXEnter, self.flipYEnter)
- self._flipValueExit = Noble.Transition.Imagetable.getFlipValue(self.rotateExit, self.flipXExit, self.flipYExit)
-
- local sequence0 = (not self.reverseEnter) and 0 or 1
- local sequence1 = (not self.reverseEnter) and 1 or 0
- local sequenceExit0 = (not self.reverseExit) and 0 or 1
- local sequenceExit1 = (not self.reverseExit) and 1 or 0
-
- if (self.imagetableEnter == self.imagetableExit) then
- self._sequenceStartValue = sequence0
- self._sequenceMidpointValue = sequence1
- self._sequenceResumeValue = sequence1
- self._sequenceCompleteValue = sequence0
- else
- self._sequenceStartValue = sequence0
- self._sequenceMidpointValue = sequence1
- self._sequenceResumeValue = sequenceExit0
- self._sequenceCompleteValue = sequenceExit1
- end
-
- -- Warnings
- if ((__properties.ease or __properties.easeEnter or __properties.easeExit) ~= nil) then
- warn("BONK: You've specified an ease value for an Noble.Transition.Imagetable transition. This will have no effect.")
- end
-
-end
-
-function transition:draw()
- local progress = self.sequence:get()
- local imagetable
- local frameCount
- local flipValue
- if not self.holdTimeElapsed then
- imagetable = self.imagetableEnter
- frameCount = self._frameCountEnter
- flipValue = self._flipValueEnter
- else
- imagetable = self.imagetableExit
- frameCount = self._frameCountExit
- flipValue = self._flipValueExit
- end
- local index = math.clamp((progress * frameCount) // 1, 1, frameCount)
- imagetable[index]:draw(0, 0, flipValue)
-end
-
-function Noble.Transition.Imagetable.getFlipValue(__rotate, __flipX, __flipY)
- if(__rotate or (__flipX and __flipY)) then
- return Graphics.kImageFlippedXY
- else
- if(__flipX) then return Graphics.kImageFlippedX
- elseif(__flipY) then return Graphics.kImageFlippedY end
- end
- return Graphics.kImageUnflipped
-end
\ No newline at end of file
diff --git a/source/libraries/noble/modules/Noble.Transition/ImagetableMask.lua b/source/libraries/noble/modules/Noble.Transition/ImagetableMask.lua
deleted file mode 100644
index 134d77d..0000000
--- a/source/libraries/noble/modules/Noble.Transition/ImagetableMask.lua
+++ /dev/null
@@ -1,83 +0,0 @@
----
--- @submodule Noble.Transition
-
-class("ImagetableMask", nil, Noble.Transition).extends(Noble.Transition)
-local transition = Noble.Transition.ImagetableMask
-transition.name = "Imagetable Mask"
-
--- Type
-transition._type = Noble.Transition.Type.MIX
-
--- Overrides
-transition.ease = Ease.linear
-
---- A wipe transition using an animated mask in the form of an imagetable.
--- @see Noble.Transition.Imagetable.defaultProperties
--- @table Noble.Transition.ImagetableMask.defaultProperties
--- @tparam Graphics.imagetable imagetable
--- @bool[opt=false] reverse Set `true` to play the imagetable's frames in reverse order.
--- @bool[opt=false] flipX
--- @bool[opt=false] flipY
--- @bool[opt=false] rotate Set as `true` to rotate the image 180-degrees
--- @bool[opt=true] hasTransparency Set as `true` if the imagetable asset has transparent pixels. Set as `false` if the image uses white pixels for transparency.
--- @bool[opt=false] invert Set as `true` to invert the image mask.
-transition.defaultProperties = {
- imagetable = Graphics.imagetable.new("libraries/noble/assets/images/BoltTransitionEnter"),
- reverse = false,
- flipX = false,
- flipY = false,
- rotate = false,
- hasTransparency = true,
- invert = false
-}
-
-function transition:setProperties(__properties)
-
- self.imagetable = __properties.imagetable or self.defaultProperties.imagetable
- self.reverse = __properties.reverse or self.defaultProperties.reverse
- self.flipX = __properties.flipX or self.defaultProperties.flipX
- self.flipY = __properties.flipY or self.defaultProperties.flipY
- self.rotate = __properties.rotate or self.defaultProperties.rotate
- self.hasTransparency = __properties.hasTransparency or self.defaultProperties.hasTransparency
- self.invert = __properties.invert or self.defaultProperties.invert
-
- -- "Private" variables
- self._flipValue = Noble.Transition.Imagetable.getFlipValue(self.rotate, self.flipX, self.flipY)
- self._imagetableLength = self.imagetable and #self.imagetable or 0
- self._maskBackground = nil
- self._maskForegroundDrawMode = nil
- if (self.invert ~= true) then
- self._maskBackground = Graphics.image.new(400, 240, Graphics.kColorWhite)
- self._maskForegroundDrawMode = Graphics.kDrawModeFillBlack
- else
- self._maskBackground = Graphics.image.new(400, 240, Graphics.kColorBlack)
- self._maskForegroundDrawMode = Graphics.kDrawModeFillWhite
- end
-
- -- Warnings
- if (__properties.imagetableExit ~= nil) then
- warn("BONK: You've specified an 'imagetableExit' for an Noble.Transition.ImagetableMask transition. This will have no effect. ")
- end
- if ((__properties.ease or __properties.easeEnter or __properties.easeExit) ~= nil) then
- warn("BONK: You've specified an ease value for an Noble.Transition.ImagetableMask transition. This will have no effect.")
- end
-
-end
-
-function transition:draw()
- local progress = self.sequence:get()
- local length = self._imagetableLength
- local index = math.clamp((progress * length) // 1, 1, length)
- local mask = Graphics.image.new(400, 240)
-
- Graphics.pushContext(mask)
- Graphics.setImageDrawMode(Graphics.kDrawModeCopy)
- self._maskBackground:draw(0,0)
- if (self.hasTransparency) then Graphics.setImageDrawMode(self._maskForegroundDrawMode) end
- self.imagetable[index]:draw(0,0, self._flipValue)
- Graphics.popContext()
-
- self.oldSceneScreenshot:setMaskImage(mask)
- self.oldSceneScreenshot:draw(0,0)
-
-end
\ No newline at end of file
diff --git a/source/libraries/noble/modules/Noble.Transition/MetroNexus.lua b/source/libraries/noble/modules/Noble.Transition/MetroNexus.lua
deleted file mode 100644
index bfb46a7..0000000
--- a/source/libraries/noble/modules/Noble.Transition/MetroNexus.lua
+++ /dev/null
@@ -1,58 +0,0 @@
----
--- @submodule Noble.Transition
-
-class("MetroNexus", nil, Noble.Transition).extends(Noble.Transition)
-local transition = Noble.Transition.MetroNexus
-transition.name = "Metro Nexus"
-
--- Type
-transition._type = Noble.Transition.Type.COVER
-
--- Overrides
-transition._sequenceResumeValue = 0
-transition._sequenceCompleteValue = 1
-transition.easeEnter = Ease.linear
-transition.easeExit = Ease.linear
-
---- A "cascade" wipe transition, taken from "Metro Nexus" by Noble Robot.
--- This transition has no properties.
--- @table Noble.Transition.MetroNexus.defaultProperties
-
--- "Static" variables
-local panels
-
-function transition:setProperties(__arguments)
-
- if (panels == nil) then
- panels = {
- Graphics.image.new(80,240, Graphics.kColorWhite),
- Graphics.image.new(80,240, Graphics.kColorWhite),
- Graphics.image.new(80,240, Graphics.kColorWhite),
- Graphics.image.new(80,240, Graphics.kColorWhite),
- Graphics.image.new(80,240, Graphics.kColorWhite)
- }
- end
-
- -- Warnings
- if (__arguments.easeEnter or __arguments.easeEnter or __arguments.ease) then
- warn("BONK: 'Noble.Transition.MetroNexus' does not support custom ease values.")
- end
-
-end
-
-function transition:draw()
- local progress = self.sequence:get()
- if (not self.holdTimeElapsed) then
- panels[1]:draw(000, (-1 + Ease.outQuint(progress, 0, 1, 1)) * 240)
- panels[2]:draw(080, (-1 + Ease.outQuart(progress, 0, 1, 1)) * 240)
- panels[3]:draw(160, (-1 + Ease.outQuart(progress, 0, 1, 1)) * 240)
- panels[4]:draw(240, (-1 + Ease.outCubic(progress, 0, 1, 1)) * 240)
- panels[5]:draw(320, (-1 + Ease.outSine (progress, 0, 1, 1)) * 240)
- else
- panels[1]:draw(000, (1 - Ease.inQuint(progress, 0, 1, 1)) * -240 + 240)
- panels[2]:draw(080, (1 - Ease.inQuart(progress, 0, 1, 1)) * -240 + 240)
- panels[3]:draw(160, (1 - Ease.inQuart(progress, 0, 1, 1)) * -240 + 240)
- panels[4]:draw(240, (1 - Ease.inCubic(progress, 0, 1, 1)) * -240 + 240)
- panels[5]:draw(320, (1 - Ease.inSine (progress, 0, 1, 1)) * -240 + 240)
- end
-end
diff --git a/source/libraries/noble/modules/Noble.Transition/SlideOff.lua b/source/libraries/noble/modules/Noble.Transition/SlideOff.lua
deleted file mode 100644
index ecfa2e4..0000000
--- a/source/libraries/noble/modules/Noble.Transition/SlideOff.lua
+++ /dev/null
@@ -1,38 +0,0 @@
----
--- @submodule Noble.Transition
-
-class("SlideOff", nil, Noble.Transition).extends(Noble.Transition)
-local transition = Noble.Transition.SlideOff
-transition.name = "Slide Off"
-
--- Type
-transition._type = Noble.Transition.Type.MIX
-
---- The previous scene slides off the screen, revealing the next scene.
--- @table Noble.Transition.SlideOff.defaultProperties
--- @tparam[opt=Ease.outInQuad] Ease ease
--- @number[opt=0] x
--- @number[opt=0] y
--- @number[opt=0] rotation
-transition.defaultProperties = {
- ease = Ease.inQuart,
- x = 0,
- y = 0,
- rotation = 0
-}
-
-function transition:setProperties(__arguments)
- self.x = __arguments.x or self.defaultProperties.x
- self.y = __arguments.y or self.defaultProperties.y
- self.rotation = __arguments.rotation or self.defaultProperties.rotation
-end
-
-function transition:draw()
- transition.super.draw(self)
- local progress = self.sequence:get()
- self.oldSceneScreenshot:drawRotated(
- self.x * progress + 200,
- self.y * progress + 120,
- self.rotation * progress
- )
-end
\ No newline at end of file
diff --git a/source/libraries/noble/modules/Noble.Transition/SlideOffDown.lua b/source/libraries/noble/modules/Noble.Transition/SlideOffDown.lua
deleted file mode 100644
index 5a003b5..0000000
--- a/source/libraries/noble/modules/Noble.Transition/SlideOffDown.lua
+++ /dev/null
@@ -1,18 +0,0 @@
----
--- @submodule Noble.Transition
-
-class("SlideOffDown", nil, Noble.Transition).extends(Noble.Transition.SlideOff)
-local transition = Noble.Transition.SlideOffDown
-transition.name = "Slide Off (Down)"
-
---- The previous scene slides off the bottom of the screen, revealing the next scene.
--- NOTE: The `x`, `y`, and `rotation` properties are locked.
--- @see Noble.Transition.SlideOff.defaultProperties
--- @table Noble.Transition.SlideOffDown.defaultProperties
-
-function transition:setProperties(__arguments)
- transition.super.setProperties(self, __arguments)
- self.x = 0
- self.y = 240
- self.rotation = 0
-end
\ No newline at end of file
diff --git a/source/libraries/noble/modules/Noble.Transition/SlideOffLeft.lua b/source/libraries/noble/modules/Noble.Transition/SlideOffLeft.lua
deleted file mode 100644
index 732fec6..0000000
--- a/source/libraries/noble/modules/Noble.Transition/SlideOffLeft.lua
+++ /dev/null
@@ -1,18 +0,0 @@
----
--- @submodule Noble.Transition
-
-class("SlideOffLeft", nil, Noble.Transition).extends(Noble.Transition.SlideOff)
-local transition = Noble.Transition.SlideOffLeft
-transition.name = "Slide Off (Left)"
-
---- The previous scene slides off the left side of the screen, revealing the next scene.
--- NOTE: The `x`, `y`, and `rotation` properties are locked.
--- @see Noble.Transition.SlideOff.defaultProperties
--- @table Noble.Transition.SlideOffLeft.defaultProperties
-
-function transition:setProperties(__arguments)
- transition.super.setProperties(self, __arguments)
- self.x = -400
- self.y = 0
- self.rotation = 0
-end
\ No newline at end of file
diff --git a/source/libraries/noble/modules/Noble.Transition/SlideOffRight.lua b/source/libraries/noble/modules/Noble.Transition/SlideOffRight.lua
deleted file mode 100644
index 4dc3bd9..0000000
--- a/source/libraries/noble/modules/Noble.Transition/SlideOffRight.lua
+++ /dev/null
@@ -1,18 +0,0 @@
----
--- @submodule Noble.Transition
-
-class("SlideOffRight", nil, Noble.Transition).extends(Noble.Transition.SlideOff)
-local transition = Noble.Transition.SlideOffRight
-transition.name = "Slide Off (Right)"
-
---- The previous scene slides off the right side of the screen, revealing the next scene.
--- NOTE: The `x`, `y`, and `rotation` properties are locked.
--- @see Noble.Transition.SlideOff.defaultProperties
--- @table Noble.Transition.SlideOffRight.defaultProperties
-
-function transition:setProperties(__arguments)
- transition.super.setProperties(self, __arguments)
- self.x = 400
- self.y = 0
- self.rotation = 0
-end
\ No newline at end of file
diff --git a/source/libraries/noble/modules/Noble.Transition/SlideOffUp.lua b/source/libraries/noble/modules/Noble.Transition/SlideOffUp.lua
deleted file mode 100644
index 68a06a4..0000000
--- a/source/libraries/noble/modules/Noble.Transition/SlideOffUp.lua
+++ /dev/null
@@ -1,18 +0,0 @@
----
--- @submodule Noble.Transition
-
-class("SlideOffUp", nil, Noble.Transition).extends(Noble.Transition.SlideOff)
-local transition = Noble.Transition.SlideOffUp
-transition.name = "Slide Off (Up)"
-
---- The previous scene slides off the top of the screen, revealing the next scene.
--- NOTE: The `x`, `y`, and `rotation` properties are locked.
--- @see Noble.Transition.SlideOff.defaultProperties
--- @table Noble.Transition.SlideOffUp.defaultProperties
-
-function transition:setProperties(__arguments)
- transition.super.setProperties(self, __arguments)
- self.x = 0
- self.y = -240
- self.rotation = 0
-end
\ No newline at end of file
diff --git a/source/libraries/noble/modules/Noble.Transition/SlideOn.lua b/source/libraries/noble/modules/Noble.Transition/SlideOn.lua
deleted file mode 100644
index 202c17d..0000000
--- a/source/libraries/noble/modules/Noble.Transition/SlideOn.lua
+++ /dev/null
@@ -1,44 +0,0 @@
----
--- @submodule Noble.Transition
-
-class("SlideOn", nil, Noble.Transition).extends(Noble.Transition)
-local transition = Noble.Transition.SlideOn
-transition.name = "Slide On"
-
--- Type
-transition._type = Noble.Transition.Type.MIX
-
--- Overrides
-transition._sequenceStartValue = 1
-transition._sequenceCompleteValue = 0
-transition._captureScreenshotsDuringTransition = true
-
---- The next scene slides on the screen, covering up the previous scene.
--- @table Noble.Transition.SlideOn.defaultProperties
--- @tparam[opt=Ease.outInQuad] Ease ease
--- @number[opt=0] x
--- @number[opt=0] y
--- @number[opt=0] rotation
-transition.defaultProperties = {
- ease = Ease.outQuart,
- x = 0,
- y = 0,
- rotation = 0
-}
-
-function transition:setProperties(__arguments)
- self.x = __arguments.x or self.defaultProperties.x
- self.y = __arguments.y or self.defaultProperties.y
- self.rotation = __arguments.rotation or self.defaultProperties.rotation
-end
-
-function transition:draw()
- transition.super.draw(self)
- local progress = self.sequence:get()
- self.oldSceneScreenshot:draw(0,0)
- self.newSceneScreenshot:drawRotated(
- self.x * progress + 200,
- self.y * progress + 120,
- self.rotation * progress
- )
-end
\ No newline at end of file
diff --git a/source/libraries/noble/modules/Noble.Transition/SlideOnDown.lua b/source/libraries/noble/modules/Noble.Transition/SlideOnDown.lua
deleted file mode 100644
index ff7e1ad..0000000
--- a/source/libraries/noble/modules/Noble.Transition/SlideOnDown.lua
+++ /dev/null
@@ -1,18 +0,0 @@
----
--- @submodule Noble.Transition
-
-class("SlideOnDown", nil, Noble.Transition).extends(Noble.Transition.SlideOn)
-local transition = Noble.Transition.SlideOnDown
-transition.name = "Slide On (Down)"
-
---- The next scene slides onto the screen from the top, covering up the previous scene.
--- NOTE: The `x`, `y`, and `rotation` properties are locked.
--- @see Noble.Transition.SlideOn.defaultProperties
--- @table Noble.Transition.SlideOnDown.defaultProperties
-
-function transition:setProperties(__arguments)
- transition.super.setProperties(self, __arguments)
- self.x = 0
- self.y = -240
- self.rotation = 0
-end
\ No newline at end of file
diff --git a/source/libraries/noble/modules/Noble.Transition/SlideOnLeft.lua b/source/libraries/noble/modules/Noble.Transition/SlideOnLeft.lua
deleted file mode 100644
index df0ac13..0000000
--- a/source/libraries/noble/modules/Noble.Transition/SlideOnLeft.lua
+++ /dev/null
@@ -1,18 +0,0 @@
----
--- @submodule Noble.Transition
-
-class("SlideOnLeft", nil, Noble.Transition).extends(Noble.Transition.SlideOn)
-local transition = Noble.Transition.SlideOnLeft
-transition.name = "Slide On (Left)"
-
---- The next scene slides onto the screen right-to-left, covering up the previous scene.
--- NOTE: The `x`, `y`, and `rotation` properties are locked.
--- @see Noble.Transition.SlideOn.defaultProperties
--- @table Noble.Transition.SlideOnLeft.defaultProperties
-
-function transition:setProperties(__arguments)
- transition.super.setProperties(self, __arguments)
- self.x = 400
- self.y = 0
- self.rotation = 0
-end
\ No newline at end of file
diff --git a/source/libraries/noble/modules/Noble.Transition/SlideOnRight.lua b/source/libraries/noble/modules/Noble.Transition/SlideOnRight.lua
deleted file mode 100644
index dbbe2c7..0000000
--- a/source/libraries/noble/modules/Noble.Transition/SlideOnRight.lua
+++ /dev/null
@@ -1,18 +0,0 @@
----
--- @submodule Noble.Transition
-
-class("SlideOnRight", nil, Noble.Transition).extends(Noble.Transition.SlideOn)
-local transition = Noble.Transition.SlideOnRight
-transition.name = "Slide On (Right)"
-
---- The next scene slides onto the screen left-to-right, covering up the previous scene.
--- NOTE: The `x`, `y`, and `rotation` properties are locked.
--- @see Noble.Transition.SlideOn.defaultProperties
--- @table Noble.Transition.SlideOnRight.defaultProperties
-
-function transition:setProperties(__arguments)
- transition.super.setProperties(self, __arguments)
- self.x = -400
- self.y = 0
- self.rotation = 0
-end
\ No newline at end of file
diff --git a/source/libraries/noble/modules/Noble.Transition/SlideOnUp.lua b/source/libraries/noble/modules/Noble.Transition/SlideOnUp.lua
deleted file mode 100644
index 701a94a..0000000
--- a/source/libraries/noble/modules/Noble.Transition/SlideOnUp.lua
+++ /dev/null
@@ -1,18 +0,0 @@
----
--- @submodule Noble.Transition
-
-class("SlideOnUp", nil, Noble.Transition).extends(Noble.Transition.SlideOn)
-local transition = Noble.Transition.SlideOnUp
-transition.name = "Slide On (Up)"
-
---- The next scene slides onto the screen from the bottom, covering up the previous scene.
--- NOTE: The `x`, `y`, and `rotation` properties are locked.
--- @see Noble.Transition.SlideOn.defaultProperties
--- @table Noble.Transition.SlideOnUp.defaultProperties
-
-function transition:setProperties(__arguments)
- transition.super.setProperties(self, __arguments)
- self.x = 0
- self.y = 240
- self.rotation = 0
-end
\ No newline at end of file
diff --git a/source/libraries/noble/modules/Noble.Transition/Spotlight.lua b/source/libraries/noble/modules/Noble.Transition/Spotlight.lua
deleted file mode 100644
index 745ecee..0000000
--- a/source/libraries/noble/modules/Noble.Transition/Spotlight.lua
+++ /dev/null
@@ -1,100 +0,0 @@
----
--- @submodule Noble.Transition
-
-class("Spotlight", nil, Noble.Transition).extends(Noble.Transition)
-local transition = Noble.Transition.Spotlight
-transition.name = "Spotlight"
-
--- Type
-transition._type = Noble.Transition.Type.COVER
-
---- A spotlight in-out transition.
--- @see Noble.Transition.SpotlightMask.defaultProperties
--- @table Noble.Transition.Spotlight.defaultProperties
--- @number[opt=0.25] holdTime
--- @tparam Graphics.image panelImage
--- @tparam[opt=Graphics.image.kDitherTypeBayer4x4] Graphics.image.kDither dither
--- @tparam[opt=Ease.outInQuad] Ease ease
--- @number[opt=200] x
--- @number[opt=120] y
--- @tparam[opt=nil] Ease easeEnter
--- @number[opt=nil] xEnter
--- @number[opt=nil] yEnter
--- @number[opt=nil] xEnterStart
--- @number[opt=nil] yEnterStart
--- @number[opt=nil] xEnterEnd
--- @number[opt=nil] yEnterEnd
--- @tparam[opt=nil] Ease easeEnter
--- @number[opt=nil] xExit
--- @number[opt=nil] yExit
--- @number[opt=nil] xExitStart
--- @number[opt=nil] yExitStart
--- @number[opt=nil] xExitEnd
--- @number[opt=nil] yExitEnd
-transition.defaultProperties = {
- holdTime = 0.25,
- panelImage = nil,
- dither = Graphics.image.kDitherTypeBayer4x4,
- ease = Ease.outInQuad,
- x = 200,
- y = 120,
- easeEnter = nil,
- xEnter = nil,
- yEnter = nil,
- xEnterStart = nil,
- yEnterStart = nil,
- xEnterEnd = nil,
- yEnterEnd = nil,
- easeExit = nil,
- xExit = nil,
- yExit = nil,
- xExitStart = nil,
- yExitStart = nil,
- xExitEnd = nil,
- yExitEnd = nil
-}
-
--- "Static" variables
-local defaultPanelImage
-
-function transition:setProperties(__arguments)
- if (defaultPanelImage == nil) then defaultPanelImage = Graphics.image.new(400,240, Graphics.kColorBlack) end
- self.panelImage = __arguments.panelImage or self.defaultProperties.panelImage or defaultPanelImage
- self.dither = __arguments.dither or self.defaultProperties.dither
- self.x = __arguments.x or self.defaultProperties.x
- self.y = __arguments.y or self.defaultProperties.y
-
- self.xEnter = __arguments.xEnter or self.defaultProperties.xEnter or self.x
- self.yEnter = __arguments.yEnter or self.defaultProperties.yEnter or self.y
- self.xEnterStart = __arguments.xEnterStart or self.defaultProperties.xEnterStart or self.xEnter
- self.yEnterStart = __arguments.yEnterStart or self.defaultProperties.yEnterStart or self.yEnter
- self.xEnterEnd = __arguments.xEnterEnd or self.defaultProperties.xEnterEnd or self.xEnter
- self.yEnterEnd = __arguments.yEnterEnd or self.defaultProperties.yEnterEnd or self.yEnter
-
- self.xExit = __arguments.xExit or self.defaultProperties.xExit or self.x
- self.yExit = __arguments.yExit or self.defaultProperties.yExit or self.y
- self.xExitStart = __arguments.xExitStart or self.defaultProperties.xExitStart or self.xExit
- self.yExitStart = __arguments.yExitStart or self.defaultProperties.yExitStart or self.yExit
- self.xExitEnd = __arguments.xExitEnd or self.defaultProperties.xExitEnd or self.xExit
- self.yExitEnd = __arguments.yExitEnd or self.defaultProperties.yExitEnd or self.yExit
-end
-
-function transition:draw()
- local progress = self.sequence:get()
- self.panelImage:drawFaded(0, 0, progress, self.dither)
- Graphics.setColor(Graphics.kColorClear)
- if (not self.midpointReached) then
- Graphics.fillCircleAtPoint(
- math.lerp(self.xEnterStart, self.xEnterEnd, progress),
- math.lerp(self.yEnterStart, self.yEnterEnd, progress),
- (1 - progress) * 233
- )
- else
- Graphics.fillCircleAtPoint(
- math.lerp(self.xExitStart, self.xExitEnd, progress),
- math.lerp(self.yExitStart, self.yExitEnd, progress),
- (1 - progress) * 233
- )
- end
- Graphics.setColor(Graphics.kColorBlack)
-end
\ No newline at end of file
diff --git a/source/libraries/noble/modules/Noble.Transition/SpotlightMask.lua b/source/libraries/noble/modules/Noble.Transition/SpotlightMask.lua
deleted file mode 100644
index 11b16f0..0000000
--- a/source/libraries/noble/modules/Noble.Transition/SpotlightMask.lua
+++ /dev/null
@@ -1,99 +0,0 @@
----
--- @submodule Noble.Transition
-
-class("SpotlightMask", nil, Noble.Transition).extends(Noble.Transition)
-local transition = Noble.Transition.SpotlightMask
-transition.name = "Spotlight Mask"
-
--- Type
-transition._type = Noble.Transition.Type.MIX
-
---- A circle wipe transition.
--- @see Noble.Transition.Spotlight.defaultProperties
--- @table Noble.Transition.SpotlightMask.defaultProperties
--- @tparam[opt=Ease.outQuad] Ease ease
--- @number[opt=200] x
--- @number[opt=120] y
--- @number[opt=nil] xStart
--- @number[opt=nil] yStart
--- @number[opt=nil] xEnd
--- @number[opt=nil] yEnd
--- @bool[opt=false] invert
-transition.defaultProperties = {
- ease = Ease.outQuad,
- x = 200,
- y = 120,
- xStart = nil,
- yStart = nil,
- xEnd = nil,
- yEnd = nil,
- invert = false
-}
-
-function transition:setProperties(__arguments)
- self.x = __arguments.x or self.defaultProperties.x
- self.y = __arguments.y or self.defaultProperties.y
- self.xStart = __arguments.xStart or self.defaultProperties.xStart or self.x
- self.yStart = __arguments.yStart or self.defaultProperties.yStart or self.y
- self.xEnd = __arguments.xEnd or self.defaultProperties.xEnd or self.x
- self.yEnd = __arguments.yEnd or self.defaultProperties.yEnd or self.y
-
- self.invert = __arguments.invert or self.defaultProperties.invert
-
- if (self.invert) then
- self.ease = Ease.reverse(self.ease)
- end
-
- -- "Private" variables
- self._maskBackground = nil
- self._maskForegroundDrawMode = nil
- if (self.invert ~= true) then
- self._maskBackground = Graphics.image.new(400, 240, Graphics.kColorWhite)
- self._maskForegroundDrawMode = Graphics.kDrawModeFillBlack
- else
- self._maskBackground = Graphics.image.new(400, 240, Graphics.kColorBlack)
- self._maskForegroundDrawMode = Graphics.kDrawModeFillWhite
- end
-
- self._startRadius = math.max(
- Geometry.distanceToPoint(self.xStart, self.yStart, 0, 0),
- Geometry.distanceToPoint(self.xStart, self.yStart, 400, 0),
- Geometry.distanceToPoint(self.xStart, self.yStart, 400, 240),
- Geometry.distanceToPoint(self.xStart, self.yStart, 0, 240)
- )
- self._endRadius = math.max(
- Geometry.distanceToPoint(self.xEnd, self.yEnd, 0, 0),
- Geometry.distanceToPoint(self.xEnd, self.yEnd, 400, 0),
- Geometry.distanceToPoint(self.xEnd, self.yEnd, 400, 240),
- Geometry.distanceToPoint(self.xEnd, self.yEnd, 0, 240)
- )
-
-end
-
-function transition:draw()
- local progress = self.sequence:get()
-
- if (not self.invert) then
- self.oldSceneScreenshot:draw(0, 0)
- Graphics.setColor(Graphics.kColorClear)
- Graphics.fillCircleAtPoint(
- math.lerp(self.xStart, self.xEnd, progress),
- math.lerp(self.yStart, self.yEnd, progress),
- progress * self._endRadius
- )
- Graphics.setColor(Graphics.kColorBlack)
- else
- local mask = Graphics.image.new(400, 240, Graphics.kColorBlack)
- Graphics.pushContext(mask)
- Graphics.setColor(Graphics.kColorWhite)
- Graphics.fillCircleAtPoint(
- math.lerp(self.xStart, self.xEnd, progress),
- math.lerp(self.yStart, self.yEnd, progress),
- (1 - progress) * self._startRadius
- )
- Graphics.popContext()
- self.oldSceneScreenshot:setMaskImage(mask)
- self.oldSceneScreenshot:draw(0, 0)
- end
-
-end
\ No newline at end of file
diff --git a/source/libraries/noble/modules/Noble.Transition/WidgetSatchel.lua b/source/libraries/noble/modules/Noble.Transition/WidgetSatchel.lua
deleted file mode 100644
index 66f8795..0000000
--- a/source/libraries/noble/modules/Noble.Transition/WidgetSatchel.lua
+++ /dev/null
@@ -1,73 +0,0 @@
----
--- @submodule Noble.Transition
-
-class("WidgetSatchel", nil, Noble.Transition).extends(Noble.Transition)
-local transition = Noble.Transition.WidgetSatchel
-transition.name = "Widget Satchel"
-
--- Type
-transition._type = Noble.Transition.Type.COVER
-
--- Overrides
-transition._sequenceCompleteValue = 2
-transition.easeEnter = Ease.outCubic
-transition.easeExit = Ease.inCubic
-
---- An "accordion" transition, taken from "Widget Satchel" by Noble Robot.
--- This transition has no properties.
--- @table Noble.Transition.MetroNexus.defaultProperties
-
--- "Static" variables
-local panels
-
-function transition:setProperties(__arguments)
-
- if (panels == nil) then
- panels = {
- Graphics.image.new(400,48, Graphics.kColorWhite),
- Graphics.image.new(400,48, Graphics.kColorWhite),
- Graphics.image.new(400,48, Graphics.kColorWhite),
- Graphics.image.new(400,48, Graphics.kColorWhite),
- Graphics.image.new(400,48, Graphics.kColorWhite)
- }
- Graphics.lockFocus(panels[1])
- Graphics.setDitherPattern(0.4, Graphics.image.kDitherTypeScreen)
- Graphics.fillRect(0,0,400,48)
- Graphics.lockFocus(panels[2])
- Graphics.setDitherPattern(0.7, Graphics.image.kDitherTypeScreen)
- Graphics.fillRect(0,0,400,48)
- Graphics.lockFocus(panels[3])
- Graphics.setDitherPattern(0.25, Graphics.image.kDitherTypeBayer8x8)
- Graphics.fillRect(0,0,400,48)
- Graphics.lockFocus(panels[4])
- Graphics.setDitherPattern(0.5, Graphics.image.kDitherTypeDiagonalLine)
- Graphics.fillRect(0,0,400,48)
- Graphics.lockFocus(panels[5])
- Graphics.setDitherPattern(0.8, Graphics.image.kDitherTypeHorizontalLine)
- Graphics.fillRect(0,0,400,48)
- Graphics.unlockFocus()
- end
-
- -- Warnings
- if (__arguments.easeEnter or __arguments.easeEnter or __arguments.ease) then
- warn("BONK: 'Noble.Transition.WidgetSatchel' does not support custom ease values.")
- end
-
-end
-
-function transition:draw()
- local progress = self.sequence:get()
- if (not self.midpointReached ) then
- panels[1]:draw(0, -48 + (progress * (48*1)) )
- panels[2]:draw(0, -48 + (progress * (48*2)) )
- panels[3]:draw(0, -48 + (progress * (48*3)) )
- panels[4]:draw(0, -48 + (progress * (48*4)) )
- panels[5]:draw(0, -48 + (progress * (48*5)) )
- else
- panels[1]:draw(0, 48*0 + (progress - 1) * 48*5)
- panels[2]:draw(0, 48*1 + (progress - 1) * 48*4)
- panels[3]:draw(0, 48*2 + (progress - 1) * 48*3)
- panels[4]:draw(0, 48*3 + (progress - 1) * 48*2)
- panels[5]:draw(0, 48*4 + (progress - 1) * 48*1)
- end
-end
\ No newline at end of file
diff --git a/source/libraries/noble/modules/NobleScene.lua b/source/libraries/noble/modules/NobleScene.lua
deleted file mode 100644
index 48536de..0000000
--- a/source/libraries/noble/modules/NobleScene.lua
+++ /dev/null
@@ -1,242 +0,0 @@
----
--- An abstract scene class.
--- Do not copy this file as a template for your scenes. Instead, your scenes will extend this class.
--- See templates/SceneTemplate.lua for a blank scene that you can copy and modify for your own scenes.
--- If you are using NobleEngine-ProjectTemplate,
--- see `scenes/ExampleScene.lua` for an implementation example.
--- @usage
--- YourSceneName = {}
--- class("YourSceneName").extends(NobleScene)
--- local scene = YourSceneName
---
--- @classmod NobleScene
---
-
-NobleScene = {}
-class("NobleScene").extends(Object)
-
---- Properties
--- @section properties
-
---- The name of this scene. Optional.
--- If you do not set this value, it will take on the scene's `className`.
-NobleScene.name = ""
-
---- This is the background color of this scene.
---
-NobleScene.backgroundColor = Graphics.kColorWhite
-
---- Tables
--- @section tables
-
---- All scenes have a default inputHandler which is made active when the scene starts.
--- If you do not define your scene's `inputHandler`, it is `nil` and input is disabled when this scene
--- starts.
--- @see Noble.Input.setHandler
---
--- @usage
--- YourSceneName.inputHandler = {
--- AButtonDown = function()
--- // Your code here
--- end,
--- AButtonHold = function()
--- // Your code here
--- end,
--- -- ...
--- -- ...
--- }
--- -- OR...
--- -- Use a non-scene-specific inputHandler, defined elsewhere.
--- YourSceneName.inputHandler = somePreviouslyDefinedInputHandler
--- -- OR...
--- -- Reuse another scene's inputHandler.
--- YourSceneName.inputHandler = SomeOtherSceneName.inputHandler
-NobleScene.inputHandler = {}
-
---- When you add a sprite to your scene, it is put in this table so the scene can keep track of it.
---
--- This is intended as `read-only`. You should not modify this table directly.
--- @see addSprite
-NobleScene.sprites = {}
-
---- Methods
--- @section Methods
-
---- Use this to add sprites to your scene instead of `playdate.graphics.sprite:add()`.
---
--- If your sprite is a `NobleSprite`, using `NobleSprite:add()` will also call this method.
---
--- Sprites added with this method that are tracked by the scene. Any not manually removed before transitioning to another scene are automatically removed in @{finish|finish}.
--- @tparam playdate.graphics.sprite __sprite The sprite to add to the scene.
--- @see NobleSprite:add
--- @see removeSprite
-function NobleScene:addSprite(__sprite)
- if (__sprite.isNobleSprite == true) then
- __sprite:superAdd()
- else
- __sprite:add()
- end
-
- if (table.indexOfElement(self.sprites, __sprite) == nil) then
- table.insert(self.sprites, __sprite)
- end
-end
-
---- Use this to remove sprites from your scene instead of `playdate.graphics.sprite:remove()`.
---
--- If your sprite is a `NobleSprite`, using `NobleSprite:remove()` will also call this method.
---
--- Sprites not manually removed before transitioning to another scene are automatically removed in @{finish|finish}.
--- @tparam playdate.graphics.sprite __sprite The sprite to add to the scene.
--- @see NobleSprite:remove
--- @see addSprite
-function NobleScene:removeSprite(__sprite)
- if (__sprite.isNobleSprite == true) then
- __sprite:superRemove()
- else
- __sprite:remove()
- end
-
- if (table.indexOfElement(self.sprites, __sprite) ~= nil) then
- table.remove(self.sprites, table.indexOfElement(self.sprites, __sprite))
- end
-end
-
---- Callbacks
--- @section callbacks
-
---- Implement this in your scene if you have code to run when your scene's object is created.
---
--- @usage
--- function YourSceneName:init()
--- YourSceneName.super.init(self)
--- --[Your code here]--
--- end
---
-function NobleScene:init()
- self.name = self.className
- self.sprites = {}
-end
-
---- Implement if you want to run code as the transition to this scene begins, such as UI animation, triggers, etc.
---
--- @usage
--- function YourSceneName:enter()
--- YourSceneName.super.enter(self)
--- --[Your code here]--
--- end
---
-function NobleScene:enter() end
-
---- Implement if you have code to run once the transition to this scene is complete. This method signifies the full activation of a scene. If this scene's `inputHandler` is defined, it is enabled now.
--- @see inputHandler
--- @usage
--- function YourSceneName:start()
--- YourSceneName.super.start(self)
--- --[Your code here]--
--- end
---
-function NobleScene:start()
- Noble.Input.setHandler(self.inputHandler)
-end
-
---- Implement to run scene-specific code on every frame while this scene is active.
--- NOTE: you may use coroutine.yield() here, because it only runs inside of playdate.update(), which is a coroutine.
---
--- @usage
--- function YourSceneName:update()
--- YourSceneName.super.update(self)
--- --[Your code here]--
--- end
---
-function NobleScene:update() end
-
---- Implement this function to draw background visual elements in your scene.
---- This runs when the engine need to redraw a background area.
---- By default it runs every frame and fills the background with self.backgroundColor. All arguments are optional.
---- Use `Graphics.sprite.setAlwaysRedraw(false)` after `Noble.new()` to optimize partial redraw.
---
--- @usage
--- function YourSceneName:drawBackground(__x, __y, __width, __height)
--- YourSceneName.super.drawBackground(self) -- optional, invokes default behavior.
--- --[Your code here]--
--- end
---
-function NobleScene:drawBackground(__x, __y, __width, __height)
- __x = __x or 0
- __y = __y or 0
- __width = __width or Display.getWidth()
- __height = __height or Display.getHeight()
-
- -- Cache the currently set color/pattern.
- local color = Graphics.getColor()
- local color_type = type(color)
-
- -- Draw background.
- Graphics.setColor(self.backgroundColor)
- Graphics.fillRect(__x, __y, __width, __height)
-
- -- Reset color/pattern from cache.
- if color_type == 'number' then
- Graphics.setColor(color)
- elseif color_type == 'table' then
- Graphics.setPattern(color)
- end
-end
-
---- Implement this in your scene if you have "goodbye" code to run when a transition to another scene
--- begins, such as UI animation, saving to disk, etc.
---
--- @usage
--- function YourSceneName:exit()
--- YourSceneName.super.exit(self)
--- --[Your code here]--
--- end
---
-function NobleScene:exit()
- for _, sprite in ipairs(self.sprites) do
- sprite:setUpdatesEnabled(false)
- sprite:setCollisionsEnabled(false)
- end
-end
-
---- Implement this in your scene if you have code to run when a transition to another scene
--- is complete, such as resetting variables.
---
--- @usage
--- function YourSceneName:finish()
--- YourSceneName.super.finish(self)
--- --[Your code here]--
--- end
---
-function NobleScene:finish()
- for _, sprite in ipairs(self.sprites) do
- if (sprite.isNobleSprite) then
- sprite:superRemove()
- else
- sprite:remove()
- end
- end
-end
-
---- `pause()` / `resume()`
---
--- Implement one or both of these in your scene if you want something to happen when the game is paused/unpaused
--- by the system. The Playdate SDK does not require you to write pause logic, but these are useful if you want a
--- custom menu image (see Playdate SDK for more details), want to obscure game elements to prevent players from
--- cheating in a time-sensitive game, want to count the number of times the player pauses the game, etc.
---
--- @usage
--- function YourSceneName:pause()
--- YourSceneName.super.pause(self)
--- --[Your code here]--
--- end
-function NobleScene:pause() end
-
----
--- @usage
--- function YourSceneName:resume()
--- YourSceneName.super.resume(self)
--- --[Your code here]--
--- end
-function NobleScene:resume() end
\ No newline at end of file
diff --git a/source/libraries/noble/modules/NobleSprite.lua b/source/libraries/noble/modules/NobleSprite.lua
deleted file mode 100644
index aad6d31..0000000
--- a/source/libraries/noble/modules/NobleSprite.lua
+++ /dev/null
@@ -1,149 +0,0 @@
----
--- An extension of Playdate's sprite object, incorporating `Noble.Animation` and other Noble Engine features.
--- Use this in place of `playdate.graphics.sprite` in most cases.
---
--- `NobleSprite` is a child class of `playdate.graphics.sprite`, so see the Playdate SDK documentation for additional methods and properties.
---
--- @classmod NobleSprite
---
-
-NobleSprite = {}
-class("NobleSprite").extends(Graphics.sprite)
-
---- Do not call an "init" method directly. Use `NobleSprite()` (see usage examples).
--- @string[opt] __view This can be: the path to an image or spritesheet image file, an image object (`Graphics.image`) or an animation object (`Noble.Animation`)
--- @bool[opt=false] __viewIsSpritesheet Set this to `true` to indicate that `__view` is a spritesheet. Will only be considered if `__view` is a string path to an image.
--- @bool[opt=false] __singleState If this sprite has just one animation, set this to true. It saves you from having to use Noble.Animation.addState()
--- @bool[opt=true] __singleStateLoop If using a single state animation, should it loop?
---
--- @usage
--- -- Provide a spritesheet image file to create a new `Noble.Animation` for a NobleSprite's view.
--- myNobleSprite = NobleSprite("path/to/spritesheet", true)
---
--- @usage
--- -- Provide an image file to create a new `Graphics.image` for a NobleSprite's view.
--- myNobleSprite = NobleSprite("path/to/image")
---
--- @usage
--- -- Use an existing `Noble.Animation` for a NobleSprite's view.
--- local myAnimation = Noble.Animation.new("path/to/spritesheet")
--- myAnimation:addState("default", 1, animation.imageTable:getLength(), nil, true)
--- myNobleSprite = NobleSprite(myAnimation)
---
--- @usage
--- -- Use an existing `Graphics.image` object for a NobleSprite's view.
--- local myImage = Graphics.image.new("path/to/image")
--- myNobleSprite = NobleSprite(myImage)
---
--- @usage
--- -- Extending NobleSprite.
---
--- -- MyCustomSprite.lua
--- MyCustomSprite = {}
--- class("MyCustomSprite").extends(NobleSprite)
---
--- function MyCustomSprite:init(__x, __y, __anotherFunArgument)
--- MyCustomSprite.super.init(self, "path/to/spritesheet", true)
--- -- Etc. etc.
--- end
---
--- -- MyNobleScene.lua
--- myNobleSprite = MyCustomSprite(100, 100, "Fun!")
---
--- @see Noble.Animation:addState
--- @see Noble.Animation.new
---
-function NobleSprite:init(__view, __viewIsSpritesheet, __singleState, __singleStateLoop)
- NobleSprite.super.init(self)
- self.isNobleSprite = true -- This is important so other methods don't confuse this for a playdate.graphics.sprite. DO NOT modify this value at runtime.
- if (__view ~= nil) then
- -- __view is the path to an image or spritesheet file.
- if (type(__view) == "string") then
- self.animated = __viewIsSpritesheet -- NO NOT modify self.animated at runtime.
-
- if (__viewIsSpritesheet == true) then
- -- Create a new Noble.Animation object.
-
- --- The animation for this NobleSprite.
- -- @see Noble.Animation.new
- self.animation = Noble.Animation.new(__view)
-
- local singleStateLoop = true
- if (__singleStateLoop ~= nil) then singleStateLoop = __singleStateLoop end
-
- if (__singleState == true) then
- self.animation:addState("default", 1, self.animation.imageTable:getLength(), nil, singleStateLoop)
- end
- else
- -- Create a new Graphics.image object.
- self:setImage(Graphics.image.new(__view))
- end
-
- -- __view is an existing Graphics.image object.
- elseif (type(__view) == "userdata") then
- self.animated = false
- self:setImage(__view)
-
- -- __view is an existing Noble.Animation object.
- elseif (type(__view) == "table") then
- self.animated = true
- self.animation = __view
- end
- end
-end
-
-function NobleSprite:draw()
- if (self.animation ~= nil) then
- self.animation:draw()
- self:markDirty()
- end
-end
-
---- This will enable the update loop for this NobleSprite, which also causes its Noble.Animation to play.
-function NobleSprite:play()
- self:setUpdatesEnabled(true)
-end
-
---- This will disable the update loop for this NobleSprite, which also causes its Noble.Animation to pause.
-function NobleSprite:pause()
- self:setUpdatesEnabled(false)
-end
-
---- This will disable the update loop for this NobleSprite, and also reset its Noble.Animation (if it exists) to the first frame of its current state.
-function NobleSprite:stop()
- self:setUpdatesEnabled(false)
- if (self.animation ~= nil) then
- self.animation.currentFrame = self.animation.current.startFrame
- end
-end
-
---- Use this to add this NobleSprite to your scene. This replaces `playdate.graphics.sprite:add()` to allow NobleSprites to be tracked by the current NobleScene.
---
--- To add a `playdate.graphics.sprite` to a scene, use `NobleScene:addSprite(__sprite)`.
--- @see NobleScene:addSprite
-function NobleSprite:add(__x, __y)
- local x = __x or 0
- local y = __y or 0
- self:moveTo(x, y)
- Noble.currentScene():addSprite(self)
-end
-
-function NobleSprite:superAdd()
- NobleSprite.super.add(self)
-end
-
---- Use this to remove this NobleSprite from your scene. This replaces `playdate.graphics.sprite:remove()` to allow NobleSprites to be tracked by the current NobleScene.
---
--- To remove a `playdate.graphics.sprite` from a scene, use `NobleScene:removeSprite(__sprite)`.
--- @see NobleScene:removeSprite
-function NobleSprite:remove()
- if (self.animation ~= nil) then
- self:stop()
- self:setUpdatesEnabled(true) -- reset!
- end
- Noble.currentScene():removeSprite(self)
-end
-
-function NobleSprite:superRemove()
- NobleSprite.super.remove(self)
-end
diff --git a/source/libraries/noble/templates/SceneTemplate.lua b/source/libraries/noble/templates/SceneTemplate.lua
deleted file mode 100644
index 5bb25c8..0000000
--- a/source/libraries/noble/templates/SceneTemplate.lua
+++ /dev/null
@@ -1,185 +0,0 @@
---
--- SceneTemplate.lua
---
--- Use this as a starting point for your game's scenes.
--- Copy this file to your root "scenes" directory,
--- and rename it.
---
-
--- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
--- !!! Rename "SceneTemplate" to your scene's name in these first three lines. !!!
--- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-SceneTemplate = {}
-class("SceneTemplate").extends(NobleScene)
-local scene = SceneTemplate
-
--- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
--- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
--- It is recommended that you declare, but don't yet define,
--- your scene-specific varibles and methods here. Use "local" where possible.
---
--- local variable1 = nil -- local variable
--- scene.variable2 = nil -- Scene variable.
--- When accessed outside this file use `SceneTemplate.variable2`.
--- ...
---
-
--- This is the background color of this scene.
-scene.backgroundColor = Graphics.kColorWhite
-
--- This runs when your scene's object is created, which is the
--- first thing that happens when transitining away from another scene.
-function scene:init()
- scene.super.init(self)
-
- -- variable1 = 100
- -- SceneTemplate.variable2 = "string"
- -- ...
-
- -- Your code here
-end
-
--- When transitioning from another scene, this runs as soon as this
--- scene needs to be visible (this moment depends on which transition type is used).
-function scene:enter()
- scene.super.enter(self)
- -- Your code here
-end
-
--- This runs once a transition from another scene is complete.
-function scene:start()
- scene.super.start(self)
- -- Your code here
-end
-
--- This runs once per frame.
-function scene:update()
- scene.super.update(self)
- -- Your code here
-end
-
--- This runs once per frame, and is meant for drawing code.
-function scene:drawBackground()
- scene.super.drawBackground(self)
- -- Your code here
-end
-
--- This runs as as soon as a transition to another scene begins.
-function scene:exit()
- scene.super.exit(self)
- -- Your code here
-end
-
--- This runs once a transition to another scene completes.
-function scene:finish()
- scene.super.finish(self)
- -- Your code here
-end
-
-function scene:pause()
- scene.super.pause(self)
- -- Your code here
-end
-function scene:resume()
- scene.super.resume(self)
- -- Your code here
-end
-
--- Define the inputHander for this scene here, or use a previously defined inputHandler.
-
--- scene.inputHandler = someOtherInputHandler
--- OR
-scene.inputHandler = {
-
- -- A button
- --
- AButtonDown = function() -- Runs once when button is pressed.
- -- Your code here
- end,
- AButtonHold = function() -- Runs every frame while the player is holding button down.
- -- Your code here
- end,
- AButtonHeld = function() -- Runs after button is held for 1 second.
- -- Your code here
- end,
- AButtonUp = function() -- Runs once when button is released.
- -- Your code here
- end,
-
- -- B button
- --
- BButtonDown = function()
- -- Your code here
- end,
- BButtonHeld = function()
- -- Your code here
- end,
- BButtonHold = function()
- -- Your code here
- end,
- BButtonUp = function()
- -- Your code here
- end,
-
- -- D-pad left
- --
- leftButtonDown = function()
- -- Your code here
- end,
- leftButtonHold = function()
- -- Your code here
- end,
- leftButtonUp = function()
- -- Your code here
- end,
-
- -- D-pad right
- --
- rightButtonDown = function()
- -- Your code here
- end,
- rightButtonHold = function()
- -- Your code here
- end,
- rightButtonUp = function()
- -- Your code here
- end,
-
- -- D-pad up
- --
- upButtonDown = function()
- -- Your code here
- end,
- upButtonHold = function()
- -- Your code here
- end,
- upButtonUp = function()
- -- Your code here
- end,
-
- -- D-pad down
- --
- downButtonDown = function()
- -- Your code here
- end,
- downButtonHold = function()
- -- Your code here
- end,
- downButtonUp = function()
- -- Your code here
- end,
-
- -- Crank
- --
- cranked = function(change, acceleratedChange) -- Runs when the crank is rotated. See Playdate SDK documentation for details.
- -- Your code here
- end,
- crankDocked = function() -- Runs once when when crank is docked.
- -- Your code here
- end,
- crankUndocked = function() -- Runs once when when crank is undocked.
- -- Your code here
- end
-}
diff --git a/source/libraries/noble/utilities/Ease.lua b/source/libraries/noble/utilities/Ease.lua
deleted file mode 100644
index b256893..0000000
--- a/source/libraries/noble/utilities/Ease.lua
+++ /dev/null
@@ -1,81 +0,0 @@
---- Extensions to `playdate.easingFunctions`, aliased as `Ease` in Noble Engine.
--- See the Playdate SDK for a list of easing functions.
--- @module Ease
-
-local componentFunctions = {
- [Ease.inOutQuad] = { enter = Ease.inQuad, exit = Ease.outQuad },
- [Ease.inOutCubic] = { enter = Ease.inCubic, exit = Ease.outCubic },
- [Ease.inOutQuart] = { enter = Ease.inQuart, exit = Ease.outQuart },
- [Ease.inOutQuint] = { enter = Ease.inQuint, exit = Ease.outQuint },
- [Ease.inOutSine] = { enter = Ease.inSine, exit = Ease.outSine },
- [Ease.inOutExpo] = { enter = Ease.inExpo, exit = Ease.outExpo },
- [Ease.inOutCirc] = { enter = Ease.inCirc, exit = Ease.outCirc },
- [Ease.inOutElastic] = { enter = Ease.inElastic, exit = Ease.outElastic },
- [Ease.inOutBack] = { enter = Ease.inBack, exit = Ease.outBack },
- [Ease.inOutBounce] = { enter = Ease.inBounce, exit = Ease.outBounce },
- [Ease.outInQuad] = { enter = Ease.outQuad, exit = Ease.inQuad },
- [Ease.outInCubic] = { enter = Ease.outCubic, exit = Ease.inCubic },
- [Ease.outInQuart] = { enter = Ease.outQuart, exit = Ease.inQuart },
- [Ease.outInQuint] = { enter = Ease.outQuint, exit = Ease.inQuint },
- [Ease.outInSine] = { enter = Ease.outSine, exit = Ease.inSine },
- [Ease.outInExpo] = { enter = Ease.outExpo, exit = Ease.inExpo },
- [Ease.outInCirc] = { enter = Ease.outCirc, exit = Ease.inCirc },
- [Ease.outInElastic] = { enter = Ease.outElastic, exit = Ease.inElastic },
- [Ease.outInBack] = { enter = Ease.outBack, exit = Ease.inBack },
- [Ease.outInBounce] = { enter = Ease.outBounce, exit = Ease.inBounce },
- [Ease.linear] = { enter = Ease.linear, exit = Ease.linear }
-}
-
-local reverseFunctions = {
- [Ease.inQuad] = Ease.outQuad,
- [Ease.inCubic] = Ease.outCubic,
- [Ease.inQuart] = Ease.outQuart,
- [Ease.inQuint] = Ease.outQuint,
- [Ease.inSine] = Ease.outSine,
- [Ease.inExpo] = Ease.outExpo,
- [Ease.inCirc] = Ease.outCirc,
- [Ease.inElastic] = Ease.outElastic,
- [Ease.inBack] = Ease.outBack,
- [Ease.inBounce] = Ease.outBounce,
- [Ease.outQuad] = Ease.inQuad,
- [Ease.outCubic] = Ease.inCubic,
- [Ease.outQuart] = Ease.inQuart,
- [Ease.outQuint] = Ease.inQuint,
- [Ease.outSine] = Ease.inSine,
- [Ease.outExpo] = Ease.inExpo,
- [Ease.outCirc] = Ease.inCirc,
- [Ease.outElastic] = Ease.inElastic,
- [Ease.outBack] = Ease.inBack,
- [Ease.outBounce] = Ease.inBounce,
- [Ease.linear] = Ease.linear
-}
-
---- Returns the first half of an "inOut" or "outIn" easing function.
--- Returns `nil` for any easing function that isn't in the form of `Ease.inOutXxxx` or `Ease.outInXxxx`. `Ease.linear` returns itself.
--- @usage
--- local ease = Ease.outInQuad
--- local easeEnter = Ease.enter(ease) -- Returns "Ease.outQuad"
-function Ease.enter(__easingFunction)
- if (componentFunctions[__easingFunction] == nil) then return nil end
- return componentFunctions[__easingFunction].enter
-end
-
---- Returns the second half of an "inOut" or "outIn" easing function.
--- Returns `nil` for any easing function that isn't in the form of `Ease.inOutXxxx` or `Ease.outInXxxx`. `Ease.linear` returns itself.
--- @usage
--- local ease = Ease.outInQuad
--- local easeExit = Ease.exit(ease) -- Returns "Ease.inQuad"
-function Ease.exit(__easingFunction)
- if (componentFunctions[__easingFunction] == nil) then return nil end
- return componentFunctions[__easingFunction].exit
-end
-
---- Returns the reverse function of the provided function.
--- Returns `nil` for any easing function that isn't in the form of `Ease.inXxxx` or `Ease.outXxxx`. `Ease.linear` returns itself.
--- @usage
--- local ease = Ease.inQuad
--- local reverseEase = Ease.reverse(ease) -- Returns "Ease.outQuad"
-function Ease.reverse(__easingFunction)
- if (reverseFunctions[__easingFunction] == nil) then return nil end
- return reverseFunctions[__easingFunction]
-end
\ No newline at end of file
diff --git a/source/libraries/noble/utilities/Utilities.lua b/source/libraries/noble/utilities/Utilities.lua
deleted file mode 100644
index 1fc871d..0000000
--- a/source/libraries/noble/utilities/Utilities.lua
+++ /dev/null
@@ -1,197 +0,0 @@
---
--- Utilities.lua
---
--- Useful helper functions and API extensions.
--- Place your own utilities in "utilities/Utilities.lua"
---
-
-Utilities = {}
-
-function Utilities.copy(obj, seen)
- if type(obj) ~= 'table' then return obj end
- if seen and seen[obj] then return seen[obj] end
- local s = seen or {}
- local res = setmetatable({}, getmetatable(obj))
- s[obj] = res
- for k, v in pairs(obj) do res[Utilities.copy(k, s)] = Utilities.copy(v, s) end
- return res
-end
-
-function Utilities.isNull(__object)
- return __object == nil or __object == ''
-end
-function Utilities.isNotNull(__object)
- return __object ~= nil and __object ~= ''
-end
-
-function Utilities.startsWith(__string, __start)
- return __string:sub(1, #__start) == __start
-end
-
-function Utilities.endsWith(__string, __ending)
- return __ending == "" or __string:sub(-#__ending) == __ending
-end
-
-function Utilities.handleOptionalBoolean(__argument, __default)
- if (__argument == nil) then
- return __default
- elseif (__argument == true or __argument == false) then
- return __argument
- else
- error("BONK: You shouldn’t pass non-boolean value as a boolean parameter.")
- return __argument
- end
-end
-
-Utilities.varName = {}
-setmetatable(
- Utilities.varName,
- {
- __index = function(self, __key, __value)
- return string.format('%s', __key)
- end
- }
-)
-
-
-function Utilities.getHypotenuse(__x,__y)
- return math.sqrt((__x*__x)+(__y*__y))
-end
-
-function Utilities.average(__a, __b)
- return (__a + __b) / 2
-end
-
-function Utilities.screenshot()
- return Graphics.getDisplayImage()
-end
-
-function Utilities.autoTable(__numberOfDimensions)
- local metatable = {};
- for i = 1, __numberOfDimensions do
- metatable[i] = {
- __index = function(__table, __key)
- if i < __numberOfDimensions then
- __table[__key] = setmetatable({}, metatable[i+1])
- return __table[__key];
- end
- end
- }
- end
- return setmetatable({}, metatable[1]);
-end
-
-function Utilities.newUUID()
- local func = function(x)
- local random = math.random(16) - 1
- random = (x == "x") and (random + 1) or (random % 4) + 9
- return ("0123456789abcdef"):sub(random, random)
- end
- return (("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"):gsub("[xy]", func))
-end
-
-
--- New math methods
---
-
-function math.clamp(__value, __min, __max)
- if (__min > __max) then
- __min, __max = __max, __min
- end
- return math.max(__min, math.min(__max, __value))
-end
-
-function math.ring(__value, __min, __max)
- if (__min > __max) then
- __min, __max = __max, __min
- end
- return __min + (__value - __min) % (__max - __min)
-end
-
-function math.ringInt(__value, __min, __max)
- return math.ring(__value, __min, __max + 1)
-end
-
-function math.approach(_value, __target, __step)
- if (_value == __target) then
- return _value, true
- end
- local d = __target - _value
- if (d > 0) then
- _value = _value + __step
- if (_value >= __target) then
- return __target, true
- else
- return _value, false
- end
- elseif (d < 0) then
- _value = _value - __step
- if (_value <= __target) then
- return __target, true
- else
- return _value, false
- end
- else
- return _value, true
- end
-end
-
-function math.infiniteApproach(at_zero, at_infinite, x_halfway, x)
- return at_infinite - (at_infinite - at_zero) * 0.5 ^ (x / x_halfway)
-end
-
-function math.round(__value, __bracket)
- local bracket = __bracket or 1
- return math.floor(__value/bracket + math.sign(__value) * 0.5) * bracket
-end
-
-function math.sign(__value)
- return (__value >= 0 and 1) or -1
-end
-
-function math.lerp(a, b, t)
- return a + (b - a) * t
-end
-
--- New array/table methods
---
-
-function table.merge(__table1, __table2)
- local mergedTable = {}
- for k,v in pairs(__table1) do
- mergedTable[k] = v
- end
- for k,v in pairs(__table2) do
- mergedTable[k] = v
- end
- return mergedTable
-end
-
-function table.random(__table)
- if (type(__table) ~= "table") then return nil end
- return __table[math.ceil(math.random(#__table))]
-end
-function table.each(__table, __function)
- if (type(__function) ~= "function") then return end
- for _, e in pairs(__table) do
- __function(e)
- end
-end
-
-function table.filter(__table, __filter)
- local out = {}
- for _, value in pairs(__table) do
- --if filterIter(v, k, table) then out[k] = v end
- if (__filter(value)) then
- __table.insert (out,value)
- end
- end
-
- return out
-end
-
-function table.getSize(__table)
- local count = 0
- for _, _ in pairs(__table) do count += 1 end
- return count
-end
diff --git a/source/main.lua b/source/main.lua
index 77eb6b9..eb05d82 100644
--- a/source/main.lua
+++ b/source/main.lua
@@ -100,19 +100,20 @@ Difficulty = {
DifficultySettings = {
[Difficulty.Easy] = {
- assebleTime = 2500,
+ assebleTime = 1700,
},
[Difficulty.Medium] = {
- assebleTime = 1500,
+ assebleTime = 1000,
},
[Difficulty.Hard] = {
- assebleTime = 800,
+ assebleTime = 500,
}
}
Noble.Settings.setup({
difficulty = Difficulty.Medium,
- music = true
+ music = true,
+ debug = true
})
Noble.GameData.setup({
diff --git a/source/scenes/Menu.lua b/source/scenes/Menu.lua
index bbfa40e..d99b8ee 100644
--- a/source/scenes/Menu.lua
+++ b/source/scenes/Menu.lua
@@ -113,7 +113,15 @@ end
function scene:setupMenu(__menu)
__menu:addItem("Start", function() Noble.transition(DroneCardSelector, nil, Noble.Transition.DipToWhite) end)
- __menu:addItem("Tutorial", function() return end)
+ __menu:addItem("Tutorial", function()
+ local debug = Noble.Settings.get("debug")
+ if debug then
+ Noble.Settings.set("debug", false)
+ else
+ Noble.Settings.set("debug", true)
+ end
+ return
+ end)
__menu:addItem("Credits", function() return end)
__menu:select("Start")
end
diff --git a/source/scripts/player.lua b/source/scripts/player.lua
index 3c8ba37..5ed7e62 100644
--- a/source/scripts/player.lua
+++ b/source/scripts/player.lua
@@ -53,8 +53,12 @@ function Player:init(x, y)
Player.bat = Player.fullBat
Player.dischargeRate = 1
Player.moveRight = false
+ Player.moveLeft = false -- TODO: refactor to use a single variable
self.lastDirection = nil
self.targetDone = false
+
+
+ self.debug = Noble.Settings.get("debug")
end
function Player:handleInput()
@@ -68,6 +72,7 @@ function Player:handleInput()
if not playdate.buttonIsPressed(playdate.kButtonLeft) and not playdate.buttonIsPressed(playdate.kButtonRight) then
self.xVelocity = self.xVelocity * self.friction
Player.moveRight = false
+ Player.moveLeft = false
self.animation:setState("down")
end
@@ -78,6 +83,8 @@ function Player:handleInput()
end
self:changeToRunState("left")
self.lastDirection = "left"
+ Player.moveLeft = true
+ Player.moveRight = false
self.xVelocity = self.xVelocity - self.acceleration
elseif playdate.buttonIsPressed(playdate.kButtonRight) then
if self.lastDirection == "left" then
@@ -85,6 +92,7 @@ function Player:handleInput()
end
self:changeToRunState("right")
Player.moveRight = true
+ Player.moveLeft = false
self.lastDirection = "right"
self.xVelocity = self.xVelocity + self.acceleration
end
@@ -95,10 +103,12 @@ function Player:handleInput()
-- Y velocity
if crankChange ~= 0 then
- if crankChange > 0 then
- self.animation:setState("up")
- else
- self.animation:setState("down")
+ if Player.moveRight == false and Player.moveLeft == false then
+ if crankChange > 0 then
+ self.animation:setState("up")
+ else
+ self.animation:setState("down")
+ end
end
self.yInertia = self.yInertia - (acceleratedChange * 0.007)
else
@@ -173,6 +183,9 @@ function Player:handleMovementAndCollisions()
self:boom()
return
elseif collisionTag == 154 then -- Baleba
+ if self.debug then
+ return
+ end
self:boom(collisionObject)
return
elseif collisionTag == 2 then -- Tank