46.1 Overview

Sprites are elementary parts of many applications. They can be used for many different purposes and Hollywood is very flexible with them because they are implemented fully in software. Thus, there are no restrictions on sprite size, colors, transparency and so on. Traditionally, sprites are used for player and enemy graphics in games but they also come handy in many other situations.

Generally spoken, sprites have three distinctive attributes which distinguishes them from brushes:

  1. Sprites are always on the front of the display.
  2. Every sprite can only be once on the screen.
  3. A Sprite can have multiple frames.

A more detailed explanation of sprite features follows below.

  1. Sprites are always on the front of the display. Look at the following code:

     
    LoadBrush(1, "test.iff")
    LoadSprite(1, "test2.iff")
    DisplaySprite(1, 0, 0)
    DisplayBrush(1, 0, 0)
    

    You see that we load two images: Brush 1 and sprite 1. Now we draw sprite 1 and after that we draw brush 1. Normally, brush 1 should be drawn over sprite 1 because it DisplayBrush() is called after DisplaySprite(). Sprites, however, are always on the front of the display and that is why in this special case, brush 1 is drawn behind sprite 1.

    This applies to all normal graphics commands of Hollywood: You can never draw graphics over a sprite! Sprites are always on the front and normal functions, i.e. non-sprite functions, can never paint sprites over. You can only draw sprites over with new sprites.

  2. Every sprite can only be on the screen once. Look at the following code:

     
    LoadSprite(1, "test.iff")
    DisplaySprite(1, 0, 0)
    DisplaySprite(1, 100, 100)
    

    You see that we display sprite 1 two times. First, it is displayed at 0:0 and second, it is displayed at 100:100. Because every sprite can only be on the screen once, the second call to DisplaySprite() will not draw sprite 1 again but move it from 0:0 to 100:100 instead. DisplaySprite() checks if sprite 1 is on the screen, and if it is, it is picked up and moved to the new position. Thus, you can easily move your sprites around on the screen.

  3. A sprite can have multiple frames. Because sprites are often used for animation, each sprite can carry multiple frames just like a Hollywood animation object. The DisplaySprite() command accepts an optional argument which allows you to specify which frame it shall show.

Additional information on the sprite implementation in Hollywood:


Show TOC