Skip to main content
gamedev.net
🔒 Locked

Algorithm annoyances...

Started by Plasmarobo Aug 3, 2006 at 6:22 PM 0 replies 300+ views
Original Post
Plasmarobo
Plasmarobo
I have created an algorithm for clearing a space in a buffer that is 80 * 32 chars wide. Here is the code for the algorithm:

for(int y = 0; y != height+1; ++y)
		{

			if(y == 0 || y == height)
				{
					for(int x = 0; x < width; ++x)
					{
						cell = begin + (x +((80 - width) * y));
						buffer[cell].Char.AsciiChar = '=';
						TranslateColor(conti->bordercolor, color);
						buffer[cell].Attributes = color;
					}
				}
			else
				{
					cell2 = cell;
					for(int x = 1; x < width; ++x)
					{	
						buffer[cell2 + (x +((80 - width) * y))].Char.AsciiChar = ' ';
						buffer[cell2 + (x +((80 - width) * y))].Attributes = WHITE;
					}
					
						buffer[cell + (y * (80 - width))].Char.AsciiChar = '=';
						buffer[cell + (y * (80 - width))].Attributes = color;
						buffer[cell + (y * 80 )].Char.AsciiChar = '=';
						buffer[cell + (y * 80 )].Attributes = color;
				}
			}
	}


Right now it works as it is intended, but with one undesirable side effect: It clears the entire line, then writes the menu. So I have massive blank gaps on either side... Here: This is what it looks like (on debug mode) Yes, those giant gaps to the left and right of the menu a box are what I am talking about, I cannot figure out what part I need to change to fix them...
_________Optimists see the glass as Half FullPessimists See the glass as Half EmptyEngineers See the glass as Twice as big as it needs to be
SiCrane
SiCrane
Moved to General Programming.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.