From 3f590d507f884636aa32bb3c6102938dec4588f2 Mon Sep 17 00:00:00 2001 From: Martijn de Boer Date: Thu, 13 Oct 2022 20:59:14 +0200 Subject: [PATCH] tiles --- assets.lua | 5 +++- assets/ships/particle.png | Bin 316 -> 345 bytes assets/tiles/gf.png | Bin 0 -> 1621 bytes main.lua | 3 +++ planet/planet.lua | 55 ++++++++++++++++++++++++++++++++++++++ scene/game.lua | 13 +++++++++ 6 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 assets/tiles/gf.png diff --git a/assets.lua b/assets.lua index 75a23ec..e647600 100644 --- a/assets.lua +++ b/assets.lua @@ -8,7 +8,8 @@ multilily = lily.loadMulti({ {lily.newImage, "assets/ships/blackstar-5.png"}, {lily.newImage, "assets/ships/excalibur-iv.png"}, {lily.newImage, "assets/ships/decorator.png"}, - {lily.newImage, "assets/ships/particle.png"} + {lily.newImage, "assets/ships/particle.png"}, + {lily.newImage, "assets/tiles/gf.png"} }) multilily:onComplete(function(_, lilies) gameLogo = lilies[1][1] @@ -22,6 +23,8 @@ multilily:onComplete(function(_, lilies) CaptainJohn.ship.image = lilies[9][1] boosterParticle = lilies[10][1] + tileGroundFull = lilies[11][1] + windowWidth = love.graphics.getWidth() windowHeight = love.graphics.getHeight() diff --git a/assets/ships/particle.png b/assets/ships/particle.png index e6003a5852682af844e1d13e7eea5511d8a8171f..a40ddd0b1310689508657d3665dc13a484d2ef17 100644 GIT binary patch delta 298 zcmV+_0oDGz0@(tPIDY{PNkllGcI_qKVZRgD}46{y?B1}6i!CFJSQICTL<&Nd6*`r()oJyu}G?Qm$m~a ztw9OWc0f|CJ3aoI`bvtfHg@V{W0_V0$U|BQaI&$~#!i(KT^~S6G10~@oNO$KG8?eT wfCmuIdH@}5Y$HuIi_yjPa4>jiB|snG7u%$6;9@eQZ2$lO07*qoM6N<$g5QFRM*si- delta 269 zcmV+o0rLLY0=xo{IDY`{NklV zlV@=9Ia*)AN$%p{s3nzb5uHRZ*at``G`ThoYK>?9IGkh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xP`C}m8tL@W|FGxpxZQ9czR zjt0E%%hP*peA_=u^F@S=U|h`*p|{4Elc)Fpsd$|=Pw&4{Yz79dCuWHVruK1PPsrRS zin+IPw9}z6<`-5kI4_v5JI3B{fY;iMZzXsa^m;veuf^tC!n)=#o(h=teAa|K_VFE6DNq*p-6YvFsa8u6SKAd%FNH z!@JcZg6_RbXwIBCB9f8F0neQ4(}8Ou$%*er`7YI}kee~)Zzp%TXGG9juUwId3-Wcq z)INW|5lghv&A;~_e&QBKR`&t!jq78)U!0F!!PU+fuR)pGXH@2n_ujr7_`dJ2hMzXJ z=8QRh9c~9^)df>UM8A;gt(A4FvXk$i89|C*rtH{X@&fQY?*W-fQXs0f8FT%b%I(ZW z^R?k5X{|Bd!Mop&=c45qao)5pEkE!beCWE#L<>wDX}xbZd1hGFTMym0n|sYs9r}5G z*s+a-y4=u@BX6 zWWQ!)?zo!~msTfy-taKzEUuqJsR(1vO1OJ}F1hw5Bl(M`JkBa2>`YoaDk#F-`|}gM z;lRD2W<1Yx((t7B2Y2Ur9^Bg(!`{>4TS;@L_x1&m9r2lwNOdGLzSw6c(h2ZijTkh| T$XDJp00000NkvXXu0mjf5S=_X literal 0 HcmV?d00001 diff --git a/main.lua b/main.lua index e3a6ca2..8b97eab 100644 --- a/main.lua +++ b/main.lua @@ -39,6 +39,8 @@ function love.load() require "ship/excaliburiv" require "ship/decorator" + require "planet/planet" + LoadScene = LoadScene() TitleScene = TitleScene() GameScene = GameScene() @@ -48,6 +50,7 @@ function love.load() currentScene = LoadScene; currentPlayer = CaptainSteve; + currentPlanet = Planet() require "assets" end diff --git a/planet/planet.lua b/planet/planet.lua index 40ccd70..db6ae0c 100644 --- a/planet/planet.lua +++ b/planet/planet.lua @@ -1,10 +1,65 @@ Planet = Object.extend(Object) function Planet:new() + Planet.super.new(self) +end + +function Planet:init() + self.canvas = love.graphics.newCanvas(windowWidth, windowHeight) + + self.map = { + {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 1, 1, 1, 1, 0}, + {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}, + {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}, + {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}, + {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}, + {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}, + {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}, + {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}, + {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}, + {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}, + {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0} + } + + self.spritemap = { + s1= tileGroundFull + } end function Planet:update(dt) end function Planet:draw() + love.graphics.setCanvas(self.canvas) + --self.canvas:clear() + + love.graphics.setColor(1,1,1,1) + + local sprite = nil + local pos = 0 + for y=1, 20 do + for x=1, 25 do + sprite = nil + pos = self.map[y][x] + if pos > 0 then + sprite = self.spritemap["s"..pos] + love.graphics.draw(sprite, (x-1)*32, (600-98) - (y-1)*32) + end + end + end + + love.graphics.setCanvas() end diff --git a/scene/game.lua b/scene/game.lua index de02ffc..47fd2d8 100644 --- a/scene/game.lua +++ b/scene/game.lua @@ -27,16 +27,29 @@ function GameScene:init() 1,1,1,0.4, 1,1,1,0.3 ) + + currentPlanet:init() + currentPlanet:draw() end function GameScene:update(dt) pSystem:update(dt) GameScene:updateInput(dt) GameScene:updateBounds(dt) + + if currentPlanet ~= nil then + love.graphics.print("hebebs",100,100); + currentPlanet.update(dt) + end end function GameScene:draw() love.graphics.setColor(255,255,255, 1) + + if currentPlanet ~= nil and currentPlanet.canvas ~= nil then + love.graphics.draw(currentPlanet.canvas,0,0) + end + love.graphics.draw(pSystem, currentPlayer.px-2, currentPlayer.py) love.graphics.draw(pSystem, currentPlayer.px+2, currentPlayer.py) love.graphics.draw(