Tuesday, 12 April 2011

A conveyor belt of sprites

This is an example of a set of wrap around (or Conveyor belt) sprites that can be used in a frogger type game. It is inspired by a problem that a student was having with the technique. It is an example of using a list to hold a list of sprites. It also demonstrates the idea of sub classing as it uses a sprite class that we developed previously. The key to the technique is that the original random spacing of conveyor sprites is maintained once they start moving and once they go off the lefthand side of the viewport you just need to reposition them at their width extent to the right of the viewport. The original random spacing is preserved. The ConveyorSprite class subclasses the Sprite Class which is a Drawable Game component and as such draws itself. The Update method is overridden to update the position of the Conveyor sprite so that it moves across the screen and if it goes off the left then it is repositioned to the right of the viewport. As the new Conveyor sprites are being added to List of Conveyor Sprites in the main game class, the start relative position of each off screen to the right is calculated.

The code can be downloaded at


2 comments:

  1. Hi, I am visit your blogs and read your content. Your content and services are very nice. I am very impressed from your service. Conveyor a wide variety of products and fulfill a wide variety of applications. I am very happiness of these services.

    ReplyDelete
  2. This is an example of a set of wrap around (or Conveyor belt) sprites that can be used in a frogger type game. It is inspired by a problem that a student was having with the technique. gravity roller conveyors

    ReplyDelete