Log In  

Hello everyone,
I was recently working on a project and wanted to implement an infinite/looping horizontal scrolling system, similar to that of games like Sega's Fantasy Zone. (footage here: https://www.youtube.com/watch?v=L7WQYjC26SU) For those unfamiliar, in this game, if you scroll far enough in either direction horizontally, you'll loop back around to the start of the stage, seamlessly. I did sort of get it to work, by constantly drawing the map according to a set variable, rather than a fixed point, and setting it so if the player passes too far in either direction it resets to the start of either end. however it's very choppy and no less, doesn't really accommodate something like the camera system that game has, or at least I don't think it does.

I'm rather new to working with the Pico-8/coding in general, so I'm sorry if this is a bit of a bad question to ask/if you have any advice please do let me know. Likewise, thanks for reading this far into this post.

P#91875 2021-05-13 05:35 ( Edited 2021-05-13 05:37)

1

I would just keep the player in a small area (1 screen) and have the map and all the enemies/objects move instead of the player. Keep the camera still or have it move back and forth a little to give the impression of camera/player movement. And only render objects and map tiles whose adjusted positions are inside the camera view.

i'd start by generating/saving all the x positions of each map/enemy/object sprite in a list in your init(), then during update(), adjust all these x-positions by the opposite of whatever the player x-movement would have been each frame. If you switch directions, have the camera move in the player's movement direction within some limit.

I don't think this method will work if you're planning on drawing your map beforehand on the map page and rendering map(). It will only work if you draw from code.

Hope this helps.

P#91876 2021-05-13 05:57

Ah, that's sort of what I've been doing to begin with, although, I've been trying to avoid drawing from code given how many tiles that's probably gonna take, lol

As mentioned in the OP, it does sorta work with pre-drawn map tiles, however, the scrolling isn't smooth at all (it looks like an old MSX-era shmup, lol.) Likewise, I'll probably give drawing from code a try and update when that's done, lol.

P#91877 2021-05-13 06:12
1

This should take care of the looping background part. It just uses two copies of a background from the map area and the modulo operator "%" to make their positions cycle. Just draw a background you like that's one screen in width in the upper left corner of the map editor. You could make the looping background wider than one screen if you want, you'd just need to change the width parameter of the map() call and multiply 128 by the number of screens in width.

x=0
speed=2

function _update60()
 cls(12)
 x+=(btn()\2%2-btn()%2)*speed
 for i=0,1 do
  map(0,0,i*128-x%128,0,16,16)
 end
end
P#91880 2021-05-13 07:08 ( Edited 2021-05-13 08:24)

[Please log in to post a comment]