[Gambas-user] smooth animation using double buffering

Rob sourceforge-raindog2 at ...94...
Thu Jun 17 18:12:56 CEST 2004


I've had a theory for a while that Qt should be fast enough at 
redrawing to let you do double buffered animation, and I was 
right.  Here's the beginnings of a simple space shooter 
(inspired by the old Videopac/Odyssey2 game Freedom Fighters) 
which I mean to use as an example of various gambas game-related 
techniques.  Right now it covers these, albeit not very well 
commented:

- timer-based game "kernel"
- smooth movement of a "sprite" around the screen using double 
buffering
- use of regular and static classes with no exposed methods as 
user defined data types
- scrolling of a background larger than the screen
- fractional positioning, acceleration, momentum
- video game style key handling (some are held down, some must be 
pressed and released repeatedly)

There's no enemies or sound effects yet, all you can do is fly 
through space (arrow keys) and shoot (space) and look at the fps 
counter, but I wanted to get it out there to give people some 
ideas.  There's really no reason you couldn't do a whole UI like 
this if you could be sure it were running on a reasonably fast 
box.  I assume some of these techniques will still apply once 
the graphic part of SDL gets into the gb.sdl component, and 
performance ought to be better then too.

Of course, doing this sort of thing in an interpreted language 
has its price, and in this case the price is that I only get 30 
frames a second when my laptop's on battery (running around 
400-500MHz.) :)

Rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DoubleBuf-0.0.6.tar.gz
Type: application/x-tgz
Size: 81126 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20040617/4f73f88d/attachment.bin>


More information about the User mailing list