How can I change the size of map, which I created in Tiled, by Simple-Tiled-Implementation library in Love?

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
codename.ruby
Prole
Posts: 2
Joined: Sat Oct 16, 2021 11:43 am

How can I change the size of map, which I created in Tiled, by Simple-Tiled-Implementation library in Love?

Post by codename.ruby »

Hi guys, I have a problem with the size of the map that I created in Tiled. How can I increase its size by using this library, https://github.com/karai17/Simple-Tiled-Implementation

It just looks that.

Image


You can check my codes to look at to find a solution and understand better the problem.

Thank you!

function love.load()
love.window.setMode(800, 600, {resizable=true, vsync=false, minwidth=400, minheight=300})

anim8 = require 'libraries/anim8/anim8'
sti = require 'libraries/Simple-Tiled-Implementation/sti'
cameraFile = require 'libraries/hump/camera'

cam = cameraFile()

sprites = {}
sprites.playerSheet = love.graphics.newImage('sprites/MarioSpriteSheet.png')
sprites.world1 = love.graphics.newImage('sprites/world1.png')

local grid = anim8.newGrid(32, 40, sprites.playerSheet:getWidth(), sprites.playerSheet:getHeight())

animations = {}
animations.marioStand = anim8.newAnimation(grid('3-7', 1), {0.3, 0.8, 0.2, 0.2, 0.3})
animations.marioRun = anim8.newAnimation(grid('1-8', 3), 0.1)
animations.marioJump = anim8.newAnimation(grid('1-2', 6), 0.3)
animations.marioFall = anim8.newAnimation(grid('1-3', 7), 0.3)

wf = require 'libraries/windfield/windfield'
world = wf.newWorld(0, 800, false)
world:setQueryDebugDrawing(true)

world:addCollisionClass('Platform')
world:addCollisionClass('Player')
world:addCollisionClass('Enemy')
world:addCollisionClass('Danger')

danger = world:newRectangleCollider(-2000, 2000, 5000, 50, {collision_class = 'Danger'})
danger:setType('static')

--require 'player'
PlayerX = 350
PlayerY = 200

mario = world:newRectangleCollider(PlayerX, PlayerY, 50, 100, {collision_class = 'Player'})

mario.animation = animations.marioStand
mario:setFixedRotation(true)
mario.speed = 240
mario.direction = 1
mario.grounded = false
mario.isMoving = false

platforms = {}
platform = world:newRectangleCollider(200, 500, 1000 ,50, {collision_class = 'Platform'})
platform:setType('static')

loadMap()
end

function love.update(dt)
world:update(dt)
gameMap:update(dt)

if mario.body then
local colliders = world:queryRectangleArea(mario:getX() - 20, mario:getY() + 50, 50, 2, { 'Platform' } )
if #colliders > 0 then
mario.grounded = true
else
mario.grounded = false
end

mario.isMoving = false
local x, y = mario:getPosition()


if love.keyboard.isDown("left") then
mario:setX(x - mario.speed *dt)
mario.isMoving = true
mario.direction = -1
end

if love.keyboard.isDown("right") then
mario:setX(x + mario.speed *dt)
mario.isMoving = true
mario.direction = 1
end

end
mario.animation:update(dt)
--playerUpdate(dt)
end

function love.keypressed(key)
if mario.body then
if key == "up" or key == "space" and mario.grounded == true then
mario:applyLinearImpulse(0, -5500)
end
end
end

function love.draw()
--love.graphics.draw(sprites.world1, 0, 0, nil, 1.98)
gameMap:drawLayer(gameMap.layers["Desen Katmanı 1"])
world:draw()
if mario.body then
local px, py = mario:getPosition()
mario.animation:draw(sprites.playerSheet, px, py, nil, 3 * mario.direction, 3, 15, 22)

if mario.grounded then
if mario.isMoving then
mario.animation = animations.marioRun
else
mario.animation = animations.marioStand
end
else
mario.animation = animations.marioJump
mario.animation:pauseAtEnd()
end
end
--playerDraw()
end

function loadMap()
gameMap = sti("maps/1.lua")
end
User avatar
Gunroar:Cannon()
Party member
Posts: 1141
Joined: Thu Dec 10, 2020 1:57 am

Re: How can I change the size of map, which I created in Tiled, by Simple-Tiled-Implementation library in Love?

Post by Gunroar:Cannon() »

Hellooo. First use [code][/code] tags instead of [quote] for code.
And try some research first :) :P

https://love2d.org/forums/viewtopic.php?t=80159 - sti scaling stuff

https://love2d.org/forums/viewtopic.php?t=84544 - camera sti stuff

http://love2d.org/forums/viewtopic.php?t=88704 - collsion sti stuff
...can do more on your own :ultrahappy:

I dunno, shouldn't you be using the box2d plugin for STI and then a camera to scale or something?

Also:
levelMap:draw(translationX, translationY, scaleX, scaleY)
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
User avatar
GVovkiv
Party member
Posts: 685
Joined: Fri Jan 15, 2021 7:29 am

Re: How can I change the size of map, which I created in Tiled, by Simple-Tiled-Implementation library in Love?

Post by GVovkiv »

Gunroar:Cannon() wrote: Sun Oct 24, 2021 10:17 pm And try some research first :) :P
Kinda funny to hear it from you
User avatar
Gunroar:Cannon()
Party member
Posts: 1141
Joined: Thu Dec 10, 2020 1:57 am

Re: How can I change the size of map, which I created in Tiled, by Simple-Tiled-Implementation library in Love?

Post by Gunroar:Cannon() »

GVovkiv wrote: Sun Oct 24, 2021 10:41 pm
Gunroar:Cannon() wrote: Sun Oct 24, 2021 10:17 pm And try some research first :) :P
Kinda funny to hear it from you
:rofl: Why? I do try. Any thread example where I did this?
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
User avatar
GVovkiv
Party member
Posts: 685
Joined: Fri Jan 15, 2021 7:29 am

Re: How can I change the size of map, which I created in Tiled, by Simple-Tiled-Implementation library in Love?

Post by GVovkiv »

Gunroar:Cannon() wrote: Sun Oct 24, 2021 10:17 pm :rofl: Why? I do try. Any thread example where I did this?
viewtopic.php?f=3&t=92211
I kinda like pgimeno's reply "Have you tried thinking instead of asking?"
viewtopic.php?f=3&t=92193
This
Why you don't google "good ui design for game" or "good hp bar design"?
Or maybe something about color rules?
Like, don't make white ui on white background, etc
viewtopic.php?f=3&t=92186&p=244222#p244222
It's not like that you can't google for "how to animate explosion" or "how to make explosion in game" or simply research real-life explosions (how they works, physics, colors, etc)
viewtopic.php?f=3&t=92119
Or even this
Seriously, you quite often asking something, that can be googled
It's not like you asking something that was never answered already by someone on internet
User avatar
Gunroar:Cannon()
Party member
Posts: 1141
Joined: Thu Dec 10, 2020 1:57 am

Re: How can I change the size of map, which I created in Tiled, by Simple-Tiled-Implementation library in Love?

Post by Gunroar:Cannon() »

These are all in the General subforum. That means I'm asking people's personal opinion on something. I can't ask google "What do you think of my health bar?" :rofl: though I could ask ... bing! (Haha, no :P )

(I learned 75% of my coding skills from google, me and google are old frenemies. Search "do a barrel roll" on google :P)

I get replies that really helped because I hadn't seen anything like that before. When I'm looking for general ideas I go to General I guess. If I really need help I go to support and development :) :?

I liked it that you spoke out. Any example from support and development?

Edit: Heheh, that's what I bought - I mean thought! Dang my peyboard.

Last edited by Gunroar:Cannon(), sometime in October, 21746 times
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
codename.ruby
Prole
Posts: 2
Joined: Sat Oct 16, 2021 11:43 am

Re: How can I change the size of map, which I created in Tiled, by Simple-Tiled-Implementation library in Love?

Post by codename.ruby »

Gunroar:Cannon() wrote: Sun Oct 24, 2021 10:17 pm Hellooo. First use tags instead of
for code.
And try some research first :) :P

https://love2d.org/forums/viewtopic.php?t=80159 - sti scaling stuff

https://love2d.org/forums/viewtopic.php?t=84544 - camera sti stuff

http://love2d.org/forums/viewtopic.php?t=88704 - collsion sti stuff
...can do more on your own :ultrahappy:

I dunno, shouldn't you be using the box2d plugin for STI and then a camera to scale or something?

Also:
levelMap:draw(translationX, translationY, scaleX, scaleY)
Well, I researched for hours before coming here. And I haven't found any reply that fixes my problem so that I asked.
You don't have to use box2d, I created my game without box2d and it works well.
And I found a solution for the size problem myself weeks ago. :) I changed the size of the tiles from 16x16 to 64x64 by using photoshop and it is solved. Thankss

Image
aa images
User avatar
Gunroar:Cannon()
Party member
Posts: 1141
Joined: Thu Dec 10, 2020 1:57 am

Re: How can I change the size of map, which I created in Tiled, by Simple-Tiled-Implementation library in Love?

Post by Gunroar:Cannon() »

codename.ruby wrote: Fri Nov 05, 2021 9:31 pmYou don't have to use box2d, I created my game without box2d and it works well.
Oh, yeah sorry. Don't know why I said that :? I think my mind went into collision detection. :|
And I found a solution for the size problem myself weeks ago. :) I changed the size of the tiles from 16x16 to 64x64 by using photoshop and it is solved. Thankss
:rofl: I see, it's that type of problem that can only be fixed by someone who looks at the "whole" game. Anyways it's looking nice.
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 9 guests