1. ## Graphics for pacman

Hi !

I have just started creating (the oft repeated & much harassed) the pacman game. I have created a 2 - D array, calling it map, that would serve to be my logical grid...

My 2 - D array contains following values :
0 - Empty, 1 - Wall, 2 - Pill, 3 - Ghost, 4 - Pacman

I want to create the grid graphically using information from 'map'...sumthng like where there is a '1' plot pixels & so on...Here's what I did (to create the walls or grid) :

Code:
```   for(int i = 0; i < MAX_SZ; i++)
{
x = 99;

for(int j = 0; j < MAX_SZ; j++)
{
if(map[i][j] == 1)
putpixel(x, y, BLUE);

x++;
}

y++;
}```
where MAX_SZ is 21 (rows or columns of map) & x & y are my starting point - 99

This code creates a 21 x 21 pixels grid (my animated pacman is bigger than the grid & gobbles it up when it is moved around )

Can you guys suggest me a better way to do this, as in creating a grid in which each cell is of uniform size (i.e, pixels) ?

I dont intend to use sprites or any other fancy graphics tool - just the graphics header in turbo c (happen to be targetting the dos enviroment).

2. The idea is probably that your grid may well be 21x21, but each "cell" is more than one pixel large. However large your pacman is -- that's how large everything should be. So if it's a wall, you don't just draw a pixel worth of blue; you make it a box of blue.

I don't know anything whatsoever about the graphics header in Turbo C, but hopefully there's a way to draw a box.

3. Thanks tabstop ! I understand the notion that you just described...in turbo c we dont have a function like a box but we do have a function called line() that can be used to achieve the same...its just that I have been unable to tweak my simple for loop to do that using line function...

4. I resolved my problem by doing this :

Code:
```   for(int i = 0; i < MAX_SZ; i++)
{
x = 49;

for(int j = 0; j < MAX_SZ; j++)
{
if(map[i][j] == 1)
{
//putpixel(x, y, BLUE);
line(x, y, x + 15, y);
line(x + 15, y, x + 15, y + 15);
line(x + 15, y + 15, x, y + 15);
line(x, y, x, y + 15);
}

x += 15;
}

y += 15;
}```
The idea is probably that your grid may well be 21x21, but each "cell" is more than one pixel large. However large your pacman is -- that's how large everything should be. So if it's a wall, you don't just draw a pixel worth of blue; you make it a box of blue.
That & an expresso really drove the point home