zez.org: Creating games with QCanvas | Linux Today

zez.org: Creating games with QCanvas

Written By
Web Webster
Web Webster
Nov 11, 2000

[ 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?)”

Complete
Story

Web Webster

Web Webster

Web Webster has more than 20 years of writing and editorial experience in the tech sector. He’s written and edited news, demand generation, user-focused, and thought leadership content for business software solutions, consumer tech, and Linux Today, he edits and writes for a portfolio of tech industry news and analysis websites including webopedia.com, and DatabaseJournal.com.

Linux Today Logo

LinuxToday is a trusted, contributor-driven news resource supporting all types of Linux users. Our thriving international community engages with us through social media and frequent content contributions aimed at solving problems ranging from personal computing to enterprise-level IT operations. LinuxToday serves as a home for a community that struggles to find comparable information elsewhere on the web.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.