readme.md 1.82 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
# Qt 3D Studio Tennis Game Demo

This demo application is created with Qt 3D Studio.
Behaviors and actions are used to implement a tennis game. The player is pitted against a computer opponent
with a mission of getting the ball behind the opponent to score. Whoever gets 3 points first wins.
The paddle of the player is controlled with a mouse by clicking on the screen and moving around.

Two custom behaviors are used: Movement.qml and Score.qml.
Movement.qml is the most complex script used. It handles the movement of the player, AI and the ball.
It includes collision detection and handles score detection and ball serving also.

Properties that can be set from the studio for Movement.qml are:
- Obstacle 1: Object that can be collided with
- Obstacle 2: Another object that can be collided with
- Has Physics: Determines if the object is handled as a ball
- Has AI: Determines if the object is handled as the AI paddle

The important handlers for Movement.qml are "onMouseDown" and "onMouseUp".
The Scene object in the presentation includes actions that listen for mouse input to the screen.
If such events occur the functions "onMouseDown" and "onMouseUp" from Movement.qml are called.
The script can then use the inputs to move the player around.

Movement.qml can also output two events: "onPlayerScore" and "onComputerScore".
The Movement script for the ball includes two actions in the studio that listen for these events.
When one side scores the functions that increment scores in the Score script, owned by the score text object, are called.

Score.qml itself also outputs two events: "onPlayerWins" and "onComputerWins".
The Score scripts increments the scores and, if one score is equal to 3, fires the win event for the owner of that score.
The actions that listen for the win events then tell the Scene object to jump to a victory or a defeat slide.