How to limit a line scroll to a certain part of the world? - Printable Version +- Tilengine - The 2D retro graphics engine forum (http://tilengine.org/forum) +-- Forum: English forums (http://tilengine.org/forum/forumdisplay.php?fid=3) +--- Forum: Game development topics (http://tilengine.org/forum/forumdisplay.php?fid=13) +--- Thread: How to limit a line scroll to a certain part of the world? (/showthread.php?tid=1368) |
How to limit a line scroll to a certain part of the world? - RootBeerKing - 12-19-2021 Hello, I'm having trouble figuring out how to go about limiting a raster effect line scroll to a certain part of the world. I understand the way raster effects work is screen based. But how would I go about having the effect only appear on screen when the world is at a certain position? Example: https://i.gyazo.com/8c9cb92f7c9108795c7f410a645cac6a.mp4 As you can see in the example the effect on the grass looks fine when the camera is low to the ground, however once you move up the raster effect is ruined as it is no longer covering the part of the background that it was once scrolling. Currently the code for this effect is pretty simple Code: void GrassLineScroll(int line) Any help with this would be much appreciated. Thank you once again. Cheers, RBK RE: How to limit a line scroll to a certain part of the world? - megamarc - 12-24-2021 Hi! Cool effectyou did with the grass. Solving the issue is easy. You just have to compensate for the y offset. For example, if you scroll the world 10 pixels positive -so the layer moves upwards from bottom to top-, you have to compensate by substracting the same amount of pixels to the raster effect lines: Code: void GrassLineScroll(int line) This works assuming that the raster lines in your code work when y_world = 0, if not, you have to include the value y_world has when it is "grounded". Happy Christmas! |