graphics and animation

 BBS: Inland Empire Archive
Date: 06-06-92 (06:06)             Number: 199
From: PHIL HODGES                  Refer#: NONE
  To: IAN REMMLER                   Recvd: NO  
Subj: graphics and animation         Conf: (2) Quik_Bas
IR>I am fairly new to programming in QB. Can anyone post any
IR>sample code having to do with graphics or animation so
IR>that I can learn how to do this. I find it easier to play
IR>with code and figure them out than to read the manual. Any
IR>help would be appreciated. Thanks in advance...

IR>        -=Ian=-

   Hello, Ian.  I love QB for being such an easy language to program
graphics in, and so do it all the time.  But without knowing what kind
of graphics you're talking do you have EGA (can you use
SCREEN 9), or VGA?  I only use SCREEN 9, which is the highest possible
screen for EGA.  Here's a commented example of how I might go about
doing something: (note: this will only work on SCREEN 9, and only with
EGA or VGA adapter with 256K)

___----------------------8< Cut here>8-------------------------------
DIM Sprite%(1700) 'dimension room for the sprite

Ap% = 1: Vp% = 0      'Set active and view pages
SCREEN 9, , Ap%, Vp%  'Draw on page 1 while viewing 0
CLS Ap%               'Clear active page
Fill$ = CHR$(203) + CHR$(140) + CHR$(1) 'String for PAINT fill

CIRCLE (300, 140), 35, 4   ' draw simple
PAINT (300, 140), Fill$, 4 ' graphics (for example's sake)

PALETTE 4, 36  'change red to orange (just for this example)

PCOPY Ap%, Vp%                      'copy the circle to the view page
GET (255, 110)-(345, 170), Sprite%  'Get sprite off active page
CLS 1                               'Clear active page


 Px% = INT((500 - 20 + 1) * RND + 20)  'randomnly select x-axis

 Py% = INT((280 - 10 + 1) * RND + 20)  'randomnly select y-axis

 PUT (Px%, Py%), Sprite%   'put sprite in random location
 PCOPY Ap%, Vp%            'then copy it to view page
 CLS 0                     'clear view page


--------------------------8< and here >8-------------------------------

This results in fairly smooth animation (though my example is pretty
bad...) with no flickering.  Hope I could be of help.

 * SLMR 2.1a * Life's for my own to live my own way...

--- Maximus 2.00
 * Origin: The Gamorian Vortex Project (1:105/601)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET