Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do sprites work?

How do sprites work?

I've seen sprites from old school games like Super Mario Brothers, and wondered how they're animated to make a game.

They're always presented as one big image map, so how are they used?

For Mario (as an example) are there precalculated image co-ordinates that outline mario, and are swapped between various mario sprites to produce animation?

Or are sprites pre "cut" during game initialization using precalculated images co-ordinates and stored in memory somewhere?

Obviously I know nothing about game development.

like image 807
Alan Avatar asked Dec 06 '22 02:12

Alan


2 Answers

On many older video game and computer systems, sprites were a hardware feature which would overlay small images onto a larger screen. Although the Atari 7800 had a sprite implementation similar to what is described in the Wikipedia article, it was practically unique in that regard. Most sprite systems used a separate group of circuitry for every sprite they could show on a scan line, including a horizontal position trigger and a shift register or other means to send data sequentially. When the raster scan reached the appropriate place on a line, the circuitry would start shifting out the shape data for the sprite.

Some machines (like the Odyssey2) included within the video chip hardware to hold the shapes of all the sprites on the screen. The Atari 2600 only held 8 bits of shape data for each sprite, and required the processor to load the data in real time anywhere it was supposed to change. The most common pattern, however, was for the video chip to clock sprite data from memory automatically. Typically, the hardware would expect the data to be in a particular format or, in some cases, one of two formats.

On some machines, the number of sprites that can display simultaneously on a frame without CPU intervention equals the number of sprite circuits. Other machines have a small number of sprite circuits, but can display more sprites; as soon as a circuit finishes displaying a sprite, it loads the parameters for the next sprite from memory. The NES fits this pattern.

like image 136
supercat Avatar answered Dec 27 '22 02:12

supercat


http://en.wikipedia.org/wiki/Sprite_(computer_graphics)

Though the article doesn't seem to talk about your specific question, now that I look through it thoroughly...

Anyway, it can probably be done either way, but if I ever had to implement a sprite handler I'd probably go with the splitting method (though as stated in another answer, the coordinate-reference method would probably be easier to implement for a simple animation).

like image 36
JAB Avatar answered Dec 27 '22 01:12

JAB