Download presentation
Presentation is loading. Please wait.
Published byMarlene Bates Modified over 9 years ago
1
Semester Project: Air Hockey
2
Areas of Work Scene Graph and Texture Mapping Physics and Collision Detection Opponent AI Interface Design
3
Scene Graph: Overall Structure
4
Texture Mapping ● Used QT functions to bind texture from file ● Reference the texture index, using glBindTexture, whenever the appropriate faces are drawn
5
Physics implementation ● Used standard mouse movement detection when left button is held, move player by same amount mouse moves ● X and Y velocity vectors for all objects ● Velocity vectors for human player equal to movement during last time step ● Velocity vectors for computer player are adjusted based on puck position and movement
6
Collision Detection ● Check the Euclidean distance between players and puck to detect player collisions ● Check the position of the puck in order to detect wall collisions ● No position interpolation between time steps, so it is possible to move so quickly as to pass completely through and object
7
New Velocity Vectors After Collision ● Wall Collisions – Simply negate the X or Y velocity vector, depending on whether we hit a horizontal or vertical wall ● Player Collisions – First, find the impact angle by calculating θ = arctan( ) – Then find the new direction by taking the sin and cos of θ – Then find the new magnitude by averaging the speeds of the puck and the impacted player
8
Opponent AI ● Consists of a set of simple conditional statements. ● These check the current position of the puck, and the puck's current velocity vectors, and adjust the velocity vectors of the opponent player accordingly
9
Interface Design
10
QMainWindow
11
Interface Design Use of Signals and Slots: ● Used the clicked() signal on Push buttons to trigger the respective slots i.e., Start, Pause, and Quit. ● Created Signals pcScoreChanged(int) and playerScoreChanged(int) to update the player and computer scores. These signals were handled by the display(int) slot.
12
Interface Design ● Qt classes Used: ● QMainWindow ● QWidget ● QGLWidget ● QScrollArea ● QLCDNumber ● QLabel ● QPushButton ● QGridLayout ● Credit: The Qt 4 examples and demos were a good source of information on how we could use the various Qt classes to develop an effective GUI.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.