From 9d1e59b46a56eee621b0687fd9f34733f416b9b2 Mon Sep 17 00:00:00 2001 From: lustlion Date: Sat, 12 Feb 2022 20:03:48 +0100 Subject: [PATCH] adjusted hook to be toggle; renamed HasPressed to CheckPressed (keybind) --- code/editor.lua | 13 ++++---- code/entities/player.lua | 40 ++++++++++++++-------- code/game.lua | 8 ++--- code/keybind.lua | 2 +- main.lua | 2 +- unused slash dev/to_do.txt | 68 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 107 insertions(+), 26 deletions(-) create mode 100644 unused slash dev/to_do.txt diff --git a/code/editor.lua b/code/editor.lua index d86e999..08f316d 100644 --- a/code/editor.lua +++ b/code/editor.lua @@ -1,7 +1,8 @@ function EditorStep() palette = palette or false AnimateTiles() - if Keybind:HasPressed(Keybind.editor.palette) then + + if Keybind:CheckPressed(Keybind.editor.palette) then if palette then palette = false palette_scroll_x = nil @@ -26,7 +27,7 @@ function EditorStep() end if palette then - if Keybind:HasPressed(Keybind.debug.debug) then + if Keybind:CheckPressed(Keybind.debug.debug) then local next = false local export = nil for k, v in pairs(tileset) do @@ -51,11 +52,11 @@ function EditorStep() end end - if Keybind:HasPressed(Keybind.debug.reload) then + if Keybind:CheckPressed(Keybind.debug.reload) then ExportLevel("test") end - if Keybind:HasPressed(Keybind.debug.editor) then + if Keybind:CheckPressed(Keybind.debug.editor) then editor_mode = false TileCreateObjects() end @@ -126,10 +127,10 @@ function EditorDoEdit() end LevelReloadTiles() - elseif Keybind:HasPressed(Keybind.generic.lshift) then + elseif Keybind:CheckPressed(Keybind.generic.lshift) then LevelExpandCanvas(math.sign(expand_h),math.sign(expand_v)) LevelReloadTiles() - elseif Keybind:HasPressed(Keybind.generic.lctrl) then + elseif Keybind:CheckPressed(Keybind.generic.lctrl) then LevelReduceCanvas(math.sign(expand_h),math.sign(expand_v)) LevelReloadTiles() end diff --git a/code/entities/player.lua b/code/entities/player.lua index 3bd5340..0100b6e 100644 --- a/code/entities/player.lua +++ b/code/entities/player.lua @@ -140,17 +140,19 @@ function Player:Smart() self.isDashing = false end - if Keybind:CheckDown(Keybind.move.hook) then - local anchor = self:CheckNearest("decoration",self.hookDistance) - if anchor then - self.isHooked = true - self.hookAnchor = { - x = anchor.pos.x, - y = anchor.pos.y - } + if Keybind:CheckPressed(Keybind.move.hook) then + if self.isHooked then + self.isHooked = false + else + local anchor = self:CheckNearest("decoration",self.hookDistance) + if anchor then + self.isHooked = true + self.hookAnchor = { + x = anchor.pos.x, + y = anchor.pos.y + } + end end - else - self.isHooked = false end end @@ -194,9 +196,19 @@ function Player:DoPhysics() if self.isHooked then local hook = Vector(self.pos.x, self.pos.y, self.hookAnchor.x, self.hookAnchor.y) if GetVectorValue(hook) > self.hookedDistance then - local hook_angle = GetAngleFromVector(hook[1],hook[2]) - local pos_x = self.hookAnchor.x + self.hookedDistance * math.cos(-math.rad(180)+hook_angle) - local pos_y = self.hookAnchor.y + self.hookedDistance * math.sin(-math.rad(180)+hook_angle) + local particle_data = { + animation = self.body, + sprite_tint = HEX2RGB("#fed100"), + sprite_alpha = 0.5, + sprite_flip = { + x = self.sprite_flip.x, + y = self.sprite_flip.y + } + } + Particle:New(self.pos.x,self.pos.y,particle_data) + local hook_angle = GetAngleFromVector(hook[1],hook[2])-math.rad(180) + local pos_x = self.hookAnchor.x + self.hookedDistance * math.cos(hook_angle) + local pos_y = self.hookAnchor.y + self.hookedDistance * math.sin(hook_angle) self.vel.x = self.vel.x + pos_x - self.pos.x self.vel.y = self.vel.y + pos_y - self.pos.y self.pos.x = pos_x @@ -206,7 +218,7 @@ function Player:DoPhysics() if self.canFall then - -- not in dash or hook; fall normally + -- not in dash self.dashTimer = 0 self.vel.y = self.vel.y + gravity end diff --git a/code/game.lua b/code/game.lua index 4d123b6..49a9fcd 100644 --- a/code/game.lua +++ b/code/game.lua @@ -20,7 +20,7 @@ function GameStep() Camera:positionCenterAt(main_Player.pos.x, main_Player.pos.y) --camera:positionAt(main_Player.pos.x, main_Player.pos.y,game.width,game.height) - if Keybind:HasPressed(Keybind.debug.debug) then + if Keybind:CheckPressed(Keybind.debug.debug) then if debug then debug = false debug_collision = true @@ -31,19 +31,19 @@ function GameStep() end end - if Keybind:HasPressed(Keybind.debug.reposition) then + if Keybind:CheckPressed(Keybind.debug.reposition) then if not editor_mode then main_Player.pos.x, main_Player.pos.y = 16,-10 end end - if Keybind:HasPressed(Keybind.debug.reload) then + if Keybind:CheckPressed(Keybind.debug.reload) then MenuClear() menu_type = "dialog" MenuInit("dialog",DialogSequence.Example) end - if Keybind:HasPressed(Keybind.debug.editor) then + if Keybind:CheckPressed(Keybind.debug.editor) then editor_mode = true end end diff --git a/code/keybind.lua b/code/keybind.lua index 7678110..d561aad 100644 --- a/code/keybind.lua +++ b/code/keybind.lua @@ -16,7 +16,7 @@ function Keybind:CheckDown(action) return false end -function Keybind:HasPressed(action) +function Keybind:CheckPressed(action) if Keybind:CheckDown(action) then if not action.pressed then action.pressed = true diff --git a/main.lua b/main.lua index bd4d2bb..8cc5d8c 100644 --- a/main.lua +++ b/main.lua @@ -93,7 +93,7 @@ function love.update(dt) end --keypressed - if Keybind:HasPressed(Keybind.menu.pause) then + if Keybind:CheckPressed(Keybind.menu.pause) then if do_pause then do_pause = false else diff --git a/unused slash dev/to_do.txt b/unused slash dev/to_do.txt new file mode 100644 index 0000000..f0bf280 --- /dev/null +++ b/unused slash dev/to_do.txt @@ -0,0 +1,68 @@ +(*) Ideas + ( ) DO FLIES + ( ) DO UI + ( ) DO DAMAGE TO PLAYER + +( ) Visual design + (~) Multicolor palette depending on area, with 3 main colors + (X) Library: Gold #fed100 + ( ) + ( ) Dialog + ( ) Fonts + ( ) Characters + ( ) Level design + ( ) Enemy design + +( ) Gameplay design + ( ) Level design + ( ) Mechanic design + ( ) Entity design + (~) FAIRY + (X) basic movement + (X) Fairy particles~~ + ( ) more intelligent movement + ( ) avoid getting stuck to walls + ( ) Playtest tools + +( ) Technical design + (?) Input + (X) ADDED KEYBINDS + ( ) + (?) Draw + (X) REHANDLE ANIMATIONS + (X) MAKE LIGHTING SYSTEM + (X) Pixel perfect entity drawing + ( ) Pixel perfect lights + (?) Player + (X) MASKS FUNCTIONALITY + ( ) + (?) Physics + (X) MAKE PHYSICS CONSISTENT + (X) MAKE HITBOXES + (X) PHYSICS BY FRAME + (X) DEACTIVATE ARROWS WHEN STUCK + ( ) + (~) Dialog + (X) Object and Basics + ( ) Fix font and align problems + ( ) Implement portrait + (X) Translating framework + ( ) Debug tools + ( ) Audio and BGM + (~) REMAKE LEVEL EDITOR + (~) ADD WAY TO EDIT A LEVEL (EDITOR MODE) + (X) SHOW PALETTE + (X) PICK UP TILE FROM PALETTE + (X) PLACE PICKED UP TILE + ( ) WAY TO INSERT ENTITIES IN THE LEVEL + (X) ADD WAY TO SAVE A LEVEL + +( ) Narrative design + ( ) Dialog + ( ) Characters + ( ) Area design + ( ) Translations + ( ) SPA "es_ES" + ( ) ENG "en_UK" + ( ) CAT "ca_ES" + ( ) HEON "Myrheonian"