summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--conf.lua10
-rw-r--r--ground.lua13
-rw-r--r--main.lua2
-rw-r--r--player.lua8
4 files changed, 22 insertions, 11 deletions
diff --git a/conf.lua b/conf.lua
index e34d170..a0f6eb2 100644
--- a/conf.lua
+++ b/conf.lua
@@ -2,12 +2,10 @@
function love.conf(t)
t.title = "Roflnauts 2"
t.version = "0.10.1"
- --[[
t.window.width = 320*3
t.window.height = 180*3
- t.window.borderless = true
- --]]
- t.window.fullscreentype = "desktop"
- t.window.fullscreen = true
- t.console = false
+ -- t.window.borderless = true
+ -- t.window.fullscreentype = "desktop"
+ -- t.window.fullscreen = true
+ t.console = true
end \ No newline at end of file
diff --git a/ground.lua b/ground.lua
index 6b0be18..683966b 100644
--- a/ground.lua
+++ b/ground.lua
@@ -34,16 +34,25 @@ function Ground:delete ()
self.sprite = nil
end
+-- Position
+function Ground:getPosition()
+ return self.body:getPosition()
+end
+
-- Draw of `Ground`
function Ground:draw (offset_x, offset_y, scale, debug)
- -- defaults
+ -- locals
local offset_x = offset_x or 0
local offset_y = offset_y or 0
local scale = scale or 1
local debug = debug or false
+ local x, y = self:getPosition()
+ -- pixel grid
+ local draw_x = (math.floor(x) + offset_x) * scale
+ local draw_y = (math.floor(y) + offset_y) * scale
-- sprite draw
love.graphics.setColor(255,255,255,255)
- love.graphics.draw(self.sprite, (self.body:getX()+offset_x)*scale, (self.body:getY()+offset_y)*scale, 0, scale, scale)
+ love.graphics.draw(self.sprite, draw_x, draw_y, 0, scale, scale)
-- debug draw
if debug then
love.graphics.setColor(255, 69, 0, 140)
diff --git a/main.lua b/main.lua
index 8736257..f91550c 100644
--- a/main.lua
+++ b/main.lua
@@ -17,7 +17,7 @@ function getScale()
--return math.max(1, math.floor(love.graphics.getWidth() / 320)-1, math.floor(love.graphics.getHeight() / 180)-1)
end
function getRealScale()
- return math.max(love.graphics.getWidth() / 320, love.graphics.getHeight() / 180)
+ return math.max(1, math.floor(math.max(love.graphics.getWidth() / 320, love.graphics.getHeight() / 180)))
end
-- Should be moved to Sprite metaclass (non-existent yet)
function newImage(path)
diff --git a/player.lua b/player.lua
index d1ce62e..324f3ef 100644
--- a/player.lua
+++ b/player.lua
@@ -293,14 +293,18 @@ end
-- Draw of `Player`
function Player:draw (offset_x, offset_y, scale, debug)
- -- defaults
+ -- locals
local offset_x = offset_x or 0
local offset_y = offset_y or 0
local scale = scale or 1
local debug = debug or false
+ local x, y = self:getPosition()
+ -- pixel grid
+ local draw_x = (math.floor(x) + offset_x) * scale
+ local draw_y = (math.floor(y) + offset_y) * scale
-- sprite draw
love.graphics.setColor(255,255,255,255)
- love.graphics.draw(self.sprite, self.current[self.frame], (self.body:getX()+offset_x)*scale, (self.body:getY()+offset_y)*scale, self.rotate, self.facing*scale, 1*scale, 12, 15)
+ love.graphics.draw(self.sprite, self.current[self.frame], draw_x, draw_y, self.rotate, self.facing*scale, 1*scale, 12, 15)
-- debug draw
if debug then
love.graphics.setColor(137, 255, 0, 140)