From bffa27ec018b3f3825b0d201de9ee98d1f056501 Mon Sep 17 00:00:00 2001 From: 0x81c Date: Thu, 12 Mar 2015 04:05:39 -0400 Subject: [PATCH] basic stuff w movemet n collision done --- entity.lua | 6 ++++-- main.lua | 21 ++++++++++++++++++--- player.lua | 9 +-------- room.lua | 4 ++-- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/entity.lua b/entity.lua index ee433e2..78c41a3 100644 --- a/entity.lua +++ b/entity.lua @@ -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 \ No newline at end of file diff --git a/main.lua b/main.lua index 067807b..a39daf1 100644 --- a/main.lua +++ b/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 diff --git a/player.lua b/player.lua index 6563b8a..0436185 100644 --- a/player.lua +++ b/player.lua @@ -18,11 +18,4 @@ 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 - +end \ No newline at end of file diff --git a/room.lua b/room.lua index 8727f74..a60e213 100644 --- a/room.lua +++ b/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)