[SOLVED] Generating a large world with an empty tileset

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
lostboii
Prole
Posts: 6
Joined: Sun Jun 28, 2020 4:00 pm
Location: North Carolina, US

[SOLVED] Generating a large world with an empty tileset

Post by lostboii »

EDIT: I realized that I had rules stating that the player would stop moving if their location was beyond the edge of the love.graphics.getWidth() values, so removing those does allow me to move freely through the map now. I also realized I was deceiving myself in thinking that the map itself wasn't being drawn, I had to put the background image on each tile to see that it was correctly tiling. I feel like I'm going to run into all sorts of other problems soon but for now I think I've got it! I'll try to include a .love file next time, haven't made it that far.

A quick note, I found that by getting the height * tileheight and width * tilewidth from the map.lua file, I could reset every love.graphics.getWidth() and love.graphics.getHeight() to respect my new mapW and mapH variables instead, which allows me to do things like center the player in the center of the map (useful since I'm not using formal "tiles" per se, just a big map that's a physics playground more or less.

--



Hello all, I'm new (<1week) to Löve, and am working on a top down space shooter with physics. I've gotten pretty far along, but I realized at some point that I was probably doing something pretty wrong.

I want a 5000x5000px play area for the player, and what I ended up doing was setting

Code: Select all

love.window.setMode(5000, 5000, {borderless=true})

which worked surprisingly well for the most part - I now have a 5000x5000 play area and I'm using hump's camera to track the player.

I noticed though when I get an error, it's a blue screen because I'm seeing only part of the "screen" on my 1080p monitor. Furthermore, HUD elements get lost somewhere in the ether or don't render at all (despite being drawn after camera:detach()) so I have resorted to relating my HUD elements to the player object.

So I decided to try using an actual tilemap in order to create the 5000x5000 area. I used Tiled and created a 10x10 map from 500px tiles that have absolutely nothing in them - no images and no object layers, just the basic tile layer.

However, when I load in, I am in a 1920x1080 area (my window.setMode) and when I move around, I'm definitely not in a 5000x5000 area. I'm not sure how to get the game to render the entire map.

My code is as follows:

In load:

Code: Select all

love.window.setMode(1920, 1080, {borderless=true})
myWorld = love.physics.newWorld(0, 0, false)

-- may be worth noting that I use a quad to tile a background
bg_quad = love.graphics.newQuad(0, 0, love.graphics.getWidth(), love.graphics.getHeight(), sprites.background:getWidth(), sprites.background:getHeight())

sti = require('sti/sti')

cameraFile = require('hump/camera')
cam = cameraFile()

gameMap = sti('map/map.lua')
In the update function I call the gameMap to update, also showing the cam rules (don't think this matters, it works as expected):

Code: Select all

gameMap:update(dt)
cam:lockPosition(player.body:getX(), player.body:getY(), cam.smooth.linear(350))
In the draw function:

Code: Select all

cam:attach()
gameMap:drawLayer(gameMap.layers['Tile Layer 1'])
-- [I draw everything else after this aka the bg quad and sprites]
cam:detach()
-- [I then draw the HUD elements]
Last edited by lostboii on Sun Jun 28, 2020 7:22 pm, edited 3 times in total.
lostboii
Prole
Posts: 6
Joined: Sun Jun 28, 2020 4:00 pm
Location: North Carolina, US

Re: Generating a large world with an empty tileset

Post by lostboii »

I realized that I had rules stating that the player would stop moving if their location was beyond the edge of the love.graphics.getWidth() values, so removing those does allow me to move freely through the map now. I also realized I was deceiving myself in thinking that the map itself wasn't being drawn, I had to put the background image on each tile to see that it was correctly tiling. I feel like I'm going to run into all sorts of other problems soon but for now I think I've got it! I'll try to include a .love file next time, haven't made it that far.
lostboii
Prole
Posts: 6
Joined: Sun Jun 28, 2020 4:00 pm
Location: North Carolina, US

Re: Generating a large world with an empty tileset

Post by lostboii »

A quick note, I found that by getting the height * tileheight and width * tilewidth from the map.lua file, I could reset every love.graphics.getWidth() and love.graphics.getHeight() to respect my new mapW and mapH variables instead, which allows me to do things like center the player in the center of the map (useful since I'm not using formal "tiles" per se, just a big map that's a physics playground more or less.
User avatar
zorg
Party member
Posts: 3444
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Generating a large world with an empty tileset

Post by zorg »

Hi and welcome to the forums.

First of all, notice that your posts have edit and delete buttons. (pencil and X, left of the ! report and " quote buttons) Feel free to edit your first post to contain the other two, then delete the other two so you avoid posting multiple times when no one else has responded yet.

So, love.window.setMode is for setting the game window's size and other properities. You really don't want to use that for defining or tying it to the size of your world.

Things can exist even if they're outside the window; as you said, just use a camera system to offset what part of the world you want displayed in your viewport, that being the window.

The other reason why it's bad is because not many people have a display that can show the entirety of an 5000x5000 window... best keep it user-settable like how most games offer you resolution settings, or just a small enough one; say 800x600... at least by default... or the size of the user's screen... although fullscreen by default may piss some people off too. :monocle:
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
lostboii
Prole
Posts: 6
Joined: Sun Jun 28, 2020 4:00 pm
Location: North Carolina, US

Re: Generating a large world with an empty tileset

Post by lostboii »

Hi zorg, thank you! I'm definitely on the right path now.

I don't seem to have a delete option, I edited my original post to include the others but I just have pencil, explanation mark and quote, no X. Oddly, I have the X option on this comment itself, but not the other 3. Edit: I think I get it, I can't delete once someone else has replied. I'll keep that in mind for next time, don't want to appear as bumping. My bad!
Post Reply

Who is online

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