"The QCanvas class fits well for 2D games development, as it
is optimized for speed and has some very useful features, like
sprites (animated images), collision detection (essential in most
2D games), various built in shape classes and built in animation
features. To use it, you add a QCanvas to your application,
and add a QCanvasView (a QWidget) to view the canvas. Then you can
add QCanvasItems to the canvas. (The QCanvasView must be subclassed
in order to interact with the canvas items.) We are going to
demonstrate this in a small game."
"The game used in the demonstration is very simple, but
strangely amusing: It consists of a 2D box and a ball. The ball can
be picked up and tossed using the mouse, and will bounce back and
forth against the walls of the box until air resistance, friction
and gravity stops it, or you pick it up again. In order to make it
all a bit more interesting, we use the box as an analogue of the
universe, and the ball is, yup, that's correct: the Earth. (Some
people might argue that there is no air resistance in space because
there is no air, and that the force of gravity being directed
downwards doesn't make any sense in space. These are usually the
same kind of people that, when you comment on the birds happy
singing on a nice spring day, will tell you that the song actually
is an aggressive marking of territory. It's technically correct,
but where's the fun in that?)"
Some of the products that appear on this site are from companies from which QuinStreet receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. QuinStreet does not include all companies or all types of products available in the marketplace.