| |
MISSION:
Using commands and experience from your
previous Quick Basic workshops you will input, test and then
improve the following missile launch program (or create your
own unique graphical projectile program from scratch for additional
bonus).
_____________________________________________________________
NEW BASIC COMMAND and REVIEW LINKS:__________________
( If you hear no sound then the PC speaker
might not be hooked up inside )
PLAY "special
characters (see below)"
A-G Plays A, B, ..., G in current
octave (+ = sharp, - = flat)
Nn Plays note n (n = 0-84, 0 is a rest)
MB Plays music in background while program continues
Ln Sets length of a note (L1 is whole, L2 is half, n=1-64)
e.g. PLAY "MBL16ABCDEFG"
Workshop 2: Quick Basic
- Quizzer
Workshop 3: Quick Basic - Graphics
QBasic 12-Step Tutorial [Word]
[RTF]
_______________________________________________
MISSILE LAUNCH Program_Example ______________
SCREEN 9
CLS
RANDOMIZE TIMER
E = 320 + INT(RND * 300) 'Random Enemy position
LINE (E - 10, 338)-(E + 10, 348), 4, BF
LINE (0, 349)-(639, 349), 10
HERE:
LINE (0, 0)-(639, 40), 0, BF
LOCATE 1, 1
INPUT "Cannon angle (1-89)"; A
INPUT "Launch velocity (0-35)"; V
VX = V * COS(A * .0174533) 'Trig math functions
VY = V * SIN(A * .0174533)
FOR T = 0 TO 40 STEP .05
X = INT(VX * T)
Y = INT(VY * T - T ^ 2)
PSET (X, 349 - Y), 14
IF Y <= 0 AND X > 10 THEN GOTO BOOM
GOSUB DELAY
NEXT T
GOTO HERE
BOOM:
FOR B = 2 TO 20 STEP 2
CIRCLE (X, 348), B, 4: SOUND 37 + INT(RND * 100), 1: CIRCLE (X,
348), B, 0
NEXT B
IF X + 18 > E AND X - 18 < E THEN GOTO WIN
GOTO HERE
WIN:
LOCATE 10, 10: PRINT "It's a direct HIT!!!";
PLAY "L16N20N20N20L1N20"
SLEEP
RUN
DELAY:
D = D + 1: IF D = 1 OR D = 2 THEN RETURN
IF D = 3 THEN PLAY "MSL64N5": D = 0
RETURN
Conclusion:
FILE - SAVE and show (or email) the instructor
your completed program for grading.
Everyone must do their own UNIQUE program improvement.
|
|