Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Hiya,

 I don't understand how that code works, updateBGColumn uses a variable y but it's never defined or populated. Not sure if you posted the whole thing or I'm missing something.

 However,  I can show you my scrolling map code if it helps. It's a bit more complicated than yours, but allows for some configuration

https://github.com/pmprog/dronedelivery.proto/blob/main/engine/mapex.h
https://github.com/pmprog/dronedelivery.proto/blob/main/engine/mapex.c

Basically, on mapex_setviewport it will completely redraw the screen at a desired location, but it takes time, so using mapex_scrollviewport to move it runs quicker (unless the distance for the scroll is too far, in which case the viewport will be completely redrawn). The scroll then just maintains the tiles that are offscreen, populating them with what's next to come.

I'm sure there's probably better ways of doing large maps than I've done here, but it works well enough for me.

PS. If you do build the project and try it out, the fact the camera is jerky as you move is not to do with the scrolling code, rather just the camera controller, which I never got around to fixing.

(1 edit)

Thank you very much. In the end I did not use your code, but I will definetely keep it around. I like how you handle the jump scroll (where you scroll to a random position and you need to fill the entire screen then).

My original code was just a sample. I did not post it all, cause there is a lot of bloat. I tried to copy the important parts. The vertical scroll code was identical to the horizontal scroll, so I skipped it. I did include the functions I believe, I was just not calling them.