I get a compile error...
"Expecting expression but encountered then"
Any ideas?
Const O=60,B=1024,M=768,Z=512,S=256,W=511,N#=0.2
Graphics B,M,32'
For R#=1To W Step N
A#=R*R/B'
SetColor A,A,A
DrawOval R/2,R/2,Z-R,Z-R 'change to DrawRect for inverted blobs
Next
H:TImage=CreateImage(Z,Z)
GrabImage(H,0,0)
Local C[O],D[O],E[O],F[O],K#[O]
For G=0To O-1
C[G]=Rand(0,B)
D[G]=Rand(0,M)
E[G]=Rand(0,4)-2
F[G]=Rand(0,4)-2
K[G]=C[G]
Next
Repeat
Cls
SetBlend 4
For G=0To O-1
C[G]:+E[G]
D[G]:+F[G]
If C[G]B Then E[G]=-E[G]
If D[G]M Then F[G]=-F[G]
K[G]:+N
SetColor B-K[G],Z-C[G],Z-D[G]
SetRotation K[G]
DrawImage H,C[G],D[G]
Next
Flip 1
Until KeyHit(27)
Change :
If C[G]B Then E[G]=-E[G]
If D[G]M Then F[G]=-F[G]
to
If C[G]>B Then E[G]=-E[G]
If D[G]>M Then F[G]=-F[G]
?
Perhaps...
If C[G]>B Or C[G]< 0 Then E[G]=-E[G]
If D[G]>M Or D[G]< 0 Then F[G]=-F[G]
WARNING: Screen saver alert!
Nice effect, awfully coded. :O)
Its taken from the 512byte challenge.
Ah okay that explains it but still you could at least name the arrays more meaningful. Are there any other examples from this challenge, a thread?
visit the blitzmax forum hehe.
Oops, double post...<snip>
Hey, I'm glad you like this effect, but maybe your cutting and pasting skills need some work ;-D
For those non-blitzmaxers who haven't been following the 256-byte and 512-byte coding challenges in the BlitzMax Programming forum, this code is deliberately as minimal as possible so that it is within the challenge limits. Below is the original program in a `normal` looking form.
'Set these to what you want
Const Objects:Int=60
Const ScrWidth:Int=1024
Const ScrHeight:Int=768
Const RotationSpeed:Float=0.2
'Open a screen and draw a blobby energy field with squared falloff
Graphics ScrWidth,ScrHeight,32
For Local Radius:Float=1 Until 512 Step 0.5
Local Energy:Float=(Radius*Radius)/1024.0
SetColor Energy,Energy,Energy
DrawOval Radius/2.0,Radius/2.0,512-Radius,512-Radius 'Try DrawRect
Next
'Turn it into an image/texture
Local Image:TImage=CreateImage(512,512)
GrabImage(Image,0,0)
'Set up the positions and movement directions/speeds/angles of objects
Local XPos:Float[Objects],YPos:Float[Objects]
Local XMove:Float[Objects],YMove:Float[Objects]
Local Rotation:Float[Objects]
Local Obj:Int
For Obj=0 Until Objects
XPos[Obj]=Rand(0,ScrWidth)
Ypos[Obj]=Rand(0,ScrHeight)
XMove[Obj]=(RndFloat()-0.5)*4
YMove[Obj]=(RndFloat()-0.5)*4
Rotation[Obj]=RndFloat()*360
Next
'Additive blending to combine blob fields
SetBlend LIGHTBLEND
'Do a demo
Repeat
Cls
For Obj=0 Until Objects
'Move the objects
XPos[Obj]:+XMove[Obj]
YPos[Obj]:+YMove[Obj]
'Bounce the objects off the screen edges
If XPos[Obj]<0 or XPos[Obj]>ScrWidth Then XMove[Obj]=-XMove[Obj]
If YPos[Obj]<0 or YPos[Obj]>ScrHeight then YMove[Obj]=-YMove[Obj]
'Rotate the objects around their corners
Rotation[Obj]:+RotationSpeed
'Set object color based on coords/angles
SetColor 1024-(Rotation[Obj] Mod 256),512-XPos[Obj],512-YPos[Obj]
'Draw the blobby object
SetRotation Rotation[Obj]
DrawImage Image,XPos[Obj],YPos[Obj]
Next
Flip 1
Until KeyHit(KEY_ESCAPE)
If you do use this effect to make a screensaver, a mention of my good self would be appreciated. :-D
Hey, I'm glad you like this effect, but maybe your cutting and pasting skills need some work ;-D
i think its verbatum from the showcase entry on the front page ... so maybe its your typeo ;-)
Oh no! Now the definition for the const/vars/arrays is too long which makes it unreadable... ;O)
Additive Blending, as simple as it is, still is one of the killer features to me. For many years we weren't able to use it in SW3D.
BTW....
Did anyone remember the way to make screen saver in BlitzMax?
Yeah I just noticed it is wrong in the gallery, which either suggests *I* cannot cut and paste ;-P, or that BRL messed it up. BRL can you change the quoted code to the corrected code:
If C[G]>B Or C[G]< 0 Then E[G]=-E[G]
If D[G]>M Or D[G]< 0 Then F[G]=-F[G]
Much appreciated.
Did anyone remember the way to make screen saver in BlitzMax?
Windows Screen Saver Framework Some source
If there was a Mac screensaver framework of some kind that works flawlessly including all the usual screensaver functionality like the proper embedded GUI options panels, I would probably buy it.
@yoko: When I made mine, I used my
CommandLineMod to help me out with the "/s" and "/c". You can use that if you like, also.
Thanks Ked and tonyg, works perfect, this screen saver looks so nice and my friends love it.