Tag Info

Hot answers tagged

12

This system with all these triggers sounds a bit too complicated and error prone. You could wrap the position of the player using modulo with something like playerPositionX = playerPositionX % mapWidth This way when your player reaches playerPosition == mapWidth the playerPosition will reset back to 0. This solution could be extended with the whole ...


10

The canonical solution is to use portals. In your example, there is only one level, except there is a portal connecting the left and right ends. Anything moving across that portal will have its coordinates translated to the other end of the portal, so that if something is moving left through the portal, it will reappear on the right side of the level and ...


6

Remember that what you display on screen, and what's in memory are two totally different things. Imagine you have a window that you need to fill with data about the world. You fill the window from left to right. While you're parsing your data to fill the world, if you reach the end of the world, simply loop back around to the beginning of your data. Using a ...


4

I assume this is because in these cases the grid lines are not exactly on screen pixels, but somewhere in between. Is this correct? Yes, this is correct. The camera in LibGDX is based on a vector, which is made out of floats. When your camera is in between pixels (like at (1.2f, 63.5f)), then you will start to see that blur you mention because the ...


2

Disconnect the rendering from the world and you can do wraparound and correct rendering without resorting to any cloning or teleporting artifacts. First, in your world you have a fixed size world, from 0 to Width. Anytime an object goes below 0 you wrap it to the end, and anytime an object is over Width wrap it to the start. This means that all logical ...


2

Just go really simple. Add a flag to the player that tells the camera when they're jumping. If they're jumping, don't follow them up. The other situation you need to handle is when the player jumps up or down to different levels. In this case it would be pretty simple to start tracking again when the player touches down, or if the player goes below the ...


1

I believe I know why it's behaving strangely. Here's a diagram I drew conceptually demonstrating the problem: I would solve the math for you too, but it should be easy enough from here. Give it a try and if you get stuck, just comment and ask.


1

So you need to call renderer.setView(orthoCamera) to reset the tile map drawing view. Then don't forget to also call camera.update() after you do anything to it.


1

Sorry for late answer - I originally jumped on the love IRC where I was pointed towards love.graphics's Coordinate Functions which allows you to modify love's coordinate system to do exactly what I wanted. Credit also to NauticaMile for suggesting hump.camera, which uses this as the underlying implementation. This example replaces my original hardcoded ...



Only top voted, non community-wiki answers of a minimum length are eligible