Super Pong Andrew Dunsmore CSC436. Overview Purpose Design Specification Software Engineering.

18
Super Pong Andrew Dunsmore CSC436

Transcript of Super Pong Andrew Dunsmore CSC436. Overview Purpose Design Specification Software Engineering.

Page 1: Super Pong Andrew Dunsmore CSC436. Overview Purpose Design Specification Software Engineering.

Super Pong

Andrew Dunsmore

CSC436

Page 2: Super Pong Andrew Dunsmore CSC436. Overview Purpose Design Specification Software Engineering.

Overview

• Purpose

• Design Specification

• Software Engineering

Page 3: Super Pong Andrew Dunsmore CSC436. Overview Purpose Design Specification Software Engineering.

Purpose

• Waste Time

• Kill Twenty Minutes

• Something to do besides homework

Page 4: Super Pong Andrew Dunsmore CSC436. Overview Purpose Design Specification Software Engineering.

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

Page 5: Super Pong Andrew Dunsmore CSC436. Overview Purpose Design Specification Software Engineering.

But what makes it SUPER?

• User level options

• Sound Effects

• Multi-Player

• Physics Models

• Ping Motion

• Boards (pre-defined and user-created)

Page 6: Super Pong Andrew Dunsmore CSC436. Overview Purpose Design Specification Software Engineering.

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

Page 7: Super Pong Andrew Dunsmore CSC436. Overview Purpose Design Specification Software Engineering.

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

Page 8: Super Pong Andrew Dunsmore CSC436. Overview Purpose Design Specification Software Engineering.

Artificial Intelligence Model

• AI model not yet determined• 2 possible Models

• Random Intelligence• Instead of AI, the

computer player randomly chooses not to try to hit the ping

• 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

Page 9: Super Pong Andrew Dunsmore CSC436. Overview Purpose Design Specification Software Engineering.

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

Page 10: Super Pong Andrew Dunsmore CSC436. Overview Purpose Design Specification Software Engineering.

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

Page 11: Super Pong Andrew Dunsmore CSC436. Overview Purpose Design Specification Software Engineering.

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

Page 12: Super Pong Andrew Dunsmore CSC436. Overview Purpose Design Specification Software Engineering.

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

Page 13: Super Pong Andrew Dunsmore CSC436. Overview Purpose Design Specification Software Engineering.

Boards

• User can pick from 6 pre-defined boards

• User-created boards also possible with included sub-program

Page 14: Super Pong Andrew Dunsmore CSC436. Overview Purpose Design Specification Software Engineering.

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

Page 15: Super Pong Andrew Dunsmore CSC436. Overview Purpose Design Specification Software Engineering.

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

Page 16: Super Pong Andrew Dunsmore CSC436. Overview Purpose Design Specification Software Engineering.

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

Page 17: Super Pong Andrew Dunsmore CSC436. Overview Purpose Design Specification Software Engineering.

Pseudo Codeconst int GAME_STATE_START = 0const int …int state;

game_init() { // initiate run-time variables: state = GAME_STATE_START;}game_main() { // note: this function is called on each frame // typically every 1/30 seconds switch (state) { case (GAME_STATE_START) // set variables for a new game // and set up the new board state = GAME_STATE_RUN; break; …}

game_shutdown() { // this function releases all resources // and returns control to the OS SendMessage(…);}WinMain() { // set up window CreateWindowEx(…); // get resources and set initial variables game(init); // enter the main game loop while(1) { if(WM_CLOSE) { // if exit msg received game_shutdown() // end the game return(0); } // end if game_main() // else call the main game

// function } // end while()}

Page 18: Super Pong Andrew Dunsmore CSC436. Overview Purpose Design Specification Software Engineering.

Super Pong

Drew Dunsmore

CSC436

?Questions?