From f021446439d387e14b4896b529bcced5ffc71f15 Mon Sep 17 00:00:00 2001 From: bizcochito Date: Tue, 18 Jan 2022 18:46:41 +0100 Subject: [PATCH 1/7] Made keybind editing "backend" --- data/scripts/entities/player.lua | 16 +++++------ data/scripts/keybind.lua | 47 +++++++++++++++++++++++++------- main.lua | 2 +- 3 files changed, 46 insertions(+), 19 deletions(-) diff --git a/data/scripts/entities/player.lua b/data/scripts/entities/player.lua index 4ea1e5f..4798690 100644 --- a/data/scripts/entities/player.lua +++ b/data/scripts/entities/player.lua @@ -73,16 +73,16 @@ function Player:Smart() if math.abs(self.vel.x) < self.zeroSpeed then self.vel.x = 0 end - if keybind:Check(keybind.moveLeft) then + if Keybind:Check(Keybind.move.left) then self.move_x = -self.moveSpeed - elseif keybind:Check(keybind.moveRight) then + elseif Keybind:Check(Keybind.move.right) then self.move_x = self.moveSpeed else self.move_x = 0 end self.vel.x = self.vel.x - if keybind:Check(keybind.moveJump) then + if Keybind:Check(Keybind.move.jump) then if self.isOnGround then self.vel.y = -self.jumpImpulse end @@ -90,18 +90,18 @@ function Player:Smart() end self.dashCooldownTimer = math.max(0,self.dashCooldownTimer - current_dt) - if keybind:Check(keybind.moveDash) then + if Keybind:Check(Keybind.move.dash) then if self.dashCooldownTimer == 0 and not self.isDashing and self.dashCount > 0 then self.dashCount = self.dashCount - 1 self.isDashing = true local vertical = 0 - if keybind:Check(keybind.moveDown) then vertical = vertical + 1 end - if keybind:Check(keybind.moveUp) then vertical = vertical - 1 end + if Keybind:Check(Keybind.move.down) then vertical = vertical + 1 end + if Keybind:Check(Keybind.move.up) then vertical = vertical - 1 end local horizontal = 0 - if keybind:Check(keybind.moveRight) then horizontal = horizontal + 1 end - if keybind:Check(keybind.moveLeft) then horizontal = horizontal - 1 end + if Keybind:Check(Keybind.move.right) then horizontal = horizontal + 1 end + if Keybind:Check(Keybind.move.left) then horizontal = horizontal - 1 end if horizontal == 0 and vertical == 0 then horizontal = self.sprite_flip.x diff --git a/data/scripts/keybind.lua b/data/scripts/keybind.lua index 6d42b06..4f2a349 100644 --- a/data/scripts/keybind.lua +++ b/data/scripts/keybind.lua @@ -1,7 +1,9 @@ -keybind = {} +Keybind = {} +Keybind.move = {} +Keybind.menu = {} -function keybind:Check(key) - for _, keyname in pairs(key) do +function Keybind:Check(action) + for _, keyname in pairs(action) do if type(keyname) == "string" then if love.keyboard.isDown(keyname) then return true end else @@ -11,11 +13,36 @@ function keybind:Check(key) return false end +function Keybind:Colision(cat, key) + for _, action in pairs(cat) do + for _, keyname in pairs(action) do + if key == keyname then return true end + end + end + return false +end -keybind.moveLeft = {"left", "a"} -keybind.moveRight = {"right", "d"} -keybind.moveUp = {"up", "w"} -keybind.moveDown = {"down", "s"} -keybind.moveJump = {"z", "space"} -keybind.moveAttack = {"x", 1} -keybind.moveDash = {"c", 2} +function Keybind:Add(action, key) + table.insert(action, key) +end + +function Keybind:Change(action, position, key) + action[position] = key +end + +function Keybind:Remove(action) + action = {} +end + +function Keybind:Default() + Keybind.move.left = {"left", "a"} + Keybind.move.right = {"right", "d"} + Keybind.move.up = {"up", "w"} + Keybind.move.down = {"down", "s"} + Keybind.move.jump = {"z", "space"} + Keybind.move.attack = {"x", 1} + Keybind.move.dash = {"c", 2} +end + +-- Set default values at start +Keybind:Default() diff --git a/main.lua b/main.lua index 15b32fb..428ee8e 100644 --- a/main.lua +++ b/main.lua @@ -48,7 +48,7 @@ function love.load() table.insert(LoadedEntities,Decoration:New(200,89,animation.decoration.candelabra,80)) table.insert(LoadedEntities,Fairy:New(200,88)) - gravity = 0.05 + gravity = 0.2 end function love.update(dt) -- 2.39.2 From e8477e87505ff2a67705f3a5d2ca4b2b501b360d Mon Sep 17 00:00:00 2001 From: bizcochito Date: Tue, 18 Jan 2022 19:45:57 +0000 Subject: [PATCH 2/7] Update 'main.lua' --- main.lua | 284 +++++++++++++++++++++++++++---------------------------- 1 file changed, 142 insertions(+), 142 deletions(-) diff --git a/main.lua b/main.lua index 428ee8e..b05ff7c 100644 --- a/main.lua +++ b/main.lua @@ -1,142 +1,142 @@ -function love.load() - - do_pause = false - - debug = false - debug_collision = false - editor_mode = false - - textScale = 1 - fps_count = 0 - fps_second = 0 - fps_draw = 0 - fps_total = 0 - - love.graphics.setColor(1,1,1) - love.keyboard.setKeyRepeat(true) - love.graphics.setDefaultFilter("nearest") -- good pixel - - game = { - scale = 2, - width = love.graphics.getWidth(), - height = love.graphics.getHeight(), - paused = false - } - - require "data/scripts" - Canvas = { - Darkness = CreateDarkness() - } - love.graphics.setCanvas(Canvas.Darkness) - SetDarkness() - love.graphics.setCanvas() - - Camera.width = game.width - Camera.height = game.height - - levelList = {"level1","2","3","ewae","tileset"} - levelNum = 1 - currLevel = levelList[levelNum] - LoadedEntities = {} - LevelLoadTiles() - - main_Player = Player:New(75,50) - - table.insert(LoadedEntities,main_Player) - table.insert(LoadedEntities,Kupo:New(100,150)) - table.insert(LoadedEntities,Kupo:New(300,150)) - table.insert(LoadedEntities,Decoration:New(200,89,animation.decoration.candelabra,80)) - table.insert(LoadedEntities,Fairy:New(200,88)) - - gravity = 0.2 -end - -function love.update(dt) - -- fps counter - if fps_second >= 1 then - fps_second = fps_second - 1 - fps_draw = fps_count - fps_count = 0 - fps_total = fps_total + 1 - end - fps_second = fps_second + dt - fps_count = fps_count + 1 - current_dt = dt - - - if editor_mode then - stepEditor() - else - stepGame() - end -end - - -function love.wheelmoved(_, y) - if editor_mode then - if palette then - p_scroll = p_scroll + y - else - local oscale = game.scale - game.scale = math.max(0.1,game.scale + y/16) - end - end -end - -function love.keypressed(key) - if key == "escape" then - if do_pause then - do_pause = false - else - pausepage = 1 - do_pause = true - end - end - - if key == "f1" then - if debug then - debug = false - debug_collision = true - elseif debug_collision then - debug_collision = false - else - debug = true - end - end - - if key == "f2" then - if editor_mode then - - else - main_Player.pos.x, main_Player.pos.y = 16,-10 - end - end - - if key == "f3" then - LoadLevel() - end - - if key == "f4" then - if editor_mode then - editor_mode = false - else - editor_mode = true - end - end -end - -function love.draw() - if game.width ~= love.graphics.getWidth() or game.height ~= love.graphics.getHeight() then - game.width = love.graphics.getWidth() - game.height = love.graphics.getHeight() - game_resize = true - else - game_resize = false - end - - if editor_mode then - drawEditor() - else - drawGame() - end -end +function love.load() + + do_pause = false + + debug = false + debug_collision = false + editor_mode = false + + textScale = 1 + fps_count = 0 + fps_second = 0 + fps_draw = 0 + fps_total = 0 + + love.graphics.setColor(1,1,1) + love.keyboard.setKeyRepeat(true) + love.graphics.setDefaultFilter("nearest") -- good pixel + + game = { + scale = 2, + width = love.graphics.getWidth(), + height = love.graphics.getHeight(), + paused = false + } + + require "data/scripts" + Canvas = { + Darkness = CreateDarkness() + } + love.graphics.setCanvas(Canvas.Darkness) + SetDarkness() + love.graphics.setCanvas() + + Camera.width = game.width + Camera.height = game.height + + levelList = {"level1","2","3","ewae","tileset"} + levelNum = 1 + currLevel = levelList[levelNum] + LoadedEntities = {} + LevelLoadTiles() + + main_Player = Player:New(75,50) + + table.insert(LoadedEntities,main_Player) + table.insert(LoadedEntities,Kupo:New(100,150)) + table.insert(LoadedEntities,Kupo:New(300,150)) + table.insert(LoadedEntities,Decoration:New(200,89,animation.decoration.candelabra,80)) + table.insert(LoadedEntities,Fairy:New(200,88)) + + gravity = 0.05 +end + +function love.update(dt) + -- fps counter + if fps_second >= 1 then + fps_second = fps_second - 1 + fps_draw = fps_count + fps_count = 0 + fps_total = fps_total + 1 + end + fps_second = fps_second + dt + fps_count = fps_count + 1 + current_dt = dt + + + if editor_mode then + stepEditor() + else + stepGame() + end +end + + +function love.wheelmoved(_, y) + if editor_mode then + if palette then + p_scroll = p_scroll + y + else + local oscale = game.scale + game.scale = math.max(0.1,game.scale + y/16) + end + end +end + +function love.keypressed(key) + if key == "escape" then + if do_pause then + do_pause = false + else + pausepage = 1 + do_pause = true + end + end + + if key == "f1" then + if debug then + debug = false + debug_collision = true + elseif debug_collision then + debug_collision = false + else + debug = true + end + end + + if key == "f2" then + if editor_mode then + + else + main_Player.pos.x, main_Player.pos.y = 16,-10 + end + end + + if key == "f3" then + LoadLevel() + end + + if key == "f4" then + if editor_mode then + editor_mode = false + else + editor_mode = true + end + end +end + +function love.draw() + if game.width ~= love.graphics.getWidth() or game.height ~= love.graphics.getHeight() then + game.width = love.graphics.getWidth() + game.height = love.graphics.getHeight() + game_resize = true + else + game_resize = false + end + + if editor_mode then + drawEditor() + else + drawGame() + end +end -- 2.39.2 From da8b9004b45fc9d0c98b62ebd8f77bd04077301e Mon Sep 17 00:00:00 2001 From: bizcochito Date: Tue, 18 Jan 2022 20:47:55 +0100 Subject: [PATCH 3/7] Made keybind editing "backend" --- data/scripts/entities/player.lua | 16 +++++------ data/scripts/keybind.lua | 47 +++++++++++++++++++++++++------- 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/data/scripts/entities/player.lua b/data/scripts/entities/player.lua index 4ea1e5f..4798690 100644 --- a/data/scripts/entities/player.lua +++ b/data/scripts/entities/player.lua @@ -73,16 +73,16 @@ function Player:Smart() if math.abs(self.vel.x) < self.zeroSpeed then self.vel.x = 0 end - if keybind:Check(keybind.moveLeft) then + if Keybind:Check(Keybind.move.left) then self.move_x = -self.moveSpeed - elseif keybind:Check(keybind.moveRight) then + elseif Keybind:Check(Keybind.move.right) then self.move_x = self.moveSpeed else self.move_x = 0 end self.vel.x = self.vel.x - if keybind:Check(keybind.moveJump) then + if Keybind:Check(Keybind.move.jump) then if self.isOnGround then self.vel.y = -self.jumpImpulse end @@ -90,18 +90,18 @@ function Player:Smart() end self.dashCooldownTimer = math.max(0,self.dashCooldownTimer - current_dt) - if keybind:Check(keybind.moveDash) then + if Keybind:Check(Keybind.move.dash) then if self.dashCooldownTimer == 0 and not self.isDashing and self.dashCount > 0 then self.dashCount = self.dashCount - 1 self.isDashing = true local vertical = 0 - if keybind:Check(keybind.moveDown) then vertical = vertical + 1 end - if keybind:Check(keybind.moveUp) then vertical = vertical - 1 end + if Keybind:Check(Keybind.move.down) then vertical = vertical + 1 end + if Keybind:Check(Keybind.move.up) then vertical = vertical - 1 end local horizontal = 0 - if keybind:Check(keybind.moveRight) then horizontal = horizontal + 1 end - if keybind:Check(keybind.moveLeft) then horizontal = horizontal - 1 end + if Keybind:Check(Keybind.move.right) then horizontal = horizontal + 1 end + if Keybind:Check(Keybind.move.left) then horizontal = horizontal - 1 end if horizontal == 0 and vertical == 0 then horizontal = self.sprite_flip.x diff --git a/data/scripts/keybind.lua b/data/scripts/keybind.lua index 6d42b06..4f2a349 100644 --- a/data/scripts/keybind.lua +++ b/data/scripts/keybind.lua @@ -1,7 +1,9 @@ -keybind = {} +Keybind = {} +Keybind.move = {} +Keybind.menu = {} -function keybind:Check(key) - for _, keyname in pairs(key) do +function Keybind:Check(action) + for _, keyname in pairs(action) do if type(keyname) == "string" then if love.keyboard.isDown(keyname) then return true end else @@ -11,11 +13,36 @@ function keybind:Check(key) return false end +function Keybind:Colision(cat, key) + for _, action in pairs(cat) do + for _, keyname in pairs(action) do + if key == keyname then return true end + end + end + return false +end -keybind.moveLeft = {"left", "a"} -keybind.moveRight = {"right", "d"} -keybind.moveUp = {"up", "w"} -keybind.moveDown = {"down", "s"} -keybind.moveJump = {"z", "space"} -keybind.moveAttack = {"x", 1} -keybind.moveDash = {"c", 2} +function Keybind:Add(action, key) + table.insert(action, key) +end + +function Keybind:Change(action, position, key) + action[position] = key +end + +function Keybind:Remove(action) + action = {} +end + +function Keybind:Default() + Keybind.move.left = {"left", "a"} + Keybind.move.right = {"right", "d"} + Keybind.move.up = {"up", "w"} + Keybind.move.down = {"down", "s"} + Keybind.move.jump = {"z", "space"} + Keybind.move.attack = {"x", 1} + Keybind.move.dash = {"c", 2} +end + +-- Set default values at start +Keybind:Default() -- 2.39.2 From 33ade3488672cc6c92952b5e798f6f8ede89c3b5 Mon Sep 17 00:00:00 2001 From: bizcochito Date: Tue, 18 Jan 2022 21:08:58 +0100 Subject: [PATCH 4/7] Merge https://git.fai.su/lustlion/Mothback --- data/scripts/entities/arrow.lua | 78 +++++++++++++++++---------------- data/scripts/entities/fairy.lua | 4 +- data/scripts/entities/kupo.lua | 4 +- data/scripts/game.lua | 73 ++++++++++++++++++++++++++++++ data/scripts/lights.lua | 1 + 5 files changed, 118 insertions(+), 42 deletions(-) diff --git a/data/scripts/entities/arrow.lua b/data/scripts/entities/arrow.lua index bb2a8ab..9e5c420 100644 --- a/data/scripts/entities/arrow.lua +++ b/data/scripts/entities/arrow.lua @@ -2,7 +2,7 @@ Arrow = Entity:New(x,y) function Arrow:New(x,y,rotation,speed) local o = Entity:New(x,y) - + arrow = arrow + 1 o.pos = {x = x, y = y} o.speed = speed or 0 o.sprite_rotation = rotation or 0 @@ -32,45 +32,47 @@ function Arrow:HandleAnimation() end function Arrow:DoPhysics() - -- horizontal collisions - if not isThereAnyCollisionAt( - self.pos.x + self.vel.x, - self.pos.y - ) then - self.pos.x = self.pos.x + self.vel.x - else - while not isThereObjectAt( - self.pos.x + math.sign(self.vel.x), - self.pos.y, - objects.collisions - ) do - self.pos.x = self.pos.x + math.sign(self.vel.x) + if not self.stuck then + -- horizontal collisions + if not isThereAnyCollisionAt( + self.pos.x + self.vel.x, + self.pos.y + ) then + self.pos.x = self.pos.x + self.vel.x + else + while not isThereObjectAt( + self.pos.x + math.sign(self.vel.x), + self.pos.y, + objects.collisions + ) do + self.pos.x = self.pos.x + math.sign(self.vel.x) + end + self.stuck = true end - self.stuck = true - end - -- vertical collision - if not isThereAnyCollisionAt( - self.pos.x, - self.pos.y + self.vel.y - ) then - self.pos.y = self.pos.y + self.vel.y - else - while not isThereObjectAt( + -- vertical collision + if not isThereAnyCollisionAt( self.pos.x, - self.pos.y + math.sign(self.vel.y), - objects.collisions - ) do - self.pos.y = self.pos.y + math.sign(self.vel.y) + self.pos.y + self.vel.y + ) then + self.pos.y = self.pos.y + self.vel.y + else + while not isThereObjectAt( + self.pos.x, + self.pos.y + math.sign(self.vel.y), + objects.collisions + ) do + self.pos.y = self.pos.y + math.sign(self.vel.y) + end + self.stuck = true + end + -- stuck into collisions + if self.stuck then + --lets allow the arrow to tip a bit into the thing + self.pos.x = self.pos.x + self.vel.x / 5 + self.pos.y = self.pos.y + self.vel.y / 5 + self.vel.x = 0 + self.vel.y = 0 + self.illuminated = false end - self.stuck = true - end - -- stuck into collisions - if self.stuck then - --lets allow the arrow to tip a bit into the thing - self.pos.x = self.pos.x + self.vel.x / 5 - self.pos.y = self.pos.y + self.vel.y / 5 - self.vel.x = 0 - self.vel.y = 0 - self.illuminated = false end end diff --git a/data/scripts/entities/fairy.lua b/data/scripts/entities/fairy.lua index b9c92e9..c06d042 100644 --- a/data/scripts/entities/fairy.lua +++ b/data/scripts/entities/fairy.lua @@ -50,8 +50,8 @@ end function Fairy:DoPhysics() - local random_x = math.random(-0.04,0.04) - local random_y = math.random(-0.04,0.04) + local random_x = math.random(-4, 4)/100 + local random_y = math.random(-4, 4)/100 self.vel.x = self.vel.x + random_x self.vel.y = self.vel.y + random_y -- move diff --git a/data/scripts/entities/kupo.lua b/data/scripts/entities/kupo.lua index 508a1f5..d0aff6b 100644 --- a/data/scripts/entities/kupo.lua +++ b/data/scripts/entities/kupo.lua @@ -69,9 +69,9 @@ function Kupo:Smart() self.bow_rotation = angle end - -- holding tight dispersion -- also affets arrows + -- holding tight dispersion -- also affects arrows if self.bow_rotation == angle then - self.bow_rotation = self.bow_rotation + math.rad(math.random(math.abs(self.bow_frame-self.bow_aim_frames-self.bow_frames)/2)) + self.bow_rotation = self.bow_rotation + math.rad(math.random(math.abs(math.floor(self.bow_frame-self.bow_aim_frames-self.bow_frames)/2))) end -- AIMING AI diff --git a/data/scripts/game.lua b/data/scripts/game.lua index 22174ef..e811436 100644 --- a/data/scripts/game.lua +++ b/data/scripts/game.lua @@ -1,5 +1,12 @@ function stepEditor() + palette = palette or false AnimateTiles() + if love.keyboard.isDown("tab") and not pressed then + if palette then palette = false else palette = true end + local pressed = true + else + pressed = false + end end function stepGame() @@ -28,6 +35,9 @@ function drawEditor() end gameworldDraw() + if palette then + paletteDraw() + end end function drawGame() @@ -91,3 +101,66 @@ function gameworldLighting() love.graphics.scale(1,1) DrawDarkness() end + +function paletteDraw() + local width = LevelData.tileset:getPixelWidth()/tileProperties.width + local height = LevelData.tileset:getPixelHeight()/tileProperties.height + + local position_x = 1 + local position_y = 1 + for i = 1, #TileIndex-width-1 do + + love.graphics.draw( + LevelData.tileset, + TileIndex[i], + position_x * tileProperties.width*2, + (--[[p_scroll +]]position_y) * tileProperties.height*2, + 0, + 2, + 2 + ) + position_x = position_x + 1 + + if position_x > width then + position_x = position_x - width + position_y = position_y + 1 + end + end + + love.graphics.rectangle( + "line", + tileProperties.width*2, + (--[[p_scroll +]] 1) * tileProperties.height*2, + 2*LevelData.tileset:getPixelWidth(), + 2*LevelData.tileset:getPixelHeight() + ) +end +--[[ +function DrawSelectingPaletteTile() + if selecting_tile ~= nil then + local width = TileProperties.tileset:getPixelWidth()/TileProperties.width + local height = TileProperties.tileset:getPixelHeight()/TileProperties.height + + local positionx = 1 + local positiony = 1 + + for i = 1, #Tile-12 do + if i == selecting_tile then + love.graphics.rectangle( + "line", + positionx * TileProperties.width*2, + (p_scroll + positiony) * TileProperties.height*2, + TileProperties.width*2-1, + TileProperties.height*2-1 + ) + end + + positionx = positionx + 1 + + if positionx > width then + positionx = positionx - width + positiony = positiony + 1 + end + end + end +end]] diff --git a/data/scripts/lights.lua b/data/scripts/lights.lua index 48d2349..0e81773 100644 --- a/data/scripts/lights.lua +++ b/data/scripts/lights.lua @@ -19,6 +19,7 @@ function CreateLight(x,y,range,lum,flicker) o.flicker_speed = flicker_speed or 60/12 o.flicker_time = 0 table.insert(Lights,o) + return o end -- 2.39.2 From ecebca515cc9333a625fceb7c2b6c1a54700031c Mon Sep 17 00:00:00 2001 From: bizcochito Date: Tue, 18 Jan 2022 21:09:33 +0100 Subject: [PATCH 5/7] merge --- main.lua | 146 ------------------------------------------------------- 1 file changed, 146 deletions(-) diff --git a/main.lua b/main.lua index a528a3f..e5e0ed8 100644 --- a/main.lua +++ b/main.lua @@ -141,149 +141,3 @@ function love.draw() drawGame() end end -======= -function love.load() - arrow = 0 - - do_pause = false - - debug = false - debug_collision = false - editor_mode = false - - textScale = 1 - fps_count = 0 - fps_second = 0 - fps_draw = 0 - fps_total = 0 - - love.graphics.setColor(1,1,1) - love.keyboard.setKeyRepeat(true) - love.graphics.setDefaultFilter("nearest") -- good pixel - - game = { - scale = 2, - width = love.graphics.getWidth(), - height = love.graphics.getHeight(), - paused = false - } - - require "data/scripts" - Canvas = { - Darkness = CreateDarkness() - } - love.graphics.setCanvas(Canvas.Darkness) - SetDarkness() - love.graphics.setCanvas() - - Camera.width = game.width - Camera.height = game.height - - levelList = {"level1","2","3","ewae","tileset"} - levelNum = 1 - currLevel = levelList[levelNum] - LoadedEntities = {} - LevelLoadTiles() - - main_Player = Player:New(75,50) - - table.insert(LoadedEntities,main_Player) - table.insert(LoadedEntities,Kupo:New(100,150)) - table.insert(LoadedEntities,Kupo:New(300,150)) - table.insert(LoadedEntities,Decoration:New(200,89,animation.decoration.candelabra,80)) - table.insert(LoadedEntities,Fairy:New(200,88)) - - gravity = 0.2 -end - -function love.update(dt) - -- fps counter - if fps_second >= 1 then - fps_second = fps_second - 1 - fps_draw = fps_count - fps_count = 0 - fps_total = fps_total + 1 - end - fps_second = fps_second + dt - fps_count = fps_count + 1 - current_dt = dt - - - if editor_mode then - stepEditor() - else - stepGame() - end -end - - -function love.wheelmoved(_, y) - if editor_mode then - if palette then - p_scroll = p_scroll + y or 0 - else - local oscale = game.scale - game.scale = math.max(0.1,game.scale + y/16) - end - end -end - -function love.keypressed(key) - if key == "escape" then - if do_pause then - do_pause = false - else - pausepage = 1 - do_pause = true - end - end - - if key == "f1" then - if debug then - debug = false - debug_collision = true - elseif debug_collision then - debug_collision = false - else - debug = true - end - end - - if key == "f2" then - if editor_mode then - - else - main_Player.pos.x, main_Player.pos.y = 16,-10 - end - end - - if key == "f3" then - LoadLevel() - end - - if key == "f4" then - if editor_mode then - editor_mode = false - else - editor_mode = true - end - end -end - -function love.draw() - if game.width ~= love.graphics.getWidth() or game.height ~= love.graphics.getHeight() then - game.width = love.graphics.getWidth() - game.height = love.graphics.getHeight() - game_resize = true - else - game_resize = false - end - - if editor_mode then - drawEditor() - else - drawGame() - end - love.graphics.print(arrow,10,40) -end ->>>>>>> 5f0256e0afc22c4f091fb621b7ff06b7d3be79c7 -- 2.39.2 From 2b48358ce732806a3743d6a6cebc490a6c581671 Mon Sep 17 00:00:00 2001 From: bizcochito Date: Tue, 18 Jan 2022 21:11:11 +0100 Subject: [PATCH 6/7] merge --- main.lua | 146 ------------------------------------------------------- 1 file changed, 146 deletions(-) diff --git a/main.lua b/main.lua index a528a3f..e5e0ed8 100644 --- a/main.lua +++ b/main.lua @@ -141,149 +141,3 @@ function love.draw() drawGame() end end -======= -function love.load() - arrow = 0 - - do_pause = false - - debug = false - debug_collision = false - editor_mode = false - - textScale = 1 - fps_count = 0 - fps_second = 0 - fps_draw = 0 - fps_total = 0 - - love.graphics.setColor(1,1,1) - love.keyboard.setKeyRepeat(true) - love.graphics.setDefaultFilter("nearest") -- good pixel - - game = { - scale = 2, - width = love.graphics.getWidth(), - height = love.graphics.getHeight(), - paused = false - } - - require "data/scripts" - Canvas = { - Darkness = CreateDarkness() - } - love.graphics.setCanvas(Canvas.Darkness) - SetDarkness() - love.graphics.setCanvas() - - Camera.width = game.width - Camera.height = game.height - - levelList = {"level1","2","3","ewae","tileset"} - levelNum = 1 - currLevel = levelList[levelNum] - LoadedEntities = {} - LevelLoadTiles() - - main_Player = Player:New(75,50) - - table.insert(LoadedEntities,main_Player) - table.insert(LoadedEntities,Kupo:New(100,150)) - table.insert(LoadedEntities,Kupo:New(300,150)) - table.insert(LoadedEntities,Decoration:New(200,89,animation.decoration.candelabra,80)) - table.insert(LoadedEntities,Fairy:New(200,88)) - - gravity = 0.2 -end - -function love.update(dt) - -- fps counter - if fps_second >= 1 then - fps_second = fps_second - 1 - fps_draw = fps_count - fps_count = 0 - fps_total = fps_total + 1 - end - fps_second = fps_second + dt - fps_count = fps_count + 1 - current_dt = dt - - - if editor_mode then - stepEditor() - else - stepGame() - end -end - - -function love.wheelmoved(_, y) - if editor_mode then - if palette then - p_scroll = p_scroll + y or 0 - else - local oscale = game.scale - game.scale = math.max(0.1,game.scale + y/16) - end - end -end - -function love.keypressed(key) - if key == "escape" then - if do_pause then - do_pause = false - else - pausepage = 1 - do_pause = true - end - end - - if key == "f1" then - if debug then - debug = false - debug_collision = true - elseif debug_collision then - debug_collision = false - else - debug = true - end - end - - if key == "f2" then - if editor_mode then - - else - main_Player.pos.x, main_Player.pos.y = 16,-10 - end - end - - if key == "f3" then - LoadLevel() - end - - if key == "f4" then - if editor_mode then - editor_mode = false - else - editor_mode = true - end - end -end - -function love.draw() - if game.width ~= love.graphics.getWidth() or game.height ~= love.graphics.getHeight() then - game.width = love.graphics.getWidth() - game.height = love.graphics.getHeight() - game_resize = true - else - game_resize = false - end - - if editor_mode then - drawEditor() - else - drawGame() - end - love.graphics.print(arrow,10,40) -end ->>>>>>> 5f0256e0afc22c4f091fb621b7ff06b7d3be79c7 -- 2.39.2 From a183dac9132eab1e75442916540de6729d0ecd33 Mon Sep 17 00:00:00 2001 From: bizcochito Date: Tue, 18 Jan 2022 21:12:13 +0100 Subject: [PATCH 7/7] merge --- main.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.lua b/main.lua index e5e0ed8..50d0f25 100644 --- a/main.lua +++ b/main.lua @@ -1,5 +1,5 @@ -<<<<<<< HEAD function love.load() + arrow = 0 do_pause = false @@ -49,7 +49,7 @@ function love.load() table.insert(LoadedEntities,Decoration:New(200,89,animation.decoration.candelabra,80)) table.insert(LoadedEntities,Fairy:New(200,88)) - gravity = 0.05 + gravity = 0.2 end function love.update(dt) @@ -76,7 +76,7 @@ end function love.wheelmoved(_, y) if editor_mode then if palette then - p_scroll = p_scroll + y + p_scroll = p_scroll + y or 0 else local oscale = game.scale game.scale = math.max(0.1,game.scale + y/16) @@ -140,4 +140,5 @@ function love.draw() else drawGame() end + love.graphics.print(arrow,10,40) end -- 2.39.2