Sprite Animation PowerPoint PPT Presentation

presentation player overlay
About This Presentation
Transcript and Presenter's Notes

Title: Sprite Animation


1
Sprite Animation
  • An exercise on filling circles and polygons to
    create the animated sprite used in Pac Man

2
What is a sprite?
  • Its a small graphics pixmap image
  • Its normally stored in off-screen VRAM
  • Its ready to be copied to on-screen VRAM
  • The copying operation is called a BitBlt
  • Several sprites can support an animation
  • Lets see how to create a sprite array, then
    synchronize BitBlts with Vertical Retrace

3
The Pac Man sprite
1. Fill a circle with the foreground color 2.
Fill a triangle in the background color
4
The Pac Man sprite-array
Create an array of sprites, arranged in a
sequence that matches the order in which they
will be drawn to VRAM
5
Typical animation loop
  • sprite pacman 8 // the array of
    sprite-images
  • int i 0
  • while ( !done )
  • draw( pacman i , vramptr )
  • vsync() // await next vertical retrace
  • hide( sprite i , vramptr )
  • i ( i ) 8 // cycle through sprite array

6
Multiple sprite-arrays
RIGHT
DOWN
UP
7
Demo sprites.cpp
  • Study the source-code for this demo
  • Arrange your sprites in an array
  • Write a sprite-animation loop
  • Incorporate movement in sprites location
  • Let user control direction with arrow-keys
  • Store your sprite-arrays in offscreen vram
Write a Comment
User Comments (0)
About PowerShow.com