200 likes | 277 Views
Are you eager to learn game programming basics and set the stage for future development in the vibrant gaming industry? Dive into an exciting introduction to computer games, once considered mere children's toys but now a multi-billion dollar market. Discover the creative essence of game development and unlock the potential to craft your virtual worlds. Learn about essential game elements such as graphics, input, music, game logic, artificial intelligence, networking, and user interfaces. With a simplistic game architecture as your foundation, explore more advanced design concepts and delve into the APIs like OpenGL, SDL, and Milkshape 3D. Enhance your skills in game architecture, special effects like particle systems, billboarding, and collision detection. Venture into gameplay dynamics, player controls, enemy interactions, and world generation techniques. Unleash your imagination and take your game development skills to the next level with special effects, enhanced AI for enemies, item pickups, and networking capabilities. Embrace the collaborative nature of modern game development, where individual specialties merge to produce a cohesive work of art. This is your guide to the exciting world of game programming – embark on this journey and unleash your creativity!
E N D
OpenGL Game by Neal Patel
Motivation • Learn the basics of game programming • Experience for future development in a growing industry • Fun
Introduction • Computer Games once used to be considered children toys. • Now they have grown into a multi-billion dollar market. • Games have come to be known as one of the more creative forms of software development. • Game developers are drawn into this industry by the idea of creating their own virtual world that people will one day experience.
Elements of A Game • Graphics • Input • Music and Sound • Game Logic and Artificial Intelligence • Networking • User Interface and Menuing System
Enough Small Talk • API used for system • OpenGL • Open Graphics Library – interface to graphics hardware. • SDL • Simple DirectMedia Layer – cross platform multimedia library designed to provide fast access to the graphics framebuffer and audio device. • Milkshape 3D – 3D animation modeler
Concepts Learned from Programming • Texture mapping • Loads BMP file via SDL LoadBMP routine SDL_Surface *image=SDL_LoadBMP(“bitmap.bmp”); If(image!=NULL) { SDL_BlitSurface(image, NULL, screen, NULL); } SDL_UpdateRect(screen,0,0,0,0); This should create memory space for an image, load it from a file, and display it onto the screen Blit - To copy a large array of bits from one part of a computer's memory to another part.
Special Effects Presented • Particle Systems • Through clever use of textures and other properties particle systems can be used to create effects like fire, smoke explosions, liquid (water or blood) spraying, snow, star fields, etc.. • Attributes the particle system possess. • Position • Velocity • Life Span • Color
Particle Effect (cont.) effect = ParticleEffect( EXPLOSION, //Type of particle effect NONE, //Type of collision detection Vector(0.0f, 0.0f, 0.6f), //Gravity vector 50, //How random to spray things out 0, //How long the effect will last 0, //How long in frames before each particle begins to fade Vector( 5.5f, 5.5f, 0.5f ), //The origin of the effect Color( r, g, b ), //The color of the effect "Data/Texture/Particle.bmp“ //What texture to load );
Other special effects • Billboarding • Allows a polygon to always face the viewer. As the player moves at an angle, they will be able to see the object at an angle. • Collision Detection • Bounding square technique – surrounds a object in the world along their extreme points. • A collision is registered whenever the distance between the player and the enemy is less than the sum of the enemy radius and the player radius.
Gameplay • Enemies die when they collide with the player, dealing damage to the player equal to (250/e), where e is the initial number of enemies on the map. • The initial health of the player is 100 and initial number of enemies is set to 50. Therefore each collision with the enemy will cause the player to lose 5 health. Health of the enemy is set to 0.
SDL implementation for control keys if(keys[SDLK_UP] || keys[SDLK_w]) { dx += (float)(PLAYER_SPEED*cos(a*PI180)); dy += (float)(PLAYER_SPEED*sin(a*PI180)); } if(keys[SDLK_DOWN] || keys[SDLK_s]) { dx -= (float)(PLAYER_SPEED*cos(a*PI180)); dy -= (float)(PLAYER_SPEED*sin(a*PI180)); } if(keys[SDLK_d]) { dx += (float)(PLAYER_SPEED*0.5f*sin(a*PI180)); dy -= (float)(PLAYER_SPEED*0.5f*cos(a*PI180)); } if(keys[SDLK_a]) { dx -= (float)(PLAYER_SPEED*0.5f*sin(a*PI180)); dy += (float)(PLAYER_SPEED*0.5f*cos(a*PI180)); }
How the world was generated • First, the map is filled with empty tiles, and the border tiles are made solid. A random point is then selected, and either a horizontal or vertical line of walls is drawn across the room, leaving a open space to navigate to different rooms. This process is called recursively until rooms are of an acceptable size.
Drawing and loading texture to a wall glColor3f(1,1,1); glBindTexture(GL_TEXTURE_2D, walltex); glBegin(GL_QUADS); if(type(i+1,j)==0) { glNormal3i(1,0,0); glTexCoord2d(0,0); glVertex3i(i+1, j, 0); glTexCoord2d(1,0); glVertex3i(i+1, j+1, 0); glTexCoord2d(1,1); glVertex3i(i+1, j+1, 1.5f); glTexCoord2d(0,1); glVertex3i(i+1, j, 1.5f); }
Future Work • Implement so player can fire a weapon like a real first person shooter is supposed to do. • Add item pickups such as multiple weapons and ammo • Better enemies with more advanced AI • And why not networking
Conclusion • Today game software is developed in teams, where each member works on his or her specialty until the work is integrated to create a work single coherent work of art. They take years to develop. Working with my abilities this is the end result. Hope you enjoyed.
References • Hawkins, Kevin and Dave Astle. OpenGL Game Programming. Premier Press, May 2004. • Woo, Mason, J. Neider, and T. Davis. OpenGL Programming Guide. Addison-Wesley, fourth edition, November 2003. • www.opengl.org • www.libsdl.org • www.gamedev.net • www.gametutorials.com • http://nehe.gamedev.net/ • http://www.psionic3d.co.uk/