-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path101.bas
More file actions
105 lines (94 loc) · 1.64 KB
/
Copy path101.bas
File metadata and controls
105 lines (94 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
''' Program: Stars.bas
'' Author: Alberto Fornasari
'' Version: 2.1
'' Date: 22/06/2002
'' =================
'' Useful constants
'' ===========
reset=chr$(27)+"[0m"
boldOn=chr$(27)+"[1m"
boldOff=chr$(27)+"[21m"
'' General introduction and main input
'' ========================
label Start
Frame=YMAX-16
gosub InitialFrame
at 35,20
? boldOn+"Program: STARS"+boldOff
at 17,50
? "--------- Version 2.1 ----------"
at 17,60
? "AlbertoFornasari@hotmail.com"
at 17,90
? "Draw stars with N sharp points."
at 17,100
? "With N integer greater than 2."
at 17,110
? "After drawing, strike any key."
at 17,YMAX-11
sound 440,100,25
N=0
input "Enter N to start or 0 to QUIT: ",N
N=int(N)
if N=0 then goto Quit
if N<3 then N=3
'' Central circle drawing
'' ===============
Frame=YMAX-1
gosub InitialFrame
Xc=int((XMAX-1)/2)
Yc=int((YMAX-1)/2)
Ofset=11
Radius=Yc-Ofset
circle Xc,Yc,Radius color 15 filled
circle Xc,Yc,Radius color 0
''Analysis and drawing
'' ==============
if (N MOD 2)=0 then
N=N/2
Sign=-1
gosub DrawStar
endif
Sign=1
gosub DrawStar
'' Ending and waiting for restart
'' ====================
sound 880,100,25
pause
goto Start
'' Quiting
'' =====
label Quit
? reset
cls
stop
'' === Subroutines ===
'' Soubroutine InitialFrame
'' =================
Label InitialFrame
? reset
cls
rect 0,0,XMAX-1,Frame color 9 filled
rect 0,0,XMAX-1,Frame color 0
return
''Soubroutine DrawStar
'' ===============
Label DrawStar
'' Initial conditions (loop preparation)
A=PI/2/N
B=A
Q=2*Radius*cos(A)
X=Xc
Y=Yc-Sign*Radius
line X,Y,X,Y
'' Lines drawing loop
for i=1 to N
X=X+Sign*Q*sin(B)
Y=Y+Sign*Q*cos(B)
line round(X),round(Y)
B=B+PI+2*A
next i
return
'' ======
end
'