Table hockey Game Description
Description of classes and objects used in table hockey games
Ball class:
Class Ball:public Qgraphicsitem
Member Properties:
Speed: Velocity
Angle: Direction of movement
Ratio: Graph Scale
Radius: radius of the Sphere
Action Properties:
Advance: Advance according to unit sampling time;
Xvel =speed*1.0/frecuency *qcos (angle);
Yvel = speed*1.0/frecuency *qsin (angle);
Collisioncalcualte (Collisiontype direction)// calculate the speed and direction after the collision
SetPos (): Set Location
void Setspeed (Qreal);
void Setangle (Qreal);
Graphwidget class
Member Properties:
Gamewidget * game; Create a pointer to a parent object for easy delivery of information
qpointf ballposition; the position of the ball
qpointf handleposition; position of the operator handle
Timerid; timer ID, timer used to generate a basic update time period
Ball *ballmove; Ice hockey
Frame *frame; Border
Frame * FRAMEUP;
Frame * FRAMELEFT;
Frame * FRAMEDOWN;
Frame * frameright;
Userhandle * USERHANDLE; Handle
Qgraphicsscene *scene; scene object that will Item join them
Gamescoretext: Scoring Text
Action Properties:
TimerEvent: Timer response function:
gets the current ball,Handle Position Information , passed to the upper gamewidget
Collision Detection: Get the collision information passed to Ball for update speed
Get collision information and decide game status
Movement of Moving Objects Update ballmove->advance ();
Gamewidget class
member properties:
Qlabel *labelball
Qlabel *labelhandle
Qlineedit *editball: Displays the coordinates of the current ball (in pixels)
Qlineedit *edithandle: displays the coordinates of the current Handle (units: pixels)
Graphwidget *showwidget: Game Animation Interface Object
Action Properties:
SetPosition (): Gets the Position property of The Next level member Showwidget , displayed on the interface
Action:
Wait for start:
Time out:
Events triggered after a goal:
The position of the ball is restored;
Update scores;
Reset:
The position of the ball is restored;
Fractional reset;
Programming Tips and Error Summary:
BASIC programming syntax to be familiar with, for example , if statements, case statements, the order of the statements implies a certain priority,if...if and if ... else if is different, add return,continue, break in the code snippet Such statements can have different effects.
fixed parameters that can be changed, such as cycle frequency, radians PI, etc. can be defined by the macro implementation, easy to change.
A series of States can be implemented with enum enum types, with a clear literal meaning
make full use of Qt signal and groove mechanism, the completion of data sharing and transmission of information, its own signals and slots to be able and another class of signal and groove connection. One-way information transfer only needs to be realized with simple signal and slot connection.
Do not know the class and function to actively search the Internet. Constantly trying to see the help document, many of the features of the class properties are similar, even can be guessed out, the logic is very clear. function functions do not have to be remembered, but should be familiar and master routines. Books and official routines.
Different functions are implemented in different classes, and specific functions are implemented in the corresponding classes.
In the premise of a certain basis, you can pre-design the corresponding class, write down the desired properties and operations, different classes to reduce coupling, exclusive and shared data separation, signal transmission direction to be clear.
Table Hockey Game Summary description