[STI] Map Scaling Help
Posted: Thu May 07, 2015 3:53 pm
Hey there,
So, I'm relatively new to the Löve API.
(I say relatively because I've taken frequent breaks, and constantly forget all about everything.)
I've recently been inspired to create a little RPG-esque game, to learn the quirks in the LÖVE API and to further improve my programming knowledge. I found out about Simple Tiled Implementation after having used Tiled for Unity projects, but I just cannot seem to get it to work.
As of right now, I do not really have any structure to my directories, and am just looking to actually render a Tiled map successfully.
So, to the problem.
When I draw the map, it is really zoomed in, and I just cannot seem to get why.
main.lua
conf.lua (Allthough not very important)
What actually comes up when I run the file
So, what I wanna know is how to limit the map to be rendered inside the window's borders.
One would think that this would produce my wanted result.
But, I digress.
Also, bonus props to those who can figure out why the [IGNORE THIS] part crashes the process.
So, I'm relatively new to the Löve API.
(I say relatively because I've taken frequent breaks, and constantly forget all about everything.)
I've recently been inspired to create a little RPG-esque game, to learn the quirks in the LÖVE API and to further improve my programming knowledge. I found out about Simple Tiled Implementation after having used Tiled for Unity projects, but I just cannot seem to get it to work.
As of right now, I do not really have any structure to my directories, and am just looking to actually render a Tiled map successfully.
So, to the problem.
When I draw the map, it is really zoomed in, and I just cannot seem to get why.
main.lua
Code: Select all
debug = false
speed = 25
-- Loads STI
local sti = require "sti"
-- Loads the lua file for the map (map1.lua)
function love.load()
-- Sets window size (scale = 0.5, the tiled map size is 2048 * 2048 (32 * (64 pixels large tiles))
love.window.setMode(2048*scale,2048*scale)
-- initiates the player var and gives it some properties
player = {x = 100, y = 100, img = nil, hp = 100, mp = 100}
-- Loads the image previously stated as nil
player.img = love.graphics.newImage("assets/player.png")
-- Initial state
state = "menu"
house = sti.new("map/map01")
end
function love.draw()
house:draw()
house:setDrawRange(5, 5, love.window.getWidth(), love.window.getHeight())
love.graphics.draw(player.img, player.x, player.y)
end
[IGNORE THIS]{
function love.update(dt)
house:update(dt)
if love.keyboard.isDown("i") then
house.x = house.x + (3 * speed)
end
end
}
function love.keypressed(key)
end
function love.resize(w, h)
house:resize(love.window.getWidth(), love.window.getHeight())
end
Code: Select all
-- Screen Size
scale = 0.5 -- Sets the global scale (normal size * this will equal actual screensize)
function love.conf(t) -- Hook for configurations
t.console=true
t.title = "RPG Test" -- Title
end
So, what I wanna know is how to limit the map to be rendered inside the window's borders.
One would think that this would produce my wanted result.
Code: Select all
function love.resize(w, h)
house:resize(love.window.getWidth(), love.window.getHeight())
end
Also, bonus props to those who can figure out why the [IGNORE THIS] part crashes the process.