I've gone and done this: https://love2d.org/wiki/Tutorial:Effici ... _Scrolling
Fast forward and I've added to the code a bit. One change I've done is have it interpret a one-dimensional array: instead of map[x][y], it's map[1,2,etc.]
My problem is, it doesn't display the first row and the last column of tiles. So instead of showing a 20x20 grid, it displays 19x19. I've tested out the original code from the tutorial and it has essentially the same issue(doesn't display last row/column.) If there's any input I can get as to what the problem is, I'd appreciate it.
I have included the project files.
Thanks!
Problem with "Tutorial:Efficient Tile-based Scrolling" Tutorial
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 2
- Joined: Thu Feb 09, 2017 8:57 am
Problem with "Tutorial:Efficient Tile-based Scrolling" Tutorial
- Attachments
-
- main.lua
- (2.55 KiB) Downloaded 125 times
-
- maptest2.lua
- The map to be generated
- (1.3 KiB) Downloaded 118 times
Re: Problem with "Tutorial:Efficient Tile-based Scrolling" Tutorial
Hi SentientPotato,
Try changing:
to (note the "+ 1"s)
and:
to (note the "- 1"):
Try changing:
Code: Select all
map_x = math.max(math.min(map_x + dx, map_w - map_display_w), 1)
map_y = math.max(math.min(map_y + dy, map_h - map_display_h), 1)
to (note the "+ 1"s)
Code: Select all
map_x = math.max(math.min(map_x + dx, map_w - map_display_w + 1), 1)
map_y = math.max(math.min(map_y + dy, map_h - map_display_h + 1), 1)
and:
Code: Select all
tilesetBatch:add(tileQuads[map[(x + (y+math.floor(map_y)) * map_w)+ math.floor(map_x)]], x*tileSize, y*tileSize)
to (note the "- 1"):
Code: Select all
tilesetBatch:add(tileQuads[map[(x + (y+math.floor(map_y - 1)) * map_w)+ math.floor(map_x)]], x*tileSize, y*tileSize)
-
- Prole
- Posts: 2
- Joined: Thu Feb 09, 2017 8:57 am
Re: Problem with "Tutorial:Efficient Tile-based Scrolling" Tutorial
Thank you, Santos!
I implemented your suggested changes, and it works! I knew it had to be something simple, I just couldn't wrap my head around what exactly was missing.
I implemented your suggested changes, and it works! I knew it had to be something simple, I just couldn't wrap my head around what exactly was missing.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 7 guests