Top White Papers
zez.org: Creating games with QCanvasNov 11, 2000, 14:04 (1 Talkback[s])
(Other stories by Gunnstein Lye)
[ Thanks to Paul K Egell-Johnsen for this link. ]
"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?)"
0 Talkback[s] (click to add your comment)