Page 1 of 8

PurePunch Contest July-August 2014

Posted: Mon Jun 30, 2014 8:50 am
by djes
-----------------

Contest is over : Link to Contest Results

-----------------

~ June, 30th of 2014 ~

******** July-August 2014 PurePunch Contest ********
Link to the french forum topic. Note : if you wanna share this information in other languages (help needed for translation), or forums, contact me.

Theme
  • Only 50 !
    Show your skills with only 50 lines of PureBasic code. It could be an utility, a game, a 3D graphical demonstration, whatever you're able to do, just push the limits, it's up to you to make it possible !
    May the best win !
Prizes & Sponsors The rules
  • 1° The program will be created using Purebasic 5.22 (minimum), API allowed, demo version allowed, no userlib.
    2° The full program source will only have a maximum of 50 text lines of 80 characters max per line. It's possible to have several text files (for example, a PB source and a textfile data, Ogre shader, preferences file, xml document...), but all text lines added should not excess the limit of 50 text lines of 80 characters per line.
    3° To be unique, either a complete creation, or bringing something new to an existing code.
    Must not to be harmful
    5° Possibility to add a graphic file (only one image, or sprite, or texture...), maximum size 512 pixels width by 512 pixels height, 32 bits. Post it on the forum or on another site which must be reachable during the contest length, or included in a full project archive posted in the forum.
    6° Possibility to add a sound file (and only one) maximum size 1Mb. Post it on another site which must be reachable during the contest length, or included in a full project archive posted in the forum.
    7° It will be possible to add a line (not accounted), at the beginning of the source, to alert the user of a program specificity (for example, a delay or a particular subsystem). This line must be like

    Code: Select all

    MessageRequester("Information", "Message", #PB_MessageRequester_Ok)
    Time limit : August 31st, 2014 @ 11:59pm (Fantaisie Software's time zone, Paris, GMT+1)
  • At the end of this period, a topic will be created to vote for the best code (only people registered in the forum before June 30th are allowed to vote). To maintain suspense, you'll be asked to give 3 points for your favorite, two for the second, one for the third. The vote will take place from September 1st, 2014 to September 14th @ 23:59. After verification, winners will be contacted to receive their prizes.
How to post
  • Post the code on this forum, after adding and completing the following header (theses lines are not counted in the 50s) :

Code: Select all

;*****************************************************************************
;*
;* July-August 2014 PurePunch contest
;* PureBasic 5.22
;* 50 lines of 80 chars, 2 months delay
;*
;* Name     :  
;* Author   : 
;* Date     : 
;* Notes    :
;*
;*****************************************************************************
Good luck to all players ! :) :)

PS : All 'official' forum's topics about PurePunch

Re: PurePunch Contest July-August 2014

Posted: Mon Jun 30, 2014 3:48 pm
by djes
A nice prize for the winner (see the first post) ! Thanks to the sponsor !

Re: PurePunch Contest July-August 2014

Posted: Mon Jun 30, 2014 5:57 pm
by Demivec
djes wrote:8° Time limit : August 31st, 2014 @ 11:59pm
For clarification, what time zone for the above time?

Re: PurePunch Contest July-August 2014

Posted: Mon Jun 30, 2014 6:31 pm
by djes
Demivec wrote:
djes wrote:8° Time limit : August 31st, 2014 @ 11:59pm
For clarification, what time zone for the above time?
Let say, Fantaisie Software's time zone (Paris), GMT+1, I think it's fair.

Re: PurePunch Contest July-August 2014

Posted: Mon Jun 30, 2014 6:39 pm
by Bananenfreak
@Demivec:
Good question :D

-----------

Thank you Goldoweb SL for your prize! :)

One question: Is posting more than one program allowed (multiple attendance? /Is this right?)?
I will take part of this PurePunch. Good Hungergames everyone :D

Re: PurePunch Contest July-August 2014

Posted: Mon Jun 30, 2014 6:44 pm
by Kuron
Bananenfreak wrote:(multiple attendance? /Is this right?)?
"Multiple entries" would be the correct term/phrase.

Re: PurePunch Contest July-August 2014

Posted: Mon Jun 30, 2014 7:54 pm
by Samuel
Sounds like it could be fun. I'll have to start thinking of some ideas.

Quick question are text files allowed? If so are they just added to the program source total?

Re: PurePunch Contest July-August 2014

Posted: Mon Jun 30, 2014 9:02 pm
by djes
Bananenfreak wrote:One question: Is posting more than one program allowed ?
Yes, no problem !
Samuel wrote:Quick question are text files allowed? If so are they just added to the program source total?
I don't see the point, what would you want to do (you can say me via pm) ?

Re: PurePunch Contest July-August 2014

Posted: Tue Jul 01, 2014 8:24 am
by djes
Samuel wrote:Quick question are text files allowed? If so are they just added to the program source total?
Rule precised, thanks to Samuel !

Re: PurePunch Contest July-August 2014

Posted: Tue Jul 01, 2014 3:18 pm
by djes
New sponsor !

Re: PurePunch Contest July-August 2014

Posted: Wed Jul 02, 2014 12:34 am
by falsam
Grayscale and Tibetan sounds. Search and click on a turtle. A turtle found adds time and a tree.

Tibetan monks you allow a mistake once.

Find 50 turtles and you get a second chance.
Find 30 more turtles and you get a third opportunity.

Image Image

Code: Select all

;*****************************************************************************
;*
;* July-August 2014 PurePunch contest
;* PureBasic 5.22
;* 50 lines of 80 chars, 2 months delay
;*
;* Name     : Where is the turtle
;* Author   : falsam   
;* Date     : Jul 02, 2014 - Update Jul 04, 2014
;* Notes    : Search and click on a turtle. A turtle found adds time and a tree.
;*
;*****************************************************************************
Structure x:s.i:x.i:y.i:a.i:EndStructure
Global fg,f1,f2,Dim m(15),NewList s.x(),ct,tf,ti,ns,li,i,ev,mr,ac=-1,bs,bo
Procedure f(w):Protected fc.b, mx, my
mx=WindowMouseX(w):my=WindowMouseY(w):MouseLocate(mx,my)
If mx>0 And mx<WindowWidth(w,1)-1 And my>0 And my<WindowHeight(w,1)-1
ReleaseMouse(0):fc=1:Else:fc=0:ReleaseMouse(1):EndIf
ProcedureReturn fc:EndProcedure
Procedure r(i,j):ProcedureReturn Random(i,j):EndProcedure
Procedure ps(f,p):SetSoundFrequency(0,f):SoundPan(0,p):PlaySound(0):EndProcedure
fg=LoadFont(-1,"Arial",20):f1=LoadFont(-1,"Arial",16)
f2=LoadFont(-1,"Arial",50,256)
InitSprite():InitKeyboard():InitMouse():InitSound():UsePNGImageDecoder()
OpenWindow(0,0,0,800,600,"Turtle",13107201):AddWindowTimer(0, 0, 1000)
OpenWindowedScreen(WindowID(0),0,0,800,600):LoadSound(0,"s.wav")
For i=0 To 15:m(i)=LoadSprite(-1,"s.png",8):ClipSprite(m(i),i*64,0,64,64):Next
ClipSprite(m(8),0,130,64,64):ClipSprite(m(9),65,130,64,64)
ClipSprite(m(10),129,130,64,64):ClipSprite(m(11),0,360,15,23)
ClipSprite(m(12),0,280,48,48):ClipSprite(m(13),200,280,32,32)
ClipSprite(m(14),280,280,32,32):ClipSprite(m(15),280,130,32,32)
Repeat:Repeat:ev=WindowEvent():If ev=13110 And ti>0:ti=ti-1:EndIf:
If ev=13116:End:EndIf:Until ev=0
FlipBuffers():ExamineKeyboard():ExamineMouse():ClearScreen($18D3D3D3)  
If ac=-1:ac=0:ct=10:ns=1:tf=0:ti=5:li=1:ps(44100,0):EndIf
If ns=1:ClearList(s()):For i=0 To ct:AddElement(s())
s()\s=m(r(7,0)):s()\x=r(692,64):s()\y=r(472,128):s()\a=r(255,128):Next
SelectElement(s(),0):s()\s=m(8):s()\x=r(448,128):s()\y=r(384,128):s()\a=255:ns=0
EndIf:ForEach s():DisplayTransparentSprite(s()\s,s()\x,s()\y,s()\a):Next
SelectElement(s(),0):DisplayTransparentSprite(m(12),380,540)
DisplayTransparentSprite(m(13),610,5):DisplayTransparentSprite(m(14),710,5)
DisplayTransparentSprite(m(15),515,5):If KeyboardReleased(19):ac=-1:EndIf
If f(0):DisplayTransparentSprite(m(11),MouseX(),MouseY()):EndIf
If MouseButton(1):If mr=0:mr=1
If SpriteCollision(m(11),MouseX(),MouseY(),m(12),380,540):ac=-1
ElseIf ac<>-2:If SpriteCollision(m(11),MouseX(),MouseY(),m(8),s()\x,s()\y)
tf+1:ps(r(50000,10000),r(300,100)-200):ti+2:ns=1:ct+1
Else:ac=2:EndIf:EndIf:EndIf:Else:mr=0:EndIf 
If tf>49 And bo=0:li+1:bo+1:EndIf:If tf>79 And bo=1:li+1:bo+1:EndIf
If ti=0 And ac<>-2 Or ac<>-1:ac=2:mr=0:EndIf   
If ac=2:If li>0:li-1:ac=0:s()\s=m(9)
Else:ti=0:ac=-2:ps(4700,0):s()\s=m(10):EndIf:EndIf
StartDrawing(ScreenOutput()):DrawingMode(1):DrawingFont(FontID(f2))
If ac=-2:RotateSprite(m(12),1,1):DrawText(200,280,"GAME OVER!",$18808080): EndIf
DrawingFont(FontID(fg)):DrawText(10, 10, "Where is the turtle",$000000)
DrawText(560,5,Str(li),$000000):DrawText(650,5,Str(tf),$000000)
DrawText(750,5,Str(ti),$000000):DrawingFont(FontID(f1))
DrawText(20,560,"falsam - PurePunch Contest 2014",$000000)
DrawText(610,560,"Escape key : End",$000000)
StopDrawing():Until KeyboardPushed(1)
You will need the sprite sheet and the sound file to run this code.
:idea: Download Turtle.zip (Source 665Ko : pb + spritesheet +wav)

I hope the translation of the presentation of the code is good. Enjoy :)

Re: PurePunch Contest July-August 2014

Posted: Wed Jul 02, 2014 8:47 am
by djes
Nice and original falsam ! My score : 101 ;)

Re: PurePunch Contest July-August 2014

Posted: Wed Jul 02, 2014 8:57 am
by falsam
djes wrote:Nice an original falsam ! My score : 101 ;)
Glad you liked it djes.

Is it possible to modify the code before the closing of contest ?

Re: PurePunch Contest July-August 2014

Posted: Wed Jul 02, 2014 9:42 am
by djes
falsam wrote:
djes wrote:Nice an original falsam ! My score : 101 ;)
Glad you liked it djes.

Is it possible to modify the code before the closing of contest ?
Yes !

Re: PurePunch Contest July-August 2014

Posted: Wed Jul 02, 2014 7:05 pm
by kvitaliy
Importunate fly:
Image

Code: Select all

;*****************************************************************************
;*
;* July-August 2014 PurePunch contest
;* PureBasic 5.22+
;* 50 lines of 80 chars, 2 months delay
;*
;* Name     :Importunate fly
;* Author   :kvitaliy
;* Date     :Jul 02, 2014 
;* Notes    :Banish a fly from the screen the mouse pointer
;*
;*****************************************************************************
UseOGGSoundDecoder():UsePNGImageDecoder():ExamineDesktops()
w=DesktopWidth(0):h=DesktopHeight(0):x=Random(w-130):y=Random(h-130)
LoadImage(3,"fly.png"):GrabImage(3,1,0,0,76,64):GrabImage(3,0,76,0,76,64)
If InitSound():LoadSound(0, "fly.ogg"):PlaySound(0): EndIf:Delay(2000)
hl=OpenWindow(0,x,y,76,64,"", #PB_Window_BorderLess|#PB_Window_Invisible)
ImageGadget(3,0,0,76,64,ImageID(1)):DisableGadget(3,1)
SetWindowColor(0,RGB(1,1,1)):StickyWindow(0,1):AddWindowTimer(0,1,200)
SetWindowLongPtr_(hl, #GWL_EXSTYLE, GetWindowLongPtr_(hl, 
#GWL_EXSTYLE) | #WS_EX_LAYERED | #WS_EX_TOOLWINDOW)
SetLayeredWindowAttributes_(WindowID(0), RGB(1,1,1), 0, #LWA_COLORKEY)
HideWindow(0, 0):Dim P.POINT(1)
Procedure.f Distance(x1,y1,x2,y2)
   ProcedureReturn Sqr( ((x2-x1)*(x2-x1))+((y2-y1)*(y2-y1)) )
EndProcedure
Repeat: Event = WaitWindowEvent(10)
GetCursorPos_(P(0)):If Distance(x,y,P(0)\x,P(0)\y) < 50
HideWindow(0, 1):PlaySound(0):HideWindow(0, 0):x=Random(w-130):y=Random(h-130)
Delay(2000):count + 1: If count>5: Break:EndIf 
ResizeWindow(0,x,y,#PB_Ignore,#PB_Ignore):HideWindow(0, 0)       
EndIf
Select Event
Case #PB_Event_Timer 
If vis:vis=0:SetGadgetState(3,ImageID(0)):Else:vis=1
SetGadgetState(3,ImageID(1)):EndIf
Case #PB_Event_CloseWindow ; Alt+F4 exit!
CloseWindow(0):Break:EndSelect:ForEver
You will need the image and the sound file ( ogg ) to run this code.
Download fly.zip (22 KB and source include )