diff --git a/source-images/hat1/hat1.png b/source-images/hat1/hat1.png new file mode 100644 index 0000000..ad30c7b Binary files /dev/null and b/source-images/hat1/hat1.png differ diff --git a/source-images/hat1/hat1.xcf b/source-images/hat1/hat1.xcf new file mode 100644 index 0000000..90c967e Binary files /dev/null and b/source-images/hat1/hat1.xcf differ diff --git a/src/Hat.lua b/src/Hat.lua new file mode 100644 index 0000000..e156445 --- /dev/null +++ b/src/Hat.lua @@ -0,0 +1,21 @@ +local class = require "lib.middleclass" + +local Hat = class('Hat') + +function Hat:initialize(imgFile, imgScale, offset, imgColor) + -- image stuff + self.image = love.graphics.newImage(imgFile) or love.graphics.newImage("images/no_hat.png") and console.e("Hat created with no image.") + self.imgHalfWidth = self.image:getWidth() / 2 + self.imgHalfHeight = self.image:getHeight() / 2 + self.imgScale = imgScale or 1 and console.d("Hat created with no scale.") + self.imgColor = imgColor or {255, 255, 255} and console.d("Hat created with no color (this is fine and normal).") + + self.offset = offset or 0 and console.d("Hat created with no offset.") +end + +function Hat:draw(x, y) + love.graphics.setColor(self.imgColor) + love.graphics.draw(self.image, x + player.Ship.x, y + player.Ship.y + self.offset, 0, self.imgScale, self.imgScale, self.imgHalfWidth, self.imgHalfHeight) +end + +return Hat diff --git a/src/images/hat1.png b/src/images/hat1.png new file mode 100644 index 0000000..ad30c7b Binary files /dev/null and b/src/images/hat1.png differ diff --git a/src/main.lua b/src/main.lua index 1aa4192..4576b76 100644 --- a/src/main.lua +++ b/src/main.lua @@ -18,6 +18,8 @@ Render = { } player = require "Ships.Demo" +local Hat = require "Hat" +local lolhat = Hat("images/hat1.png", 1.6, -20, {255, 255, 255}) function love.update(dt) -- player rotation input @@ -136,6 +138,9 @@ function love.draw() end end + -- lolhat draw + lolhat:draw(Camera.x, Camera.y) + -- Fuel UI draw love.graphics.setColor(175, 255, 255) love.graphics.setFont(Render.hudFont)