I moved to a new URL! Check it out!

Dev Log: Parallax and Repeating

Dev Log: Parallax and Repeating
Just churning away at my SFML framework that I'm building with C#. The past two days I've added parallax scrolling (similar to Flashpunk's scrollX and scrollY variables) to images, as well as the ability for images to repeat. The cool thing about the repeating is that it's being done at the base image class, so even animated sprites can be repeated across the screen!

Image


Also if you're working with SFML C# yourself, you should check out this TextureAtlas class written by Mark J. A. Smith. I have yet to implement something like this in my framework yet because I haven't really noticed performance issues, but using texture atlases can greatly reduce the amount of texture switching between drawing things, which helps a lot with performance.

Back to work!

Comments

Jacob Albano
Jacob Albano
Nice! What sort of approach are you going with for parallax? It it a scrollX/Y render offset type of deal, and if so are you still using SFML Views to orient the camera? I'm still trying to decide how I'm going to implement parallax in my framework.
Posted June 7th 2013 2:17 PM
Kyle
Kyle
Here's my code to draw stuff now:

float renderX = X + x, renderY = Y + y;
if (ScrollX != 1) {
renderX = X + Draw.Target.CameraX * (1 - ScrollX) + x;
}
if (ScrollY != 1) {
renderY = Y + Draw.Target.CameraY * (1 - ScrollY) + y;
}

Draw.Target a class that wraps rendertexture that is currently active, and cameraX and cameraY just control the view for that texture. That formula "X + cameraX(1-scrollX)" seems to do the trick, but I'm not sure if that's the best way to do it!
Posted June 7th 2013 2:21 PM
Jacob Albano
Jacob Albano
Cool, sounds good. I've got ScrollX and ScrollY properties in all of my graphic classes and they aren't doing anything at the moment. :P Time to put them to use!
Posted June 7th 2013 2:31 PM
new comment!

Post your comment!

Name
Email
Comment