| |
This workshop will attempt to get you up to speed on the basics
of the BASIC Graphic programming in the fastest and most efficient
way possible. The free version of Microsoft
QuickBASIC v1.1 will be our development tool. If you have
a Mac you will have to use the DOS emulator.
If you would like to use this program at home, create a folder
on the desktop, CLICK
HERE to download the basiczip.exe
file, select your folder. Open the file when the download is complete
and it will expand into 2 separate files (QBASIC.EXE & QBASIC.HLP).
You can delete basiczip.exe
if you like. To start QuickBasic just click on the QBASIC.EXE
file and click OK. After you have started the QuickBasic program
you should familiarize yourself with the menus so that you can
SAVE, LOAD, RUN and get HELP. Use the mouse to click on FILE to
access SAVE & LOAD features (or use the keyboard <Alt-F>).
When you SAVE use a file name that is 8 characters or less long
and choose the TEXT format so that you have the option later to
use other editors (e.g. NOTEPAD, WORD, etc). Once you have typed
in a program you can click on RUN - START or <shift-F5>
to check it out. Let's get started!
____________________________________________________
LIST OF BASIC COMMANDS :________________________
SCREEN 9
Must use this command at start of program to set program into
higher resolution graphics/text mode
640 x 350 pixels for graphics. Text mode 80 columns x 25 rows
DRAW "special characters (see below)"
B Optional prefix - move, no line
Un, Dn, Ln, Rn Up, Down, Left, Right n pixels
En, Fn, Gn, Hn Diagonals n pixels
Mx,y Move to screen point x,y (if x has a + or - in
front, move is relative)
Cn Change drawing (foreground) color
Pp,b Fill enclosed shape that has border color b with
color p
TAn Rotate (0 >= n <= 360) degrees
LINE (x1,y1)-(x2,y2) , c [,B or BF]
Graphic statement to draw line from point (x1,y1) to (x2,y2) with
color c
B or BF can be omitted. This is a special feature to draw boxes
with opposite
corners (x1,y1) and (x2,y2). B is empty box BF is filled box
CIRCLE (x,y),r,c,a1,a2,ar
Graphic statement to draw circle (or oval) centered at (x,y) with
radius r and color c. If you want to draw an arc you can start
and stop the circle draw
at a1 and a2 (0 to 6.28), otherwise omit the values. The variable
ar can be a number
from .1 to 10 and causes the circle to be flattened (1 is a perfect
circle).
COLOR X
Whatever is printed on the screen following a COLOR command will
be that color. X =
0 = black 1 = blue 2 = green 3 = cyan 4 = red 5 = magenta
6 = brown 7 = white 8 = grey 9 = light blue 10 = light green 11
= light cyan
12 = light red 13 = light magenta 14 = yellow 15 = bright white
PSET ( x , y ) , c
Graphic statement to turn on pixel x , y with color c (x = 0 to
639, y = 0 to 349 in SCREEN 9)
( 0 , 0 ) is in the upper left and ( 639 , 349 ) is in the lower
right screen corner
SLEEP
Pauses the computer until a key is pressed
_______________________________________________________
Sample Graphic Program __________________________________
Type the following program in the QBasic Editor EXACTLY and save
the file (using FILE - SAVE AS), naming it with your
initials + WS3.BAS (e.g. SAJWS3.BAS). Hereafter you can
just select FILE - SAVE. To RUN press <Shift + F5>. If your
program locks up you may have to <Ctrl + Break> or <Ctrl
+ C> to get back to the editor mode. As you type, the editor
will catch some of your mistakes as you make them and attempt
to warn you.
SCREEN 9
CLS
X = 320 : Y = 175 'Position of screen center
LINE (260 , 100) - (370,225) , 9 , B
CIRCLE ( 315 , 165 ) , 70 , 3
PSET ( X , Y ) , 0 'Positions graphics pen at screen center
DRAW "C6 R10 D10 L10 D20 L10 U20 L10 U10 R10 C8 H10 U30 E15
F15 D30 G10"
SLEEP
END
_______________________________________________________________
The CHALLENGE !______________________________________________
Create a graphical tutorial quizzer using the DRAW, LINE &
CIRCLE commands on another science topic (atoms. molecules?).
FILE - SAVE and show (or email) the instructor
your completed program for grading.
|
|