diff --git a/assets/characters/decoration/candelabra1.png b/assets/characters/decoration/candelabra1.png new file mode 100644 index 0000000..faaaed6 Binary files /dev/null and b/assets/characters/decoration/candelabra1.png differ diff --git a/assets/characters/decoration/candelabra2.png b/assets/characters/decoration/candelabra2.png new file mode 100644 index 0000000..a8e3cc6 Binary files /dev/null and b/assets/characters/decoration/candelabra2.png differ diff --git a/assets/characters/decoration/candelabra3.png b/assets/characters/decoration/candelabra3.png new file mode 100644 index 0000000..9e3b93b Binary files /dev/null and b/assets/characters/decoration/candelabra3.png differ diff --git a/assets/characters/decoration/candelabra4.png b/assets/characters/decoration/candelabra4.png new file mode 100644 index 0000000..4f2cc1d Binary files /dev/null and b/assets/characters/decoration/candelabra4.png differ diff --git a/assets/characters/decoration/candelabra5.png b/assets/characters/decoration/candelabra5.png new file mode 100644 index 0000000..f49b4c0 Binary files /dev/null and b/assets/characters/decoration/candelabra5.png differ diff --git a/assets/characters/decoration/candelabra6.png b/assets/characters/decoration/candelabra6.png new file mode 100644 index 0000000..7728183 Binary files /dev/null and b/assets/characters/decoration/candelabra6.png differ diff --git a/assets/characters/decoration/candelabra7.png b/assets/characters/decoration/candelabra7.png new file mode 100644 index 0000000..9e3b93b Binary files /dev/null and b/assets/characters/decoration/candelabra7.png differ diff --git a/assets/characters/decoration/candelabra8.png b/assets/characters/decoration/candelabra8.png new file mode 100644 index 0000000..4a45f06 Binary files /dev/null and b/assets/characters/decoration/candelabra8.png differ diff --git a/assets/characters/fairy/flying1.png b/assets/characters/fairy/flying1.png new file mode 100644 index 0000000..24fc77f Binary files /dev/null and b/assets/characters/fairy/flying1.png differ diff --git a/assets/characters/fairy/flying2.png b/assets/characters/fairy/flying2.png new file mode 100644 index 0000000..bc77f8b Binary files /dev/null and b/assets/characters/fairy/flying2.png differ diff --git a/assets/characters/kupo/kupo1.png b/assets/characters/kupo/kupo1.png index 2224a29..7c2bb42 100644 Binary files a/assets/characters/kupo/kupo1.png and b/assets/characters/kupo/kupo1.png differ diff --git a/assets/characters/kupo/kupo2.png b/assets/characters/kupo/kupo2.png index 6f86f95..b054ed7 100644 Binary files a/assets/characters/kupo/kupo2.png and b/assets/characters/kupo/kupo2.png differ diff --git a/assets/characters/kupo/kupo3.png b/assets/characters/kupo/kupo3.png index fb04a2a..caa2541 100644 Binary files a/assets/characters/kupo/kupo3.png and b/assets/characters/kupo/kupo3.png differ diff --git a/assets/characters/kupo/kupo4.png b/assets/characters/kupo/kupo4.png index da424a2..61f6f5e 100644 Binary files a/assets/characters/kupo/kupo4.png and b/assets/characters/kupo/kupo4.png differ diff --git a/assets/characters/kupo/kupo_arrow1.png b/assets/characters/kupo/kupo_arrow1.png index 36614ea..cc93e38 100644 Binary files a/assets/characters/kupo/kupo_arrow1.png and b/assets/characters/kupo/kupo_arrow1.png differ diff --git a/assets/characters/kupo/kupo_bow1.png b/assets/characters/kupo/kupo_bow1.png index b912b83..6ebad6a 100644 Binary files a/assets/characters/kupo/kupo_bow1.png and b/assets/characters/kupo/kupo_bow1.png differ diff --git a/assets/characters/kupo/kupo_bow2.png b/assets/characters/kupo/kupo_bow2.png index 50b6321..6b50fe7 100644 Binary files a/assets/characters/kupo/kupo_bow2.png and b/assets/characters/kupo/kupo_bow2.png differ diff --git a/assets/characters/kupo/kupo_bow3.png b/assets/characters/kupo/kupo_bow3.png index 0f94d4d..16dcc5a 100644 Binary files a/assets/characters/kupo/kupo_bow3.png and b/assets/characters/kupo/kupo_bow3.png differ diff --git a/assets/characters/kupo/kupo_bow4.png b/assets/characters/kupo/kupo_bow4.png index 292407e..d3bb1fe 100644 Binary files a/assets/characters/kupo/kupo_bow4.png and b/assets/characters/kupo/kupo_bow4.png differ diff --git a/assets/characters/kupo/kupo_bow5.png b/assets/characters/kupo/kupo_bow5.png index f8c5369..5e6bfa5 100644 Binary files a/assets/characters/kupo/kupo_bow5.png and b/assets/characters/kupo/kupo_bow5.png differ diff --git a/assets/characters/kupo/kupo_bow6.png b/assets/characters/kupo/kupo_bow6.png index 0483185..bac1bb3 100644 Binary files a/assets/characters/kupo/kupo_bow6.png and b/assets/characters/kupo/kupo_bow6.png differ diff --git a/assets/characters/nancy/fall1.png b/assets/characters/nancy/fall1.png index c673723..72f8f45 100644 Binary files a/assets/characters/nancy/fall1.png and b/assets/characters/nancy/fall1.png differ diff --git a/assets/characters/nancy/fall2.png b/assets/characters/nancy/fall2.png index f082e9a..1cc9626 100644 Binary files a/assets/characters/nancy/fall2.png and b/assets/characters/nancy/fall2.png differ diff --git a/assets/characters/nancy/fall3.png b/assets/characters/nancy/fall3.png index a1d10fd..81a10d2 100644 Binary files a/assets/characters/nancy/fall3.png and b/assets/characters/nancy/fall3.png differ diff --git a/assets/characters/nancy/idle1.png b/assets/characters/nancy/idle1.png index 4771efe..8b4f766 100644 Binary files a/assets/characters/nancy/idle1.png and b/assets/characters/nancy/idle1.png differ diff --git a/assets/characters/nancy/idle2.png b/assets/characters/nancy/idle2.png index 2a42d74..d611083 100644 Binary files a/assets/characters/nancy/idle2.png and b/assets/characters/nancy/idle2.png differ diff --git a/assets/characters/nancy/idle3.png b/assets/characters/nancy/idle3.png index f4da759..d8462de 100644 Binary files a/assets/characters/nancy/idle3.png and b/assets/characters/nancy/idle3.png differ diff --git a/assets/characters/nancy/idle4.png b/assets/characters/nancy/idle4.png index 7d90e55..b0fe12c 100644 Binary files a/assets/characters/nancy/idle4.png and b/assets/characters/nancy/idle4.png differ diff --git a/assets/characters/nancy/jump1.png b/assets/characters/nancy/jump1.png index 46a3605..e132221 100644 Binary files a/assets/characters/nancy/jump1.png and b/assets/characters/nancy/jump1.png differ diff --git a/assets/characters/nancy/jump2.png b/assets/characters/nancy/jump2.png index 446ff22..075740c 100644 Binary files a/assets/characters/nancy/jump2.png and b/assets/characters/nancy/jump2.png differ diff --git a/assets/characters/nancy/jump3.png b/assets/characters/nancy/jump3.png index 6e32136..a4a625e 100644 Binary files a/assets/characters/nancy/jump3.png and b/assets/characters/nancy/jump3.png differ diff --git a/assets/characters/nancy/moth_mask/fall1.png b/assets/characters/nancy/moth_mask/fall1.png index 926ca8a..3036448 100644 Binary files a/assets/characters/nancy/moth_mask/fall1.png and b/assets/characters/nancy/moth_mask/fall1.png differ diff --git a/assets/characters/nancy/moth_mask/fall2.png b/assets/characters/nancy/moth_mask/fall2.png index 926ca8a..3036448 100644 Binary files a/assets/characters/nancy/moth_mask/fall2.png and b/assets/characters/nancy/moth_mask/fall2.png differ diff --git a/assets/characters/nancy/moth_mask/fall3.png b/assets/characters/nancy/moth_mask/fall3.png index 926ca8a..3036448 100644 Binary files a/assets/characters/nancy/moth_mask/fall3.png and b/assets/characters/nancy/moth_mask/fall3.png differ diff --git a/assets/characters/nancy/moth_mask/idle1.png b/assets/characters/nancy/moth_mask/idle1.png index 926ca8a..3036448 100644 Binary files a/assets/characters/nancy/moth_mask/idle1.png and b/assets/characters/nancy/moth_mask/idle1.png differ diff --git a/assets/characters/nancy/moth_mask/idle2.png b/assets/characters/nancy/moth_mask/idle2.png index 926ca8a..3036448 100644 Binary files a/assets/characters/nancy/moth_mask/idle2.png and b/assets/characters/nancy/moth_mask/idle2.png differ diff --git a/assets/characters/nancy/moth_mask/idle3.png b/assets/characters/nancy/moth_mask/idle3.png index 926ca8a..3036448 100644 Binary files a/assets/characters/nancy/moth_mask/idle3.png and b/assets/characters/nancy/moth_mask/idle3.png differ diff --git a/assets/characters/nancy/moth_mask/idle4.png b/assets/characters/nancy/moth_mask/idle4.png index 926ca8a..3036448 100644 Binary files a/assets/characters/nancy/moth_mask/idle4.png and b/assets/characters/nancy/moth_mask/idle4.png differ diff --git a/assets/characters/nancy/moth_mask/jump1.png b/assets/characters/nancy/moth_mask/jump1.png index 284391c..d0c01d7 100644 Binary files a/assets/characters/nancy/moth_mask/jump1.png and b/assets/characters/nancy/moth_mask/jump1.png differ diff --git a/assets/characters/nancy/moth_mask/jump2.png b/assets/characters/nancy/moth_mask/jump2.png index 284391c..d0c01d7 100644 Binary files a/assets/characters/nancy/moth_mask/jump2.png and b/assets/characters/nancy/moth_mask/jump2.png differ diff --git a/assets/characters/nancy/moth_mask/jump3.png b/assets/characters/nancy/moth_mask/jump3.png index 284391c..d0c01d7 100644 Binary files a/assets/characters/nancy/moth_mask/jump3.png and b/assets/characters/nancy/moth_mask/jump3.png differ diff --git a/assets/characters/nancy/moth_mask/run1.png b/assets/characters/nancy/moth_mask/run1.png index 0ce1a95..fbd086c 100644 Binary files a/assets/characters/nancy/moth_mask/run1.png and b/assets/characters/nancy/moth_mask/run1.png differ diff --git a/assets/characters/nancy/moth_mask/run2.png b/assets/characters/nancy/moth_mask/run2.png index ee7afb4..559c189 100644 Binary files a/assets/characters/nancy/moth_mask/run2.png and b/assets/characters/nancy/moth_mask/run2.png differ diff --git a/assets/characters/nancy/moth_mask/run3.png b/assets/characters/nancy/moth_mask/run3.png index ee7afb4..559c189 100644 Binary files a/assets/characters/nancy/moth_mask/run3.png and b/assets/characters/nancy/moth_mask/run3.png differ diff --git a/assets/characters/nancy/moth_mask/run4.png b/assets/characters/nancy/moth_mask/run4.png index 0ce1a95..fbd086c 100644 Binary files a/assets/characters/nancy/moth_mask/run4.png and b/assets/characters/nancy/moth_mask/run4.png differ diff --git a/assets/characters/nancy/moth_mask/run5.png b/assets/characters/nancy/moth_mask/run5.png index ee7afb4..559c189 100644 Binary files a/assets/characters/nancy/moth_mask/run5.png and b/assets/characters/nancy/moth_mask/run5.png differ diff --git a/assets/characters/nancy/moth_mask/run6.png b/assets/characters/nancy/moth_mask/run6.png index ee7afb4..559c189 100644 Binary files a/assets/characters/nancy/moth_mask/run6.png and b/assets/characters/nancy/moth_mask/run6.png differ diff --git a/assets/characters/nancy/run1.png b/assets/characters/nancy/run1.png index c4619d8..451f07e 100644 Binary files a/assets/characters/nancy/run1.png and b/assets/characters/nancy/run1.png differ diff --git a/assets/characters/nancy/run2.png b/assets/characters/nancy/run2.png index 64e3c5f..fbba558 100644 Binary files a/assets/characters/nancy/run2.png and b/assets/characters/nancy/run2.png differ diff --git a/assets/characters/nancy/run3.png b/assets/characters/nancy/run3.png index 3606397..fd4b45c 100644 Binary files a/assets/characters/nancy/run3.png and b/assets/characters/nancy/run3.png differ diff --git a/assets/characters/nancy/run4.png b/assets/characters/nancy/run4.png index 7470db7..11a68d1 100644 Binary files a/assets/characters/nancy/run4.png and b/assets/characters/nancy/run4.png differ diff --git a/assets/characters/nancy/run5.png b/assets/characters/nancy/run5.png index 786e84b..f65bb0f 100644 Binary files a/assets/characters/nancy/run5.png and b/assets/characters/nancy/run5.png differ diff --git a/assets/characters/nancy/run6.png b/assets/characters/nancy/run6.png index 7a3b757..717d493 100644 Binary files a/assets/characters/nancy/run6.png and b/assets/characters/nancy/run6.png differ diff --git a/assets/tileset/books.png b/assets/tileset/books.png index bde318d..c558133 100644 Binary files a/assets/tileset/books.png and b/assets/tileset/books.png differ diff --git a/assets/tileset/library.png b/assets/tileset/library.png index e1814ea..a4ffe16 100644 Binary files a/assets/tileset/library.png and b/assets/tileset/library.png differ diff --git a/assets/ui/heonian.png b/assets/ui/heonian.png new file mode 100644 index 0000000..9e1ff02 Binary files /dev/null and b/assets/ui/heonian.png differ diff --git a/data/levels/level1.lua b/data/levels/level1.lua index bd8aeeb..d426457 100644 --- a/data/levels/level1.lua +++ b/data/levels/level1.lua @@ -2,15 +2,13 @@ return { name = "level1", tileset = tileset.library, tiles = { - { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13}, { }, { 0, 0, 0, 0, 0, 0, 5,25,26, 6,25,26, 7, 0, 5,25,26, 7}, { 0, 0, 0, 0, 0, 0, 5,37,38, 6,37,38, 7, 0, 5,37,38, 7}, { 0, 0, 0, 0, 0, 0, 5,37,38, 6,37,38, 7, 0, 5,37,38, 7}, { 0, 0, 0, 0, 0, 0, 5,49,50, 6,49,50, 7, 0, 5,49,50, 7}, - { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, - {13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13}, + { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} }, objects = {} } diff --git a/data/scripts.lua b/data/scripts.lua index 223faa5..176c3b7 100644 --- a/data/scripts.lua +++ b/data/scripts.lua @@ -16,4 +16,5 @@ require "data/scripts/lights" require "data/scripts/objects" -- UI functions require "data/scripts/debug" +require "data/scripts/keybind" require "data/scripts/pause" diff --git a/data/scripts/animation.lua b/data/scripts/animation.lua index 5ebe669..d3a82fc 100644 --- a/data/scripts/animation.lua +++ b/data/scripts/animation.lua @@ -34,8 +34,8 @@ function Animation:DrawFrame(frame, x, y, rotate, sx, sy) local sy = sy or 1 love.graphics.draw( self.imgs[frame], - x - Camera.pos.x, - y - Camera.pos.y, + math.floor(x - Camera.pos.x), + math.floor(y - Camera.pos.y), rotate, sx, sy @@ -66,8 +66,8 @@ function Animation:Draw(x, y, rotate, sx, sy) local sy = sy or 1 love.graphics.draw( self.imgs[self.frame], - x, - y, + math.floor(x), + math.floor(y), rotate, sx, sy diff --git a/data/scripts/debug.lua b/data/scripts/debug.lua index 40c91eb..ad9a3a9 100644 --- a/data/scripts/debug.lua +++ b/data/scripts/debug.lua @@ -37,12 +37,13 @@ function DebugEntities() love.graphics.setColor(0,1,0) love.graphics.circle("fill", -Camera.pos.x + enty.pos.x, -Camera.pos.y + enty.pos.y, 1) -- draw collision box PURPLE - love.graphics.setColor(0,1,1) - love.graphics.points( - -Camera.pos.x + enty.pos.x + enty.boxCollision.from.x, -Camera.pos.y + enty.pos.y + enty.boxCollision.from.y, - -Camera.pos.x + enty.pos.x + enty.boxCollision.from.x, -Camera.pos.y + enty.pos.y + enty.boxCollision.to.y, - -Camera.pos.x + enty.pos.x + enty.boxCollision.to.x, -Camera.pos.y + enty.pos.y + enty.boxCollision.from.y, - -Camera.pos.x + enty.pos.x + enty.boxCollision.to.x, -Camera.pos.y + enty.pos.y + enty.boxCollision.to.y + love.graphics.setColor(1,0,1) + love.graphics.rectangle( + "line", + -Camera.pos.x + enty.pos.x + enty.boxCollision.from.x, + -Camera.pos.y + enty.pos.y + enty.boxCollision.from.y, + -Camera.pos.x + enty.pos.x + enty.boxCollision.to.x -(-Camera.pos.x + enty.pos.x + enty.boxCollision.from.x), + -Camera.pos.y + enty.pos.y + enty.boxCollision.to.y -(-Camera.pos.y + enty.pos.y + enty.boxCollision.from.y) ) end end diff --git a/data/scripts/entities/arrow.lua b/data/scripts/entities/arrow.lua index f9bc79c..bb2a8ab 100644 --- a/data/scripts/entities/arrow.lua +++ b/data/scripts/entities/arrow.lua @@ -28,13 +28,7 @@ function Arrow:Smart() end function Arrow:HandleAnimation() - self.body:Draw( - self.pos.x - Camera.pos.x - ( (self.sprite_offset.x) * math.cos(self.sprite_rotation) - (self.sprite_offset.y) * math.sin(self.sprite_rotation)) * self.sprite_scale.x * self.sprite_flip.x, - self.pos.y - Camera.pos.y - ( (self.sprite_offset.x) * math.sin(self.sprite_rotation) + (self.sprite_offset.y) * math.cos(self.sprite_rotation)) * self.sprite_scale.y * self.sprite_flip.y, - self.sprite_rotation, - self.sprite_scale.x * self.sprite_flip.x, - self.sprite_scale.y * self.sprite_flip.y - ) + self:Draw(self.body) end function Arrow:DoPhysics() diff --git a/data/scripts/entities/decoration.lua b/data/scripts/entities/decoration.lua new file mode 100644 index 0000000..b02e519 --- /dev/null +++ b/data/scripts/entities/decoration.lua @@ -0,0 +1,33 @@ +Decoration = Entity:New(x,y) + +function Decoration:New(x,y,animation,lightRange) + local o = Entity:New(x,y) + + o.pos = {x = x, y = y} + + -- animations + o.body = Animation:New(animation) + o:centerOffset(o.body) + o:getBoundingBox(o.body) + + if lightRange ~= nil then + o.lightRange = lightRange + o.light = CreateLight(o.pos.x,o.pos.y,o.lightRange,nil,60/6) + end + + setmetatable(o, self) + self.__index = self + + return o + end + +function Decoration:Smart() +end + +function Decoration:HandleAnimation() + self.body:Animate() + self:Draw(self.body) +end + +function Decoration:DoPhysics() +end diff --git a/data/scripts/entities/fairy.lua b/data/scripts/entities/fairy.lua new file mode 100644 index 0000000..b656fed --- /dev/null +++ b/data/scripts/entities/fairy.lua @@ -0,0 +1,64 @@ +Fairy = Entity:New(x,y) + + function Fairy:New(x,y) + local o = Entity:New(x,y) + + o.pos = {x = x, y = y} + o.speed = 0.23 + o.range = 20 + o.target = {x = x, y = y} + + -- animations + o.body = Animation:New(animation.fairy.flying) + o:centerOffset(o.body) + o:getBoundingBox(o.body) + + + o.lightRange = 1155 + o.light = CreateLight(o.pos.x,o.pos.y,o.lightRange) + + setmetatable(o, self) + self.__index = self + + return o + end + +function Fairy:Smart() + self.light.pos.x = self.pos.x-self.target_offset.x + self.light.pos.y = self.pos.y-self.target_offset.y + + self.target.x = main_Player.pos.x - main_Player.target_offset.x + self.target.y = main_Player.pos.y - main_Player.target_offset.y - 10 + local distance_x = self.target.x - self.pos.x + local distance_y = self.target.y - self.pos.y + local distance = math.sqrt(distance_x ^ 2 + distance_y ^ 2) + local angle = GetAngleFromVector(distance_x,distance_y) + if distance < self.range then + self.vel.x = 0 + self.vel.y = 0 + else + self.vel.x = math.cos(angle)*self.speed*distance/(8*game.scale) + self.vel.y = math.sin(angle)*self.speed*distance/(8*game.scale) + end +end + +function Fairy:HandleAnimation() + self.body:Animate() + --if self:isCollidingWith(main_Player) then self.sprite_tint = {1,0,0} else self.sprite_tint = {1,1,1} end + self:Draw(self.body) +end + +function Fairy:DoPhysics() + + local random_x = math.random(-0.04,0.04) + local random_y = math.random(-0.04,0.04) + self.vel.x = self.vel.x + random_x + self.vel.y = self.vel.y + random_y + -- move + if not self:isCollidingAt(self.pos.x + self.vel.x, self.pos.y, objects.collisions) then + self.pos.x = self.pos.x + self.vel.x + end + if not self:isCollidingAt(self.pos.x, self.pos.y + self.vel.y, objects.collisions) then + self.pos.y = self.pos.y + self.vel.y + end +end diff --git a/data/scripts/entities/kupo.lua b/data/scripts/entities/kupo.lua index 0ca1b62..508a1f5 100644 --- a/data/scripts/entities/kupo.lua +++ b/data/scripts/entities/kupo.lua @@ -25,7 +25,7 @@ Kupo = Entity:New(x,y) o.bow_aim_frames = 8 o.hostile = true - o.lightRange = o.range/10 + o.lightRange = o.range/2 o.light = CreateLight(o.pos.x,o.pos.y,o.lightRange) setmetatable(o, self) @@ -35,23 +35,17 @@ Kupo = Entity:New(x,y) end function Kupo:Smart() + self.light.pos.x = self.pos.x-self.target_offset.x + self.light.pos.y = self.pos.y-self.target_offset.y self.target.x = main_Player.pos.x - main_Player.target_offset.x self.target.y = main_Player.pos.y - main_Player.target_offset.y local distance_x = self.target.x - self.pos.x local distance_y = self.target.y - self.pos.y local distance = math.sqrt(distance_x ^ 2 + distance_y ^ 2) - local angle = math.atan(distance_y/distance_x) + local angle = GetAngleFromVector(distance_x,distance_y) self.draw_bow = false if distance <= self.range then - - if distance_x > 0 then - self.sprite_flip.x = 1 - else - angle = angle + math.rad(180) - self.sprite_flip.x = -1 - end - if self.hostile == true then self.draw_bow = true -- fix so it can rotate from 0 to 360 @@ -133,26 +127,29 @@ function Kupo:Smart() end function Kupo:HandleAnimation() - -- flip sprite to look in the direction is moving - if self.vel.x ~= 0 then self.sprite_flip.x = math.sign(self.vel.x) end + local distance_x = self.target.x - self.pos.x + local distance_y = self.target.y - self.pos.y - self.body:Animate() - self.body:Draw( - self.pos.x - Camera.pos.x - ( (self.sprite_offset.x) * math.cos(self.sprite_rotation) - (self.sprite_offset.y) * math.sin(self.sprite_rotation)) * self.sprite_scale.x * self.sprite_flip.x, - self.pos.y - Camera.pos.y - ( (self.sprite_offset.x) * math.sin(self.sprite_rotation) + (self.sprite_offset.y) * math.cos(self.sprite_rotation)) * self.sprite_scale.y * self.sprite_flip.y, - self.sprite_rotation, - self.sprite_scale.x * self.sprite_flip.x, - self.sprite_scale.y * self.sprite_flip.y - ) + if distance_x > 0 then + self.sprite_flip.x = 1 + else + self.sprite_flip.x = -1 + end - if self.draw_bow == true then - self.bow:DrawFrame( - math.min(self.bow_frame,self.bow_frames), - self.pos.x + ( 8 * math.sin(self.bow_rotation)), - self.pos.y + (2 - 6 * math.cos(self.bow_rotation)), - self.bow_rotation - ) - end + -- flip sprite to look in the direction is moving + if self.vel.x ~= 0 then self.sprite_flip.x = math.sign(self.vel.x) end + + self.body:Animate() + self:Draw(self.body) + + if self.draw_bow == true then + self.bow:DrawFrame( + math.min(self.bow_frame,self.bow_frames), + self.pos.x + ( 8 * math.sin(self.bow_rotation)), + self.pos.y + (2 - 6 * math.cos(self.bow_rotation)), + self.bow_rotation + ) + end end function Kupo:DoPhysics() diff --git a/data/scripts/entities/player.lua b/data/scripts/entities/player.lua index f3da319..4077548 100644 --- a/data/scripts/entities/player.lua +++ b/data/scripts/entities/player.lua @@ -7,15 +7,33 @@ Player.coins = 0 -- physics - o.moveSpeed = 1.5 + o.moveSpeed = 1.3 + o.zeroSpeed = 0.01 + o.move_x = 0 + + o.airFriction = 0.01 + o.groundFriction = 0.3 + + o.jumpImpulse = 3.5 + + o.dashCooldownTime = 0.1 + o.dashCooldownTimer = 0 + + o.dashTimer = 0 + o.dashTime = 0.15 + o.dashDistance = 40 + o.dashSpeed = o.dashDistance / (o.dashTime*60) + o.dashCount = 1 o.boxCollision = { from = {x = -8, y = -16}, to = {x = 8, y = 0} } - o.lightRange = 32 + o.lightRange = 0--32 + -- status + o.isDashing = false o.isJumping = false o.isOnGround = 0 o.coyoteValue = 5 @@ -26,10 +44,11 @@ o.maskType = animation.moth_mask -- sprite - o.sprite_offset = {x = 8, y = 16} o.target_offset = {x = 0, y = 12} o.body = Animation:New(animation.nancy.idle) o.mask = Animation:New(animation.moth_mask.idle) + o:centerOffset(o.body) + o:getBoundingBox(o.body, 3,-3,0,-1) -- lights o.light = CreateLight(o.pos.x,o.pos.y,o.lightRange) @@ -41,25 +60,100 @@ end function Player:Smart() - if love.keyboard.isDown("a") then self.vel.x = -self.moveSpeed - elseif love.keyboard.isDown("d") then self.vel.x = self.moveSpeed - else self.vel.x = 0 end - if love.keyboard.isDown("w") then self.vel.y = -self.moveSpeed - elseif love.keyboard.isDown("s") then self.vel.y = self.moveSpeed - else self.vel.y = 0 end -end - -function Player:DoPhysics() - self.pos.x = self.pos.x + self.vel.x - self.pos.y = self.pos.y + self.vel.y -end - -function Player:HandleAnimation() + -- light self.light.pos.x = self.pos.x-self.target_offset.x self.light.pos.y = self.pos.y-self.target_offset.y + if self.dashTimer <= 0 then + if self.isOnGround then + self.vel.x = self.vel.x * (1-self.groundFriction) + else + self.vel.x = self.vel.x * (1-self.airFriction) + end + + if math.abs(self.vel.x) < self.zeroSpeed then self.vel.x = 0 end + + if love.keyboard.isDown(keybind.moveLeft) then + self.move_x = -self.moveSpeed + elseif love.keyboard.isDown(keybind.moveRight) then + self.move_x = self.moveSpeed + else + self.move_x = 0 + end + self.vel.x = self.vel.x + + if love.keyboard.isDown(keybind.moveJump) then + if self.isOnGround then + self.vel.y = -self.jumpImpulse + end + end + end + + self.dashCooldownTimer = math.max(0,self.dashCooldownTimer - current_dt) + if love.keyboard.isDown(keybind.moveDash) 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 love.keyboard.isDown(keybind.moveDown) then vertical = vertical + 1 end + if love.keyboard.isDown(keybind.moveUp) then vertical = vertical - 1 end + local horizontal = 0 + if love.keyboard.isDown(keybind.moveRight) then horizontal = horizontal + 1 end + if love.keyboard.isDown(keybind.moveLeft) then horizontal = horizontal - 1 end + + if horizontal == 0 and vertical == 0 then + horizontal = self.sprite_flip.x + end + + self.dashDirection = GetAngleFromVector(horizontal, vertical) + self.dashTimer = self.dashTime + end + else + self.isDashing = false + end +end + +function Player:DoPhysics() + + self.isOnGround = false + + self.dashTimer = self.dashTimer - current_dt + if self.dashTimer > 0 then + self.dashCooldownTimer = self.dashCooldownTime + self.vel.x = self.dashSpeed * math.cos(self.dashDirection) + self.vel.y = self.dashSpeed * math.sin(self.dashDirection) + else + self.dashTimer = 0 + self.vel.y = self.vel.y + gravity + end + + if not self:isCollidingAt(self.pos.x + self.vel.x + self.move_x, self.pos.y, objects.collisions) then + self.pos.x = self.pos.x + self.vel.x + self.move_x + else + self.vel.x = 0 + end + + if not self:isCollidingAt(self.pos.x, self.pos.y + self.vel.y, objects.collisions) then + self.pos.y = self.pos.y + self.vel.y + else + if self.vel.y > 0 then + self.isOnGround = true + self.dashCount = 1 + self.vel.y = 0 + end + end +end + +function Player:HandleAnimation() + if self.dashTimer > 0 then + self.sprite_tint = {1,1,0} + else + self.sprite_tint = {1,1,1} + end -- flip sprite to look in the direction is moving - if self.vel.x ~= 0 then self.sprite_flip.x = math.sign(self.vel.x) end + if self.move_x ~= 0 then self.sprite_flip.x = math.sign(self.move_x) end -- animation priority if self.vel.y > 1.25 then @@ -68,7 +162,7 @@ function Player:HandleAnimation() elseif self.vel.y < 0 then self.body = self.body:ChangeTo(animation.nancy.jump) self.mask = self.mask:ChangeTo(self.maskType.jump) - elseif self.vel.x ~= 0 then + elseif self.vel.x + self.move_x ~= 0 then self.body = self.body:ChangeTo(animation.nancy.run) self.mask = self.mask:ChangeTo(self.maskType.run) else @@ -82,18 +176,8 @@ function Player:HandleAnimation() end self.body:Animate() - self.body:Draw( - math.floor(self.pos.x) - Camera.pos.x - ( (self.sprite_offset.x) * math.cos(self.sprite_rotation) - (self.sprite_offset.y) * math.sin(self.sprite_rotation)) * self.sprite_scale.x * self.sprite_flip.x, - math.floor(self.pos.y)- Camera.pos.y - ( (self.sprite_offset.x) * math.sin(self.sprite_rotation) + (self.sprite_offset.y) * math.cos(self.sprite_rotation)) * self.sprite_scale.y * self.sprite_flip.y, - self.sprite_rotation, - self.sprite_scale.x * self.sprite_flip.x, - self.sprite_scale.y * self.sprite_flip.y - ) - self.mask:Draw( - math.floor(self.pos.x) - Camera.pos.x - ( (self.sprite_offset.x) * math.cos(self.sprite_rotation) - (self.sprite_offset.y) * math.sin(self.sprite_rotation)) * self.sprite_scale.x * self.sprite_flip.x, - math.floor(self.pos.y)- Camera.pos.y - ( (self.sprite_offset.x) * math.sin(self.sprite_rotation) + (self.sprite_offset.y) * math.cos(self.sprite_rotation)) * self.sprite_scale.y * self.sprite_flip.y, - self.sprite_rotation, - self.sprite_scale.x * self.sprite_flip.x, - self.sprite_scale.y * self.sprite_flip.y - ) + self:Draw(self.body) + if self.dashCount > 0 then + self:Draw(self.mask) + end end diff --git a/data/scripts/entity.lua b/data/scripts/entity.lua index 3f6cb23..38ef0d8 100644 --- a/data/scripts/entity.lua +++ b/data/scripts/entity.lua @@ -1,5 +1,4 @@ -Entity = { - } +Entity = {class = "Entity"} function Entity:New(x,y) o = {} @@ -8,14 +7,14 @@ function Entity:New(x,y) o.boxCollision = { from = {x = x, y = y}, - to = {x = x, y = y} + to = {x = x, y = y}, } - o.class = "Entity" - + o.target_offset = {x = 0, y = 0} o.sprite_offset = {x = 0, y = 0} o.sprite_scale = {x = 1, y = 1} o.sprite_rotation = math.rad(0) + o.sprite_tint = {1,1,1} o.sprite_flip = { x = 1, y = 1} o.illuminated = false @@ -24,14 +23,45 @@ function Entity:New(x,y) return o end +function Entity:centerOffset(animation,x,y) + local x = x or 0 + local y = y or 0 + self.sprite_offset.x = animation.imgs[1]:getWidth()/2 + x + self.sprite_offset.y = animation.imgs[1]:getHeight()/2 + y +end + +function Entity:getBoundingBox(animation,left,right,top,bottom) + local left = left or 0 + local right = right or 0 + local top = top or 0 + local bottom = bottom or 0 + self.boxCollision.from.x = -animation.imgs[1]:getWidth()/2 + left + self.boxCollision.to.x = animation.imgs[1]:getWidth()/2 + right + self.boxCollision.from.y = -animation.imgs[1]:getHeight()/2 + top + self.boxCollision.to.y = animation.imgs[1]:getHeight()/2 + bottom +end + +function Entity:Draw(animation) + local c1, c2, c3, a = love.graphics.getColor() + love.graphics.setColor(self.sprite_tint[1],self.sprite_tint[2],self.sprite_tint[3]) + animation:Draw( + self.pos.x - Camera.pos.x - ( (self.sprite_offset.x) * math.cos(self.sprite_rotation) - (self.sprite_offset.y) * math.sin(self.sprite_rotation)) * self.sprite_scale.x * self.sprite_flip.x, + self.pos.y - Camera.pos.y - ( (self.sprite_offset.x) * math.sin(self.sprite_rotation) + (self.sprite_offset.y) * math.cos(self.sprite_rotation)) * self.sprite_scale.y * self.sprite_flip.y, + self.sprite_rotation, + self.sprite_scale.x * self.sprite_flip.x, + self.sprite_scale.y * self.sprite_flip.y + ) + love.graphics.setColor(c1,c2,c3,a) +end + -- returns true if theres a collision at that point. also marks collisioned tile as collision true function Entity:isCollidingAt(x,y,object) local result = false for _, col in pairs(object) do - result = self.pos.x + self.boxCollision.from.x < col.to.x - and self.pos.x + self.boxCollision.to.x > col.from.x - and self.pos.y + self.boxCollision.from.y < col.to.y - and self.pos.y + self.boxCollision.to.y > col.from.y + result = x + self.boxCollision.from.x < col.to.x + and col.from.x < x + self.boxCollision.to.x + and y + self.boxCollision.from.y < col.to.y + and col.from.y < y + self.boxCollision.to.y if result == true then break end end return result @@ -39,9 +69,9 @@ end function Entity:isCollidingWith(entity) return self.pos.x + self.boxCollision.from.x < entity.pos.x + entity.boxCollision.to.x - and self.pos.x + self.boxCollision.to.x > entity.pos.x + entity.boxCollision.from.x + and entity.pos.x + entity.boxCollision.from.x < self.pos.x + self.boxCollision.to.x and self.pos.y + self.boxCollision.from.y < entity.pos.y + entity.boxCollision.to.y - and self.pos.y + self.boxCollision.to.y > entity.pos.y + entity.boxCollision.from.y + and entity.pos.y + entity.boxCollision.from.y < self.pos.y + self.boxCollision.to.y end function Entity:isCollidingAtAll(x,y) @@ -58,131 +88,8 @@ function Entity:isCollidingAtAll(x,y) return result end ---[[function Entity:Draw() - if self.sprite ~= nil then - local relative_position_x = self.pos.x - Camera.pos.x - local relative_position_y = self.pos.y - Camera.pos.y - local origin_compensation_x = - ( (self.sprite_offset.x) * math.cos(self.sprite_rotation) - (self.sprite_offset.y) * math.sin(self.sprite_rotation)) - local origin_compensation_y = - ( (self.sprite_offset.x) * math.sin(self.sprite_rotation) + (self.sprite_offset.y) * math.cos(self.sprite_rotation)) - local dimensions_x = self.sprite_scale.x * self.sprite_flip.x - local dimensions_y = self.sprite_scale.y * self.sprite_flip.y - love.graphics.draw( - self.sprite, - relative_position_x + origin_compensation_x * dimensions_x, - relative_position_y + origin_compensation_y * dimensions_y, - self.sprite_rotation, - self.sprite_scale.x * self.sprite_flip.x, - self.sprite_scale.y * self.sprite_flip.y - ) - if debug_collision then - love.graphics.setColor(1, 0, 0) - love.graphics.circle( "line", relative_position_x, relative_position_y, 2 ) - love.graphics.setColor(0, 1 ,0) - love.graphics.circle( "line", - relative_position_x + origin_compensation_x * dimensions_x, - relative_position_y + origin_compensation_y * dimensions_y, - 2 - ) - end - love.graphics.setColor(1, 1 ,1) - end -end - -function Entity:NewAnimation(anim,frames,speed) - local anim_data = { - frame = 1, - subframe = 1, - path = anim.path, - frames = anim.frames, - speed = anim.speed, - imgs = anim.imgs - } - self.animations[#self.animations+1] = anim_data - - return self.animations[#self.animations] -end - -function DrawAnimationFrame(animation, frame, x, y, rotate, sx, sy) - local x = x or 0 - local y = y or 0 - local sx = sx or 1 - local sy = sy or 1 - love.graphics.draw( - animation.imgs[frame], - x - Camera.pos.x, - y - Camera.pos.y, - rotate, - sx, - sy - ) -end - -function DrawAnimation(animation, x, y, rotate, sx, sy) - local x = x or 0 - local y = y or 0 - local sx = sx or 1 - local sy = sy or 1 - if game_paused ~= true then - -- try to animate - animation.subframe = animation.subframe + current_dt - - if animation.subframe >= animation.speed then - animation.frame = animation.frame + 1 - animation.subframe = animation.subframe - animation.speed - end - - -- cycle - if animation.frame >= animation.frames+1 then - animation.frame = animation.frame - animation.frames - end - end - love.graphics.draw( - animation.imgs[animation.frame], - x - Camera.pos.x, - y - Camera.pos.y, - rotate, - sx, - sy - ) -end - -function Entity:Animate() - if game_paused ~= true and self.anim.path ~= nil then - -- try to animate - self.anim.subframe = self.anim.subframe + current_dt - - if self.anim.subframe >= self.anim.speed then - self.anim.frame = self.anim.frame + 1 - self.anim.subframe = self.anim.subframe - self.anim.speed - end - - -- cycle - if self.anim.frame >= self.anim.frames+1 then - self.anim.frame = self.anim.frame - self.anim.frames - end - - -- change - self.sprite = self.anim.imgs[self.anim.frame] - end -end - -function Entity:LoadAnimation(anim,frames,speed) - if self.anim.path ~= anim and self.anim.path ~= anim.path then - if frames ~= nil and speed ~= nil then - self.anim.path = anim or nil - self.anim.frames = frames or 4 - self.anim.speed = speed or frames - else - self.anim.path = anim.path - self.anim.frames = anim.frames - self.anim.speed = anim.speed - end - - self.anim.imgs = anim.imgs - end -end -]]-- - require "data/scripts/entities/kupo" require "data/scripts/entities/arrow" +require "data/scripts/entities/decoration" require "data/scripts/entities/player" +require "data/scripts/entities/fairy" diff --git a/data/scripts/enums.lua b/data/scripts/enums.lua index edea2dc..46dea88 100644 --- a/data/scripts/enums.lua +++ b/data/scripts/enums.lua @@ -1,6 +1,20 @@ -- animationsç -- all these are linear animations, maybe in the future make proper animations? animation = { + fairy = { + flying = { + path = "assets/characters/fairy/flying", + frames = 2, + speed = 1/30 + } + }, + decoration = { + candelabra = { + path = "assets/characters/decoration/candelabra", + frames = 8, + speed = 1/6 + } + }, kupo = { body = { path = "assets/characters/kupo/kupo", diff --git a/data/scripts/in_out.lua b/data/scripts/in_out.lua index 914782e..47dcb8c 100644 --- a/data/scripts/in_out.lua +++ b/data/scripts/in_out.lua @@ -1,9 +1,3 @@ -function doOutput(table) - local file = io.open("map.json", "w") - io.output(file) - io.write(json.encode(table)) - io.close(file) -end function getInput(filename) local file = io.open(filename, "r") diff --git a/data/scripts/keybind.lua b/data/scripts/keybind.lua new file mode 100644 index 0000000..e1acf4c --- /dev/null +++ b/data/scripts/keybind.lua @@ -0,0 +1,9 @@ +keybind = {} + +keybind.moveLeft = "left" +keybind.moveRight = "right" +keybind.moveUp = "up" +keybind.moveDown = "down" +keybind.moveJump = "z" +keybind.moveAttack = "x" +keybind.moveDash = "c" diff --git a/data/scripts/level.lua b/data/scripts/level.lua index 77929ab..d1f75e9 100644 --- a/data/scripts/level.lua +++ b/data/scripts/level.lua @@ -8,8 +8,6 @@ function LevelLoadTiles() overlay = render another tile id or, if multiple tiles {id, id, id,} or overlay_depth = foreground/background overlay depth type = collision type - - ]] LevelData = dofile("Mothback/data/levels/"..currLevel..".lua") diff --git a/data/scripts/lights.lua b/data/scripts/lights.lua index aa84a96..48d2349 100644 --- a/data/scripts/lights.lua +++ b/data/scripts/lights.lua @@ -2,7 +2,7 @@ Lights = {} LightTimer = 0 function CreateDarkness() - return love.graphics.newCanvas(game.width, game.height) + return love.graphics.newCanvas(game.width/game.scale, game.height/game.scale) end function CreateLight(x,y,range,lum,flicker) @@ -13,10 +13,10 @@ function CreateLight(x,y,range,lum,flicker) } o.range = range o.lum = lum or 1 - o.flicker_value = flicker or 1 + o.flicker_value = flicker or 2 o.flicker = 0 o.dim = 0 - o.flicker_speed = flicker_speed or 10 + o.flicker_speed = flicker_speed or 60/12 o.flicker_time = 0 table.insert(Lights,o) return o @@ -24,7 +24,7 @@ end function SetDarkness() love.graphics.setColor(0,0,0,1) - love.graphics.rectangle("fill",0,0,game.width,game.height) + love.graphics.rectangle("fill",0,0,game.width ,game.height) end function DoLights() @@ -34,37 +34,30 @@ function DoLights() if light.flicker_time >= light.flicker_speed then light.flicker_time = light.flicker_time - light.flicker_speed - light.flicker = 0 + math.random(-1,1) + light.flicker = 0 + math.random(0,1) light.flicker = math.min(math.max(light.flicker, -light.flicker_value),light.flicker_value) end end ---[[ - -- first, border - love.graphics.setColor(1,1,1) - for _, light in pairs(Lights) do - - love.graphics.circle( - "fill", - light.pos.x - Camera.pos.x, - light.pos.y - Camera.pos.y, - light.range + light.flicker + 1 - ) - end - ]] love.graphics.setBlendMode("replace") - for _, enty in pairs(LoadedEntities) do - end - - local shades = 200 - for i=1, shades do - for _, light in pairs(Lights) do - local luminosity = shades*light.lum/100 - love.graphics.setColor(0,0,0,math.min(1,math.max(0,(shades-i-luminosity+1)/(shades-luminosity+1)))) + love.graphics.setColor(1,1,1,1) + for _, light in pairs(Lights) do + if light.range ~= 0 then love.graphics.circle( "fill", - light.pos.x - Camera.pos.x, - light.pos.y - Camera.pos.y, - (light.range + light.flicker)*(shades-i+1)/shades + (light.pos.x - Camera.pos.x) / game.scale, + (light.pos.y - Camera.pos.y) / game.scale, + (light.range + light.flicker + 1) / game.scale + ) + end + end + love.graphics.setColor(0,0,0,0) + for _, light in pairs(Lights) do + if light.range ~= 0 then + love.graphics.circle( + "fill", + (light.pos.x - Camera.pos.x) / game.scale, + (light.pos.y - Camera.pos.y) / game.scale, + (light.range + light.flicker) / game.scale ) end end @@ -75,5 +68,5 @@ function DoBorder() end function DrawDarkness() - love.graphics.draw(Canvas.Darkness, 0, 0, 0, 0.5, 0.5) + love.graphics.draw(Canvas.Darkness, 0, 0, 0, 2/game.scale) end diff --git a/data/scripts/math.lua b/data/scripts/math.lua index f2e3a48..704a8f1 100644 --- a/data/scripts/math.lua +++ b/data/scripts/math.lua @@ -7,3 +7,11 @@ function math.sign(x) return 0 end end + +function GetAngleFromVector(x,y) + local reduce = 0 + if x < 0 then + reduce = math.rad(180) + end + return math.atan(y/x) - reduce +end diff --git a/main.lua b/main.lua index e4f10f0..b13b151 100644 --- a/main.lua +++ b/main.lua @@ -1,21 +1,28 @@ 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() @@ -23,19 +30,25 @@ function love.load() 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(0,20) + + main_Player = Player:New(75,50) + table.insert(LoadedEntities,main_Player) table.insert(LoadedEntities,Kupo:New(700,150)) table.insert(LoadedEntities,Kupo:New(800,150)) - CreateLight(200,64,80,nil,5,{1,0,0}) - main_Player.sprite = love.graphics.newImage("assets/characters/nancy/idle1.png") + 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) @@ -50,16 +63,35 @@ function love.update(dt) fps_count = fps_count + 1 current_dt = dt - -- GAME STEP - if not do_pause then - SetCollisionFlags(main_Player) - for _, enty in pairs(LoadedEntities) do - enty:Smart() - enty:DoPhysics() - end + + if editor_mode then + + AnimateTiles() - Camera:CenterAt(main_Player.pos.x, main_Player.pos.y) - --camera:ScreenAt(main_Player.pos.x, main_Player.pos.y,game.width,game.height) + else + -- GAME STEP + if not do_pause then + SetCollisionFlags(main_Player) + for _, enty in pairs(LoadedEntities) do + enty:Smart() + enty:DoPhysics() + end + AnimateTiles() + Camera:CenterAt(main_Player.pos.x, main_Player.pos.y) + --camera:ScreenAt(main_Player.pos.x, main_Player.pos.y,game.width,game.height) + end + 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 @@ -86,19 +118,23 @@ function love.keypressed(key) end if key == "f2" then - main_Player.pos.x, main_Player.pos.y = -16,-0.1 + 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 == "f5" then - levelNum = levelNum + 1 - if levelNum > #levelList then levelNum = levelNum - #levelList end - currLevel = levelList[levelNum] - LevelLoadTiles() - main_Player.pos.x, main_Player.pos.y = 0,-0.1 + if key == "f4" then + if editor_mode then + editor_mode = false + else + editor_mode = true + end end end