The Vintage Computer Forums  

Go Back   The Vintage Computer Forums > Technical Support > Vintage Computer Programming

Reply
 
Thread Tools Display Modes
  #1  
Old March 16th, 2004, 04:37 PM
CP/M User's Avatar
CP/M User CP/M User is offline
Senior Member
 
Join Date: May 2003
Location: Back of Burke (Guday!), Australia
Posts: 2,601
Default Drawing a Solid Circle in Degrees (GWBASIC program)

Code:
1 ' Draw Circle in Degrees (GWBASIC)
2 ' Public Domain
10 CLS:KEY OFF:SCREEN 2:FOR A=1 TO 360
20 GOSUB 1000
30 XPOS = 160*COS(COSDEG) : YPOS = 80*SIN(SINDEG)
40 LINE (320,100)-(320+XPOS,100+YPOS)
50 NEXT A:WHILE INKEY$<>" ":WEND:SCREEN 0:KEY 
   ON:END
1000 PI=3.141592:COSDEG=A*PI/180 : SINDEG=A*PI/180 : 
     RETURN

---- Notes ----

Okay, so we're drawing a circle in 640x200 screen mode &
this was about as round as I could get it in this resolution
(if it was 640x400 I might of been able to do more with it
in terms of how big & round I could have got it, but this
will do! ;-)

In this program, I've started up a loop & created a subroutine
(line 1000) which calculates the degrees of the Cosine & 
Sine, returns & calculates the SIN & COS of that (which 
obviously gives it it a result in Degrees - even though it's 
still in radians - thanks to the conversion formula, the result
comes out very well! :-)

I've made this program a little bit friendlier (to that of the other 
two I posted a little while ago) - in that at the end of the 
drawning cycle, the program pauses - this is when you can 
press space & it will take the user back to text mode 80x25
(well I hope no-one protests about the 80x25 screen mode,
some of you might be into the 80x50, but if you're using 
GWBASIC which supports 80x50 (mine doesn't - it's so ol'
that it doesn't do EGA! ;-) feel free to change the SCREEN 0
at the end to whatever gets you into 80x50 (or 80x43).
Cheers,
CP/M User.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 12:42 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2002-2010 Vintage-Computer.com. All rights reserved.