Advertisement
spacechase0

Objects

May 28th, 2011
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. // Container
  2. std::list< GameObject* > objects;
  3.  
  4. // Step
  5. for ( std::list< GameObject* >::iterator it = objects.begin(); it != objects.end(); ++it )
  6. {
  7.     ( * it )->StepEvent();
  8. }
  9.  
  10. SortObjectsByDepth(); // Just one of my functions, you don't need to worry about that. :P
  11.  
  12. // Events
  13. for ( std::list< GameObject* >::iterator it = objects.begin(); it != objects.end(); ++it )
  14. {
  15.     ( * it )->StepEvent( event );
  16. }
  17.  
  18. // Draw
  19. for ( std::list< GameObject* >::iterator it = objects.begin(); it != objects.end(); ++it )
  20. {
  21.     ( * it )->Draw( window );
  22. }
  23.  
  24. // Termination
  25. for ( std::list< GameObject* >::iterator it = objects.begin(); it != objects.end(); ++it )
  26. {
  27.     delete ( * it );
  28. }
  29.  
  30. objects.clear();
  31.  
  32. // Adding objects - Example 1
  33. objects.push_back( new Block( Scene, pos, theme, blockType ) );
  34.  
  35. // Adding objects - Example 2
  36. objects.push_back( new Player( Scene, pos, drawingStyle ) );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement