Computer Science Canada Background for a side-scroller |
Author: | chaos [ Mon Aug 08, 2011 2:05 pm ] |
Post subject: | Background for a side-scroller |
I have an image that I want to use as a background for a side-scroller. The problem that I am having is looping the image infinitely. How do I go about this? |
Author: | ProgrammingFun [ Mon Aug 08, 2011 2:50 pm ] |
Post subject: | RE:Background for a side-scroller |
Any code? |
Author: | chaos [ Mon Aug 08, 2011 3:51 pm ] |
Post subject: | Re: Background for a side-scroller |
Sure, I put the code as an image. The first is the code and the second is the background. |
Author: | ProgrammingFun [ Mon Aug 08, 2011 4:01 pm ] |
Post subject: | RE:Background for a side-scroller |
Just to clarify, this background scrolls as the player moves along? |
Author: | chaos [ Mon Aug 08, 2011 4:23 pm ] |
Post subject: | Re: Background for a side-scroller |
Not exactly. I want the background to scroll while the player moves freely about the screen. My goal is to first get the background scrolling in a seamless loop first, and then I wish to move onto player control. |
Author: | crossley7 [ Mon Aug 08, 2011 8:51 pm ] | ||
Post subject: | Re: Background for a side-scroller | ||
I would recommend having a variable(x) that contains the x position of the picture (which spot is at x = 0 on the screen) and a variable that holds the size of the picture(y) (unless it is a known number you will always use) then once it reaches a point where x+ screenx = y then you will draw the picture at x+screenx as well until x=y (the first picture has looped through) at which point you can reset x to 0. So the code might look like
|