Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Sprite Animation An exercise on filling circles and polygons to create the animated sprite used in ‘Pac Man’"— Presentation transcript:

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

2 What is a ‘sprite’? It’s a small graphics pixmap image
It’s normally stored in off-screen VRAM It’s ready to be copied to on-screen VRAM The copying operation is called a ‘BitBlt’ Several sprites can support an animation Let’s 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 sprite’s location Let user control direction with arrow-keys Store your sprite-arrays in offscreen vram


Download ppt "Sprite Animation An exercise on filling circles and polygons to create the animated sprite used in ‘Pac Man’"

Similar presentations


Ads by Google