opengl game l.
Skip this Video
Loading SlideShow in 5 Seconds..
OpenGL Game PowerPoint Presentation
Download Presentation
OpenGL Game

Loading in 2 Seconds...

  share
play fullscreen
1 / 20
Download Presentation

OpenGL Game - PowerPoint PPT Presentation

Gabriel
324 Views
Download Presentation

OpenGL Game

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. OpenGL Game by Neal Patel

  2. Motivation • Learn the basics of game programming • Experience for future development in a growing industry • Fun

  3. 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.

  4. Elements of A Game • Graphics • Input • Music and Sound • Game Logic and Artificial Intelligence • Networking • User Interface and Menuing System

  5. Simplistic Game Architecture

  6. More Advanced Game Architectural Design

  7. 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

  8. SDL Architecture

  9. 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.

  10. 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

  11. 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 );

  12. 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.

  13. 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.

  14. User Interface

  15. 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)); }

  16. 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.

  17. 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); }

  18. 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

  19. 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.

  20. 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/