-
Notifications
You must be signed in to change notification settings - Fork 0
/
Weave.bb
116 lines (103 loc) · 2.58 KB
/
Weave.bb
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
106
107
108
109
110
111
112
113
114
115
116
;strange demo
;NO SHEEP THO' GEORGE ;)
;Copyright ©2000 EdzUp
;written by Ed Upton
If Trim$(CommandLine$()) = "/c" Or Trim$(CommandLine$()) = "" Then
.prompt
lines = Input("Number of Lines? (50-5000) ")
If lines < 1 Then lines = 1
If lines < 50 Then If Proceed("Are you sure? Less than 50 can be boring.") < 1 Then Goto prompt
If lines > 5000 Then If Proceed("Are you sure? More than 5000 can make your computer slow!",True) < 1 Then Goto prompt
If FileType(GetEnv$("APPDATA") + "\Jason's Screensavers") = 0 Then CreateDir(GetEnv$("APPDATA") + "\Jason's Screensavers")
dir$ = GetEnv$("APPDATA") + "\Jason's Screensavers\"
file = WriteFile(dir$ + "Weave.txt")
WriteShort(file,lines)
CloseFile(file)
End
End If
If Trim$(CommandLine$()) <> "/S" Then End
SeedRnd(MilliSecs())
;adjust this for more lines
Global lns=BetweenTheLines() - 1
Global w = GadgetWidth(Desktop())
Global h = GadgetHeight(Desktop())
window = CreateWindow("Screen Saver",0,0,w,h,0,0)
canvas = CreateCanvas(0,0,w,h,window)
SetBuffer CanvasBuffer(canvas)
HidePointer canvas
Global r
Global g
Global b
Global tim
;X,Y screen coordinates
;F facing direction
;T timer till it needs to change direction
Type bit
Field x,y,f,t
End Type
tim=Rnd(500)
r=Rnd(255)
g=Rnd(255)
b=Rnd(255)
setup()
mouse_x = MouseX()
mouse_y = MouseY()
While Not KeyDown(1)
e = WaitEvent(1)
If e = $101 Or e = $201 Or e = $204 Or mouse_x <> MouseX() Or mouse_y <> MouseY() Then End
update()
tim=tim-1
If tim<0
tim=500
r=Rnd(255)
g=Rnd(255)
b=Rnd(255)
EndIf
FlipCanvas canvas
Wend
End
;setup lines
Function setup()
For n=0 To lns
bitz.bit=New bit
bitz\x=Rnd(w)
bitz\y=Rnd(h)
bitz\f=Rnd(3)
bitz\t=Rnd(20)
Next
End Function
;update function
Function update()
For bitz.bit=Each bit
Color r,g,b
Plot bitz\x,bitz\y
bitz\t=bitz\t-1
If bitz\t<=0
bitz\f=Rnd(3)
bitz\t=Rnd(20)
EndIf
If bitz\f=0 Then bitz\y=bitz\y-1
If bitz\f=1 Then bitz\x=bitz\x+1
If bitz\f=2 Then bitz\y=bitz\y+1
If bitz\f=3 Then bitz\x=bitz\x-1
If bitz\x<0 Then bitz\x=w-1
If bitz\x>w-1 Then bitz\x=0
If bitz\y<0 Then bitz\y=h-1
If bitz\y>h-1 Then bitz\y=0
Color 255,255,255
Plot bitz\x,bitz\y
Next
End Function
Function BetweenTheLines()
If FileType(GetEnv$("APPDATA") + "\Jason's Screensavers") = 0 Then CreateDir(GetEnv$("APPDATA") + "\Jason's Screensavers")
dir$ = GetEnv$("APPDATA") + "\Jason's Screensavers\"
If FileType(dir$ + "Weave.txt") = 0 Then
file = WriteFile(dir$ + "Weave.txt")
WriteShort(file,500)
CloseFile(file)
End If
file = ReadFile(dir$ + "Weave.txt")
retval = ReadShort(file)
CloseFile(file)
Return retval
End Function