summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2016-06-26 21:04:31 +0200
committerAki <nthirtyone@gmail.com>2016-06-26 21:04:31 +0200
commit71db337cb1928080f78b6b14646cce3731ecff5a (patch)
tree40c7ccfdcf28bf159fc0f1ba10b317232b00e580
parent7524f0e1a5ed2c1fb20201ffecb7e31c0709bb98 (diff)
downloadroflnauts-71db337cb1928080f78b6b14646cce3731ecff5a.zip
roflnauts-71db337cb1928080f78b6b14646cce3731ecff5a.tar.gz
roflnauts-71db337cb1928080f78b6b14646cce3731ecff5a.tar.bz2
Scaled background image
-rw-r--r--assets/background-default.pngbin0 -> 790 bytes
-rw-r--r--camera.lua1
-rw-r--r--main.lua3
-rw-r--r--maps/default.lua4
-rw-r--r--world.lua16
5 files changed, 12 insertions, 12 deletions
diff --git a/assets/background-default.png b/assets/background-default.png
new file mode 100644
index 0000000..959f4f9
--- /dev/null
+++ b/assets/background-default.png
Binary files differ
diff --git a/camera.lua b/camera.lua
index 0245218..32a1bed 100644
--- a/camera.lua
+++ b/camera.lua
@@ -8,6 +8,7 @@ Camera = {
dest_x = 0,
dest_y = 0,
scale = getScale(),
+ scaler = getRealScale(),
shake = 0,
timer = 0,
delay = 0,
diff --git a/main.lua b/main.lua
index d5552d0..930a57b 100644
--- a/main.lua
+++ b/main.lua
@@ -10,6 +10,9 @@ end
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)
+end
-- Require
require "world"
diff --git a/maps/default.lua b/maps/default.lua
index 956f24c..df909b4 100644
--- a/maps/default.lua
+++ b/maps/default.lua
@@ -4,9 +4,7 @@ return {
center_y = 0,
width = 360,
height = 240,
- color_top = {193, 100, 99, 255},
- color_mid = {189, 95, 93, 255},
- color_bot = {179, 82, 80, 255},
+ background = "assets/background-default.png",
respawns = {
{x = -15, y = -80},
{x = -5, y = -80},
diff --git a/world.lua b/world.lua
index 6fd5203..1e46c06 100644
--- a/world.lua
+++ b/world.lua
@@ -25,6 +25,7 @@ World = {
clouds_initial = nil,
-- Map
map = nil,
+ background = nil,
-- Gameplay status
lastNaut = false,
-- "WINNER"
@@ -94,6 +95,7 @@ function World:loadMap(name)
for _,decoration in pairs(self.map.decorations) do
self:createDecoration(decoration.x, decoration.y, decoration.sprite)
end
+ self.background = love.graphics.newImage(self.map.background)
end
-- Spawn all the nauts for the round
@@ -245,18 +247,14 @@ end
-- Draw
function World:draw()
- -- Hard-coded background (for now)
- love.graphics.setColor(self.map.color_bot)
- love.graphics.rectangle("fill", 0, 0, love.graphics.getWidth(), love.graphics.getHeight())
- love.graphics.setColor(self.map.color_mid)
- love.graphics.rectangle("fill", 0, 0, love.graphics.getWidth(), love.graphics.getHeight()*0.8)
- love.graphics.setColor(self.map.color_top)
- love.graphics.rectangle("fill", 0, 0, love.graphics.getWidth(), love.graphics.getHeight()*0.25)
-
-- Camera stuff
local offset_x, offset_y = self.camera:getOffsets()
local scale = self.camera.scale
-
+ local scaler = self.camera.scaler
+
+ -- Background
+ love.graphics.draw(self.background, 0, 0, 0, scaler, scaler)
+
-- Draw clouds
for _,cloud in pairs(self.Clouds) do
cloud:draw(offset_x, offset_y, scale)