Tile map scrolling

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
bcvery1
Prole
Posts: 5
Joined: Wed Nov 12, 2014 11:18 am

Tile map scrolling

Post 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
Attachments
MazePrim.love
(55.04 KiB) Downloaded 137 times
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Tile map scrolling

Post 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.

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
Azhukar
Party member
Posts: 478
Joined: Fri Oct 26, 2012 11:54 am

Re: Tile map scrolling

Post 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.
Attachments
MazePrim_debug.love
(55.87 KiB) Downloaded 121 times
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 6 guests