Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Menu Drawing is Tweaking Out! MEDIC!!

This thread is locked; no one can reply to it. rss feed Print
Menu Drawing is Tweaking Out! MEDIC!!
xmltorrent
Member #7,673
August 2006

I'm writing a bit of code to handle drawing windows in a menu system for a RPG. So far everything works but I'm having a slight problem.

I can draw two windows no problem. When I go to draw the third window, the background of the window overflows off the bottom of the screen and for the life of me, I can' figure out why the heck it's doing that. I'm not sure if it's in the function I'm using to draw the window or not.

Here's the function:

1void drawMenuRect(BITMAP *target, int x1, int y1, int x2, int y2){
2 //variable declarations
3 int borderCounter = 1;
4 int innerCounter = 6;
5 int red = 205;
6 int green = 205;
7 int blue = 205;
8 
9 //acquire the bitmap to draw on to optimize speed
10 acquire_bitmap(target);
11 
12 //draw the outer border rectangle to start with
13 rect(target, x1, y1, x2, y2, makecol(255, 255, 255));
14 
15 //finish the border
16 while(borderCounter < 6){
17 //draw a rectangle with the current values
18 rect(target, x1 + borderCounter, y1 + borderCounter, x2 - borderCounter, y2 - borderCounter, makecol(red, green, blue));
19 
20 //increment borderCounter;
21 borderCounter++;
22 
23 //decrease the col color values (3D effect)
24 red -= 25;
25 green -= 25;
26 blue -= 25;
27 }
28 
29 //reset the color values to draw the inside of the window
30 red = 0;
31 green = 0;
32 blue = 255;
33 
34 //draw the color for the windows
35 while(innerCounter <= y2 - 15){
36 //draw a line of color
37 line(target, x1 + 6, y1 + innerCounter, x2 - 6, y1 + innerCounter, makecol(red, green, blue));
38 
39 //increment innerCounter
40 innerCounter++;
41 
42 //decrement the value of blue
43 blue -= 1;
44 
45 //make sure that if blue reaches zero, make sure it stays zero
46 if(blue <= 0)
47 blue = 0;
48 }
49 
50 //release the bitmap
51 release_bitmap(target);
52}END_OF_FUNCTION(drawMenuRect);

Thanks in advance for any help.

Kris Asick
Member #1,424
July 2001

You should post the code that calls your drawing routine and a screenshot of the windows being drawn. "background of the window overflows off the bottom of the screen" could mean a lot of different things.

--- Kris Asick (Gemini)
--- http://www.pixelships.com

--- Kris Asick (Gemini)
--- http://www.pixelships.com

Go to: