[STI] Map Scaling Help

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Falling
Prole
Posts: 3
Joined: Thu May 07, 2015 3:37 pm

[STI] Map Scaling Help

Post by Falling »

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

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
conf.lua (Allthough not very important)

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
What actually comes up when I run the file

Image

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
But, I digress.

Also, bonus props to those who can figure out why the [IGNORE THIS] part crashes the process.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: [STI] Map Scaling Help

Post by Jasoco »

Multi-line comments are done like this:

Code: Select all

--[[
    SOME TEXT TO COMMENT GOES HERE
]]
User avatar
cohadar
Prole
Posts: 25
Joined: Mon May 04, 2015 5:46 am
Contact:

Re: [STI] Map Scaling Help

Post by cohadar »

Here is a really short and simple game that uses both Tiled and game scaling.
http://ludumdare.com/compo/ludum-dare-3 ... &uid=18586
User avatar
I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

Re: [STI] Map Scaling Help

Post by I~=Spam »

Jasoco wrote:Multi-line comments are done like this:

Code: Select all

--[[
    SOME TEXT TO COMMENT GOES HERE
]]
I really like lua's multiline comments because you can do this too.

Code: Select all

--[[
    ...
    CODE
    ...
--]]
If you are constantly switching between using this code and not you can just remove the "[[" and it runs. :D
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610
Falling
Prole
Posts: 3
Joined: Thu May 07, 2015 3:37 pm

Re: [STI] Map Scaling Help

Post by Falling »

Thank you for your replies,

These unfortunately do not help solve my issue.
The source code is very large and is hard to navigate to find the specific thing I'm looking to replicate.
I'd appreciate some sort of reference, so that I know what I'm doing wrong.

Thank you again though,

Falling
User avatar
cohadar
Prole
Posts: 25
Joined: Mon May 04, 2015 5:46 am
Contact:

Re: [STI] Map Scaling Help

Post by cohadar »

Code: Select all

function love.draw()
   love.graphics.scale( scale )  -- perhaps you are missing this?
   house:draw()
   house:setDrawRange(5, 5, love.window.getWidth(), love.window.getHeight())
   love.graphics.draw(player.img, player.x, player.y)
end
Falling
Prole
Posts: 3
Joined: Thu May 07, 2015 3:37 pm

Re: [STI] Map Scaling Help

Post by Falling »

cohadar wrote:

Code: Select all

function love.draw()
   love.graphics.scale( scale )  -- perhaps you are missing this?
   house:draw()
   house:setDrawRange(5, 5, love.window.getWidth(), love.window.getHeight())
   love.graphics.draw(player.img, player.x, player.y)
end
This fixed it, thanks a lot!
Post Reply

Who is online

Users browsing this forum: No registered users and 54 guests