Gdc09 Minipong

753 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
753
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Gdc09 Minipong

  1. 2. MiniGames Rebuilding Three Classics Joe Linhoff Eugene Jarvis Darren Torpey
  2. 3. Pong, 1972
  3. 4. Goals <ul><li>Not to recreate &quot;Pong&quot; -- get an emulator </li></ul><ul><ul><li>lots of MUCH easier ways to do this that will turn out MUCH better with MUCH less time </li></ul></ul><ul><li>Program a Pong-like game from scratch </li></ul><ul><li>Learn game development </li></ul><ul><ul><li>programming </li></ul></ul><ul><ul><li>game design </li></ul></ul><ul><ul><li>process </li></ul></ul>
  4. 5. Why Pong <ul><li>First game </li></ul><ul><ul><li>games must keep score, start and end </li></ul></ul><ul><ul><li>first with score, sound </li></ul></ul><ul><li>Static </li></ul><ul><ul><li>fixed number of game objects </li></ul></ul><ul><li>Simple </li></ul>
  5. 6. Game Development <ul><li>Process </li></ul><ul><ul><li>workflow </li></ul></ul><ul><li>Design </li></ul><ul><ul><li>what are you trying to do </li></ul></ul><ul><li>Development tools and language </li></ul><ul><ul><li>build an exe </li></ul></ul><ul><li>Game development techniques </li></ul><ul><ul><li>solutions to the problem space </li></ul></ul>
  6. 7. 1000 Features (handout) unique value 0..1000 possible feature for your game -- focus on what you see, hear, and how to get it on the screen
  7. 8. Tennis 78' -39..39 in X 27' -14..14 in Z Camera is above, looking down paddles ball X Z
  8. 9. Teaching Goal lead students through first iteration <ul><li>do brainstorm and design </li></ul><ul><li>1000 features handout </li></ul><ul><li>cover 000ZY coordinates </li></ul><ul><li>'draw' the camera </li></ul><ul><li>draw the court </li></ul><ul><li>exit cleanly </li></ul><ul><li>notes </li></ul><ul><ul><li>treat camera, matrix as black box code </li></ul></ul><ul><ul><ul><li>adventurous students can dig in </li></ul></ul></ul><ul><ul><li>focus on drawing game objects </li></ul></ul>
  9. 10. Game Loop <ul><li>update (voluntary) </li></ul><ul><ul><li>move player paddles </li></ul></ul><ul><ul><li>move ball </li></ul></ul><ul><li>collide (involuntary) </li></ul><ul><ul><li>ball versus paddles </li></ul></ul><ul><ul><li>ball versus court </li></ul></ul><ul><ul><li>player versus court </li></ul></ul><ul><li>draw </li></ul><ul><ul><li>draw court </li></ul></ul><ul><ul><li>draw ball </li></ul></ul><ul><ul><li>draw paddles </li></ul></ul><ul><ul><li>draw score (HUD) </li></ul></ul><ul><li>update </li></ul><ul><ul><li>performs voluntary movement </li></ul></ul><ul><li>collision </li></ul><ul><ul><li>handles involuntary movement </li></ul></ul>
  10. 11. Velocities <ul><li>variable frame rates </li></ul><ul><li>float qeTimeFrame() </li></ul><ul><ul><li>returns seconds since engine start / restart </li></ul></ul><ul><li>keep track of the time since the last update </li></ul><ul><li>use Euler integration </li></ul>// JFL 25 Jan 09 class Ball : public qe { public: chr name[16]; // name float timeOfLastUpdate; // in seconds float xyz[3]; // current float vel[3]; // velocity Ball(chr *name); // constructor int update(); // update function int draw(); // draw function }; // class Ball // update, move the ball float t; // find time since last update t=this->timeOfLastUpdate; this->timeOfLastUpdate=qeTimeFrame(); t=this->timeOfLastUpdate-t; // delta // xyz += vel*t this->xyz[0]+=this->vel[0]*t; this->xyz[1]+=this->vel[1]*t; this->xyz[2]+=this->vel[2]*t;
  11. 12. Collisions <ul><li>simplifications </li></ul><ul><ul><li>move, then collide non-moving objects </li></ul></ul><ul><ul><li>don't worry about resolution order </li></ul></ul><ul><ul><li>run through once </li></ul></ul><ul><li>guarantee </li></ul><ul><ul><li>after detection, move objects out of that collision (may be in another -- too bad) </li></ul></ul><ul><ul><li>end up in valid world position </li></ul></ul><ul><ul><li>no movement after collision resolution </li></ul></ul>
  12. 13. Collisions <ul><li>ball v world </li></ul><ul><ul><li>if over right or left </li></ul></ul><ul><ul><ul><li>score point, re-serve </li></ul></ul></ul><ul><ul><li>if over top or bottom </li></ul></ul><ul><ul><ul><li>set to top or bottom </li></ul></ul></ul><ul><ul><ul><li>reflect (flip z vel) </li></ul></ul></ul><ul><li>paddle v world </li></ul><ul><ul><li>make sure player stays on the court </li></ul></ul><ul><li>ball v paddles </li></ul><ul><ul><li>test against near edge of paddle </li></ul></ul><ul><ul><ul><li>set to near edge </li></ul></ul></ul><ul><ul><ul><li>bounce (flip x vel) </li></ul></ul></ul><ul><ul><ul><li>add English (later) </li></ul></ul></ul><ul><li>improvements </li></ul><ul><ul><li>preserve distance when colliding </li></ul></ul><ul><ul><ul><li>don't just set to collision edge </li></ul></ul></ul><ul><ul><ul><li>reflect at collision point </li></ul></ul></ul><ul><li>does order matter? </li></ul><ul><ul><li>theoretically </li></ul></ul><ul><ul><li>unlikely </li></ul></ul><ul><li>fast balls </li></ul><ul><ul><li>could run through the paddle </li></ul></ul><ul><ul><ul><li>depends on paddle size and ball speed </li></ul></ul></ul><ul><ul><ul><li>really need to handle moving collisions </li></ul></ul></ul>
  13. 14. Draw simple filled rectangle glColor3f(1,1,1); glPolygonMode(GL_FRONT,GL_FILL); // draw filled polygons glBegin(GL_QUADS); // draw quads counter-clockwise from camera's view glVertex3f(-1,0,-3); glVertex3f(-1,0,3); glVertex3f(2,0,3); glVertex3f(2,0,-3); glEnd();

×