Skip to main content
GameDev.net gamedev.net
🔒 Locked

Scrolling static objects

Started by andfol Mar 26, 2012 at 10:52 AM 0 replies 1k views
Original Post
andfol
andfol
Hi,

I have implemented scrolling on two players in the game I am creating using gluLookAt in main:

{float x = (g_Player1.getPosX()+g_Player2.getPosX()/2);
float y = (g_Player1.getPosY()+g_Player2.getPosY()/2);
float z = (g_Player1.getPosZ()+g_Player2.getPosZ()/2);

gluLookAt( x, y+50,z+100,x, y, z,0.0f,1.0f,0.0f);}

I also have other objects in my game drawn with OpenGL that are static. I would like to get these objects to scroll through the game also. I would be grateful for any help.

Thanks.
destructivArts
destructivArts
I rrcently implemented this in my game, Im pretty sure there is a more effective way of doing this but this was how i tackled it:
Make two array lists for each kind of object that will be scrolling, one called active_____ and the other inactive______. Now create a function that will run through each array list checking if it is on the screen or not, and moving the elements to the appropriat function. Now all you have to do is check if the player is at the edge of the screen or near it. If he isnt, move the player, if he is, loop through each element and shift is x or y positions appropriately at the same speed the player moves at but in the opposite direction.

Hope this helps
Peter
-------------------------------------
"Other than that, I have no opinion."
My Blog - Check it Out

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.