Jump to content
  • Advertisement
Sign in to follow this  
andfol

Scrolling static objects

This topic is 2450 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!