[SOLVED] Generating a large world with an empty tileset
Posted: Sun Jun 28, 2020 4:25 pm
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
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:
In the update function I call the gameMap to update, also showing the cam rules (don't think this matters, it works as expected):
In the draw function:
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')
Code: Select all
gameMap:update(dt)
cam:lockPosition(player.body:getX(), player.body:getY(), cam.smooth.linear(350))
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]