Breach

Update of "Design"
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview

Artifact ID: 0f48ce607c75ceea23e6575a27032e20eaa40725
Page Name:Design
Date: 2012-11-02 04:48:43
Original User: Donny
Parent: da8e8102dd284d1f7f33103f8f884ba91e379a3c
Content

See attached document for the original (pre fossil).


Breach Technical Document Requirements: The program must be able to run on both Windows and Linux. The program must not require any additional files/dependencies, and it needs to be small. It needs to run on any modern day computer. It should be controlled exclusively by the mouse. No other input device should be required. The game is for one human player. The program will have a separate binary which serves as the level editor. Overview Of Design: The game will be written natively in Linux with C++ and SDL for portability. The game code will be as clean, efficient, and simplistic as possible. The goal is to write good code. It will also be as object oriented as possible, implementing design concepts such as a state manager for the menu and loading screens/transitions. A level editor will also be created to create the levels, in C++. Drawing: The game will utilize the standard image drawing functions provided by SDL. Art will be made in Photoshop 7.0. The blocks to break will be rectangles of a uniform size. The ball will be represented by a circular graphic. The paddle will be a semicircle shaped graphic. Walls will be part of the background as they are static and will not change. Input: The mouse will be used for input. The menu will be navigated by mousing over and left clicking options. Right clicking will go backwards through the menus. Right clicking during gameplay will pause the game. Moving the mouse in the game will rotate the semicircle paddle around a center point in the middle of the screen. The mouse pointer will be hidden during gameplay and centered when it is unhidden to navigate menus. Logic: The game will implement a state machine to move between the various menus and levels of the game. The ball, items, blocks (soft or hard), and bounding wall sections will all inherit from a base GameObject class. The paddle will always be dead center in the game and be its very own Paddle class derived from GameObject. There will be four planes which designate the bounding box for the map. The game boundaries are divided into sections which can be either harm the ball or not. The ball will utilize as accurate physics as reasonable. Collision boxes will be used for collision detection (where necessary), with the exception of the ball implementing circular collision detection. Level files will be binary files which store every GameObject in the map. The ball, items, blocks, and bounding wall sections will be contained together in a fixed size array. The data structure will consist of members of GameObject, which is possible by implementing GameObject as an abstract base class. The ball is always the first element of this array.

All coordinate systems used (whether for SDL functions or ones I create) will utilize having the origin in the top left corner. This is due to SDL’s coordinates used this way and will avoid confusion. Coordinates for any object will be the top left corner of it, except for the ball, which will have its coordinates in the center for collision detection purposes. Subtracting the radius of the circle from its coordinates will yield the top left coordinate required for blitting. A native 640x480 resolution will be used with the option of going fullscreen. The paddle’s coordinate is the center of the map and its orientation represented by an angle. Mouse movement will control the paddle’s change of direction. The only mouse movement considered for calculation will be that which rests on the axis perpendicular to the paddle’s current facing. The mouse will be recentered if possible in SDL, also it will be invisible during gameplay. Collision between the ball and the paddle will take place in 2 stages. First, circular collision detection will be performed on both to see if the ball is inside the paddle radius. Then an angle of the line from the center of the ball to the center of the paddle rotation will be compared to the paddle’s current angle to see if it falls inside the paddle (at the same time compare the radius because the ball can sit on the center).

A singleton may contain global settings such as mouse sensitivity (a multiplier), fullscreen toggle, sound etc. Project Break Down: The project has a total of 19 files. GameObject, Item, Ball, Block, WallSection, Paddle, StateManager, graphics, and sound all have a header and source file. The main function + game loop and simple helper functions (such as checking command line parameters) are contained in breach.cpp, which will also contain the necessary globals. GameObject: Class GameObject Properties: Its location Width/Height of its collision box The Object type (Item, Block, Ball, etc) that this GameObject is

Methods: Draw – applys the correct screen surface to the screen (pure virtual)

OnCollide(GameObject * otherObject) – handles what to do when this collides with something (like the ball) (pure virtual) GetLoc – returns the top left coordinates of the GameObject by reference GetCenter – returns coordinates of center of GameObject by reference (virtual) SetLoc – sets location of GameObject GetObjectType() – returns the Object type of this GameObject

GetSpeed – gets the speed (virtual) GetAngle – gets the angle the object is moving in (virtual)

Virtual ~GameObject – virtual destructor fixAngle – makes sure the angle is from 0-359 doMove – (pure virtual)

Item Derived Properties: The type of item this object represents.

Methods: Draw – applys the correct screen surface to the screen (pure virtual)

OnCollide(GameObject * otherObject) – handles what to do when this collides with something (like the ball) (pure virtual) GetLoc – returns the top left coordinates of the GameObject by reference GetCenter – returns coordinates of center of GameObject by reference (virtual) SetLoc – sets location of GameObject GetObjectType() – returns the Object type of this GameObject

Virtual ~GameObject – virtual destructor fixAngle – makes sure the angle is from 0-359 doMove – takes current speed and angle from last update to set new position for this logic update

Block Derived Properties: Whether or not the block is hard (ball bounces off) Pointer to the item contained inside (null if none)

Methods: Draw – applys the correct screen surface to the screen (pure virtual)

OnCollide(GameObject * otherObject) – handles what to do when this collides with something (like the ball) (pure virtual) GetLoc – returns the top left coordinates of the GameObject by reference GetCenter – returns coordinates of center of GameObject by reference (virtual) SetLoc – sets location of GameObject GetObjectType() – returns the Object type of this GameObject

Virtual ~GameObject – virtual destructor fixAngle – makes sure the angle is from 0-359 doMove – takes current speed and angle from last update to set new position for this logic update

Ball Derived Properties: Radius of the ball X and y velocity

Methods: Draw – applys the correct screen surface to the screen (pure virtual)

OnCollide(GameObject * otherObject) – handles what to do when this collides with something (like the ball) (pure virtual) GetLoc – returns the top left coordinates of the GameObject by reference GetCenter – returns coordinates of center of GameObject by reference (virtual) SetLoc – sets location of GameObject GetObjectType() – returns the Object type of this GameObject

Virtual ~GameObject – virtual destructor

fixAngle – makes sure the angle is from 0-359 doMove – takes current speed and angle from last update to set new position for this logic update

Wall Section Derived Properties: Whether or not the wall section is hazardous to the ball (spiky) or the ball just bounces off

Methods: Draw – applys the correct screen surface to the screen (pure virtual)

OnCollide(GameObject * otherObject) – handles what to do when this collides with something (like the ball) (pure virtual) GetLoc – returns the top left coordinates of the GameObject by reference GetCenter – returns coordinates of center of GameObject by reference (virtual) SetLoc – sets location of GameObject GetObjectType() – returns the Object type of this GameObject

Virtual ~GameObject – virtual destructor fixAngle – makes sure the angle is from 0-359 doMove – takes current speed and angle from last update to set new position for this logic update

Paddle Derived Properties: The current angle of facing The x and y coordinate of the mouse from the last frame (should be (0,0) if it is reset to the center each frame, but just to be sure)

Methods: Draw – applys the correct screen surface to the screen (pure virtual) OnCollide – handles what to do when this collides with something (like the ball) (pure virtual) GetLoc – returns the top left coordinates of the GameObject by reference GetCenter – returns coordinates of center of rotation of GameObject by reference (virtual) SetLoc – sets location of GameObject GetObjectType() – returns the Object type of this GameObject

Virtual ~GameObject – virtual destructor

fixAngle – makes sure the angle is from 0-359 doMove – finds out the current mouse x/y, find the difference in relation to previous frame’s mouse loc, and calculates the new angle (which the paddle’s angle is now set to) StateMachine: The states (stored as enum)

STATE_SPLASH STATE_MMAIN STATE_MCHOOSEDIFFICULTY STATE_MLISTSAVEGAMES STATE_MOPTIONS STATE_MCONTROLS STATE_MCONFIMEXIT STATE_MCREDITS STATE_MHIGHSCORES STATE_PLAYING STATE_EXIT STATE_NULL

All states will contain these virtual fuctions: HandleInput UpdateGame DrawGame Future Considerations: In the future, the game may benefit from extra modes such as time attack and also incorporate high scores. Possibly set all these leaderboards up with a website so players from all over can see how they stack up.