Computer Science Canada

Help with making the screen scroll

Author:  NeutronX [ Tue Nov 06, 2007 8:49 pm ]
Post subject:  Help with making the screen scroll

I am making a racing game that requires the cars to move to the right of the screen. When a car gets to a certain point, I want the screen to scroll to the side which means that I can see new parts of the map. It is 2-D and I want the screen to stop scrolling at a certain amount. For example if 2000 pixels where scrolled right, then I want it to stop scrolling. Can someone please send me a code to do tjhis for me? Thanks in advanced!

Author:  Euphoracle [ Tue Nov 06, 2007 8:55 pm ]
Post subject:  RE:Help with making the screen scroll

Offset all your drawing, and if something is out of screen bounds, don't draw it at all. Very simply really :p

Author:  NeutronX [ Tue Nov 06, 2007 8:58 pm ]
Post subject:  Re: Help with making the screen scroll

I want the object which i can move myself more to the side and when it goes to a certain point it will scroll the screen

Author:  Euphoracle [ Tue Nov 06, 2007 9:24 pm ]
Post subject:  RE:Help with making the screen scroll

Then check if it is past XX% of the screen, and if it is, increase your offset to scroll it, and if they are less than YY%|YY<XX of the screen, scroll the other way. I don't really know how to explain it better than that.

Author:  NeutronX [ Tue Nov 06, 2007 9:26 pm ]
Post subject:  Re: Help with making the screen scroll

ok i understand but how do you increase your offset. Can you give me some code showing exactly what you mean plz?

Author:  Euphoracle [ Tue Nov 06, 2007 9:29 pm ]
Post subject:  RE:Help with making the screen scroll

var xoffset, yoffset : int
drawfill(xoffset + X, yoffset + Y, ...)

<check if the player is passed XX%>
xoffset += 30
<check if they are less than YY%|YY<XX>
xoffset -= 30

Or something rather. Haven't touched turing in years, sorry :p


: