PurePunch Contest #5

Share your advanced PureBasic knowledge/code with the community.
Nituvious
Addict
Addict
Posts: 1029
Joined: Sat Jul 11, 2009 4:57 am
Location: United States

Re: PurePunch Contest #5

Post by Nituvious »

Do we have to use 20 lines? Or can it be less? Because I got what I needed in 10 lines.
▓▓▓▓▓▒▒▒▒▒░░░░░
Nituvious
Addict
Addict
Posts: 1029
Joined: Sat Jul 11, 2009 4:57 am
Location: United States

Re: PurePunch Contest #5

Post by Nituvious »

Ha, I'm a dummy. I thought there was a 20 line limit!
Oh well, here my my attempt. It is 13 lines of code with less than 80 characters each, and includes a single 300x400 image.
I am just a newby, so don't be to harsh! :mrgreen:

Code: Select all

;*****************************************************************************
;*
;* PurePunch Contest #5
;*
;* Name     : Thunder Storm
;* Author   : Nituvious
;* Category : Beginner, Demo
;* Date     : November 3rd, 2009
;* Purebasic Version : 4.31(x86)
;* Notes    : Creates rain and lightning effect. Includes an image of the
;*            Street Fighter character "Akuma" with glowing eyes.
;*
;*****************************************************************************
w=300:h=300:OpenWindow(0,500,200,w,h,""):InitSprite():InitMouse():InitKeyboard()
OpenWindowedScreen(WindowID(0),0,0,w,h,0,0,0):LoadSprite(1,"e.bmp",0):d=0
Global v=0:Global c=0:Procedure s(x,y,r):Line(x,y,-3,r,RGB(0,0,80+Random(50)))
Line(x,y,-4,r,RGB(0,0,80+Random(50))):EndProcedure:Procedure l():If v=1
Box(0,0,300,300,RGB(255,255,255)):Else:Box(0,0,300,300,RGB(0,0,0)):EndIf
EndProcedure:Macro o:k=Random(299):p=Random(299):EndMacro:Procedure i()
DisplayTranslucentSprite(2,260,130,c):EndProcedure:Repeat:v=Random(100):c+d
If c<20:d+1:Delay(20):ElseIf c>20:d-1:Delay(20):EndIf:ClipSprite(1,5,5,200,200)
CopySprite(1,2,0):ClipSprite(2,102,300,20,25)
DisplayTranslucentSprite(1,99,99,6):i():FlipBuffers():ExamineMouse()
ExamineKeyboard():StartDrawing(ScreenOutput()):l():s(k,p,3+Random(35)):o
s(k,p,3+Random(35)):o:s(k,p,3+Random(35)):o:StopDrawing():e=WaitWindowEvent()
Until e=#PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
Image: here.
▓▓▓▓▓▒▒▒▒▒░░░░░
Post Reply