basic stuff w movemet n collision done
This commit is contained in:
parent
03112bb0fb
commit
bffa27ec01
4 changed files with 25 additions and 15 deletions
|
|
@ -6,6 +6,7 @@ function Entity:initialize(t)
|
|||
self.color = Color:new(t.color)
|
||||
self.collision = t.collision --either "none", "moveable", "unmoveable"
|
||||
self.sprite = t.sprite
|
||||
self.shaAmount = t.sha or 1
|
||||
end
|
||||
|
||||
function Entity:atGridPos(x, y)
|
||||
|
|
@ -31,7 +32,7 @@ end
|
|||
function Entity:draw()
|
||||
love.graphics.setColor(self.color:set())
|
||||
local p = self:getDrawPos()
|
||||
love.graphics.draw(self.sprite, p.x, p.y, 0, drawScale, drawScale)
|
||||
love.graphics.draw(self.sprite, p.x + self:sha(), p.y + self:sha(), 0, drawScale, drawScale)
|
||||
end
|
||||
|
||||
function Entity:isAlignedWithPlayerMovement(axis, pos)
|
||||
|
|
@ -53,6 +54,7 @@ function Entity:move(axis, direction)
|
|||
self[axis] = self[axis] + direction
|
||||
end
|
||||
|
||||
function Entity:push(direction)
|
||||
|
||||
function Entity:sha()
|
||||
return math.random(-self.shaAmount, self.shaAmount) * .5
|
||||
end
|
||||
21
main.lua
21
main.lua
|
|
@ -1,5 +1,6 @@
|
|||
class = require "libs/middleclass"
|
||||
Timer = require "libs/hump/timer"
|
||||
sfxr = require "libs/sfxrlua/sfxr"
|
||||
require "input"
|
||||
require "color"
|
||||
require "room"
|
||||
|
|
@ -9,6 +10,7 @@ require "debug_helpers"
|
|||
function love.load()
|
||||
_initDefaults()
|
||||
_initGridVars()
|
||||
_initSounds()
|
||||
loadSprites()
|
||||
|
||||
gameCanvas = love.graphics.newCanvas()
|
||||
|
|
@ -59,10 +61,11 @@ function love.draw()
|
|||
love.graphics.draw(gameCanvas, 0, 0)
|
||||
love.graphics.setCanvas()
|
||||
|
||||
pixelate:send("seed", math.random())
|
||||
pixelate:send("zoom", .2)
|
||||
love.graphics.setShader(pixelate)
|
||||
love.graphics.setBlendMode("alpha")
|
||||
love.graphics.setColor(255, 255, 255, 255)
|
||||
love.graphics.draw(finalCanvas, 0, 0)
|
||||
love.graphics.print("Current FPS: "..tostring(love.timer.getFPS( )), 10, 10)
|
||||
|
||||
end
|
||||
|
||||
function love.keypressed(key)
|
||||
|
|
@ -96,6 +99,18 @@ function _initGridVars()
|
|||
drawScale = width / gridWidth / 16
|
||||
end
|
||||
|
||||
function _initSounds()
|
||||
staticWave = sfxr.newSound()
|
||||
staticWave.wavetype = 3
|
||||
staticWave.frequency.start = .1
|
||||
staticWave.envelope.release = 0
|
||||
staticWave.envelope.sustain = 1
|
||||
staticWave.envelope.decay = 0
|
||||
static = love.audio.newSource(staticWave:generateSoundData())
|
||||
static:setLooping(true)
|
||||
static:setVolume(.15)
|
||||
static:play()
|
||||
end
|
||||
function createCanvases()
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,10 +19,3 @@ end
|
|||
function Player:update()
|
||||
|
||||
end
|
||||
|
||||
function Player:draw()
|
||||
love.graphics.setColor(self.color:set())
|
||||
local p = self:getDrawPos()
|
||||
love.graphics.draw(self.sprite, p.x, p.y, 0, drawScale, drawScale)
|
||||
end
|
||||
|
||||
|
|
|
|||
4
room.lua
4
room.lua
|
|
@ -23,14 +23,14 @@ function Room:initialize(t)
|
|||
self.activeColors[color] = true
|
||||
end
|
||||
|
||||
for i=0, 20 do
|
||||
for i=0, 50 do
|
||||
local c = randomColor()
|
||||
local x, y = math.random(1, gridWidth), math.random(1, gridHeight)
|
||||
self.collideables[c]["b: " .. x .. ", " .. y] = Box:new(x, y, c)
|
||||
end
|
||||
|
||||
|
||||
for i=0, 20 do
|
||||
for i=0, 50 do
|
||||
local c = randomColor()
|
||||
local x, y = math.random(1, gridWidth), math.random(1, gridHeight)
|
||||
self.collideables[c]["w: " .. x .. ", " .. y] = Wall:new(x, y, c)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue