Advertisement

How to program a chess: a forum based tutorial

Started by December 23, 2004 11:09 PM
276 comments, last by da_grat1 19 years, 8 months ago
Quote:
Classes are about encapsulation, inheritance is about code reuse. Because classes are about encapsulation they are often better for "big projects", however you choose to define "big".


Very true...sry if i'm not too clear...I think classes are more about object orientation than encapsulation (at least the way the are done in C++). When you write a class then the instance of the class represents a concrete object. That is the way classes are designed; it is something that is separate from others of its type, it has properties and actions that it can take.

Quote:
While there is nothing wrong with using "just functions", doing so just because "that what most games use" is a bad reason.


I'm not too sure about that and the reason is because of natural selection. If X number of programmers try a number of different architectures and the majority of the projects that succeed use a certain technique then we should probably be asking why did this technique work?

Given that programmers are typically hesitant to move away from something they are used to, there are reasons why the push to c++ still hasent been that fast; that is to say if c++ gave you a real edge then shouldn't it be easy for us to create a large game? I can create a web browser in VB is several seconds, why cant i do the same for a game?

Large scale game design is probably one of the hardest things you can do in your career. Some design strategies and in extension the structures that facilitate them make it really easy to do certain things. Its hard to imagine someone doing a database subsystem and not using classes or structures in the least (although its probably been done). At the same time, you wouldnt write a class that abstracts a print object, inherit from it and then have it print "Hello World". This is an example of using the wrong tool for the job. I guess the thing to do is to look at the problems and try to figure out the easiest solution.

Quote:
Also note that it is entirely possible to write object-oriented code without using classes.


Absolutely. For this project I think our code should be object oriented and encapsulated in their respecitve .cpp files. I think using classes gives us different scope (that is we can easily instantiate a ton of them when all we really want is one), weather we want that or not.

Quote:
This discussion has nothing to do with inheritance. This is about design. Inheritance is a tool to be applied when you discover related classes during the design phase of a project.


Very true; we are essentially looking for a tool that will let us synthesize different components and inheritance is not it. Inheritance and polymorphs will however come in handy when we do our console (it will drastically reduce the ammount of work we have to do).

Quote:
This is an argument for "right tool for the job". All classes is just as bad as no classes. If it's an object, or can easily be abstracted as an object, then use a class. If not then consider using a function.


Yup; we are essentially trying to avoid extremes. The type of architexture I'm invisioning is one where we use a mix of classes and functions to implelent our individual subsystems. We then combine these systems through a series of funciton calls as we get to the top layers of our pyramid.

Quote:
With functions you have no concept of information hiding anyway.


With functions the only thing that gets exposed is the function header (if you wish). The only disadvantage is that it is either global or local. No in between (might be ways around this but I haven't had the need to look for them). You can easily overcome these problems using a fairly easy naming convention to be covered later.

Quote:
If you're worried about people changing the header to remove a 'private' qualifier you should be equally worried about somebody changing your function headers to rewrite a function.


My concern is not really about possibilities; theres nothing stopping someone from completely rewriting your program. My concern is about which is easier. You could easily comment out a private keyword (intentionally or mistakingly with /* */). Its a bit more work (and it must be intentional work) to make a private function global and a lot more work to make a private variable global.

Quote:
By all means use functions instead of classes, but don't do so for the (IMHO) poorly defined reasons above.


lol, me and my friends tried to do something similar to this thread a while back. We got to essentially the same place (one of my best friends loves classes). I think for the moment, discussing which tool we use is silly. We are worried about wether we should use a rotary saw or a ban saw before we decide what exactly it is we are building. It will probably be the case that we will use both to do different things (which is what we should be striving for). I hope you reply regularly Enigma; that way my "functionistic" tendancies are kept in check ;)

Lets put this particular discussion on hold and try to look at the problems we have to face. My next post will concern the design/implementation process. Where to start and what to start on. The first subsystem we will tackle is probably going to be a context manager. This system will tell us what exactly is running on the screen at a given time (ie the opening window, the game, the menu, or the console). It will also tell us when the game is over.

Will post later,
- llvllatrix
I think the first thing to do is to draw a chess board. It should be 8x8 matrix. Should we use array to do that :)
Advertisement
Quote: Original post by shadowwz

also about classes,do as you want,use what is comfortable for you,but saying "don't use classes" is wrong.

i always use classes ,not for everything of course:
- the main reason,debuging - it's more easy to find errors,memory leaks(for me at least).
- they organize my code and save me a lot of time.
- it's more understandable when code is writen with classes.
- easy to manipulate.

* anything can be done without classes,and i pointed in previous my post about classes only because - "Classes and inheritance usually dont work for this kind of thing" for me it works,and i'm sure "i'm not alone",but how to write the program is up to programmer.


I also use classes for pretty much the same reasons, but also because they are very helpfull in keeping things encapsulated and that they keep the code in an Object Oriented format.

So I agree with shadowwz here in that classes can be very usefull if they are used properly, I recommend that classes should be used where they are usefull.

But thats just my two cents though
how to use array to draw the 8x8 chessboard.. I only know how to use "for loop" to draw the 8x8 square.. :)
Quote:
how to use array to draw the 8x8 chessboard.. I only know how to use "for loop" to draw the 8x8 square.. :)


lol, still quite far from drawing the board. But if you want to try it out you can either use a modeling program to draw the board (what we will probably be doing in the game) or you could also do this:

void draw_quad(void){    glBegin(GL_QUADS);        glVertex3f(-1.0f, 0.0f, 1.0f);        glVertex3f( 1.0f, 0.0f, 1.0f);        glVertex3f( 1.0f, 0.0f,-1.0f);        glVertex3f(-1.0f, 0.0f,-1.0f);    glEnd();}void draw_board(void){    // Starting from bottom left    for(int x = 0; x < 8; x ++)    {        for(int z = 0; z < 8; z++)        {	    // Determine color	    // % modulas operator	    // ^ xor operator            float col = (float)((x % 2) ^ (z % 2));            glColor3f(col, col, col);            glPushMatrix();	        glTranslatef((float)(2*x), 0, (float)(2*z));		draw_quad();                            glPopMatrix();        }    }}


Post if you need some clarification, especially on the line (float)((x % 2) ^ (z % 2)). It requires a bit of boolean algebra. Next post to come soon...just finishing it up :)
I understand the function, but don't know how to display it :)
Do I need to include everything such as "include <gl/gl.h> ,include <gl/glu.h>..etc" just like in the Nehe tutorial...? Any simple way to display or run it.. :)
Thanks for the coding
Advertisement
Try download the nehe basecode; it should be on the main site. If you dont feel comfortable writing GL basecode, I can do it for this project...lol, I've done it quite a few times, so i have a bit of code i can reuse :)
This is the basecode i download from the Nehe main site. "simple Basecode"

 #include <windows.h>		// Header File For Windows#include <gl\gl.h>			// Header File For The OpenGL32 Library#include <gl\glu.h>			#include <gl\glaux.h>		# pragma comment ( lib, "opengl32.lib" )	#pragma comment( lib, "glu32.lib" )	#pragma comment( lib, "glaux.lib" )	HDC		hDC=NULL;		// Private GDI Device ContextHGLRC		hRC=NULL;		// Permanent Rendering ContextHWND		hWnd=NULL;		// Holds Our Window HandleHINSTANCE	hInstance;		// Holds The Instance Of The Applicationbool	keys[256];			// Array Used For The Keyboard Routinebool	active=TRUE;		// Window Active Flag Set To TRUE By Defaultbool	fullscreen=TRUE;	// Fullscreen Flag Set To Fullscreen Mode By DefaultLRESULT	CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);	// Declaration For WndProcGLvoid ReSizeGLScene(GLsizei width, GLsizei height)		// Resize And Initialize The GL Window{	if (height==0)										// Prevent A Divide By Zero By	{		height=1;										// Making Height Equal One	}	glViewport(0,0,width,height);						// Reset The Current Viewport	glMatrixMode(GL_PROJECTION);						// Select The Projection Matrix	glLoadIdentity();									// Reset The Projection Matrix	// Calculate The Aspect Ratio Of The Window	gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);	glMatrixMode(GL_MODELVIEW);							// Select The Modelview Matrix	glLoadIdentity();									// Reset The Modelview Matrix}int InitGL(GLvoid)										// All Setup For OpenGL Goes Here{	glShadeModel(GL_SMOOTH);			// Enable Smooth Shading	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);	// Black Background	glClearDepth(1.0f);			// Depth Buffer Setup	glEnable(GL_DEPTH_TEST);			// Enables Depth Testing	glDepthFunc(GL_LEQUAL);	   // The Type Of Depth Testing To Do	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations	return TRUE;										// Initialization Went OK}int DrawGLScene(GLvoid)									// Here's Where We Do All The Drawing{	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear Screen And Depth Buffer	glLoadIdentity();									// Reset The Current Modelview Matrix	glTranslatef(-1.5f,0.0f,-6.0f);	glBegin(GL_QUADS);		glColor3f(1.0f,1.0f,0.0f);	        glVertex3f(-1.0f, -1.0f, 1.0f);        glVertex3f( 1.0f, -1.0f, 1.0f);        glVertex3f( 1.0f, -1.0f,-1.0f);        glVertex3f(-1.0f, -1.0f,-1.0f);    glEnd();   	return TRUE;										// Everything Went OK}GLvoid KillGLWindow(GLvoid)								// Properly Kill The Window{	if (fullscreen)										// Are We In Fullscreen Mode?	{		ChangeDisplaySettings(NULL,0);					// If So Switch Back To The Desktop		ShowCursor(TRUE);								// Show Mouse Pointer	}	if (hRC)											// Do We Have A Rendering Context?	{		if (!wglMakeCurrent(NULL,NULL))					// Are We Able To Release The DC And RC Contexts?		{			MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);		}		if (!wglDeleteContext(hRC))						// Are We Able To Delete The RC?		{			MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);		}		hRC=NULL;										// Set RC To NULL	}	if (hDC && !ReleaseDC(hWnd,hDC))					// Are We Able To Release The DC	{		MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);		hDC=NULL;										// Set DC To NULL	}	if (hWnd && !DestroyWindow(hWnd))					// Are We Able To Destroy The Window?	{		MessageBox(NULL,"Could Not Release hWnd.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);		hWnd=NULL;										// Set hWnd To NULL	}	if (!UnregisterClass("OpenGL",hInstance))			// Are We Able To Unregister Class	{		MessageBox(NULL,"Could Not Unregister Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);		hInstance=NULL;									// Set hInstance To NULL	}}/*	This Code Creates Our OpenGL Window.  Parameters Are:					* *	title			- Title To Appear At The Top Of The Window				* *	width			- Width Of The GL Window Or Fullscreen Mode				* *	height			- Height Of The GL Window Or Fullscreen Mode			* *	bits			- Number Of Bits To Use For Color (8/16/24/32)			* *	fullscreenflag	- Use Fullscreen Mode (TRUE) Or Windowed Mode (FALSE)	*/ BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag){	GLuint		PixelFormat;			// Holds The Results After Searching For A Match	WNDCLASS	wc;						// Windows Class Structure	DWORD		dwExStyle;				// Window Extended Style	DWORD		dwStyle;				// Window Style	RECT		WindowRect;				// Grabs Rectangle Upper Left / Lower Right Values	WindowRect.left=(long)0;			// Set Left Value To 0	WindowRect.right=(long)width;		// Set Right Value To Requested Width	WindowRect.top=(long)0;				// Set Top Value To 0	WindowRect.bottom=(long)height;		// Set Bottom Value To Requested Height	fullscreen=fullscreenflag;			// Set The Global Fullscreen Flag	hInstance			= GetModuleHandle(NULL);				// Grab An Instance For Our Window	wc.style			= CS_HREDRAW | CS_VREDRAW | CS_OWNDC;	// Redraw On Size, And Own DC For Window.	wc.lpfnWndProc		= (WNDPROC) WndProc;					// WndProc Handles Messages	wc.cbClsExtra		= 0;									// No Extra Window Data	wc.cbWndExtra		= 0;									// No Extra Window Data	wc.hInstance		= hInstance;							// Set The Instance	wc.hIcon			= LoadIcon(NULL, IDI_WINLOGO);			// Load The Default Icon	wc.hCursor			= LoadCursor(NULL, IDC_ARROW);			// Load The Arrow Pointer	wc.hbrBackground	= NULL;									// No Background Required For GL	wc.lpszMenuName		= NULL;									// We Don't Want A Menu	wc.lpszClassName	= "OpenGL";								// Set The Class Name	if (!RegisterClass(&wc))									// Attempt To Register The Window Class	{		MessageBox(NULL,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION);		return FALSE;											// Return FALSE	}		if (fullscreen)												// Attempt Fullscreen Mode?	{		DEVMODE dmScreenSettings;								// Device Mode		memset(&dmScreenSettings,0,sizeof(dmScreenSettings));	// Makes Sure Memory's Cleared		dmScreenSettings.dmSize=sizeof(dmScreenSettings);		// Size Of The Devmode Structure		dmScreenSettings.dmPelsWidth	= width;				// Selected Screen Width		dmScreenSettings.dmPelsHeight	= height;				// Selected Screen Height		dmScreenSettings.dmBitsPerPel	= bits;					// Selected Bits Per Pixel		dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;		// Try To Set Selected Mode And Get Results.  NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.		if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)		{			// If The Mode Fails, Offer Two Options.  Quit Or Use Windowed Mode.			if (MessageBox(NULL,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?","NeHe GL",MB_YESNO|MB_ICONEXCLAMATION)==IDYES)			{				fullscreen=FALSE;		// Windowed Mode Selected.  Fullscreen = FALSE			}			else			{				// Pop Up A Message Box Letting User Know The Program Is Closing.				MessageBox(NULL,"Program Will Now Close.","ERROR",MB_OK|MB_ICONSTOP);				return FALSE;									// Return FALSE			}		}	}	if (fullscreen)												// Are We Still In Fullscreen Mode?	{		dwExStyle=WS_EX_APPWINDOW;								// Window Extended Style		dwStyle=WS_POPUP;										// Windows Style		ShowCursor(FALSE);										// Hide Mouse Pointer	}	else	{		dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;			// Window Extended Style		dwStyle=WS_OVERLAPPEDWINDOW;							// Windows Style	}	AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle);		// Adjust Window To True Requested Size	// Create The Window	if (!(hWnd=CreateWindowEx(	dwExStyle,							// Extended Style For The Window								"OpenGL",							// Class Name								title,								// Window Title								dwStyle |							// Defined Window Style								WS_CLIPSIBLINGS |					// Required Window Style								WS_CLIPCHILDREN,					// Required Window Style								0, 0,								// Window Position								WindowRect.right-WindowRect.left,	// Calculate Window Width								WindowRect.bottom-WindowRect.top,	// Calculate Window Height								NULL,								// No Parent Window								NULL,								// No Menu								hInstance,							// Instance								NULL)))								// Dont Pass Anything To WM_CREATE	{		KillGLWindow();								// Reset The Display		MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);		return FALSE;								// Return FALSE	}	static	PIXELFORMATDESCRIPTOR pfd=				// pfd Tells Windows How We Want Things To Be	{		sizeof(PIXELFORMATDESCRIPTOR),				// Size Of This Pixel Format Descriptor		1,											// Version Number		PFD_DRAW_TO_WINDOW |						// Format Must Support Window		PFD_SUPPORT_OPENGL |						// Format Must Support OpenGL		PFD_DOUBLEBUFFER,							// Must Support Double Buffering		PFD_TYPE_RGBA,								// Request An RGBA Format		bits,										// Select Our Color Depth		0, 0, 0, 0, 0, 0,							// Color Bits Ignored		0,											// No Alpha Buffer		0,											// Shift Bit Ignored		0,											// No Accumulation Buffer		0, 0, 0, 0,									// Accumulation Bits Ignored		16,											// 16Bit Z-Buffer (Depth Buffer)  		0,											// No Stencil Buffer		0,											// No Auxiliary Buffer		PFD_MAIN_PLANE,								// Main Drawing Layer		0,											// Reserved		0, 0, 0										// Layer Masks Ignored	};		if (!(hDC=GetDC(hWnd)))							// Did We Get A Device Context?	{		KillGLWindow();								// Reset The Display		MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);		return FALSE;								// Return FALSE	}	if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd)))	// Did Windows Find A Matching Pixel Format?	{		KillGLWindow();								// Reset The Display		MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);		return FALSE;								// Return FALSE	}	if(!SetPixelFormat(hDC,PixelFormat,&pfd))		// Are We Able To Set The Pixel Format?	{		KillGLWindow();								// Reset The Display		MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);		return FALSE;								// Return FALSE	}	if (!(hRC=wglCreateContext(hDC)))				// Are We Able To Get A Rendering Context?	{		KillGLWindow();								// Reset The Display		MessageBox(NULL,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);		return FALSE;								// Return FALSE	}	if(!wglMakeCurrent(hDC,hRC))					// Try To Activate The Rendering Context	{		KillGLWindow();								// Reset The Display		MessageBox(NULL,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);		return FALSE;								// Return FALSE	}	ShowWindow(hWnd,SW_SHOW);						// Show The Window	SetForegroundWindow(hWnd);						// Slightly Higher Priority	SetFocus(hWnd);									// Sets Keyboard Focus To The Window	ReSizeGLScene(width, height);					// Set Up Our Perspective GL Screen	if (!InitGL())									// Initialize Our Newly Created GL Window	{		KillGLWindow();								// Reset The Display		MessageBox(NULL,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION);		return FALSE;								// Return FALSE	}	return TRUE;									// Success}LRESULT CALLBACK WndProc(	HWND	hWnd,			// Handle For This Window							UINT	uMsg,			// Message For This Window							WPARAM	wParam,			// Additional Message Information							LPARAM	lParam)			// Additional Message Information{	switch (uMsg)									// Check For Windows Messages	{		case WM_ACTIVATE:							// Watch For Window Activate Message		{			if (!HIWORD(wParam))					// Check Minimization State			{				active=TRUE;						// Program Is Active			}			else			{				active=FALSE;						// Program Is No Longer Active			}			return 0;								// Return To The Message Loop		}		case WM_SYSCOMMAND:							// Intercept System Commands		{			switch (wParam)							// Check System Calls			{				case SC_SCREENSAVE:					// Screensaver Trying To Start?				case SC_MONITORPOWER:				// Monitor Trying To Enter Powersave?				return 0;							// Prevent From Happening			}			break;									// Exit		}		case WM_CLOSE:								// Did We Receive A Close Message?		{			PostQuitMessage(0);						// Send A Quit Message			return 0;								// Jump Back		}		case WM_KEYDOWN:							// Is A Key Being Held Down?		{			keys[wParam] = TRUE;					// If So, Mark It As TRUE			return 0;								// Jump Back		}		case WM_KEYUP:								// Has A Key Been Released?		{			keys[wParam] = FALSE;					// If So, Mark It As FALSE			return 0;								// Jump Back		}		case WM_SIZE:								// Resize The OpenGL Window		{			ReSizeGLScene(LOWORD(lParam),HIWORD(lParam));  // LoWord=Width, HiWord=Height			return 0;								// Jump Back		}	}	// Pass All Unhandled Messages To DefWindowProc	return DefWindowProc(hWnd,uMsg,wParam,lParam);}int WINAPI WinMain(	HINSTANCE	hInstance,			// Instance					HINSTANCE	hPrevInstance,		// Previous Instance					LPSTR		lpCmdLine,			// Command Line Parameters					int			nCmdShow)			// Window Show State{	MSG		msg;									// Windows Message Structure	BOOL	done=FALSE;								// Bool Variable To Exit Loop	// Ask The User Which Screen Mode They Prefer	if (MessageBox(NULL,"Would You Like To Run In Fullscreen Mode?", "Start FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO)	{		fullscreen=FALSE;							// Windowed Mode	}	// Create Our OpenGL Window	if (!CreateGLWindow("NeHe's OpenGL Framework",640,480,16,fullscreen))	{		return 0;									// Quit If Window Was Not Created	}	while(!done)									// Loop That Runs While done=FALSE	{		if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))	// Is There A Message Waiting?		{			if (msg.message==WM_QUIT)				// Have We Received A Quit Message?			{				done=TRUE;							// If So done=TRUE			}			else									// If Not, Deal With Window Messages			{				TranslateMessage(&msg);				// Translate The Message				DispatchMessage(&msg);				// Dispatch The Message			}		}		else										// If There Are No Messages		{			// Draw The Scene.  Watch For ESC Key And Quit Messages From DrawGLScene()			if (active)								// Program Active?			{				if (keys[VK_ESCAPE])				// Was ESC Pressed?				{					done=TRUE;						// ESC Signalled A Quit				}				else								// Not Time To Quit, Update Screen				{					DrawGLScene();					// Draw The Scene					//	DrawGLScen();						SwapBuffers(hDC);				// Swap Buffers (Double Buffering)				}			}			if (keys[VK_F1])						// Is F1 Being Pressed?			{				keys[VK_F1]=FALSE;					// If So Make Key FALSE				KillGLWindow();						// Kill Our Current Window				fullscreen=!fullscreen;				// Toggle Fullscreen / Windowed Mode				// Recreate Our OpenGL Window				if (!CreateGLWindow("NeHe's OpenGL Framework",640,480,16,fullscreen))				{					return 0;						// Quit If Window Was Not Created				}			}		}	}	// Shutdown	KillGLWindow();									// Kill The Window	return (msg.wParam);							// Exit The Program}


Where should I add this code..
 void draw_quad(void){    glBegin(GL_QUADS);        glVertex3f(-1.0f, 0.0f, 1.0f);        glVertex3f( 1.0f, 0.0f, 1.0f);        glVertex3f( 1.0f, 0.0f,-1.0f);        glVertex3f(-1.0f, 0.0f,-1.0f);    glEnd();}void draw_board(void){    // Starting from bottom left    for(int x = 0; x < 8; x ++)    {        for(int z = 0; z < 8; z++)        {	    // Determine color	    // % modulas operator	    // ^ xor operator            float col = (float)((x % 2) ^ (z % 2));            glColor3f(col, col, col);            glPushMatrix();	        glTranslatef((float)(2*x), 0, (float)(2*z));		draw_quad();                            glPopMatrix();        }    }}


Quote: If you dont feel comfortable writing GL basecode, I can do it for this project...lol, I've done it quite a few times, so i have a bit of code i can reuse :)


Have you done this project before? what basecode do you use to display the code..

Quote: Original post by da_grat1
Where should I add this code..


If I am correct, You should add the code to the "DrawGLScene" function but remove the function headers (void draw_quad(void) & void draw_board(void)) as well as the opening/closing brackets from the code in question, or just leave the two functions like they are, put them in the basecode outside the DrawGLScene function, and just call the two funtions from within the DrawGLScene function.

[Edited by - wcm4Him on December 27, 2004 5:07:05 AM]
Use a 8x8 array to hold information of chess pieces as well. Maybe you can also compile the board into a list as its state information will never change. You can model it as well using a 3d model program which will allow you to make it more aesthetic but IMO a set of checkerboard pattern quad should do.

Well good luck
The more applications I write, more I find out how less I know

This topic is closed to new replies.

Advertisement