Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Background for a side-scroller
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
chaos




PostPosted: 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?
Sponsor
Sponsor
Sponsor
sponsor
ProgrammingFun




PostPosted: Mon Aug 08, 2011 2:50 pm   Post subject: RE:Background for a side-scroller

Any code?
chaos




PostPosted: 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.


scrollingBackground.bmp
 Description:
 Filesize:  1.81 MB
 Viewed:  165 Time(s)

scrollingBackground.bmp



Background.t Code.bmp
 Description:
 Filesize:  1.39 MB
 Viewed:  247 Time(s)

Background.t Code.bmp


ProgrammingFun




PostPosted: 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?
chaos




PostPosted: 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.
crossley7




PostPosted: 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

Turing:

setscreen ("offscreenonly")
const screenx = 600
const picx = 2000
var xposition = 0
loop
    Pic.Draw (picid,-xposition,0,picCopy)
    if xposition = picx then
        xposition = 0
    elsif xposition + screenx >= picx then
        Pic.Draw (picid,picx-xposition,0,picCopy)
   end if
   % Player movement and collision detection etc.
   View.Update
   xposition+=1
end loop
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: