Draw Pacman

In this activity you need to complete the function drawPacman in the provided program.

Download pacman.c, or copy it into your current directory on a CSE system by running

$ cp /web/cs1511/17s2/week06/files/pacman.c .

You are provided with the following representation of a pixel:

typedef struct _pixel {
    unsigned char red;
    unsigned char green;
    unsigned char blue;
} pixel;

You need to complete the drawPacman function so that it fills in its given 2-dimensional pixel buffer with the colours to show an image of pacman.

You have artistic licence here, so it doesn’t have to be exact.

Remember, the pixel buffer is used pixels[y][x], with rows first.

If you don’t think that a three by three image is large enough to draw a good PacMan, you can change the value of SIZE to make the image larger.

The program will send the data for the image to the screen output. To send it into a file instead run it using the following commands:

$ dcc -o pacman pacman.c
$ ./pacman > pacman.bmp
$ eog pacman.bmp

To run Styl-o-matic:

$ 1511 stylomatic pacman.c
Looks good!

You’ll get advice if you need to make changes to your code.

Submit your work with the give command, like so:

$ give cs1511 wk06_pacman

Or, if you are working from home, upload the relevant file(s) to the wk06_pacman activity on Give Online.