Problem with QB 4.5 program
Author Message
Problem with QB 4.5 program

I have a question with a QB game I am making.  In the subroutine
Compass, I am passing a value in degrees which I have made sure is
between 0 and 359.  The arrow keys cycle up and down through degree
values.  In Compass, I want some sort of indicator to move around the
compass (drawn in the top right-hand corner) indicating degree
position.  0 degrees must be straight up.  As you can see, I cannot find
a way to do this.  I have tried using CIRCLE with arcs to no avail.
Thanks in advance for any help.

----- Program Start -----

' ?
' o Laser Battle II 1.0 o
' o     Build 0001      o
' ???????????????????????
' o  By Chase Covello   o
' o Copyright (C) 1997  o
' o by CHASOFt Software o
' ?

DECLARE SUB DrawCpit ()
DECLARE SUB Compass (degrees%)

DEFINT A-Z
CONST version = "1.0", build = "0001"
CONST PI# = 3.141592653589793#

SCREEN 13
CLS

DrawCpit

DO
WAIT &H3DA, 8, 8
WAIT &H3DA, 8

a\$ = INKEY\$

IF a\$ = CHR\$(0) + CHR\$(77) THEN x = x + 1
IF a\$ = CHR\$(0) + CHR\$(80) THEN y = y + 1
IF a\$ = CHR\$(0) + CHR\$(75) THEN x = x - 1
IF a\$ = CHR\$(0) + CHR\$(72) THEN y = y - 1

IF x > 359 THEN x = 0
IF x < 0 THEN x = 359

Compass (x)
LOOP WHILE a\$ <> CHR\$(27)

COLOR 12
LOCATE 12, 15
PRINT "GAME OVER"

SUB Compass (degrees)
CIRCLE (285, 25), 15, 12, (degrees - 90) / 57.29578, (degrees - 90) /
57.29578

LOCATE 1, 1
IF degrees < 10 THEN
PRINT "  ";
ELSEIF 10 < degrees < 100 THEN
PRINT " ";
END IF
PRINT degrees
END SUB

DEFSNG A-Z
SUB DrawCpit
FOR c = 31 TO 20 STEP -1
i = c - 31
COLOR c
LINE (0, i + 60)-(40, i + 60)
LINE (40, i + 60)-(84, i + 16)
LINE (84, i + 16)-(216, i + 16)
LINE (216, i + 16)-(260, i + 60)
LINE (260, i + 60)-(319, i + 60)
PAINT (0, 0), c, c
NEXT c

c = 19
FOR i = 0 TO -11 STEP -1
c = c + 1
COLOR c
LINE (0, i + 140)-(40, i + 140)
LINE (40, i + 140)-(84, i + 184)
LINE (84, i + 184)-(216, i + 184)
LINE (216, i + 184)-(260, i + 140)
LINE (260, i + 140)-(319, i + 140)
NEXT i
PAINT (0, 199), 19, 20

CIRCLE (285, 25), 25, 18, PI * 1.25, PI / 3
CIRCLE (285, 25), 24, 18, PI * 1.25, PI / 3
CIRCLE (285, 25), 25, 24, PI / 3, PI * 1.25
CIRCLE (285, 25), 24, 24, PI / 3, PI * 1.25

CIRCLE (285, 25), 20, 0
PAINT (285, 25), 0, 0

CIRCLE (285, 25), 21, 24, PI * 1.25, PI / 3
CIRCLE (285, 25), 21, 18, PI / 3, PI * 1.25

END SUB

----- Program End -----

--

REALITY.SYS corrupted.  Reboot Universe? [Y/N/C]

Chase Covello

http://www.*-*-*.com/

Sat, 13 May 2000 03:00:00 GMT
Problem with QB 4.5 program

Quote:

>I have a question with a QB game I am making.  In the subroutine
>Compass, I am passing a value in degrees which I have made sure is
>between 0 and 359.  The arrow keys cycle up and down through degree
>values.  In Compass, I want some sort of indicator to move around the
>compass (drawn in the top right-hand corner) indicating degree
>position.  0 degrees must be straight up.  As you can see, I cannot find
>a way to do this.  I have tried using CIRCLE with arcs to no avail.
>Thanks in advance for any help.

Here's a little routine I use to compute the hands on a clock.
X% and Y% are the center of your circle
Points%   for you would be 360
Pnt%      for you would be the degree
Col% and Row% are the returning values of the end of a line
to be drawn from X%,Y% to Col%,Row%

SUB ClockHand( X%, Y%, Radius%, Points%, Pnt%, Col%, Row%)
SHARED Pi#
LOCAL A!, D!

D!   = ( 2 * Pi# / Points% )
A!   = ( Pnt% * D! - 1.570796 )
Col% = ( COS(A!) * Radius% + X% )
Row% = ( SIN(A!) * Radius% + Y% )

END SUB

____    _    ____      ____  _____
|  _ \  / \  / ___) __ | ___)(_   _)
| |_)  / _ \ \____\/  \|  _)   | |
|____//_/ \_\(____/\__/|_|     |_|

www.basicguru.com/schullian

Mon, 15 May 2000 03:00:00 GMT

 Page 1 of 1 [ 2 post ]

Relevant Pages