Hey guys,
sry for the long wait. I was busy preparing this:
http://www.eng.uwaterloo.ca/~rramraj/Gamedev/chess_tutorial/src_tree/chess_src.zip
It's a fully functional implementation of the subsystems we have discussed so far. You can find our source tree in the console basecode. I also made a few changes to the implementation of the context manager.
You'll notice that some lines are commented out in our main function where the unit tests are. What exactly is a unit test? A unit test is code that "proves" the functionality of a particular subsystem. The test is not responsible for dealing with the errors that pop up per say. It simply puts the subsystem through its paces. If there are any problems, it's the responsibility of the developer watching the test to deal with them accordingly.
You'll also notice that I've included my own gl basecode in with the source. The code is similar to nehe's but I've also included a set of libraries that will let us do modeling, texture loading, and math. For those that want to read ahead its a good place to start. We will be using toned down versions of these libraries in our resource manager.
So, grab a cup of hot chocolate, sit in front of the fire place, and prepare yourself for a trek into the source. Its a story of love, betrayal, and ambition ;) At the moment I have to turn my attention a bit to the winamp gl contest; need to get the demos online. Check 'em out if you have the time :) I'll try to get the sound loader online asap.
Will post later,
- llvllatrix
How to program a chess: a forum based tutorial
Without meaning to question the excellent work you are doing Ivllatrix, why not just focus on the game by making the windows creation/management code as simple as possible for the time being; for example by using GLUT or SDL? For a simple project like this it seems better to develope the gaming code first and concentrate later on the interface code. It may also be less confusing for a beginner.
For example, here is the chess board in just 80 lines of code using glut:
For example, here is the chess board in just 80 lines of code using glut:
// Basic 60-line Glut code from http://personal.nbnet.nb.ca/daveg/opengl/misc/#PicoCube#include <GL/glut.h>void reshapeFunc( int w, int h ){ glViewport( 0, 0, w, h ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); if( h < 1 ) h = 1; gluPerspective( 30.0, (double)w / (double)h, 1.0, 1000.0 ); glMatrixMode( GL_MODELVIEW );}void draw_board(void){ int x, z; for (x = 0; x < 8; x++) { for (z = 0; z < 8; z++) { float col = (float)((x % 2) ^ (z % 2)); glColor3f(col, col, col); glPushMatrix(); glTranslatef((float)(2*x), 0, (float)(2*z)); 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(); glPopMatrix(); } }}void displayFunc(void){ static GLfloat angle1 = 0.0f; angle1 += 1.0f; glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glLoadIdentity(); // Cancels all transformations gluLookAt( 20.0f, 15.0f, 20.0f, // Camera position 0.0f, 0.0f, 0.0f, // Camera direction 0, 1, 0 ); // Camera up vector glPushMatrix(); // Objects rendered between push and popMatrix will be transformed without affecting camera glRotatef( angle1, 0.0f, 1.0f, 0.0f ); // Rotates objects which follow glTranslatef( -7.0, 0.0, -7.0 ); // Centers board on coords 0,0,0 draw_board(); glPopMatrix(); // Objects rendered between push and popMatrix will be transformed without affecting camera glutSwapBuffers(); glutPostRedisplay();}void keyboardFunc( unsigned char key, int x, int y ){ switch( key ) { case 27: // ESC key glutDestroyWindow( glutGetWindow() ); exit( 0 ); }}int main( int argc, char* argv[] ){ glutInit( &argc, argv ); glutInitWindowSize(640, 480); glutInitDisplayMode( GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGB ); (void)glutCreateWindow("Basic Glut App"); glutReshapeFunc( reshapeFunc ); glutDisplayFunc( displayFunc ); glutKeyboardFunc( keyboardFunc ); glClearColor( 0.0, 0.75, 0.75, 0.0 ); glEnable( GL_DEPTH_TEST ); glutMainLoop(); return 0; // Never called! glutMainLoop() never returns....}
keermalec...
Yeah that code is simple and easy to understand... It would be nice if we can display a menu screen for the game.... :)
yes I will check the demos... :)
Yeah that code is simple and easy to understand... It would be nice if we can display a menu screen for the game.... :)
Quote: At the moment I have to turn my attention a bit to the winamp gl contest; need to get the demos online. Check 'em out if you have the time :) I'll try to get the sound loader online asap.
yes I will check the demos... :)
Quote:
Without meaning to question the excellent work you are doing Ivllatrix
lol, no worries :) As I said, questioning my work is very valuable because it lets us further our discussion.
Quote:
why not just focus on the game by making the windows creation/management code as simple as possible for the time being; for example by using GLUT or SDL? For a simple project like this it seems better to develope the gaming code first and concentrate later on the interface code. It may also be less confusing for a beginner.
Actually, that’s a good point. There are several libraries that we can easily use in place of the windows creation subsystem (GLUT and SDL). We could either write our own, use GLUT or use SDL. Keermalec's source uses GLUT and as you can see it is very elegant. Writing our own would essentially consist of a review of nehe's first tutorial. If we wrap our windows creation routines, we can also easily switch between the different options. Are there any preferences?
Thanks Keermalec :),
- llvllatrix
I think that for such a program, using libraries like GLUT or SDL would be ok.
Generally speaking though, do these libraries limit performances?
I read somewhere that glut, for example, causes a slowdown, compared to something like NeHe's basecode; is this true?
Generally speaking though, do these libraries limit performances?
I read somewhere that glut, for example, causes a slowdown, compared to something like NeHe's basecode; is this true?
I think GLUT would be a good choice since most of us are probably familiar with it (not to mention this thread is on an OGL website).
[Edited by - wcm4Him on January 10, 2005 1:13:39 PM]
[Edited by - wcm4Him on January 10, 2005 1:13:39 PM]
llvllatrix, when are u going to continue the chess tutorial.. I think the next tutorial is about the game menu... :)
sry for the long delay...been kinda busy with the winamp contest...
Unfortunately, we still have a ways to go to get to the game menu, but if its any consolation, once we get there we will be more than half way through our project :D.
My next tutorial will be on sound loading using OpenAL. I expect to be finished the resource manager within this week. When the resource manager and window creation subsystems are done, we can start on the game menu.
Will post later,
- llvllatrix
Quote:
llvllatrix, when are u going to continue the chess tutorial.. I think the next tutorial is about the game menu... :)
Unfortunately, we still have a ways to go to get to the game menu, but if its any consolation, once we get there we will be more than half way through our project :D.
My next tutorial will be on sound loading using OpenAL. I expect to be finished the resource manager within this week. When the resource manager and window creation subsystems are done, we can start on the game menu.
Will post later,
- llvllatrix
llvllatrix
Do u think this tutorial can be finished within this month...? I think the most difficult part is to implement the artificial intelligent into the game..
Do u think this tutorial can be finished within this month...? I think the most difficult part is to implement the artificial intelligent into the game..
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement