Computer Science Canada

Moving the screen

Author:  Diablo117 [ Fri Jun 05, 2009 12:04 am ]
Post subject:  Moving the screen

What is it you are trying to achieve?
Moving the screen as my character moves in a 2D side scrolling shooter

What is the problem you are having?
It..doesnt move?

Please specify what version of Turing you are using
4.0.5

Author:  shoobyman [ Fri Jun 05, 2009 12:42 am ]
Post subject:  Re: Moving the screen

Well, your not going to be moving the screen. Instead, every background object will need to have an x and y location variable, and when u want the illusion of a moving screen, you just move the background scenery by changing the x and y variables (uniformly)

Author:  saltpro15 [ Fri Jun 05, 2009 8:41 am ]
Post subject:  RE:Moving the screen

I think the proper name for it is blitting. Like shoobyman said, you are going to need x and y position variables and use them to move your background.

Author:  Diablo117 [ Fri Jun 05, 2009 8:00 pm ]
Post subject:  Re: Moving the screen

Alright, so for something like this, I would create "spawn points" for my enemy objects to appear in every once in a while, and they would move to the left as required. When the player is at a certain area(past half-way of the screen) then all the objects move an additional position to the left?

Author:  saltpro15 [ Fri Jun 05, 2009 8:17 pm ]
Post subject:  RE:Moving the screen

that would work yes, as long as you remember to repeat your background so you don't have whitespace

Author:  Diablo117 [ Fri Jun 05, 2009 10:19 pm ]
Post subject:  Re: Moving the screen

Mmm, im thinking of making a tile-based background for easier collision detection but idk.

Author:  PrimalDoom [ Thu Jun 11, 2009 9:25 pm ]
Post subject:  Re: Moving the screen

The best way I've found to move the screen is to do this

WinY = half of your screen along the Y axis
WinX = half of your screen along the X axis

Y = your players Y coordinate
X = your players X coordinate

WinMoveY = the location all players are moved to on the screen when you move. Your player is also affected by this. WinMoveY is added to the Y coordinate of everything that gets drawn on the screen.

WinMoveX = the location all players are moved to on the screen when you move. Your player is also affected by this. WinMoveX is added to the Y coordinate of everything that gets drawn on the screen.

if WinY - Y ~= 0 then
WinMoveY := - Y + WinY

end if

if WinX - X ~= 0 then
WinMoveX := - X + WinX

end if

or something like that any way i solved it in the game i was making, it's not done yet but it works and i haven't found any flaws with the game in terms of were this piece of code is concerned.


: