This commit is contained in:
Paul Liverman
2015-01-16 15:25:48 -08:00
parent 8a80e3d9f6
commit 29c1e247d2
5 changed files with 26 additions and 0 deletions

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

Binary file not shown.

21
src/Hat.lua Normal file
View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

View File

@@ -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)