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]