Super Pong - GEOCITIES.ws

Download Report

Transcript Super Pong - GEOCITIES.ws

Super Pong
Andrew Dunsmore
CSC436
Overview
• Purpose
• Design Specification
• Software Engineering
Purpose
• Waste Time
• Kill Twenty Minutes
• Something to do besides homework
Super Pong
• Video ping pong
• Players move paddle
to intercept ping (ball)
• If the ping is missed,
opponent scores a
point
• Played until a player
scores a set number of
points
But what makes it SUPER?
•
•
•
•
•
•
User level options
Sound Effects
Multi-Player
Physics Models
Ping Motion
Boards (pre-defined and user-created)
Sounds
• Default or user-defined
• Categories can be set independently
– External/Internal Wall Impacts
– Own/Opponent Paddle
• User-defined sounds limited to digital (wav)
of a set length
Single/Multi-Player
• Single player games can be played at 3
levels of difficulty
• Multi-player options
– Direct connect using IP addresses
– Connection to server program
• Multi-Player communication using
Windows Sockets
Artificial Intelligence Model
• AI model not yet determined
• 2 possible Models
• Time-deferred guessing
• Computer calculates
expected position using
pings current position and
dx and dy
• Data can not be acted
upon for dt, then must
wait to gain more data
• Random Intelligence
• Instead of AI, the
computer player randomly
chooses not to try to hit
the ping
AI Model (continued)
• The choice of AI Model will be based on 2
metrics
– Realism: the user should not be aware when the
computer chose not to hit the ping
– Difficulty rating: algorithm must ensure that
Amateur games are easy and Expert games are
hard
Multi-Player Issues
• Utilizes Windows Sockets
• At a minimum the game must communicate:
– Both paddle positions
– Ping position
• Issue:
– User’s screen resolution is based on their desktop
settings
– Points will need to be translated between different
resolutions
Physics Models
• User can choose from 3
different models
• True
– Angle of reflection = -Angle of
incident
• Pool
– Angle of reflection is based on
angle of incident, speed of
ping, and firmness of bumper
– Bumper firmness can be set by
user as a percentage – 100%
firmness will behave like True
model
• Crazy
– Angle of reflection is random
Ping Motion (or Physics II)
• Ping motion can be set by
user
• Motion can be static, free
rotate, or incident rotate
• Ping will begin rotating if:
– Paddle is in motion at time
of collision
– Low incident angle with a
wall
• A ping’s rotation will
affect its reflection angle
Boards
• User can pick from 6 pre-defined boards
• User-created boards also possible with
included sub-program
Board Customization
• Included board creation sub-program will be similar to MS Paint Brush
• Differences:
– Area will be defined by fixed grid
– A cell in grid is either filled or blank
– Only half of board needs to be designed – other half of board is a mirror
image
• Details:
– Mirror image used to ensure equality for both players
– Grids used to ease board recognition by program
– For diagonal filled boxes, user can hit a button and computer will half fill
adjacent boxes
• For multi-player games, if other player doesn’t have the board, the
program will automatically send it
SE – Finite State Machine
•
•
•
•
•
•
Game Init: Setting variables when
game is loaded into memory
Game Menu: Resting point for the
game – executes menu commands
Game Starting: Scores, Timers, etc.
reset Resources acquired for Game
Run
Game Run: Handles the bulk of the
game’s instructions, physics, video,
etc. (typically ran every 1/30
second)
Game Restart: Displays winner,
releases resources used in Game
Run
Game Exit: Releases all resources
and returns control to the OS
The FSM and OO C++
• The Finite State Machine smoothly
translates to Object Oriented languages
• The states become C++ functions
•
•
•
•
•
•
Game Init = game_init
Game Menu = handled in WinMain
Game Starting = handled in game_main
Game Run = game_main
Game Restart = handled in game_main
Game Exit = game_shutdown
Pseudo Code
game_shutdown() {
// this function releases all resources
// and returns control to the OS
SendMessage(…);
}
game_init() {
WinMain() {
// initiate run-time variables:
// set up window
state = GAME_STATE_START;
CreateWindowEx(…);
}
// get resources and set initial variables
game_main() {
// note: this function is called on each frame game(init);
// enter the main game loop
// typically every 1/30 seconds
while(1) {
switch (state) {
if(WM_CLOSE) { // if exit msg received
case (GAME_STATE_START)
game_shutdown() // end the game
// set variables for a new game
return(0);
// and set up the new board
} // end if
state = GAME_STATE_RUN;
game_main() // else call the main game
break;
// function
…
} // end while()
}
}
const int GAME_STATE_START = 0
const int …
int state;
Super Pong
Drew Dunsmore
CSC436
?Questions?