hat
This commit is contained in:
BIN
source-images/hat1/hat1.png
Normal file
BIN
source-images/hat1/hat1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 243 B |
BIN
source-images/hat1/hat1.xcf
Normal file
BIN
source-images/hat1/hat1.xcf
Normal file
Binary file not shown.
21
src/Hat.lua
Normal file
21
src/Hat.lua
Normal file
@@ -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
|
BIN
src/images/hat1.png
Normal file
BIN
src/images/hat1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 243 B |
@@ -18,6 +18,8 @@ Render = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
player = require "Ships.Demo"
|
player = require "Ships.Demo"
|
||||||
|
local Hat = require "Hat"
|
||||||
|
local lolhat = Hat("images/hat1.png", 1.6, -20, {255, 255, 255})
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
-- player rotation input
|
-- player rotation input
|
||||||
@@ -136,6 +138,9 @@ function love.draw()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- lolhat draw
|
||||||
|
lolhat:draw(Camera.x, Camera.y)
|
||||||
|
|
||||||
-- Fuel UI draw
|
-- Fuel UI draw
|
||||||
love.graphics.setColor(175, 255, 255)
|
love.graphics.setColor(175, 255, 255)
|
||||||
love.graphics.setFont(Render.hudFont)
|
love.graphics.setFont(Render.hudFont)
|
||||||
|
Reference in New Issue
Block a user