Page 84 of 92

Re: Simple Tiled Implementation - STI v1.2.3.0

Posted: Wed Sep 23, 2020 8:30 pm
by RockEt__2580__
Pls need help I have every thing working... Mostly
The Collision
Camera
Movement
Sti...
But when I try using 0.7 or any 0.x value as sxx for my scale, the sti canvas gets cut of from the right and bottom, what other way do I fix the zooming out according to my code method, any help will be much appreciated thx.

Code: Select all

local gamera=require "gamera.gamera"
local bump = require 'bump.bump'
local sti = require "sti.sti"
function love.load()
blob={
x = 430 , 
y =250 , 
w =30, 
h = 60, 
speed=200
} 
cam = gamera.new(-1900 ,-1600,7130,7460)

sxx = 0.7

cam:setScale(sxx)
	
	
	-- Load map file
	map = sti("Map01.lua",{"bump"})
map:resize(love.graphics.getWidth(),love.graphics.getHeight())
	
world = bump. newWorld(40)
	map:bump_init(world)
end

function love.update(dt)
	map:update(dt)
end

function love . draw()
local screeen_width =love.graphics.getWidth()/ sxx
local screeen_height =love.graphics.getHeight()/ sxx
tx = math .floor(blob.x - screeen_width /2 )
ty = math .floor(blob.y -screeen_height /2 )
love .graphics .setColor (1 , 1, 1)
map:draw(-tx,-ty,sxx,sxx)
love .graphics .setColor (0 , 0, 0)
map:bump_draw(world,-tx,-ty,sxx,sxx)
cam:draw(function()
drawBlob()
end
end) 
And sorry for any mistakes in my English... :(,

Re: Simple Tiled Implementation - STI v1.2.3.0

Posted: Wed Sep 23, 2020 9:16 pm
by Karai17
Hm. It should be scaling the draw and drawing it to the normal sized canvas. Are you adjusting the window size at all? If you adjust the window size, you need to resize the canvas using map:resize(). You are calling resize right after creating the map, you don't need to do that, it should automatically set the canvas size to the current window size.

Re: Simple Tiled Implementation - STI v1.2.3.0

Posted: Wed Sep 23, 2020 9:22 pm
by RockEt__2580__
Pls can you put it to code or explain more, I am a beginner

Re: Simple Tiled Implementation - STI v1.2.3.0

Posted: Wed Sep 23, 2020 9:58 pm
by Karai17

Code: Select all

function love.resize(w, h)
   map:resize(w, h)
end

Re: Simple Tiled Implementation - STI v1.2.3.0

Posted: Wed Sep 23, 2020 10:26 pm
by RockEt__2580__
Haha I just figured a hack for it I did

Code: Select all

map:resize(width+width ,height + height)
I know its a stupid one.
BTW let me clerify my self, I know about the map:resize and I know by default its the windows dimension, but you see I am tryiny to use gamera.lua with your sti even after you sad its not really full proof, I got the translate to work with both libs but the scaling was the issue! My sxx probably contributed to the problem but I think now am good (Hopefully)
There is also probably a better solution if I composed well enough or attached files but am on mobile and lazy... so I'll take the easy way
Also great lib, I thought I was gonna do those two dimensional array tings by hand -phew
-PS. first comment on your sti thrend BTW
-PPS. sorry for lots of typos and wrong English

Re: Simple Tiled Implementation - STI v1.2.3.0

Posted: Sat Sep 26, 2020 10:08 am
by Karai17
I'm glad you found a solution. :)

Re: Simple Tiled Implementation - STI v1.2.3.0

Posted: Tue Oct 13, 2020 10:16 am
by ChicoGameDev
Hi,

I'm working on a little project and I want to use STI for managing maps.

I want to use my own library, Luven, for lights and camera.

And bump.lua for collisions.

So it's hard to explain but I get hard times getting everything "aligned". Maybe someone will find a way to make them all work together and I'm sure they can !

Actually the main problem is with the bump colliders. Just run the attached love file and you will see the issue I'm talking about.

Hope someone will find a solution I'll keep you all updated if I find something.

Thanks in advance.


Regards.

Little edit: @Karai17, you'll notice if you take a look that I added a little bit of code to manage layer tint from tiled, maybe you'll consider adding this feature to STI ? :D

luven_vs_sti_vs_bump.love
(538.87 KiB) Downloaded 578 times

Re: Simple Tiled Implementation - STI v1.2.3.0

Posted: Fri Oct 16, 2020 12:48 am
by Karai17
So a few things:

1) Lua's module paths are NOT filesystem paths! You want to use dots instead of slashes when you require files.
2) You're using so many globals that it's impossible to really determine exactly what anything is doing, I'd highly recommend using locals for everything that you can, including designing your code in such a way that globals are almost completely unnecessary.
3) The love file didn't run, i had to extract the files to run it. Not sure what that's about.

As for the actual issue at hand, briefly looking at luven's code, I'm not really sure what it's supposed to be doing but the api is unnecessarily complex and the vast majority of the code inside luven.lua could be removed. I fixed the problem by removing the drawBegin, drawEnd, camera.set, and camera.unset function calls from love.draw, none of which seem to do anything particularly useful anyway...

Re: Simple Tiled Implementation - STI v1.2.3.0

Posted: Fri Oct 16, 2020 3:23 am
by ChicoGameDev
Interesting "answer".

Sorry for taking your time sir.

Thanks at least for the dot path, wasn't aware of that.


Have a nice day.


Regards.

Re: Simple Tiled Implementation - STI v1.2.3.0

Posted: Fri Oct 16, 2020 5:18 am
by Karai17
Obviously not the answer you were hoping to hear, but I'm not trying to be rude or mean here. Luven as it is currently designed seems to have a lot of unnecessary code and a bloated API that doesn't really do much. The functionality of Luven seems to be fine enough, just the way in which one would access that functionality could be significantly tidied up and some of the features could be reworked to be more compatible with other libraries. STI has some code in it that makes it fairly difficult to work properly with external camera libraries, but those libraries tend to not be all that useful to begin with so it's never been much of a problem. Not to say that having camera-like functionality itself is useless, just that most camera libs are just simple wrappers for love calls and don't really provide much beyond a different API.

Perhaps it would be useful to write a camera plugin for STI that provides a "simplified" API that people seem want, but external cameras usually end up conflicting with STI in ways that I don't really intend to "fix" unless said fix improves STI's performance or simplifies the code without reducing functionality.

If you're interested in discussing more about Luven, feel free to pm me and we can chat in private~