Page 1 of 1

Tile map scrolling

Posted: Thu Nov 27, 2014 10:51 am
by bcvery1
Hi, I'm relatively new to this, and have put together a maze generator (using the Randomized Prim's algorithm) with a player to navigate around the maze.

The maze generates fine, and I have created physics boxes for the walls and the player with no problem. I can get the player to move around the map, but the map, whilst scrolling at the same rate, is not moving the drawing range quickly enough. I.E. it is starting drawing an earlier tile than it should.

I realise that this is not that easy to explain in words, however if you run the file and move right/down (using wasd) you'll see the map stop drawing.


Have I missed out a +/- somewhere, or am I misunderstanding something about graphics.translate (or something else entirely!)?

Many thanks,
BCvery1

Re: Tile map scrolling

Posted: Thu Nov 27, 2014 4:03 pm
by s-ol
bcvery1 wrote:Hi, I'm relatively new to this, and have put together a maze generator (using the Randomized Prim's algorithm) with a player to navigate around the maze.

The maze generates fine, and I have created physics boxes for the walls and the player with no problem. I can get the player to move around the map, but the map, whilst scrolling at the same rate, is not moving the drawing range quickly enough. I.E. it is starting drawing an earlier tile than it should.

I realise that this is not that easy to explain in words, however if you run the file and move right/down (using wasd) you'll see the map stop drawing.


Have I missed out a +/- somewhere, or am I misunderstanding something about graphics.translate (or something else entirely!)?

Many thanks,
BCvery1
About physics bodies:
From love.physics on the wiki:
"love.physics is not lightweight, and not even remotely simple to use. It's a ten-ton hammer designed for heavy-lifting (er...hammer...lifting?)
If you are just trying to make a character jump around on blocks or the likes, then move along, nothing to see here."

By using love.physics you are overpowering and slowing down your game plenty. Box2D/l.p is made well enough for you to not notice that immediately, but as you build larger levels and have enemies and other dynamic objects this might get hard to keep up, it also is more complicated than a more fitting solution like bump.lua anyway.

I will look at your actual code & question when I'm home.

Re: Tile map scrolling

Posted: Thu Nov 27, 2014 4:16 pm
by Azhukar
I have added a physics world debug function to your main.lua file. Here is the updated .love archive. Play around with it and see how you can make map scrolling.

The only thing I added was the debugWorldDraw function and its callback, plus I disabled your own world draw and called the debugWorldDraw function in love.draw, all in main.lua. The important part for you is the translate coordinates.