MiniGamesRebuilding Three Classics
Joe LinhoffEugene JarvisDarren Torpey
Pong, 1972
Goals
Not to recreate "Pong" -- get an emulator lots of MUCH easier ways to do this that will turn
out MUCH better with MUCH less time Program a Pong-like game from scratch Learn game development
programming game design process
Why Pong
First game games must keep score, start and end first with score, sound
Static fixed number of game objects
Simple
Game Development
Process workflow
Design what are you trying to do
Development tools and language build an exe
Game development techniques solutions to the problem space
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
Tennis
78'-39..39 in X
27'-14..14 in Z
X
Z
Camera is above, looking down
paddlesball
Teaching Goallead students through first iteration
do brainstorm and design
1000 features handout
cover 000ZY coordinates
'draw' the camera draw the court exit cleanly
notes treat camera, matrix
as black box code adventurous students
can dig in focus on drawing
game objects
Game Loop update (voluntary)
move player paddles move ball
collide (involuntary) ball versus paddles ball versus court player versus court
draw draw court draw ball draw paddles draw score (HUD)
update performs voluntary
movement collision
handles involuntary movement
Velocities
variable frame rates float qeTimeFrame()
returns seconds since engine start / restart
keep track of the time since the last update
use Euler integration
// JFL 25 Jan 09class 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 ballfloat t;
// find time since last updatet=this->timeOfLastUpdate;this->timeOfLastUpdate=qeTimeFrame();t=this->timeOfLastUpdate-t; // delta
// xyz += vel*tthis->xyz[0]+=this->vel[0]*t;this->xyz[1]+=this->vel[1]*t;this->xyz[2]+=this->vel[2]*t;
Collisions
simplifications move, then collide
non-moving objects don't worry about
resolution order run through once
guarantee after detection, move
objects out of that collision (may be in another -- too bad)
end up in valid world position
no movement after collision resolution
Collisions ball v world
if over right or left score point, re-serve
if over top or bottom set to top or bottom reflect (flip z vel)
paddle v world make sure player
stays on the court ball v paddles
test against near edge of paddle set to near edge bounce (flip x vel) add English (later)
improvements preserve distance
when colliding don't just set to
collision edge reflect at collision point
does order matter? theoretically unlikely
fast balls could run through the
paddle depends on paddle
size and ball speed really need to handle
moving collisions
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();
Top Related