Thread: Display Lists (OpenGL)

  1. #1
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    968

    Display Lists (OpenGL)

    Are they the equivalent of writing into memory and using whats stored in memory to draw what you see on the screen?

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Well I don't pretend to be an OpenGL expert but it is my understanding that once you have created and populated a display list, calling the list would cause the commands in the list to be executed just as if had been given normally by the user.

    Here is the OpenGL ref page that maybe of some help:

    http://www.opengl.org/documentation/...1/node123.html
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  3. #3
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    I concur with MrWizard's understanding. Only I believe it is supposed to also be faster than calling them yourself because no function call is being made for each instruction.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  4. #4
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    968
    Alrighty so thats not what im interested in yet either...

    I'm interested in learning how to draw things just to memory without displaying them, and then bringing them out of memory on the fly and sending them back when i dont need to see them anymore

    A few friends of mine made a breakout game in turbo C++ and after a few levels it started getting very laggy, I'm assuming because they never actually destroyed the blocks, they just either made them black or transparent.....

    I'm looking for a way to get around that,

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Quote Originally Posted by Shamino
    Alrighty so thats not what im interested in yet either...

    I'm interested in learning how to draw things just to memory without displaying them, and then bringing them out of memory on the fly and sending them back when i dont need to see them anymore

    A few friends of mine made a breakout game in turbo C++ and after a few levels it started getting very laggy, I'm assuming because they never actually destroyed the blocks, they just either made them black or transparent.....

    I'm looking for a way to get around that,
    As long as you free all of your resources at the end of each level that need to be freed, I don't see why after a few levels it would become laggy. They probably just had some serious memory leaks.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  6. #6
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    yes, something you're doing outside of opengl calls is likely allocating memory and failing to free it. Post code?
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  7. #7
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    968
    we made these in a programming class in high school, we really didn't use pointers way back then, not allocating memory for much of anything...

    I just think that because they would draw the blocks with a function, you can never actually get rid of them unless you write them into the backbuffer and flip it n stuff... so it would just add up and add up, a memory leak I suppose, I'll post the code....

  8. #8
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    968
    Now remember, this is me, a 17 year old kid, not quite a year of C++ experience, making breakout.... Here goes...

    Code:
    #include<iostream.h>
    #include<constream.h>
    #include<graphics.h>
    #include<conio.h>
    #include<dos.h>
    #include<process.h>
    #include<stdlib.h>
    #include<string.h>
    #include<strstrea.h>
    #include<time.h>
    #include"ms-mouse.h"
    
    
    const int RAD = 5;
    const int MAX = 10;
    const int MAX2 = 20;
    const int MIN = 6;
    const int GRAY = 8;
    int D = 60;
    const int C = 6;
    const int T = 7;
    const int T2 = 1;
    const int T3 = 1;
    const int e = 2;
    const int H = 3;
    int W = 30;
    const int BH = 6;
    const int BW = 42;
    const char RARROW = 77;
    const char LARROW = 75;
    const char RIGHT2 = 120;
    const char LEFT2 = 122;
    const char QUIT = 17;
    const char RETURN = 13;
    const char PAUSE = 112;
    const char SOUND = 115;
    const char CHEAT1 = 26;
    const char CHEAT2 = 24;
    const char CHEAT3 = 22;
    const char SPACE = 32;
    
    
    int mod = 0;
    int bmod = 0;
    int lasers = 0;
    int oldlasers = lasers;
    int victorys = 0;
    int left = 5;
    int right;
    int speed;
    int pscore = 0;
    int oldpscore = pscore;
    int level = 1;
    int oldlevel = 0;
    int ballnumb=4;
    int oldball = ballnumb;
    int s = 0;
    enum status{NORMAL, BALLUP, TRIBALL, EXPANDED, SLOWBALL, LASER, SAFETYBAR, DOUBLETROUBLE, BALLDOWN, SPEEDBALL, SKINNY};
    enum horz{LEFT, RIGHT};
    enum vert{UP, DOWN};
    enum yesno{YES, NO};
    enum rotation{CLOCKWISE, COUNTERCLOCKWISE};
    yesno soun = YES;
    yesno oldsound=soun;
    yesno ball1 = YES;
    yesno ball2 = NO;
    yesno ball3 = NO;
    status stat = NORMAL;
    yesno score = NO;
    yesno lasera = NO;
    yesno mouseactive = YES;
    class player;
    
    void stdboard();
    void good(player,player);
    void bad(player,player);
    
    
    class money
    	{
    	private:
    	long double money1;
    	char money2[MAX2];
    
    	public:
    	money()
    		{
    		for(int j=0; j<MAX2; j++)
    			{
    			money2[j] = '\0';
    			}
    		}
    	void ldtoms();
    	void reversit();
    	void putld(int numb)
    		{
    		money1 = numb;
    		ldtoms();
    		}
    	char* retmon()
    		{
    		return money2;
    		}
    	};
    
    class ball
    	{
    	private:
    		int oldx;
    		int oldy;
    		int xco;
    		int yco;
    		int xspeed;
    		int yspeed;
    		int oldxs;
    		int oldys;
    		horz hdir;
    		horz newd1;
    		vert vdir;
    		vert newd2;
    		int timer;
    		int xhit;
    		int yhit;
    
    	public:
    		ball(int x, int y, int xs, int ys)
    			{
    			xco = x;
    			yco = y;
    			oldx = x;
    			oldy = y;
    			hdir = RIGHT;
    			vdir = UP;
    			xspeed = xs;
    			yspeed = ys;
    			timer = 0;
    			xhit = 0;
    			yhit = 0;
    			}
    		void set(int x, int y, int xs, int ys)
    			{
    			xco = x;
    			yco = y;
    			oldx = x;
    			oldy = y;
    			hdir = RIGHT;
    			vdir = UP;
    			xspeed = xs;
    			yspeed = ys;
    			timer=0;
    			xhit = 0;
    			yhit = 0;
    			}
    		int rety()
    			{
    			return yco;
    			}
    		int retx()
    			{
    			return xco;
    			}
    		void calc()
    			{
    			oldx = xco;
    			oldy = yco;
    			if((timer==0)||(yco>435))
    				{
    			int test1 = random(4);
    			if(xhit == 1)
    					{
    					xspeed = oldxs;
    					yspeed = oldys;
    					hdir=newd1;
    					switch(test1)
    						{
    						case 1:
    							xspeed++;
    							break;
    						case 2:
    							xspeed--;
    							break;
    						case 3:
    							xspeed--;
    							break;
    						default:
    							break;
    						}
    					xhit = 0;
    					if(soun == YES)
    						{
    						sound(100); delay(20); nosound();
    						}
    					}
    				if(yhit == 1)
    					{
    					yspeed = oldys;
    					xspeed = oldxs;
    					vdir=newd2;
    					switch(test1)
    						{
    						case 1:
    							yspeed++;
    							break;
    						case 2:
    							yspeed--;
    							break;
    						case 3:
    							yspeed++;
    							break;
    						default:
    							break;
    						}
    					yhit = 0;
    					if(soun == YES)
    						{
    						sound(100); delay(20); nosound();
    						}
    					}
    
    
    
    
    
    
    
    			if(xspeed > speed)
    				{
    				speed = xspeed;
    				}
    			if(yspeed > speed)
    				{
    				speed = yspeed;
    				}
    
    			for(int j = e; j < speed; j++)
    				{
    				switch(getpixel(xco + RAD + j, yco))
    					{
    					case BLACK:
    						break;
    					default:
    						if(hdir==RIGHT)
    							{
    						newd1 = LEFT;
    						xhit = 1;
    						timer = T2;
    							}
    						break;
    					}
    				switch(getpixel(xco - RAD - j, yco))
    					{
    					case BLACK:
    						break;
    					default:
    						if(hdir==LEFT)
    							{
    						newd1 = RIGHT;
    						xhit = 1;
    						timer = T2;
    							}
    						break;
    					}
    				switch(getpixel(xco, yco + RAD + j))
    					{
    					case BLACK:
    						break;
    					default:
    						if(vdir==DOWN)
    							{
    						newd2 = UP;
    						yhit = 1;
    						timer = T2;
    							}
    						break;
    					}
    				switch(getpixel(xco, yco - RAD - j))
    					{
    					case BLACK:
    						break;
    					default:
    						if(vdir==UP)
    							{
    						newd2 = DOWN;
    						yhit = 1;
    						timer = T2;
    							}
    						break;
    					}
    
    				}
    
    
    					}
    				else
    					{
    					timer--;
    					}
    
    			if(xhit == 1)
    				{
    				oldxs = xspeed;
    				oldys = yspeed;
    				xspeed = 1;
    				yspeed = 1;
    				}
    			if(yhit == 1)
    				{
    				oldys = yspeed;
    				oldxs = xspeed;
    				xspeed = 1;
    				yspeed = 1;
    				}
    
    			switch(hdir)
    				{
    				case LEFT:
    					xco -= xspeed;
    					break;
    				case RIGHT:
    					xco += xspeed;
    					break;
    				}
    			switch(vdir)
    				{
    				case UP:
    					yco -= yspeed;
    					break;
    				case DOWN:
    					yco += yspeed;
    					break;
    				}
    
    				if(xspeed > MAX)
    					{
    					xspeed = MAX;
    					}
    				if(yspeed > MAX)
    					{
    					yspeed = MAX;
    					}
    				if(xspeed < MIN)
    					{
    					xspeed = MIN;
    					}
    				if(yspeed < MIN)
    					{
    					yspeed = MIN;
    					}
    				if(xco>right-RAD-C)
    					{
    					hdir = LEFT;
    					}
    				if(xco<left+RAD+C)
    					{
    					hdir = RIGHT;
    					}
    				if(yco<5+RAD+C)
    					{
    					vdir = DOWN;
    					}
    
    
    			if((yco > getmaxy()+8))
    				{
    				score = YES;
    				}
    
    			}
    
    		void draw()
    			{
    			setcolor(BLACK);
    			setlinestyle(SOLID_LINE, 0, THICK_WIDTH);
    			setfillstyle(SOLID_FILL, BLACK);
    			pieslice(oldx,oldy,0,360,RAD);
    
    			setcolor(WHITE);
    			setlinestyle(SOLID_LINE, 0, THICK_WIDTH);
    			setfillstyle(SOLID_FILL, WHITE);
    			pieslice(xco,yco,0,360,RAD);
    			}
    		};
    
    class player
    	{
    	protected:
    		unsigned int xco;
    		int yco;
    		int oldx;
    		int oldy;
    		char rightk;
    		char leftk;
    		int paddlespeed;
    		int lb;
    		int rb;
    
    		unsigned int mx;
    		unsigned char ml,mr,mm;
    		yesno sl,sr,sm;
    
    
    	public:
    		player()
    			{}
    		player(int x, int y, char r, char l, int p)
    			{
    			xco = x;
    			yco = y;
    			rightk = r;
    			leftk = l;
    			paddlespeed = p;
    			rb=getmaxx()/2+150;
    			lb=32;
    			}
    		int retx()
    			{
    			return xco;
    			}
    		int rety()
    			{
    			return yco;
    			}
    		void set(int x, int y, char r, char l, int p)
    			{
    			xco = x;
    			yco = y;
    			rightk = r;
    			leftk = l;
    			paddlespeed = p;
    			}
    
    		void check(char k)
    			{
    			oldx=xco;
    			if(mouseactive == YES)
    				{
    				unsigned int dumb;
    				mouse_s3tatus(&xco,&dumb,&ml,&mr,&mm);
    				if(ml == 1)
    					{
    					if(sl==NO)
    						{
    						k = SPACE;
    						}
    					sl = YES;
    					}
    				else
    					{
    					sl = NO;
    					}
    				if(mr == 1)
    					{
    					if(sr==NO)
    						{
    						k = 'b';
    						}
    					sr = YES;
    					}
    				else
    					{
    					sr = NO;
    					}
    				if(mm == 1)
    					{
    					if(sm==NO)
    						{
    						k = 'w';
    						}
    					sm = YES;
    					}
    				else
    					{
    					sm = NO;
    					}
    				}
    
    			setcolor(BLACK);
    
    			if(k == rightk)
    				{
    				for(int j=0; j<paddlespeed; j++)
    					{
    					xco++;
    					}
    				}
    
    
    			if(k == leftk)
    				{
    				for(int j=0; j<paddlespeed; j++)
    					{
    					xco--;
    					}
    
    				}
    			if(k == QUIT)
    				{
    				closegraph();
    				exit(0);
    				}
    
    			if(k == PAUSE)
    				{
    				getch();
    				}
    			if(k == SOUND)
    				{
    				if(soun == YES)
    					{
    					soun = NO;
    					}
    				else
    					{
    					soun = YES;
    					}
    				}
    			if(k == CHEAT1)
    				{
    				ballnumb++;
    				}
    			if(k == CHEAT2)
    				{
    				level++;
    				pscore = s+mod;
    				}
    			if(k == CHEAT3)
    				{
    				lasers++;
    				}
    			if(k == SPACE)
    				{
    				if((lasera==NO)&&(lasers>0))
    					{
    					l1.set(xco,yco);
    					lasers--;
    					}
    				}
    
    			setcolor(BLACK);
    			setfillstyle(SOLID_FILL,BLACK);
    
    
    
    			if(xco > rb-bmod)
    				{
    				xco = rb-bmod;
    				}
    
    			if(xco < lb+8+bmod)
    				{
    				xco = lb+8+bmod;
    				}
    
    
    			}
    		void draw()
    			{
    			if(oldx!=xco)
    				{
    				setcolor(BLACK);
    				setlinestyle(SOLID_LINE, 0, 1);
    				setfillstyle(SOLID_FILL, BLACK);
    				bar(oldx - W, yco - H, oldx + W, yco + H);
    				}
    			setcolor(WHITE);
    			setlinestyle(SOLID_LINE, 0, 1);
    			setfillstyle(SOLID_FILL, WHITE);
    			bar(xco - W, yco - H, xco + W, yco + H);
    			}
    
    
    	};
    
    
    
    class bard
    	{
    	private:
    		int xco;
    		int yco;
    		int width;
    		int height;
    		int color;
    		int timer;
    		int hitcheck;
    
    	public:
    		bard(int x, int y, int c, int w, int h)
    			{
    			xco = x;
    			yco = y;
    			color = c;
    			timer = 0;
    			width = w;
    			height = h;
    			hitcheck = 1;
    			}
    		void check(ball b, player p1, ball b2, ball b3, player p2)
    			{
    			if((b.rety()>yco-height-(speed + 3))&&(b.rety()<yco+height+(speed + 3))||(hitcheck==1)||(b2.rety()>yco-height-(speed + 3))&&(b2.rety()<yco+height+(speed + 3))||(b3.rety()>yco-height-(speed + 3))&&(b3.rety()<yco+height+(speed + 3))||(l1.rety()>yco-height-11)&&(l1.rety()<yco+height+11))
    				{
    			if((b.retx()>xco-width-(speed + 3))&(b.retx()<xco+width+(speed + 3))||(hitcheck==1)||(b2.retx()>xco-width-(speed + 3))&&(b2.retx()<xco+width+(speed + 3))||(b3.retx()>xco-width-(speed + 3))&&(b3.retx()<xco+width+(speed + 3))||(l1.retx()>xco-width-11)&&(l1.retx()<xco+width+11))
    				{
    			if(timer == 0)
    				{
    				hitcheck = 0;
    				if((b.rety()>yco-height-(speed+3))&&(b.rety()<yco+height+(speed + 3))||(b2.rety()>yco-height-(speed + 3))&&(b2.rety()<yco+height+(speed + 3))||(b3.rety()>yco-height-(speed + 3))&&(b3.rety()<yco+height+(speed + 3))||(l1.rety()>yco-height-11)&&(l1.rety()<yco+height+11))
    				{
    				if((b.retx()>xco-width-(speed+3))&&(b.retx()<xco+width+(speed + 3))||(b2.retx()>xco-width-(speed + 3))&&(b2.retx()<xco+width+(speed + 3))||(b3.retx()>xco-width-(speed + 3))&&(b3.retx()<xco+width+(speed + 3))||(l1.retx()>xco-width-11)&&(l1.retx()<xco+width+11))
    				{
    
    				if((b.retx()>xco)||(b2.retx()>xco)||(b3.retx()>xco))
    					{
    				for(int j=(-height);j<height;j++)
    					{
    					for(int k=speed+3; k>0; k--)
    						{
    						if(getpixel((xco+width+k),(yco+j))==WHITE)
    							{
    							hitcheck = 1;
    							}
    						}
    					}
    					}
    
    				if((b.retx()<xco)||(b2.retx()<xco)||(b3.retx()<xco))
    					{
    				for(int j=(-height);j<height;j++)
    					{
    					for(int k=speed+3; k>0; k--)
    						{
    						if(getpixel(xco-width-k,yco+j)==WHITE)
    							{
    							hitcheck = 1;
    							}
    						}
    					}
    					}
    
    				if((b.rety()>yco)||(b2.rety()>yco)||(b3.rety()>yco)||(l1.rety()<yco))
    					{
    				for(int j=(-width);j<width;j++)
    					{
    					for(int k=speed+3; k>0; k--)
    						{
    						if(getpixel(xco+j,yco+height+k)==WHITE)
    							{
    							hitcheck = 1;
    							}
    						}
    					}
    					}
    
    				if((b.rety()<yco)||(b2.rety()<yco)||(b3.rety()<yco))
    					{
    				for(int j=(-width);j<width;j++)
    					{
    					for(int k=speed+3; k>0; k--)
    						{
    						if(getpixel(xco+j,yco-height-k)==WHITE)
    							{
    							hitcheck = 1;
    							}
    						}
    					}
    					}
    
    					}
    					}
    
    
    				if(hitcheck==1)
    					{
    					timer = T;
    					pscore+=10;
    					if(soun==YES)
    						{
    						sound(1500); delay(10); sound(1000); delay(10); nosound();
    						}
    					}
    				}
    			else
    				{
    				timer--;
    				if(timer==T-3)
    					{
    					color--;
    					if(color == WHITE)
    						{
    						color--;
    						}
    					if(color == GRAY)
    						{
    						color--;
    						}
    					if(color == BLACK)
    						{
    						randomize();
    						int temp = random(15);
    						switch(temp)
    							{
    							case 1:
    								good(p1,p2);
    								break;
    							case 2:
    								good(p1,p2);
    								break;
    							case 3:
    								good(p1,p2);
    								break;
    							case 4:
    								good(p1,p2);
    								break;
    							case 5:
    								good(p1,p2);
    								break;
    							case 6:
    								good(p1,p2);
    								break;
    							case 7:
    								good(p1,p2);
    								break;
    							case 8:
    								bad(p1,p2);
    								break;
    							case 9:
    								bad(p1,p2);
    								break;
    							case 10:
    								bad(p1,p2);
    								break;
    							default:
    								break;
    							}
    						}
    
    					}
    				}
    				}
    				}
    			}
    
    
    		void draw()
    			{
    			setcolor(color);
    			setfillstyle(SOLID_FILL, color);
    			setlinestyle(SOLID_LINE, 0, THICK_WIDTH);
    			bar(xco-width,yco-height,xco+width,yco+height);
    			}
    
    
    		int retcolor()
    			{
    			return color;
    			}
    
    	};
    
    class laser
    	{
    	private:
    		int xco;
    		int yco;
    		int oldx;
    		int oldy;
    		int color;
    		int color1;
    		int color2;
    		int width;
    		int height;
    		int height2;
    		int hitcheck;
    		int timer;
    
    	public:
    		laser()
    			{
    			lasera = NO;
    			}
    		void activeset()
    			{
    			height=4;
    			width = 2;
    			oldx = xco;
    			oldy = yco;
    			xco = 0;
    			yco = 0;
    			lasera = NO;
    			draw();
    			}
    		void cset(int c1, int c2)
    			{
    			color1 = c1;
    			color2 = c2;
    			}
    		int retx()
    			{
    			return xco;
    			}
    		int rety()
    			{
    			return yco;
    			}
    		void set(int x,int y)
    			{
    			xco = x;
    			yco = y;
    			height = 4;
    			width = 2;
    			hitcheck = 0;
    			timer = 0;
    			lasera = YES;
    			color = color1;
    			height2 = height;
    			}
    		yesno aret()
    			{
    			return lasera;
    			}
    		void check()
    			{
    			oldx = xco;
    			oldy = yco;
    
    			if(color == color1)
    				{
    				color = color2;
    				}
    			else
    				{
    				color=color1;
    				}
    
    			if(timer == 0)
    				{
    
    				for(int j=-width; j<width; j++)
    					{
    					for(int k=0; k<1; k++)
    						{
    						if(getpixel(xco+j,yco-k-5)!=BLACK)
    							{
    							hitcheck = 1;
    							}
    						}
    					}
    
    
    				if(hitcheck == 1)
    					{
    					timer = 1;
    					color = color1;
    					height2 = height / 2;
    					yco -= 4;
    					}
    				else
    					{
    					yco -= 4;
    					}
    				}
    			else
    				{
    				lasera = NO;
    				yco = 0;
    				xco = 0;
    				}
    			if(yco>480)
    				{
    				yco = 0;
    				xco = 0;
    				lasera = NO;
    				}
    			}
    		void draw()
    			{
    			setcolor(BLACK);
    			setfillstyle(SOLID_FILL, BLACK);
    			bar(oldx - width, oldy - height, oldx + width, oldy + height);
    			if(lasera==YES)
    				{
    				setcolor(color);
    				setfillstyle(SOLID_FILL, color);
    				bar(xco - width, yco - height2, xco + width, yco + height2);
    				}
    			}
    		};
    
    
    
    class mbar
    	{
    	private:
    		int xco;
    		int yco;
    		int oldx;
    		int width;
    		int height;
    		int xspeed;
    		int timer;
    		horz hdir;
    		horz ndir;
    	public:
    		mbar(int x, int y, int w, int h, int s, horz d)
    			{
    			xco = x;
    			yco = y;
    			width = w;
    			height = h;
    			xspeed = s;
    			hdir = d;
    			timer = 0;
    			}
    		void set(int s)
    			{
    			xspeed = s;
    			timer = 0;
    			}
    
    
    		void calc(ball b1,ball b2, ball b3)
    			{
    			oldx = xco;
    
    			if(timer == 0)
    				{
    
    			if(((b1.rety() < yco + (height * 2))&&(b1.rety() > yco - (height * 2)))||(xco>right-30)||(xco < 45)||((b2.rety() < yco + (height * 2))&&(b2.rety() > yco - (height * 2)))||((b3.rety() < yco + (height * 2))&&(b3.rety() > yco - (height * 2))))
    				{
    			if(((b1.retx() < xco + (width * 2))&&(b1.retx() > xco - (width * 2)))||(xco>right-30)||(xco < 45)||((b2.retx() < xco + (width * 2))&&(b2.retx() > xco - (width * 2)))||((b3.retx() < xco + (width * 2))&&(b3.retx() > xco - (width * 2))))
    				{
    			for(int j = e; j<xspeed; j++)
    				{
    				switch(getpixel(xco+width+j,yco))
    					{
    					case BLACK:
    						break;
    					default:
    						if(hdir==RIGHT)
    							{
    							ndir = LEFT;
    							timer = T3;
    							}
    						break;
    					}
    				switch(getpixel(xco-width-j,yco))
    					{
    					case BLACK:
    						break;
    					default:
    						if(hdir==LEFT)
    							{
    							ndir = RIGHT;
    							timer = T3;
    							}
    						break;
    					}
    				}
    				}
    				}
    
    				}
    			else
    				{
    				timer--;
    				if(timer == 0)
    					{
    					hdir = ndir;
    					if(soun == YES)
    						{
    						sound(1000); delay(20); nosound();
    						}
    					}
    				}
    			switch(hdir)
    				{
    				case RIGHT:
    					xco += xspeed;
    					break;
    				case LEFT:
    					xco -= xspeed;
    					break;
    				}
    
    			}
    		void draw()
    			{
    			setcolor(BLACK);
    			setlinestyle(SOLID_LINE, 0, NORM_WIDTH);
    			setfillstyle(SOLID_FILL, BLACK);
    			bar(oldx-width, yco-height, oldx+width, yco+height);
    
    			setcolor(GRAY);
    			setlinestyle(SOLID_LINE, 0, NORM_WIDTH);
    			setfillstyle(SOLID_FILL, GRAY);
    			bar(xco-width, yco-height, xco+width, yco+height);
    			}
    	};
    
    class spinwheel
    	{
    	private:
    		int xco;
    		int yco;
    		int speed;
    		rotation rot;
    		int radius;
    		int size;
    		int angle1;
    		int angle2;
    		int oldangle1;
    		int oldangle2;
    	public:
    		spinwheel(int x, int y, int s, rotation r, int rad, int si)
    			{
    			xco = x;
    			yco = y;
    			speed = s;
    			rot = r;
    			radius = rad;
    			size = si;
    			angle1 = 0;
    			angle2 = 180;
    			}
    		void calc()
    			{
    			oldangle1 = angle1;
    			oldangle2 = angle2;
    			switch(rot)
    				{
    				case CLOCKWISE:
    					angle1 -= speed;
    					angle2 -= speed;
    					if(angle1 < 0)
    						{
    						angle1 = 360-size;
    						}
    					if(angle2 < 0)
    						{
    						angle2 = 360-size;
    						}
    					break;
    				case COUNTERCLOCKWISE:
    					angle1 += speed;
    					angle2 += speed;
    					if(angle1+size >= 360)
    						{
    						angle1 = 0;
    						}
    					if(angle2+size >= 360)
    						{
    						angle2 = 0;
    						}
    					break;
    				}
    			}
    		void draw()
    			{
    			setcolor(BLACK);
    			setlinestyle(SOLID_LINE, 0, NORM_WIDTH);
    			setfillstyle(SOLID_FILL, BLACK);
    			pieslice(xco, yco, oldangle1, oldangle1+size, radius);
    			pieslice(xco, yco, oldangle2, oldangle2+size, radius);
    
    
    
    			setcolor(GRAY);
    			setlinestyle(SOLID_LINE, 0, NORM_WIDTH);
    			setfillstyle(SOLID_FILL, GRAY);
    			pieslice(xco, yco, angle1, angle1+size, radius);
    			pieslice(xco, yco, angle2, angle2+size, radius);
    			}
    	};
    
    void stdstart();
    
    laser l1;
    
    
    //****************************************************************************
    
    
    
    void main()
    	{
    	reset_mouse_driver();
    	clrscr();
    	l1.cset(WHITE,YELLOW);
    	int driver = DETECT;
    	int mode = VGAHI;
    	initgraph(&driver, &mode, "");
    	int e2 = 5;
    	right = getmaxx()/2+150+W+4;
    
    if(0==0)
    	{
    	mbar bar1(210,240,110,10,0,LEFT);
    	mbar bar2(430,240,110,10,0,RIGHT);
    	mbar bar3(210,260,110,10,0,LEFT);
    	mbar bar4(430,260,110,10,0,RIGHT);
    	mbar bar5(210,280,110,10,0,LEFT);
    	mbar bar6(430,280,110,10,0,RIGHT);
    	mbar bar7(210,300,110,10,0,LEFT);
    	mbar bar8(430,300,110,10,0,RIGHT);
    
    
    
    
    	ball b1(getmaxx()/2-50,getmaxy()/2+100,2,2);
    	ball b2(getmaxx()/2-50,getmaxy()/2+100,2,2);
    	ball b3(getmaxx()/2-50,getmaxy()/2+100,2,2);
    	score = NO;
    	int timer = 0;
    	outtextxy(285,220,"WELCOME TO");
    	while(kbhit())
    		{
    		getch();
    		}
    	while(score == NO)
    		{
    
    		bar1.calc(b1,b2,b3); bar1.draw();
    		bar2.calc(b1,b2,b3); bar2.draw();
    		bar3.calc(b1,b2,b3); bar3.draw();
    		bar4.calc(b1,b2,b3); bar4.draw();
    		bar5.calc(b1,b2,b3); bar5.draw();
    		bar6.calc(b1,b2,b3); bar6.draw();
    		bar7.calc(b1,b2,b3); bar7.draw();
    		bar8.calc(b1,b2,b3); bar8.draw();
    
    		delay(80);
    		timer++;
    		if(timer > 5)
    			{
    			bar1.set(10);
    			bar2.set(10);
    			}
    		if(timer > 7)
    			{
    			bar3.set(10);
    			bar4.set(10);
    			}
    		if(timer > 9)
    			{
    			bar5.set(10);
    			bar6.set(10);
    			}
    		if(timer > 11)
    			{
    			bar7.set(10);
    			bar8.set(10);
    			}
    		if(timer > 4)
    			{
    			settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
    			setcolor(GRAY);
    			outtextxy(265,260,"BREAKOUT");
    			}
    
    		if(timer >45)
    			{
    			while(kbhit())
    				{
    				getch();
    				}
    			settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
    			setcolor(WHITE);
    			outtextxy(25,460,"press any key to play");
    			getch();
    			score = YES;
    			}
    		if(kbhit())
    			{
    			break;
    			}
    		}
    
    	}
    	settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
    
    while(ballnumb > 0)
    	{
    
    if((level==1)&&(ballnumb>0))
    	{
    	int numb1 = random(4);
    	int numb2 = random(4);
    	s = 300;
    	numb1++;
    	numb2++;
    	numb1++;
    	numb2++;
    	player p1(getmaxx()/2,460,RARROW,LARROW,13);
    	player p2(getmaxx()/2,460,RIGHT2,LEFT2,13);
    	ball b1(getmaxx()/2-50,getmaxy()/2+100,numb1,numb2);
    	ball b2(getmaxx()/2-25,getmaxy()/2+100,numb1,numb2);
    	ball b3(getmaxx()/2-75,getmaxy()/2+100,numb1,numb2);
    
    	bard bar1((left+right)/2,120,2,BW,BH);
    	bard bar2(((left+right)/2)+(BW*2)+e2,120,2,BW,BH);
    	bard bar3(((left+right)/2)-(BW*2)-e2,120,2,BW,BH);
    	bard bar14(((left+right)/2)+(BW*4)+(e2*2),120,2,BW,BH);
    	bard bar15(((left+right)/2)-(BW*4)-(e2*2),120,2,BW,BH);
    	bard bar4(((left+right)/2),120+(BH*2)+e2,2,BW,BH);
    	bard bar5(((left+right)/2)+(BW*2)+e2,120+(BH*2)+e2,2,BW,BH);
    	bard bar6(((left+right)/2)-(BW*2)-e2,120+(BH*2)+e2,2,BW,BH);
    	bard bar10(((left+right)/2)+(BW*4)+(e2*2),120+(BH*2)+e2,2,BW,BH);
    	bard bar11(((left+right)/2)-(BW*4)-(e2*2),120+(BH*2)+e2,2,BW,BH);
    	bard bar7(((left+right)/2),120+(BH*4)+(e2*2),2,BW,BH);
    	bard bar8(((left+right)/2)+(BW*2)+e2,120+(BH*4)+(e2*2),2,BW,BH);
    	bard bar9(((left+right)/2)-(BW*2)-e2,120+(BH*4)+(e2*2),2,BW,BH);
    	bard bar12(((left+right)/2)+(BW*4)+(e2*2),120+(BH*4)+(e2*2),2,BW,BH);
    	bard bar13(((left+right)/2)-(BW*4)-(e2*2),120+(BH*4)+(e2*2),2,BW,BH);
    
    
    
    	char key = '/0';
    
    	while((ballnumb>0)&&(score<s+mod))
    		{
    		stdstart();
    		b1.set(getmaxx()/2-50,getmaxy()/2+100,numb1,numb2);
    		b2.set(getmaxx()/2-25,getmaxy()/2+100,numb1,numb2);
    		b3.set(getmaxx()/2-75,getmaxy()/2+100,numb1,numb2);
    
    	while(score == NO)
    		{
    		stdboard();
    
    		if(ball1 == YES)
    			{
    			b1.calc(); b1.draw();
    			if(score == YES)
    				{
    				ball1 = NO;
    				b1.set(getmaxx()/2-50,getmaxy()/2+100,numb1,numb2);
    				if((ball2==NO)&&(ball3==NO))
    					{
    					score = YES;
    					}
    				else
    					{
    					score = NO;
    					}
    				}
    			}
    		if(ball2 == YES)
    			{
    			b2.calc(); b2.draw();
    			if(score == YES)
    				{
    				ball2 = NO;
    				b2.set(getmaxx()/2-25,getmaxy()/2+100,numb1,numb2);
    				if((ball1==NO)&&(ball3==NO))
    					{
    					score = YES;
    					}
    				else
    					{
    					score = NO;
    					}
    				}
    			}
    		if(ball3 == YES)
    			{
    			b3.calc(); b3.draw();
    			if(score == YES)
    				{
    				ball3 = NO;
    				b3.set(getmaxx()/2-75,getmaxy()/2+100,numb1,numb2);
    				if((ball2==NO)&&(ball1==NO))
    					{
    					score = YES;
    					}
    				else
    					{
    					score = NO;
    					}
    				}
    			}
    
    
    		p1.draw(); p1.check(key);
    
    		if(stat==DOUBLETROUBLE)
    			{
    			p2.draw(); p2.check(key);
    			}
    
    
    
    		if(bar1.retcolor()!=BLACK)
    			{
    			bar1.check(b1,p1,b2,b3,p2); bar1.draw();
    			}
    		if(bar2.retcolor()!=BLACK)
    			{
    			bar2.check(b1,p1,b2,b3,p2); bar2.draw();
    			}
    		if(bar3.retcolor()!=BLACK)
    			{
    			bar3.check(b1,p1,b2,b3,p2); bar3.draw();
    			}
    		if(bar4.retcolor()!=BLACK)
    			{
    			bar4.check(b1,p1,b2,b3,p2); bar4.draw();
    			}
    		if(bar5.retcolor()!=BLACK)
    			{
    			bar5.check(b1,p1,b2,b3,p2); bar5.draw();
    			}
    		if(bar6.retcolor()!=BLACK)
    			{
    			bar6.check(b1,p1,b2,b3,p2); bar6.draw();
    			}
    		if(bar7.retcolor()!=BLACK)
    			{
    			bar7.check(b1,p1,b2,b3,p2); bar7.draw();
    			}
    		if(bar8.retcolor()!=BLACK)
    			{
    			bar8.check(b1,p1,b2,b3,p2); bar8.draw();
    			}
    		if(bar9.retcolor()!=BLACK)
    			{
    			bar9.check(b1,p1,b2,b3,p2); bar9.draw();
    			}
    		if(bar10.retcolor()!=BLACK)
    			{
    			bar10.check(b1,p1,b2,b3,p2); bar10.draw();
    			}
    		if(bar11.retcolor()!=BLACK)
    			{
    			bar11.check(b1,p1,b2,b3,p2); bar11.draw();
    			}
    		if(bar12.retcolor()!=BLACK)
    			{
    			bar12.check(b1,p1,b2,b3,p2); bar12.draw();
    			}
    		if(bar13.retcolor()!=BLACK)
    			{
    			bar13.check(b1,p1,b2,b3,p2); bar13.draw();
    			}
    		if(bar14.retcolor()!=BLACK)
    			{
    			bar14.check(b1,p1,b2,b3,p2); bar14.draw();
    			}
    		if(bar15.retcolor()!=BLACK)
    			{
    			bar15.check(b1,p1,b2,b3,p2); bar15.draw();
    			}
    
    		key='/0';
    		while(kbhit())
    			{
    			key = getch();
    			}
    
    		if(level>1)
    			{
    			break;
    			}
    
    		if(pscore==s+mod)
    			{
    			level++;
    			delay(2000);
    			break;
    			}
    
    		}
    		if(level>1)
    			{
    			break;
    			}
    		ballnumb--;
    
    		}
    	}
    
    if((level==2)&&(ballnumb>0))
    	{
    	int numb1 = random(4);
    	int numb2 = random(4);
    	s = 880;
    	numb1++;
    	numb2++;
    	numb1++;
    	numb2++;
    	player p1(getmaxx()/2,460,RARROW,LARROW,13);
    	player p2(getmaxx()/2,460,RIGHT2,LEFT2,13);
    	ball b1(getmaxx()/2-50,getmaxy()/2+100,numb1,numb2);
    	ball b2(getmaxx()/2-25,getmaxy()/2+100,numb1,numb2);
    	ball b3(getmaxx()/2-75,getmaxy()/2+100,numb1,numb2);
    
    	bard bar1((left+right)/2,120,4,BW,BH);
    	bard bar2(((left+right)/2)+(BW*2)+e2,120,4,BW,BH);
    	bard bar3(((left+right)/2)-(BW*2)-e2,120,4,BW,BH);
    	bard bar14(((left+right)/2)+(BW*4)+(e2*2),120,4,BW,BH);
    	bard bar15(((left+right)/2)-(BW*4)-(e2*2),120,4,BW,BH);
    	bard bar4(((left+right)/2),120+(BH*2)+e2,2,BW,BH);
    	bard bar5(((left+right)/2)+(BW*2)+e2,120+(BH*2)+e2,4,BW,BH);
    	bard bar6(((left+right)/2)-(BW*2)-e2,120+(BH*2)+e2,4,BW,BH);
    	bard bar10(((left+right)/2)+(BW*4)+(e2*2),120+(BH*2)+e2,4,BW,BH);
    	bard bar11(((left+right)/2)-(BW*4)-(e2*2),120+(BH*2)+e2,4,BW,BH);
    	bard bar7(((left+right)/2),120+(BH*4)+(e2*2),4,BW,BH);
    	bard bar8(((left+right)/2)+(BW*2)+e2,120+(BH*4)+(e2*2),4,BW,BH);
    	bard bar9(((left+right)/2)-(BW*2)-e2,120+(BH*4)+(e2*2),4,BW,BH);
    	bard bar12(((left+right)/2)+(BW*4)+(e2*2),120+(BH*4)+(e2*2),4,BW,BH);
    	bard bar13(((left+right)/2)-(BW*4)-(e2*2),120+(BH*4)+(e2*2),4,BW,BH);
    
    	char key = '/0';
    
    	while((ballnumb>0)&&(score<s+mod))
    		{
    
    	b1.set(getmaxx()/2-50,getmaxy()/2+100,numb1,numb2);
    	b2.set(getmaxx()/2-25,getmaxy()/2+100,numb1,numb2);
    	b3.set(getmaxx()/2-75,getmaxy()/2+100,numb1,numb2);
    
    	stdstart();
    
    	while(score == NO)
    		{
    		stdboard();
    
    		if(ball1 == YES)
    			{
    			b1.calc(); b1.draw();
    			if(score == YES)
    				{
    				ball1 = NO;
    				b1.set(getmaxx()/2-50,getmaxy()/2+100,numb1,numb2);
    				if((ball2==NO)&&(ball3==NO))
    					{
    					score = YES;
    					}
    				else
    					{
    					score = NO;
    					}
    				}
    			}
    		if(ball2 == YES)
    			{
    			b2.calc(); b2.draw();
    			if(score == YES)
    				{
    				ball2 = NO;
    				b2.set(getmaxx()/2-25,getmaxy()/2+100,numb1,numb2);
    				if((ball1==NO)&&(ball3==NO))
    					{
    					score = YES;
    					}
    				else
    					{
    					score = NO;
    					}
    				}
    			}
    		if(ball3 == YES)
    			{
    			b3.calc(); b3.draw();
    			if(score == YES)
    				{
    				ball3 = NO;
    				b3.set(getmaxx()/2-75,getmaxy()/2+100,numb1,numb2);
    				if((ball2==NO)&&(ball1==NO))
    					{
    					score = YES;
    					}
    				else
    					{
    					score = NO;
    					}
    				}
    			}
    
    
    		p1.draw(); p1.check(key);
    
    		if(stat==DOUBLETROUBLE)
    			{
    			p2.draw(); p2.check(key);
    			}
    
    
    		if(bar1.retcolor()!=BLACK)
    			{
    			bar1.check(b1,p1,b2,b3,p2); bar1.draw();
    			}
    		if(bar2.retcolor()!=BLACK)
    			{
    			bar2.check(b1,p1,b2,b3,p2); bar2.draw();
    			}
    		if(bar3.retcolor()!=BLACK)
    			{
    			bar3.check(b1,p1,b2,b3,p2); bar3.draw();
    			}
    		if(bar4.retcolor()!=BLACK)
    			{
    			bar4.check(b1,p1,b2,b3,p2); bar4.draw();
    			}
    		if(bar5.retcolor()!=BLACK)
    			{
    			bar5.check(b1,p1,b2,b3,p2); bar5.draw();
    			}
    		if(bar6.retcolor()!=BLACK)
    			{
    			bar6.check(b1,p1,b2,b3,p2); bar6.draw();
    			}
    		if(bar7.retcolor()!=BLACK)
    			{
    			bar7.check(b1,p1,b2,b3,p2); bar7.draw();
    			}
    		if(bar8.retcolor()!=BLACK)
    			{
    			bar8.check(b1,p1,b2,b3,p2); bar8.draw();
    			}
    		if(bar9.retcolor()!=BLACK)
    			{
    			bar9.check(b1,p1,b2,b3,p2); bar9.draw();
    			}
    		if(bar10.retcolor()!=BLACK)
    			{
    			bar10.check(b1,p1,b2,b3,p2); bar10.draw();
    			}
    		if(bar11.retcolor()!=BLACK)
    			{
    			bar11.check(b1,p1,b2,b3,p2); bar11.draw();
    			}
    		if(bar12.retcolor()!=BLACK)
    			{
    			bar12.check(b1,p1,b2,b3,p2); bar12.draw();
    			}
    		if(bar13.retcolor()!=BLACK)
    			{
    			bar13.check(b1,p1,b2,b3,p2); bar13.draw();
    			}
    		if(bar14.retcolor()!=BLACK)
    			{
    			bar14.check(b1,p1,b2,b3,p2); bar14.draw();
    			}
    		if(bar15.retcolor()!=BLACK)
    			{
    			bar15.check(b1,p1,b2,b3,p2); bar15.draw();
    			}
    
    
    		key='/0';
    		while(kbhit())
    			{
    			key = getch();
    			}
    
    		if(level>2)
    			{
    			break;
    			}
    
    
    		if(pscore==s+mod)
    			{
    			level++;
    			delay(2000);
    			break;
    			}
    
    		}
    		if(level>2)
    			{
    			break;
    			}
    		ballnumb--;
    
    		}
    	}
    
    
    if((level==3)&&(ballnumb>0))
    	{
    	int numb1 = random(4);
    	int numb2 = random(4);
    	s=1360;
    	numb1++;
    	numb2++;
    	numb1++;
    	numb2++;
    	int cx = ((left+right)/2)+150;
    	int cy = 465/2-100;
    	player p1(getmaxx()/2,460,RARROW,LARROW,13);
    	player p2(getmaxx()/2,460,RIGHT2,LEFT2,13);
    	ball b1(getmaxx()/2,getmaxy()/2+100,numb1,numb2);
    	ball b2(getmaxx()/2-25,getmaxy()/2+100,numb1,numb2);
    	ball b3(getmaxx()/2-75,getmaxy()/2+100,numb1,numb2);
    
    	bard bar1(cx, cy+35, 3, 15,15);
    	bard bar2(cx, cy-35, 3, 15,15);
    	bard bar3(cx+35,cy,3,15,15);
    	bard bar4(cx-35,cy,3,15,15);
    	bard bar5(cx+35,cy+35,3,15,15);
    	bard bar6(cx+35,cy-35,3,15,15);
    	bard bar7(cx-35,cy+35,3,15,15);
    	bard bar8(cx-35,cy-35,3,15,15);
    
    	cx = ((left+right)/2)-150;
    
    	bard bar9(cx, cy+35, 3, 15,15);
    	bard bar10(cx, cy-35, 3, 15,15);
    	bard bar11(cx+35,cy,3,15,15);
    	bard bar12(cx-35,cy,3,15,15);
    	bard bar13(cx+35,cy+35,3,15,15);
    	bard bar14(cx+35,cy-35,3,15,15);
    	bard bar15(cx-35,cy+35,3,15,15);
    	bard bar16(cx-35,cy-35,3,15,15);
    
    
    
    
    	char key = '/0';
    
    	while((ballnumb>0)&&(score<s+mod))
    		{
    
    	b1.set(getmaxx()/2,getmaxy()/2+100,numb1,numb2);
    	b2.set(getmaxx()/2-25,getmaxy()/2+100,numb1,numb2);
    	b3.set(getmaxx()/2-75,getmaxy()/2+100,numb1,numb2);
    
    	stdstart();
    
    	while(score == NO)
    		{
    		stdboard();
    
    
    		if(ball1 == YES)
    			{
    			b1.calc(); b1.draw();
    			if(score == YES)
    				{
    				ball1 = NO;
    				b1.set(getmaxx()/2-50,getmaxy()/2+100,numb1,numb2);
    				if((ball2==NO)&&(ball3==NO))
    					{
    					score = YES;
    					}
    				else
    					{
    					score = NO;
    					}
    				}
    			}
    		if(ball2 == YES)
    			{
    			b2.calc(); b2.draw();
    			if(score == YES)
    				{
    				ball2 = NO;
    				b2.set(getmaxx()/2-25,getmaxy()/2+100,numb1,numb2);
    				if((ball1==NO)&&(ball3==NO))
    					{
    					score = YES;
    					}
    				else
    					{
    					score = NO;
    					}
    				}
    			}
    		if(ball3 == YES)
    			{
    			b3.calc(); b3.draw();
    			if(score == YES)
    				{
    				ball3 = NO;
    				b3.set(getmaxx()/2-75,getmaxy()/2+100,numb1,numb2);
    				if((ball2==NO)&&(ball1==NO))
    					{
    					score = YES;
    					}
    				else
    					{
    					score = NO;
    					}
    				}
    			}
    
    
    		p1.draw(); p1.check(key);
    
    		if(stat==DOUBLETROUBLE)
    			{
    			p2.draw(); p2.check(key);
    			}
    
    
    		if(bar1.retcolor()!=BLACK)
    			{
    			bar1.check(b1,p1,b2,b3,p2); bar1.draw();
    			}
    		if(bar2.retcolor()!=BLACK)
    			{
    			bar2.check(b1,p1,b2,b3,p2); bar2.draw();
    			}
    		if(bar3.retcolor()!=BLACK)
    			{
    			bar3.check(b1,p1,b2,b3,p2); bar3.draw();
    			}
    		if(bar4.retcolor()!=BLACK)
    			{
    			bar4.check(b1,p1,b2,b3,p2); bar4.draw();
    			}
    		if(bar5.retcolor()!=BLACK)
    			{
    			bar5.check(b1,p1,b2,b3,p2); bar5.draw();
    			}
    		if(bar6.retcolor()!=BLACK)
    			{
    			bar6.check(b1,p1,b2,b3,p2); bar6.draw();
    			}
    		if(bar7.retcolor()!=BLACK)
    			{
    			bar7.check(b1,p1,b2,b3,p2); bar7.draw();
    			}
    		if(bar8.retcolor()!=BLACK)
    			{
    			bar8.check(b1,p1,b2,b3,p2); bar8.draw();
    			}
    		if(bar9.retcolor()!=BLACK)
    			{
    			bar9.check(b1,p1,b2,b3,p2); bar9.draw();
    			}
    		if(bar10.retcolor()!=BLACK)
    			{
    			bar10.check(b1,p1,b2,b3,p2); bar10.draw();
    			}
    		if(bar11.retcolor()!=BLACK)
    			{
    			bar11.check(b1,p1,b2,b3,p2); bar11.draw();
    			}
    		if(bar12.retcolor()!=BLACK)
    			{
    			bar12.check(b1,p1,b2,b3,p2); bar12.draw();
    			}
    		if(bar13.retcolor()!=BLACK)
    			{
    			bar13.check(b1,p1,b2,b3,p2); bar13.draw();
    			}
    		if(bar14.retcolor()!=BLACK)
    			{
    			bar14.check(b1,p1,b2,b3,p2); bar14.draw();
    			}
    		if(bar15.retcolor()!=BLACK)
    			{
    			bar15.check(b1,p1,b2,b3,p2); bar15.draw();
    			}
    		if(bar16.retcolor()!=BLACK)
    			{
    			bar16.check(b1,p1,b2,b3,p2); bar16.draw();
    			}
    
    		key='/0';
    		while(kbhit())
    			{
    			key = getch();
    			}
    		if(level>3)
    			{
    			break;
    			}
    
    		if(pscore==s+mod)
    			{
    			level++;
    			delay(2000);
    			break;
    			}
    
    		}
    		if(level>3)
    			{
    			break;
    			}
    		ballnumb--;
    
    		}
    	}
    
    
    if((level==4)&&(ballnumb>0))
    	{
    
    	int numb1 = random(4);
    	int numb2 = random(4);
    	s=1570;
    	numb1++;
    	numb2++;
    	numb1++;
    	numb2++;
    
    	player p1(getmaxx()/2,460,RARROW,LARROW,13);
    	player p2(getmaxx()/2,460,RIGHT2,LEFT2,13);
    	ball b1(getmaxx()/2,getmaxy()/2+100,numb1,numb2);
    	ball b2(getmaxx()/2-25,getmaxy()/2+100,numb1,numb2);
    	ball b3(getmaxx()/2-75,getmaxy()/2+100,numb1,numb2);
    
    	mbar b4(getmaxx()/2,getmaxy()-130,27,7,6,RIGHT);
    	mbar b5(getmaxx()/2,getmaxy()-200,27,7,4,LEFT);
    	mbar b6(getmaxx()/2,getmaxy()-250,27,7,5,LEFT);
    	mbar b7(getmaxx()/2,getmaxy()-310,27,7,4,RIGHT);
    	mbar b8(getmaxx()/2,25,27,7,4,RIGHT);
    	bard bar1((left+right)/2,120,7,BW,BH);
    	bard bar2(((left+right)/2)+(BW*2)+e2,120,7,BW,BH);
    	bard bar3(((left+right)/2)-(BW*2)-e2,120,7,BW,BH);
    
    
    
    	char key = '/0';
    
    	while((ballnumb>0)&&(score<s+mod))
    		{
    
    	b1.set(getmaxx()/2,getmaxy()/2+100,numb1,numb2);
    	b2.set(getmaxx()/2-25,getmaxy()/2+100,numb1,numb2);
    	b3.set(getmaxx()/2-75,getmaxy()/2+100,numb1,numb2);
    
    	stdstart();
    
    	while(score == NO)
    		{
    		stdboard();
    
    
    		if(ball1 == YES)
    			{
    			b1.calc(); b1.draw();
    			if(score == YES)
    				{
    				ball1 = NO;
    				b1.set(getmaxx()/2-50,getmaxy()/2+100,numb1,numb2);
    				if((ball2==NO)&&(ball3==NO))
    					{
    					score = YES;
    					}
    				else
    					{
    					score = NO;
    					}
    				}
    			}
    		if(ball2 == YES)
    			{
    			b2.calc(); b2.draw();
    			if(score == YES)
    				{
    				ball2 = NO;
    				b2.set(getmaxx()/2-25,getmaxy()/2+100,numb1,numb2);
    				if((ball1==NO)&&(ball3==NO))
    					{
    					score = YES;
    					}
    				else
    					{
    					score = NO;
    					}
    				}
    			}
    		if(ball3 == YES)
    			{
    			b3.calc(); b3.draw();
    			if(score == YES)
    				{
    				ball3 = NO;
    				b3.set(getmaxx()/2-75,getmaxy()/2+100,numb1,numb2);
    				if((ball2==NO)&&(ball1==NO))
    					{
    					score = YES;
    					}
    				else
    					{
    					score = NO;
    					}
    				}
    			}
    
    
    
    		p1.draw(); p1.check(key);
    
    		if(stat==DOUBLETROUBLE)
    			{
    			p2.draw(); p2.check(key);
    			}
    
    		b4.calc(b1,b2,b3); b4.draw();
    		b5.calc(b1,b2,b3); b5.draw();
    		b6.calc(b1,b2,b3); b6.draw();
    		b7.calc(b1,b2,b3); b7.draw();
    
    
    		if(bar1.retcolor()!=BLACK)
    			{
    			bar1.check(b1,p1,b2,b3,p2); bar1.draw();
    			}
    		if(bar2.retcolor()!=BLACK)
    			{
    			bar2.check(b1,p1,b2,b3,p2); bar2.draw();
    			}
    		if(bar3.retcolor()!=BLACK)
    			{
    			bar3.check(b1,p1,b2,b3,p2); bar3.draw();
    			}
    
    		key='/0';
    		while(kbhit())
    			{
    			key = getch();
    			}
    		if(level>4)
    			{
    			break;
    			}
    
    		if(pscore==s+mod)
    			{
    			level++;
    			delay(2000);
    			break;
    			}
    
    		}
    		if(level>4)
    			{
    			break;
    			}
    		ballnumb--;
    
    		}
    	}
    
    
    
    if((level==5)&&(ballnumb>0))
    	{
    
    	int numb1 = random(4);
    	int numb2 = random(4);
    	s=1810;
    	numb1++;
    	numb2++;
    	numb1++;
    	numb2++;
    
    	player p1(getmaxx()/2,460,RARROW,LARROW,13);
    	player p2(getmaxx()/2,460,RIGHT2,LEFT2,13);
    	ball b1(getmaxx()/2,getmaxy()/2+100,numb1,numb2);
    	ball b2(getmaxx()/2-25,getmaxy()/2+100,numb1,numb2);
    	ball b3(getmaxx()/2-75,getmaxy()/2+100,numb1,numb2);
    
    	bard bar1((left+right)/2,120,6,BW,BH);
    	bard bar2((left+right)/2,145,6,BW,BH);
    	bard bar3((left+right)/2,170,6,BW,BH);
    	bard bar4((left+right)/2,195,6,BW,BH);
    	spinwheel s1(getmaxx()/2-180,getmaxy()/2-100,4,CLOCKWISE,40,20);
    	spinwheel s2(getmaxx()/2+50,getmaxy()/2-100,4,COUNTERCLOCKWISE,40,20);
    
    
    	char key = '/0';
    
    	while((ballnumb>0)&&(score<s+mod))
    		{
    	b1.set(getmaxx()/2,getmaxy()/2+100,6,6);
    	b2.set(getmaxx()/2-25,getmaxy()/2+100,numb1,numb2);
    	b3.set(getmaxx()/2-75,getmaxy()/2+100,numb1,numb2);
    
    	stdstart();
    
    	while(score == NO)
    		{
    		stdboard();
    		p1.draw(); p1.check(key);
    
    		if(stat==DOUBLETROUBLE)
    			{
    			p2.draw(); p2.check(key);
    			}
    
    		s1.calc(); s1.draw();
    		s2.calc(); s2.draw();
    
    
    		if(ball1 == YES)
    			{
    			b1.calc(); b1.draw();
    			if(score == YES)
    				{
    				ball1 = NO;
    				b1.set(getmaxx()/2-50,getmaxy()/2+100,numb1,numb2);
    				if((ball2==NO)&&(ball3==NO))
    					{
    					score = YES;
    					}
    				else
    					{
    					score = NO;
    					}
    				}
    			}
    		if(ball2 == YES)
    			{
    			b2.calc(); b2.draw();
    			if(score == YES)
    				{
    				ball2 = NO;
    				b2.set(getmaxx()/2-25,getmaxy()/2+100,numb1,numb2);
    				if((ball1==NO)&&(ball3==NO))
    					{
    					score = YES;
    					}
    				else
    					{
    					score = NO;
    					}
    				}
    			}
    		if(ball3 == YES)
    			{
    			b3.calc(); b3.draw();
    			if(score == YES)
    				{
    				ball3 = NO;
    				b3.set(getmaxx()/2-75,getmaxy()/2+100,numb1,numb2);
    				if((ball2==NO)&&(ball1==NO))
    					{
    					score = YES;
    					}
    				else
    					{
    					score = NO;
    					}
    				}
    			}
    
    
    
    		if(bar1.retcolor()!=BLACK)
    			{
    			bar1.check(b1,p1,b2,b3,p2); bar1.draw();
    			}
    		if(bar2.retcolor()!=BLACK)
    			{
    			bar2.check(b1,p1,b2,b3,p2); bar2.draw();
    			}
    		if(bar3.retcolor()!=BLACK)
    			{
    			bar3.check(b1,p1,b2,b3,p2); bar3.draw();
    			}
    		if(bar4.retcolor()!=BLACK)
    			{
    			bar4.check(b1,p1,b2,b3,p2); bar4.draw();
    			}
    
    		key='/0';
    		while(kbhit())
    			{
    			key = getch();
    			}
    		if(level>5)
    			{
    			break;
    			}
    
    
    		if(pscore==s+mod)
    			{
    			level++;
    			delay(2000);
    			break;
    			}
    
    
    		}
    		if(level>5)
    			{
    			break;
    			}
    		ballnumb--;
    
    		}
    	}
    
    if((level==6)&&(ballnumb>0))
    	{
    	int numb1 = random(4);
    	int numb2 = random(4);
    	s=1940;
    	numb1++;
    	numb2++;
    	numb1++;
    	numb2++;
    
    	player p1(getmaxx()/2,460,RARROW,LARROW,13);
    	player p2(getmaxx()/2,460,RIGHT2,LEFT2,13);
    	ball b1(getmaxx()/2,getmaxy()/2+100,numb1,numb2);
    	ball b2(getmaxx()/2-25,getmaxy()/2+100,numb1,numb2);
    	ball b3(getmaxx()/2-75,getmaxy()/2+100,numb1,numb2);
    
    	bard bar1((left+right)/2,145,14,BW,BH);
    	spinwheel s1(getmaxx()/2-180,getmaxy()/2-100,4,CLOCKWISE,40,20);
    	spinwheel s2(getmaxx()/2+50,getmaxy()/2-100,4,COUNTERCLOCKWISE,40,20);
    	mbar b4(getmaxx()/2,getmaxy()/2-160,27,7,4,RIGHT);
    	mbar b5(getmaxx()/2,getmaxy()/2-40,27,7,4,RIGHT);
    
    	char key = '/0';
    
    	while((ballnumb>0)&&(score<s+mod))
    		{
    
    	b1.set(getmaxx()/2,getmaxy()/2+100,6,6);
    	b2.set(getmaxx()/2-25,getmaxy()/2+100,numb1,numb2);
    	b3.set(getmaxx()/2-75,getmaxy()/2+100,numb1,numb2);
    
    	stdstart();
    
    	while(score == NO)
    		{
    		stdboard();
    		p1.draw(); p1.check(key);
    
    		if(stat==DOUBLETROUBLE)
    			{
    			p2.draw(); p2.check(key);
    			}
    
    		s1.calc(); s1.draw();
    		s2.calc(); s2.draw();
    
    
    		if(ball1 == YES)
    			{
    			b1.calc(); b1.draw();
    			if(score == YES)
    				{
    				ball1 = NO;
    				b1.set(getmaxx()/2-50,getmaxy()/2+100,numb1,numb2);
    				if((ball2==NO)&&(ball3==NO))
    					{
    					score = YES;
    					}
    				else
    					{
    					score = NO;
    					}
    				}
    			}
    		if(ball2 == YES)
    			{
    			b2.calc(); b2.draw();
    			if(score == YES)
    				{
    				ball2 = NO;
    				b2.set(getmaxx()/2-25,getmaxy()/2+100,numb1,numb2);
    				if((ball1==NO)&&(ball3==NO))
    					{
    					score = YES;
    					}
    				else
    					{
    					score = NO;
    					}
    				}
    			}
    		if(ball3 == YES)
    			{
    			b3.calc(); b3.draw();
    			if(score == YES)
    				{
    				ball3 = NO;
    				b3.set(getmaxx()/2-75,getmaxy()/2+100,numb1,numb2);
    				if((ball2==NO)&&(ball1==NO))
    					{
    					score = YES;
    					}
    				else
    					{
    					score = NO;
    					}
    				}
    			}
    
    
    
    
    
    
    		b4.draw(); b4.calc(b1,b2,b3);
    		b5.draw(); b5.calc(b1,b2,b3);
    
    		if(bar1.retcolor()!=BLACK)
    			{
    			bar1.check(b1,p1,b2,b3,p2); bar1.draw();
    			}
    
    		key='/0';
    		while(kbhit())
    			{
    			key = getch();
    			}
    		if(level>6)
    			{
    			break;
    			}
    
    		if(pscore==s+mod)
    			{
    			level++;
    			delay(2000);
    			break;
    			}
    
    
    		}
    		if(level>6)
    			{
    			break;
    			}
    		ballnumb--;
    
    		}
    	}
    
    
    
    	D = D/2;
    	mod = pscore;
    	level = 1;
    	victorys++;
    
    	if((victorys == 1)&&(ballnumb>0))
    	{
    	clearviewport();
    	while(kbhit())
    		{
    		getch();
    		}
    	outtextxy(30,30,"Congrats!  You Beat the first round");
    	outtextxy(30,55,"for extraballs press [Ctrl]-z");
    	outtextxy(30,80,"to up your levels press [Ctrl]-x");
    	outtextxy(30,105,"to up your lasers press [Ctrl]-v");
    	outtextxy(30,130,"Now you will repeat the levels but at a faster speed");
    	outtextxy(30,155,"Press any key to continue");
    	getch();
    	}
    
    	}
    
    	closegraph();
    	}
    
    
    
    //****************************************************************************
    
    
    
    
    void money::ldtoms()
    	{
    	ostrstream conv(money2, MAX);
    	conv << setiosflags(ios::fixed) << setprecision(2) <<  money1;
    
    	char temp;
    	int count = 0;
    	int strlength;
    	unsigned long test;
    	test = money1;
    
    
    	if((money1 != test)&&(money1 < 4000000000))
    		{
    		while(temp != '.')
    			{
    			temp = money2[count];
    			count++;
    			}
    		strlength = count + 1;
    		money2[strlength+1] = '\0';
    		}
    	else
    		{
    		int check = 1;
    		while(check != 0)
    			{
    			switch(money2[count])
    				{
    				case '0':
    					count++;
    					break;
    				case '1':
    					count++;
    					break;
    				case '2':
    					count++;
    					break;
    				case '3':
    					count++;
    					break;
    				case '4':
    					count++;
    					break;
    				case '5':
    					count++;
    					break;
    				case '6':
    					count++;
    					break;
    				case '7':
    					count++;
    					break;
    				case '8':
    					count++;
    					break;
    				case '9':
    					count++;
    					break;
    				default:
    					check = 0;
    					break;
    				}
    
    			}
    		money2[count + 1] = '\0';
    		}
    
    	reversit();
    	char t[MAX2];
    	strcpy(t,  money2);
    	strcpy(money2, t);
    	reversit();
    	for(int j=0; j<strlen(money2); j++)
    		{
    		t[j] = money2[j];
    		}
    	t[strlen(money2)] = '\0';
    	strcpy(money2, t);
    	}
    
    void money::reversit()
    	{
    	int max;
    	max = strlen(money2) - 1;
    	for(int j=0; j<max; j++, max--)
    		{
    		char temp;
    
    		temp = money2[j];
    		money2[j] = money2[max];
    		money2[max] = temp;
    		}
    	}
    
    void stdboard()
    	{
    	delay(D);
    	setcolor(WHITE);
    	setlinestyle(SOLID_LINE,0,3);
    	line(left,5,left,460);
    	line(right,5,right,460);
    	line(left,5,right,5);
    	if(stat == SAFETYBAR)
    		{
    		line(left,460,right,460);
    		}
    	outtextxy(right+20,55,"SCORE:");
    	if(oldpscore != pscore)
    		{
    		money s1;
    		s1.putld(oldpscore);
    		setcolor(BLACK);
    		setlinestyle(SOLID_LINE,0,3);
    		outtextxy(right+80,55,s1.retmon());
    		s1.putld(pscore);
    		setcolor(WHITE);
    		setlinestyle(SOLID_LINE,0,3);
    		outtextxy(right+80,55,s1.retmon());
    		oldpscore=pscore;
    		}
    	outtextxy(right+20,getmaxy()-65,"LASERS:");
    	if(lasers != oldlasers)
    		{
    		money s1;
    		setcolor(BLACK);
    		setlinestyle(SOLID_LINE,0,3);
    		setfillstyle(SOLID_FILL,BLACK);
    		bar(right+80,getmaxy()-70,right+110,getmaxy()-58);
    		s1.putld(lasers);
    		setcolor(WHITE);
    		setlinestyle(SOLID_LINE,0,3);
    		outtextxy(right+80,getmaxy()-65,s1.retmon());
    		oldlasers=lasers;
    		}
    
    	if(ballnumb!=oldball)
    		{
    		oldball = ballnumb;
    		setcolor(BLACK);
    		setfillstyle(SOLID_FILL, BLACK);
    		outtextxy(right+20,getmaxy()-50,"BALLS: ");
    
    		int numbtemp=ballnumb-1;
    		for(int g=0; g<3; g++)
    			{
    			for(int j=0; j<3; j++)
    				{
    				circle( right+80+(j*20),getmaxy()-47+(g*20),4);
    				floodfill(right+80+(j*20),getmaxy()-47+(g*20),BLACK);
    				}
    			}
    
    		oldball = ballnumb;
    		setcolor(WHITE);
    		setfillstyle(SOLID_FILL, WHITE);
    		outtextxy(right+20,getmaxy()-50,"BALLS: ");
    
    
    		for(g=0; g<3; g++)
    			{
    			for(int j=0; j<3; j++)
    				{
    				if(numbtemp>0)
    					{
    					circle( right+80+(j*20),getmaxy()-47+(g*20),4);
    					floodfill(right+80+(j*20),getmaxy()-47+(g*20),WHITE);
    					}
    				numbtemp--;
    				}
    			}
    		}
    
    
    	if(oldsound!=soun)
    		{
    		oldsound = soun;
    		settextstyle(SMALL_FONT,HORIZ_DIR,4);
    		switch(soun)
    			{
    			case YES:
    				setcolor(BLACK);
    				outtextxy(right+90, getmaxy()/2+25, "OFF");
    				setcolor(WHITE);
    				outtextxy(right+90, getmaxy()/2+25, "ON");
    				break;
    			case NO:
    				setcolor(BLACK);
    				outtextxy(right+90, getmaxy()/2+25, "ON");
    				setcolor(WHITE);
    				outtextxy(right+90, getmaxy()/2+25, "OFF");
    				break;
    			}
    		settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
    		}
    	if(lasera==YES)
    		{
    		l1.check(); l1.draw();
    		}
    
    	}
    
    void stdstart()
    	{
    	clearviewport();
    	while(kbhit())
    		{
    		getch();
    		}
    
    	if((ball1==NO)&&(ball2==NO)&&(ball3==NO))
    		{
    		ball1 = YES;
    		}
    	setcolor(WHITE);
    	setfillstyle(SOLID_FILL, WHITE);
    	outtextxy(right+20,getmaxy()-50,"BALLS: ");
    
    	int numbtemp=ballnumb-1;
    	for(int g=0; g<3; g++)
    		{
    		for(int j=0; j<3; j++)
    			{
    			if(numbtemp>0)
    				{
    				circle( right+80+(j*20),getmaxy()-47+(g*20),4);
    				floodfill(right+80+(j*20),getmaxy()-47+(g*20),WHITE);
    				}
    			numbtemp--;
    			}
    		}
    
    		if(0==0)
    			{
    			money s1;
    			s1.putld(pscore);
    			setcolor(WHITE);
    			setlinestyle(SOLID_LINE,0,3);
    			outtextxy(right+80,55,s1.retmon());
    			oldpscore=pscore;
    			}
    		outtextxy(right+20,80,"LEVEL: ");
    		if(0==0)
    			{
    			money s1;
    			s1.putld(oldlevel);
    			setcolor(BLACK);
    			setlinestyle(SOLID_LINE,0,3);
    			outtextxy(right+80,80,s1.retmon());
    			s1.putld(level);
    			setcolor(WHITE);
    			setlinestyle(SOLID_LINE,0,3);
    			outtextxy(right+80,80,s1.retmon());
    			oldlevel=level;
    			}
    		if(0==0)
    			{
    			money s1;
    			s1.putld(oldlasers);
    			setcolor(BLACK);
    			setlinestyle(SOLID_LINE,0,3);
    			outtextxy(right+80,getmaxy()-65,s1.retmon());
    			s1.putld(lasers);
    			setcolor(WHITE);
    			setlinestyle(SOLID_LINE,0,3);
    			outtextxy(right+80,getmaxy()-65,s1.retmon());
    			oldlasers=lasers;
    			}
    
    		settextstyle(SMALL_FONT,HORIZ_DIR,4);
    		outtextxy(right+30, getmaxy()/2-25, "[CTRL]-q to quit");
    		outtextxy(right+30, getmaxy()/2, "p to pause");
    		outtextxy(right+30, getmaxy()/2+25, "(s)ound is");
    		switch(soun)
    			{
    			case YES:
    				setcolor(BLACK);
    				outtextxy(right+90, getmaxy()/2+25, "OFF");
    				setcolor(WHITE);
    				outtextxy(right+90, getmaxy()/2+25, "ON");
    				break;
    			case NO:
    				setcolor(BLACK);
    				outtextxy(right+90, getmaxy()/2+25, "ON");
    				setcolor(WHITE);
    				outtextxy(right+90, getmaxy()/2+25, "OFF");
    				break;
    			}
    
    		settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
    		setcolor(YELLOW);
    
    	switch(stat)
    		{
    		case NORMAL:
    			break;
    		case BALLUP:
    			outtextxy(right + 50,getmaxy()/2+150,"BALLUP");
    			break;
    		case TRIBALL:
    			outtextxy(right+50,getmaxy()/2+150,"TRIBALL");
    			break;
    		case EXPANDED:
    			outtextxy(right+50,getmaxy()/2+150,"EXPANDED");
    			break;
    		case SLOWBALL:
    			outtextxy(right+50,getmaxy()/2+150,"SLOWBALL");
    			break;
    		case LASER:
    			outtextxy(right+50,getmaxy()/2+150,"LASER");
    			break;
    		case SAFETYBAR:
    			outtextxy(right+50,getmaxy()/2+150,"SAFETYBAR");
    			break;
    		case DOUBLETROUBLE:
    			outtextxy(right+50,getmaxy()/2+150,"DOUBLE TROUBLE");
    			break;
    		case BALLDOWN:
    			outtextxy(right+50,getmaxy()/2+150,"BALLDOWN");
    			break;
    		case SPEEDBALL:
    			outtextxy(right+50,getmaxy()/2+150,"SPEED BALL");
    			break;
    		case SKINNY:
    			outtextxy(right+50,getmaxy()/2+150,"SKINNY");
    			break;
    		}
    
    		setcolor(WHITE);
    
    	score=NO;
    
    
    	}
    
    void good(player p1, player p2)
    	{
    	switch(stat)
    		{
    		case NORMAL:
    			break;
    		case BALLUP:
    			break;
    		case TRIBALL:
    			break;
    		case EXPANDED:
    			setcolor(BLACK);
    			setlinestyle(SOLID_LINE, 0, 1);
    			setfillstyle(SOLID_FILL, BLACK);
    			bar(p1.retx() - W, p1.rety() - H, p1.retx() + W, p1.rety() + H);
    			W = W/2;
    			bmod -= 30;
    			break;
    		case SLOWBALL:
    			D = D / 2;
    			break;
    		case LASER:
    			break;
    		case SAFETYBAR:
    			setcolor(BLACK);
    			setlinestyle(SOLID_LINE,0,THICK_WIDTH);
    			line(left,460,right,460);
    			break;
    		case DOUBLETROUBLE:
    			setcolor(BLACK);
    			setlinestyle(SOLID_LINE, 0, 1);
    			setfillstyle(SOLID_FILL, BLACK);
    			bar(p2.retx() - W, p2.rety() - H, p2.retx() + W, p2.rety() + H);
    			break;
    		case BALLDOWN:
    			break;
    		case SPEEDBALL:
    			D = D * 2;
    			break;
    		case SKINNY:
    			W = W*2;
    			bmod += 15;
    			break;
    		}
    	setcolor(BLACK);
    		setfillstyle(SOLID_FILL, BLACK);
    		bar(right+45 ,getmaxy()/2+150-10,right+150 ,getmaxy()/2+150+10);
    
    	setcolor(YELLOW);
    	randomize();
    	switch(random(14))
    		{
    		case 0:
    			stat = BALLUP;
    			ballnumb++;
    			outtextxy(right + 50,getmaxy()/2+150,"BALLUP");
    			break;
    		case 1:
    			stat = TRIBALL;
    			ball1 = YES;
    			ball2 = YES;
    			ball3 = YES;
    			outtextxy(right+50,getmaxy()/2+150,"TRIBALL");
    			break;
    		case 2:
    			stat = EXPANDED;
    			outtextxy(right+50,getmaxy()/2+150,"EXPANDED");
    			W = W*2;
    			bmod += 30;
    			break;
    		case 3:
    			stat = SLOWBALL;
    			D = D * 2;
    			outtextxy(right+50,getmaxy()/2+150,"SLOWBALL");
    			break;
    		case 4:
    			stat = LASER;
    			lasers++;
    			lasers++;
    			lasers++;
    			outtextxy(right+50,getmaxy()/2+150,"LASER");
    			break;
    		case 5:
    			stat = SAFETYBAR;
    			outtextxy(right+50,getmaxy()/2+150,"SAFETYBAR");
    			break;
    		case 6:
    			stat = DOUBLETROUBLE;
    			outtextxy(right+50,getmaxy()/2+150,"DOUBLE TROUBLE");
    			break;
    		case 7:
    			stat = BALLUP;
    			ballnumb++;
    			outtextxy(right + 50,getmaxy()/2+150,"BALLUP");
    			break;
    		case 8:
    			stat = TRIBALL;
    			ball1 = YES;
    			ball2 = YES;
    			ball3 = YES;
    			outtextxy(right+50,getmaxy()/2+150,"TRIBALL");
    			break;
    		case 9:
    			stat = EXPANDED;
    			outtextxy(right+50,getmaxy()/2+150,"EXPANDED");
    			W = W*2;
    			bmod += 30;
    			break;
    		case 10:
    			stat = SLOWBALL;
    			D = D * 2;
    			outtextxy(right+50,getmaxy()/2+150,"SLOWBALL");
    			break;
    		case 11:
    			stat = LASER;
    			lasers++;
    			outtextxy(right+50,getmaxy()/2+150,"LASER");
    			break;
    		case 12:
    			stat = SAFETYBAR;
    			outtextxy(right+50,getmaxy()/2+150,"SAFETYBAR");
    			break;
    		case 13:
    			stat = DOUBLETROUBLE;
    			outtextxy(right+50,getmaxy()/2+150,"DOUBLE TROUBLE");
    			break;
    
    		}
    	}
    
    void bad(player p1,player p2)
    	{
    	switch(stat)
    		{
    		case NORMAL:
    			break;
    		case BALLUP:
    			break;
    		case TRIBALL:
    			break;
    		case EXPANDED:
    			setcolor(BLACK);
    			setlinestyle(SOLID_LINE, 0, 1);
    			setfillstyle(SOLID_FILL, BLACK);
    			bar(p1.retx() - W, p1.rety() - H, p1.retx() + W, p1.rety() + H);
    			W = W/2;
    			bmod -= 30;
    			setcolor(WHITE);
    			setlinestyle(SOLID_LINE, 0, 1);
    			setfillstyle(SOLID_FILL, WHITE);
    			bar(p1.retx() - W, p1.rety() - H, p1.retx() + W, p1.rety() + H);
    			break;
    		case SLOWBALL:
    			D = D / 2;
    			break;
    		case LASER:
    			break;
    		case SAFETYBAR:
    			setcolor(BLACK);
    			setlinestyle(SOLID_LINE,0,THICK_WIDTH);
    			line(left,460,right,460);
    			break;
    		case DOUBLETROUBLE:
    			setcolor(BLACK);
    			setlinestyle(SOLID_LINE, 0, 1);
    			setfillstyle(SOLID_FILL, BLACK);
    			bar(p2.retx() - W, p2.rety() - H, p2.retx() + W, p2.rety() + H);
    			break;
    		case BALLDOWN:
    			break;
    		case SPEEDBALL:
    			D = D * 2;
    			break;
    		case SKINNY:
    			W = W*2;
    			bmod += 15;
    			break;
    		}
    	setcolor(BLACK);
    		setfillstyle(SOLID_FILL, BLACK);
    		bar(right + 45 ,getmaxy()/2+150-10,right+150 ,getmaxy()/2+150+10);
    	setcolor(YELLOW);
    	randomize();
    	switch(random(6))
    		{
    		case 0:
    			stat = BALLDOWN;
    			if(ballnumb > 1)
    				{
    				ballnumb--;
    				outtextxy(right+50,getmaxy()/2+150,"BALLDOWN");
    				}
    			break;
    		case 1:
    			stat = SPEEDBALL;
    			D = D/2;
    			outtextxy(right+50,getmaxy()/2+150,"SPEED BALL");
    			break;
    		case 2:
    			stat = SKINNY;
    			setcolor(BLACK);
    			setlinestyle(SOLID_LINE, 0, 1);
    			setfillstyle(SOLID_FILL, BLACK);
    			bar(p1.retx() - W, p1.rety() - H, p1.retx() + W, p1.rety() + H);
    			W = W/2;
    			bmod -= 15;
    			setcolor(WHITE);
    			setlinestyle(SOLID_LINE, 0, 1);
    			setfillstyle(SOLID_FILL, WHITE);
    			bar(p1.retx() - W, p1.rety() - H, p1.retx() + W, p1.rety() + H);
    			setcolor(YELLOW);
    			outtextxy(right+50,getmaxy()/2+150,"SKINNY");
    			break;
    		case 3:
    			stat = BALLDOWN;
    			if(ballnumb > 1)
    				{
    				ballnumb--;
    				outtextxy(right+50,getmaxy()/2+150,"BALLDOWN");
    				}
    			break;
    		case 4:
    			stat = SPEEDBALL;
    			D = D/2;
    			outtextxy(right+50,getmaxy()/2+150,"SPEED BALL");
    			break;
    		case 5:
    			stat = SKINNY;
    			setcolor(BLACK);
    			setlinestyle(SOLID_LINE, 0, 1);
    			setfillstyle(SOLID_FILL, BLACK);
    			bar(p1.retx() - W, p1.rety() - H, p1.retx() + W, p1.rety() + H);
    			W = W/2;
    			bmod -= 15;
    			setcolor(WHITE);
    			setlinestyle(SOLID_LINE, 0, 1);
    			setfillstyle(SOLID_FILL, WHITE);
    			bar(p1.retx() - W, p1.rety() - H, p1.retx() + W, p1.rety() + H);
    			setcolor(YELLOW);
    			outtextxy(right+50,getmaxy()/2+150,"SKINNY");
    			break;
    
    		}
    
    	}

  9. #9
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    968
    But my question is this...

    How can I use the backbuffer to actually make the breakout blocks GO AWAY instead of changing them black so theyre invisible?

  10. #10
    ---
    Join Date
    May 2004
    Posts
    1,379
    Code:
    void main()
    	{
    You should know better.

    Quote Originally Posted by Shamino
    But my question is this...

    How can I use the backbuffer to actually make the breakout blocks GO AWAY instead of changing them black so theyre invisible?
    Oh no, not again...

  11. #11
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    You obviously didnt learn much from the previous post about backbuffer. the backbuffer is there because it makes the drawing better, you dont use it for objects to go away. Here is how drawing using a backbuffer works:
    You draw to the backbuffer using functions
    You swap buffers which basicly means you swap pointers.
    Now the previous backbuffer is the frontbuffer.
    Repeat!

    To make objects go away you have to delete them from the objects that should be drawn!!
    STL Util a small headers-only library with various utility functions. Mainly for fun but feedback is welcome.

  12. #12
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    968
    I see... I was under the impression on my last post that that was the way you do it............... WRONG... lol.. well okay, heres my next best idea..


    Create a structure or class for each object to draw...

    Code:
    class square
    {
    // Then we create a bool
    bool ACTIVE;
    
    blah blah how to draw the object;
    };
    
    
    then, in my drawGLScene function, I do this...
    
    
    if square.ACTIVE = true
    {
    draw this square or this anything
    }
    and I do that if statement for every object I may want to draw on my screen... wewt...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 10:17 AM
  2. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  3. advantages of display lists...
    By DavidP in forum Game Programming
    Replies: 3
    Last Post: 09-21-2003, 03:38 PM
  4. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM