Game Programming using Qt 5 Beginner's Guide
Pavel Strakhov Witold Wysota Lorenz Haas更新时间:2021-08-27 18:32:26
最新章节:Leave a review - let other readers know what you think封面
Title Page
Copyright and Credits
Game Programming Using Qt 5 Beginner's Guide Second Edition
Dedication
Packt Upsell
Why subscribe?
PacktPub.com
Contributors
About the authors
About the reviewers
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Conventions used
Get in touch
Reviews
Introduction to Qt
A journey through time
The cross-platform programming
Supported platforms
GUI scalability
Qt versions
Structure of Qt framework
Qt Essentials
Qt Add-ons
qmake
Modern C++ standards
Choosing the right license
An open source license
A commercial license
Summary
Installation
Installing the Qt SDK
Time for action – Installing Qt using an online installer
What just happened?
Qt Creator
Qt Creator's modes
Setting up compilers Qt versions and kits
Time for action – Loading an example project
Qt documentation
Time for action – Running the Affine Transformations project
What just happened?
Summary
Qt GUI Programming
Creating GUI in Qt
Time for action – Creating a Qt Widgets project
What just happened?
Design mode interface
Time for action – Adding widgets to the form
Layouts
Time for action – Adding a layout to the form
Signals and slots
Creating signals and slots
Connecting signals and slots
Old connect syntax
Signal and slot access specifiers
Time for action – Receiving the button-click signal from the form
What just happened?
Automatic slot connection and its drawbacks
Time for action – Changing the texts on the labels from the code
Creating a widget for the tic-tac-toe board
Choosing between designer forms and plain C++ classes
Time for action – Creating a game board widget
What just happened?
Automatic deletion of objects
Time for action – Functionality of a tic-tac-toe board
Time for action – Reacting to the game board's signals
What just happened?
Advanced form editor usage
Time for action – Designing the game configuration dialog
Accelerators and label buddies
The tab order
Time for action – Public interface of the dialog
Polishing the application
Size policies
Protecting against invalid input
Main menu and toolbars
Time for action – Creating a menu and a toolbar
What just happened?
The Qt resource system
Time for action – Adding icons to the project
Have a go hero – Extending the game
Pop quiz
Summary
Custom 2D Graphics with Graphics View
Graphics View architecture
Time for action – Creating a project with a Graphics View
What just happened?
Coordinate systems
The item's coordinate system
The scene's coordinate system
The viewport's coordinate system
Origin point of the transformation
What just happened?
Have a go hero – Applying multiple transformations
Parent–child relationship between items
Time for action – Using child items
Have a go hero – Implementing the custom rectangle as a class
Conversions between coordinate systems
Overview of functionality
Standard items
Anti-aliasing
Pens and brushes
Item selection
Keyboard focus in graphics scene
Painter paths
Time for action – Adding path items to the scene
Z-order of items
Ignoring transformations
Time for action – Adding text to a custom rectangle
Finding items by position
Showing specific areas of the scene
Saving a scene to an image file
What just happened?
Have a go hero – Rendering only specific parts of a scene
Custom items
Time for action – Creating a sine graph project
Time for action – Creating a graphics item class
What just happened?
Events
Time for action – Implementing the ability to scale the scene
What just happened?
Time for action – Taking the zoom level into account
Time for action – Reacting to an item's selection state
What just happened?
Time for action – Event handling in a custom item
Time for action – Implementing the ability to create and delete elements with mouse
Time for action – Changing the item's size
Have a go hero – Extending the item's functionality
Widgets inside Graphics View
Optimization
A binary space partition tree
Caching the item's paint function
Optimizing the view
OpenGL in the Graphics View
Pop quiz
Summary
Animations in Graphics View
The jumping elephant or how to animate the scene
The game play
Time for action - Creating an item for Benjamin
The playing field
Time for action - Making Benjamin move
What just happened?
Parallax scrolling
Time for action - Moving the background
What just happened?
Have a go hero - Adding new background layers
The Animation framework
Properties
Time for action - Adding a jump animation
Property animations
Time for action - Using animations to move items smoothly
What just happened?
Have a go hero - Letting the item handle Benjamin's jump
Time for action - Keeping multiple animations in sync
What just happened?
Chaining multiple animations
Adding gamepad support
Working with gamepads in Qt
Time for action - Handling gamepad events
Item collision detection
Time for action - Making the coins explode
What just happened?
Finishing the game
Have a go hero - Extending the game
A third way of animation
Pop quiz
Summary
Qt Core Essentials
Text handling
String encodings
QByteArray and QString
Using other encodings
Basic string operations
The string search and lookup
Dissecting strings
Converting between numbers and strings
Internationalization
Using arguments in strings
Regular expressions
Time for action – A simple quiz game
What just happened?
Extracting information out of a string
Finding all pattern occurrences
Containers
Main container types
Convenience containers
Allowed item types
Implicit sharing
Pointer invalidation
What just happened?
Unnecessary allocation
Range-based for and Qt foreach macro
What just happened?
Data storage
Files and devices
Traversing directories
Reading and writing files
Devices
Time for action – Implementing a device to encrypt data
What just happened?
Have a go hero – A GUI for the Caesar cipher
Text streams
Binary streams
Time for action – Serialization of a custom structure
What just happened?
XML streams
Time for action – Implementing an XML parser for player data
What just happened?
What just happened?
Have a go hero – An XML serializer for player data
QVariant
QSettings
Settings hierarchy
Customizing the settings location and format
JSON files
Time for action – The player data JSON serializer
Time for action – Implementing a JSON parser
What just happened?
Pop quiz
Summary
Networking
QNetworkAccessManager
Setting up a local HTTP server
Preparing a URL for testing
Time for action – Downloading a file
Have a go hero – Extending the basic file downloader
Single network manager per application
Time for action – Displaying a proper error message
Downloading files over FTP
Downloading files in parallel
The finished signal
Time for action – Writing the OOP conform code using QSignalMapper
What just happened?
The error signal
The readyRead signal
Time for action – Showing the download progress
What just happened?
Using a proxy
Connecting to Google Facebook Twitter and co.
Time for action – Using Google's Distance Matrix API
Time for action – Constructing the query
Time for action – Parsing the server's reply
Have a go hero – Choosing XML as the reply's format
Controlling the connectivity state
QNetworkConfigurationManager
QNetworkConfiguration
QNetworkSession
QNetworkInterface
Communicating between games
Time for action – Realizing a simple chat program
The server – QTcpServer
Time for action – Setting up the server
What just happened?
Time for action – Reacting on a new pending connection
What just happened?
Time for action – Forwarding a new message
Have a go hero – Using QSignalMapper
Time for action – Detecting a disconnect
What just happened?
The client
Time for action – Setting up the client
What just happened?
Time for action – Receiving text messages
Time for action – Sending text messages
Have a go hero – Extending the chat server and client
Synchronous network operations
Using UDP
Time for action – Sending a text via UDP
Have a go hero – Connecting players of the Benjamin game
Pop quiz
Summary
Custom Widgets
Raster and vector graphics
Raster painting
Painter attributes
Coordinate systems
Drawing operations
Creating a custom widget
Time for action – Custom-painted widgets
What just happened?
Time for action – Transforming the viewport
What just happened?
Time for action – Drawing an oscillogram
Time for action – Making oscillograms selectable
Have a go hero – Reacting only to the left mouse button
Touch events
Working with images
Loading
Modifying
Painting
Painting text
Static text
Optimizing widget painting
Time for action – Optimizing oscillogram drawing
What just happened?
Have a go hero – Caching the oscillogram in a pixmap
Implementing a chess game
Time for action – Developing the game architecture
What just happened?
Time for action – Implementing the game board class
What just happened?
Time for action – Understanding the ChessView class
What just happened?
Time for action – Rendering the pieces
What just happened?
Time for action – Making the chess game interactive
What just happened?
Time for action – Connecting the game algorithm
What just happened?
Have a go hero – Implementing the UI around the chess board
Have a go hero – Connecting a UCI-compliant chess engine
Pop quiz
Summary
OpenGL and Vulkan in Qt applications
Introduction to OpenGL with Qt
OpenGL windows and contexts
Accessing OpenGL functions
Using OpenGL in immediate mode
Time for action – Drawing a triangle using Qt and OpenGL
Multisampling
Time for action – Scene-based rendering
What just happened?
Time for action – Drawing a textured cube
Have a go hero – Animating a cube
Modern OpenGL with Qt
Shaders
Time for action – Shaded objects
GL buffers
Using multiple OpenGL versions
Offscreen rendering
Vulkan in Qt applications
Preparing the developing environment
Vulkan instance window and renderer
Time for action – Creating the minimal Vulkan project
What just happened?
Using Vulkan types and functions
Time for action – Drawing with a dynamic background color
Logs and validation
Combining OpenGL or Vulkan with Qt Widgets
Pop quiz
Summary
Scripting
Why script?
Evaluating JavaScript expressions
Time for action – Creating a JavaScript editor
What just happened?
Global object state
Exposing C++ objects and functions to JavaScript code
Accessing C++ object's properties and methods
Data type conversions between C++ and JavaScript
Accessing signals and slots in scripts
Time for action – Using a button from JavaScript
Restricting access to C++ classes from JavaScript
Creating C++ objects from JavaScript
Exposing C++ functions to JavaScript
Creating a JavaScript scripting game
Time for action – Implementing the game engine
Time for action – Exposing the game state to the JS engine
What just happened?
Time for action – Loading scripts provided by users
Time for action – Executing the strategy scripts
Time for action – Writing a strategy script
Have a go hero – Extending the game
Python scripting
Time for action – Writing a Qt wrapper for embedding Python
What just happened?
Time for action – Converting data between C++ and Python
What just happened?
Have a go hero – Implementing the remaining conversions
Time for action – Calling functions and returning values
What just happened?
Have a go hero – Wrapping Qt objects into Python objects
Pop quiz
Summary
Introduction to Qt Quick
Declarative UI programming
Time for action – Creating the first project
Time for action – Editing QML
What just happened?
Property groups
Anchors
Time for action – Positioning items relative to each other
QML types components and documents
How does it work?
Time for action – Property binding
A limitation of automatic property updates
Overview of QML types provided by Qt
Qt Quick Designer
Time for action – Adding a form to the project
Form editor files
Form editor interface
Time for action – Adding an import
Time for action – Adding items to the form
Time for action – Editing anchors
Time for action – Applying layouts to the items
Time for action – Assigning an expression to the property
Time for action – Exposing items as properties
What just happened?
Time for action – Creating an event handler
Qt Quick and C++
Accessing C++ objects from QML
Accessing QML objects from C++
Bringing life into static user interfaces
Fluid user interfaces
States and transitions
Time for action – Adding states to the form
Time for action – Adding smooth transition effect
What just happened?
Have a go hero – Adding an animation of the item's position
Pop quiz
Summary
Customization in Qt Quick
Creating a custom QML component
Time for action – Creating a button component
What just happened?
Time for action – Adding button content
What just happened?
Time for action – Sizing the button properly
What just happened?
Time for action – Making the button a reusable component
What just happened?
Importing components
QML and virtual resource paths
Event handlers
Time for action – Making the button clickable
What just happened?
Time for action – Visualizing button states
What just happened?
Time for action – Notifying the environment about button states
What just happened?
Touch input
Time for action – Dragging an item around
What just happened?
Time for action – Rotating and scaling a picture by pinching
What just happened?
Have a go hero – Rotating and scaling with a mouse
Keyboard input
Have a go hero – Practicing key-event propagation
Text input fields
Gamepad input
What just happened?
Sensor input
Detecting device location
Creating advanced QML components
Time for action – A simple analog clock application
What just happened?
Time for action – Adding needles to the clock
What just happened?
Time for action – Making the clock functional
What just happened?
Dynamic and lazy loading of QML objects
Creating objects on request
Delaying item creation
Imperative painting on Canvas using JavaScript
Time for action – Preparing Canvas for heartbeat visualization
What just happened?
Time for action - drawing a heartbeat
What just happened?
Time for action – Hiding properties
Time for action – Making the diagram more colorful
What just happened?
Using C++ classes as QML components
Time for action – Self-updating car dashboard
What just happened?
Time for action – Grouping engine properties
What just happened?
Time for action – Registering C++ class as QML type
Time for action – Making CarInfo instantiable from QML
What just happened?
Pop quiz
Summary
Animations in Qt Quick Games
Animation framework in Qt Quick
Generic animations
Time for action – Scene for an action game
What just happened?
Time for action – Animating the sun's horizontal movement
What just happened?
Composing animations
Time for action – Making the sun rise and set
What just happened?
Non-linear animations
Time for action – Improving the path of the sun
What just happened?
Property value sources
Time for action – Adjusting the sun's color
What just happened?
Time for action – Furnishing sun animation
What just happened?
Have a go hero – Animating the sun's rays
Behaviors
Time for action – Animating the car dashboard
What just happened?
States
Transitions
More animation types
Quick game programming
Game loops
Input processing
Time for action – Character navigation
What just happened?
Time for action – Another approach to character navigation
What just happened?
Have a go hero – Polishing the animation
Time for action – Generating coins
What just happened?
Sprite animation
Time for action – Implementing simple character animation
What just happened?
Time for action – Animating characters using sprites
What just happened?
Time for action – Adding jumping with sprite transitions
What just happened?
Have a go hero – Making Benjamin wiggle his tail in anticipation
Time for action – Revisiting parallax scrolling
What just happened?
Have a go hero – Vertical parallax sliding
Collision detection
Time for action – Collecting coins
What just happened?
Have a go hero – Extending the game
Pop quiz
Summary
Advanced Visual Effects in Qt Quick
Making the game more attractive
Auto-scaling user interfaces
Graphical effects
Have a go hero – The blur parallax scrolled game view
Particle systems
Tuning the emitter
Rendering particles
Making particles move
Time for action – Vanishing coins spawning particles
What just happened?
Custom OpenGL-based Qt Quick items
The scene graph
Time for action – Creating a regular polygon item
What just happened?
Have a go hero – Creating a supporting border for RegularPolygon
Using QPainter interface in Qt Quick
Time for action – Creating an item for drawing outlined text
What just happened?
Pop quiz
Summary
3D Graphics with Qt
Qt 3D overview
Entities and components
Qt 3D modules
Stable modules
Experimental modules
Using modules
Rendering 3D objects
Mesh material and transform
Lighting
Time for action – creating a 3D scene
What just happened?
Time for action – constructing the Tower of Hanoi scene
Time for action – repeating 3D objects
What just happened?
Time for action – creating disks
Handling user input
Devices
Keyboard and mouse buttons
Input chords
Analog (axis) input
Object picker
Frame-based input handling
Time for action – receiving mouse input
What just happened?
Performing animations
Time for action – animating disk movements
What just happened?
Time for action – implementing game logic
Have a go hero – improving the game
Integration with 3D modeling software
Time for action – using OBJ files for the disks
Loading a 3D scene
Working with Qt 3D using C++
Time for action – creating a 3D scene using C++
Integration with Qt Widgets and Qt Quick
Embedding Qt Quick UI into a 3D scene
Embedding a Qt 3D scene into a Qt Quick form
Pop quiz
Summary
Pop quiz answers
Other Books You May Enjoy
Leave a review - let other readers know what you think
更新时间:2021-08-27 18:32:26