PurePunch Contest July-August 2014

Developed or developing a new product in PureBasic? Tell the world about it.
Mr.L
Enthusiast
Enthusiast
Posts: 146
Joined: Sun Oct 09, 2011 7:39 am

Re: PurePunch Contest July-August 2014

Post by Mr.L »

Hi everyone!
Here is my attempt: A not 100% perfect clone of the famous C64 game "Boulder Dash"!
Maybe one or another in this forum was addicted to this game like me, back in the old days :lol:

This imagefile file is needed. Please save the code and the image to the same directory.
http://picload.org/image/lwggdpp/b.png

Code: Select all

;*******************************************************************************
;*
;* July-August 2014 PurePunch contest
;* PureBasic 5.22
;* 50 lines of 80 chars, 2 months delay
;*
;* Name     :   BoulderDash-Clone
;* Author   :   Mr.L
;* Date     :   20/07/14
;* Notes    :   My not 100% perfect remake of the famous C64 game :-)
;*              Use Arrow-Keys to move, Escape-Key = restart Map
;*
;*******************************************************************************
UsePNGImageDecoder():#w=40:#h=22:Structure bm:b.i[8]:c.l:n.l:m.l:d.l;##########
EndStructure:LoadImage(0,"b.png"):NewList p.bm():OpenWindow(0,0,0,800,600,"BD")
CanvasGadget(0,0,0,800,600,#PB_Canvas_Keyboard):SetActiveGadget(0);############
AddWindowTimer(0,0,100):AddWindowTimer(0,1,50):AddWindowTimer(0,2,1000);#######
Dim b.bm(30):Macro F:EndIf:EndMacro:Macro H:Case:EndMacro:Macro G();###########
Dim w(#w,#h):ky=0:xs=0:xr=0:pl=3:ClearList(P()):StartDrawing(ImageOutput(0));##
u=lv*40:di=Point(u,406):ti=Point(u+1,406):dp=Point(u+2,406):ep=Point(u+3,406);#
For v=0 To #h-1:For u=0 To #w-1:w(u,v)=Point(u+lv*40,v+384):Select w(u,v):H 2;#
x=u:y=v:w(u,v)=18:H 99:hx=u:hy=v:w(u,v)=14:EndSelect:Next:Next:StopDrawing();##
EndMacro:Macro M(k,u,v,s):If ky=k:w=w(u,v):If w<2:w(x,y)=0:w(u,v)=s:x=u:y=v;###
ElseIf w=18:lv=(lv+1)%6:sc+ti:ti=0:de=50:w(x,y)=0:x=u:y=v:ElseIf w=7:di-1:sc+dp
If di=0:w(hx,hy)=18:bg=$FFFFFF:F:w(x,y)=0:w(u,v)=s:x=u:y=v:ElseIf w=5 And;#####
w(x+(x-u)*2,v)=0 And Random(3)=0:w(x,y)=0:w(u,v)=s:w(x+(x-u)*2,v)=5:x=u:y=v:F:F
EndMacro:Macro E(i,x,y):AddElement(p()):p()\m=x:p()\n=y:p()\d=i:p()\c=4;#######
EndMacro:Macro N(i,x,y):If c=i:If w(u+y*d,v-x*d)=0:j+y*d:k-x*d:p=1;############
ElseIf w(u+x,v+y)=0:j+x:k+y:F:F:EndMacro:Macro S(x,y):Select Abs(w(u+x,v+y));##
H 0,1:If xg And Random(120)=0:w(u+x,v+y)=15:xg=0:F:xt=0:H 9 To 12:E(0,u+x,v+y);
EndSelect:EndMacro:Macro L:Next:EndMacro:Macro I(x,y,c=8):For u=x To x+c-1;####
b(i)\b[u-x]=GrabImage(0,#PB_Any,u*32,y*32,32,32):L:b(i)\n=c:i+1:EndMacro;######
I(0,6,1):I(1,7,1):I(0,1):I(0,4):I(0,5):I(0,7,1):I(0,7,1):I(0,10):I(0,10):I(0,9)
I(0,9):I(0,9):I(0,9):I(3,6,1):I(1,6,1):I(0,8):I(1,0,3):I(4,6,4):I(4,0,4):lv=0;#
G():de=20:fi=LoadFont(0,"Verdana",16,#PB_Font_Bold):Repeat;####################
Select WaitWindowEvent():H #PB_Event_CloseWindow:End:H #PB_Event_Gadget;#######
If EventType()=#PB_EventType_KeyDown:ky=GetGadgetAttribute(0,#PB_Canvas_Key):F;
If EventType()=#PB_EventType_KeyUp:ky=0:If de<1:w(x,y)=2:F:F;##################
If ky=#PB_Shortcut_Escape:G():de=10:F:H #PB_Event_Timer:Select EventMenu():H 0;
If de<1:M(#PB_Shortcut_Up,x,y-1,3):M(#PB_Shortcut_Down,x,y+1,4);###############
M(#PB_Shortcut_Left,x-1,y,3):M(#PB_Shortcut_Right,x+1,y,4):F:xt=1:xg=1;########
For v=0 To #h-1:For u=0 To #w-1:c=w(u,v):j=u:k=v:d=Abs(w(u,v+1)):Select c:H 5,7
If d=0:c+1:ElseIf d=13 Or(d>4 And d<9):If w(u-1,v)=0 And w(u-1,v+1)=0:c+1;#####
ElseIf w(u+1,v)=0 And w(u+1,v+1)=0:c+1:F:F:H 6,8:Select d:H 2,3,4:E(0,x,y);####
H 9 To 12:E(7,u,v):H 17:If w(u,v+2)=0:k+2:If c=6:c=8:Else:c=6:F:F:EndSelect;###
If d=0:k+1:ElseIf d=13 Or(d>4 And d<9):If w(u-1,v)=0 And w(u-1,v+1)=0:j-1;#####
ElseIf w(u+1,v)=0 And w(u+1,v+1)=0:j+1:F:F:If j=u And k=v:c-1:F:H 9 To 12:d=1;#
N(9,1,0):N(10,0,1):N(11,-1,0):N(12,0,-1):If p:p=0:c-d:ElseIf(j=u And k=v);#####
c+d:F:If c=8:c=12:ElseIf c=13:c=9:F:For b=-1 To 1:For a=-1 To 1:If (a*b)=0;####
Select Abs(w(u+a,v+b)):H 2,3,4:E(0,u,v):EndSelect:F:L:L:H 15:If xs:c=7;########
ElseIf xr:c=5:Else:S(-1,0):S(1,0):S(0,-1):S(0,1):F:EndSelect:w(u,v)=0;#########
w(j,k)=-c:L:L:xs=xt:ForEach p():c=p()\c-1:d=p()\d:If c>0:d=16:F;###############
For v=p()\n-1 To p()\n+1:For u=p()\m-1 To p()\m+1:Select Abs(w(u,v)):H 2,3,4;##
de=30:E(0,u,v):H 9 To 12:E(0,u,v):H 15:xr=1:EndSelect:If Abs(w(u,v))<>14;######
w(u,v)=d:F:L:L:p()\c=c:If c<=0:DeleteElement(p()):F:L:If de:de-1:If de=20:G();#
ElseIf de=0:w(x,y)=2:F:F:H 1:c=((x*32+sx)-400):If Abs(c)>250:sx-c/20:F;########
c=((y*32+sy)-300):If Abs(c)>150:sy-c/15:F:c=((x*32)-400):For i=0 To 18;########
b(i)\c=(b(i)\c+1)%(b(i)\n):L:StartDrawing(CanvasOutput(0)):DrawingFont(fi);####
Box(0,0,800,600,0):For v=0 To #h-1:For u=0 To #w-1:b=Abs(w(u,v)):If b:w(u,v)=b;
DrawImage(ImageID(b(b)\b[b(b)\c]),u*32+sx,v*32+sy,32,32):Else;#################
Box(u*32+sx,v*32+sy,32,32,bg):F:L:L:bg=0;######################################
DrawText(0,0,"   D:"+Str(di)+Space(40)+Str(ti)+Space(40)+RSet(Str(sc),6,"0"));#
StopDrawing():H 2:If de<1:ti-1:If ti=0:E(0,x,y):F:F:EndSelect:EndSelect:ForEver
Last edited by Mr.L on Sun Jul 20, 2014 8:46 pm, edited 1 time in total.
User avatar
Otrebor
Enthusiast
Enthusiast
Posts: 210
Joined: Mon Mar 17, 2014 1:42 pm
Location: São Paulo, Brasil
Contact:

Re: PurePunch Contest July-August 2014

Post by Otrebor »

@Mr.L
Very nice :)
User avatar
majikeyric
Enthusiast
Enthusiast
Posts: 187
Joined: Mon Oct 21, 2013 5:21 pm
Location: France
Contact:

Re: PurePunch Contest July-August 2014

Post by majikeyric »

Impressive use of macros ! :D
my favourite punch until now :D
User avatar
falsam
Enthusiast
Enthusiast
Posts: 632
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: PurePunch Contest July-August 2014

Post by falsam »

majikeyric wrote:my favourite punch until now :D
Please not influence the vote.

PS : Vote for me :mrgreen:

➽ Windows 11 64-bit - PB 6.21 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect 🤪
User avatar
majikeyric
Enthusiast
Enthusiast
Posts: 187
Joined: Mon Oct 21, 2013 5:21 pm
Location: France
Contact:

Re: PurePunch Contest July-August 2014

Post by majikeyric »

falsam wrote:
majikeyric wrote:my favourite punch until now :D
Please not influence the vote.

PS : Vote for me :mrgreen:
Where is the turtle kicks asses too :mrgreen:
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: PurePunch Contest July-August 2014

Post by davido »

@Mr.L ,

Very nice, Thank you. :D
DE AA EB
User avatar
TazNormand
User
User
Posts: 27
Joined: Tue May 26, 2009 3:17 pm
Location: France

Re: PurePunch Contest July-August 2014

Post by TazNormand »

Mr.L wrote:.../...
the famous C64 game "Boulder Dash"!
.../...
Hummm Not so nice as the Amstrad version :lol:

Good Job Mr.L, your "Punch" make me feeling good : i'm not a lonely 40+ years old guy in PB french & english forum
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Re: PurePunch Contest July-August 2014

Post by djes »

Second place prize updated.
User avatar
graph100
Enthusiast
Enthusiast
Posts: 115
Joined: Tue Aug 10, 2010 3:17 pm

Re: PurePunch Contest July-August 2014

Post by graph100 »

Here is my MoonLander. The goal is Not To land, but To Not crash against the walls And collect As many point As possible :D

To move, play With momentum With the super physical engine Graph100 certified, And also With the direction key :

[Righ] And [Left] activate the left And right boosters, use this To change the vaissel direction
[Down] control the main thrust, And allow quick acceleration
[Up] start the two boosters To tweek your move further ( :lol: )

If Not For a PB bug (TransformSprite() ), the code would work on PB 5.22 windows / linux / mac

Snapshot :
Image

The following image must be saved in the same directory As the code :
Image

Code :

Code: Select all

;*******************************************************************************
;*
;* July-August 2014 PurePunch contest
;* PureBasic 5.22
;* 50 lines of 80 chars, 2 months delay
;*
;* Name : MoonLander nightmare
;* Author : Graph100 
;* Date : 21/07/2014 
;* Notes :	You are inside an asteroid, and must go on as long as possible,
;*					collecting fuel and point. Try to have the higest score !
;*  				
;*  				[Left][Rigth] : direction booster
;*  				[Bas] : main thrust
;*  				[Haut] : syncro Booster
;*  				
;* Version 6
;*******************************************************************************
Macro M:Macro:EndMacro:M E:End:End#M:M St:Structure:End#M:M Sp:Sprite:End#M:C.d;
M H:Element:E#M:M Q:#PB_Key_:E#M:M R:Window:E#M:M U:Random:E#M:M Ke:Keyboard:E#M
Init#Sp():M SM:x.d:y.d:a.d:u.d:v.d:m.d:l.d:b.d:E#St:E#M:UsePNGImageDecoder():T.d
St Mo:SM:St Ob:w.d:I.d:List f.Mo():SM:K.Ob:B.Ob:L.Ob:Open#R(0,0,0,800,600,"M",;#
#PB_#R#_ScreenCentered|#PB_#R#_SystemMenu):Open#R#edScreen(R#ID(0),0,0,800,600);
Load#Sp(0,"M.png"):M N:Next:E#M:Init#Ke():x.d:y.d:M CC(i,x,y,k,l,b=2):Copy#Sp(0,
i,4):Clip#Sp(i,x,y,k,l):Zoom#Sp(i,k*b,l*b):E#M:Clip#Sp(0,2,21,55,42):CC(1,61,38,
15,25,1):For i=0 To 9:CC(10+i,80,3+i*6,5,7):N:CC(9,80,9,13,7):CC(6,56,3,25,7);##
CC(7,60,9,21,7):CC(8,1,9,53,9,4):Create#Sp(4,10,10):F.d:Procedure DN(L,x,y):i=0+
Int(Log10(L)):p=Pow(10,i):For j=0 To i:r=Int(L/p):L-r*p:p/10:Display#Sp(10+r,x,;
y):x+8:N:E#Procedure:DB: :NewList S.Ob():Clear#St(L,Ob):Initialize#St(L,Ob):D.d;
L\x=400:L\b=50000000:L\y=300:L\m=1206:L\I=43172:#P=#PI/2:*d.Mo=Add#H(L\f()):CR=0
*g.Mo=Add#H(L\f()):*d\a=0.715743:*d\l=30.479501:*c.Mo=Add#H(L\f()):*d\b=-#P:CS=5
*g\a=2.425849:*g\l=30.4:*g\b=-#P:Initialize#St(K,Ob):*o.Mo=Add#H(K\f()):*c\b=-#P
M El:ElapsedMilliseconds():E#M:K\x=-10:K\y=300:*c\m=0:*c\a=#P:*o\m=50:Ke#Mode(1)
CB=50:*c\l=5:*o\a=0:*o\l=300:ti=El:Repeat:*d\m=0:*g\m=0:Z.d=(El-ti)/1000:*c\m=0;
Repeat:EV=R#Event():If EV=#PB_Event_Close#R:E:E#If:Until EV=0:Examine#Ke():ti=El
If Ke#Pushed(Q#Escape):E:E#If:If CR:Z=0:If Ke#Pushed(Q#Space):Goto DB:E#If:Else;
If Ke#Pushed(Q#Up):*d\m=10000:*g\m=10000:D=0:E#If:If Ke#Pushed(Q#Left):*d\m+5000
E#If:A.d=0:If Ke#Pushed(Q#Right):*g\m+5000:E#If:If Ke#Pushed(Q#Down):*c\m=50000;
E#If:E#If:C=0:CT+1:ForEach L\f():*m.Mo=L\f():L\b-*m\m:If L\b<0:L\b=0:Break:E#If;
T=L\a+*m\a:*m\x=*m\l*Cos(T):G.d:*m\y=*m\l*Sin(T):T=L\a+*m\b:*m\u=*m\m*Cos(T);###
*m\v=*m\m*Sin(T):D+*m\x**m\v-*m\u**m\y:A+*m\u:C+*m\v:N:A/L\m:C/L\m+10:D/L\I:L\u+
A*Z:L\v+C*Z:L\w+D*Z:L\a+L\w*Z:T=L\u*Z:B\x-T:K\x-T:T=L\v*Z:B\y-T:ClearScreen(0);#
K\y-T:Rotate#Sp(0,L\a*90/#P,0):DisplayTransparent#Sp(0,L\x-27,L\y-21):Grab#Sp(2,
L\x-34,L\y-34,68,68,4):ClearScreen($FFFFFF):Repeat:If F>=-200 And F<=1000 And;##
G>=-200 And G<=800:x1.d:*e.Mo=Add#H(K\f()):*e\a=*o\a+(U(20)-10)/#P/20:*e\l=*o\l+
U(20)-10:If *e\l<100:*e\l=100:E#If:If *e\l>400:*e\l=400:E#If:CB-1:CS-1:*e\m=0+;#
U(20)+40:*e=*o:E#If:F=K\x:G=K\y:ForEach K\f():T=K\f()\a+#P:x=F+K\f()\l*Cos(T)/2;
y=G+K\f()\l*Sin(T)/2:T=K\f()\a-#P:x1=F+K\f()\l*Cos(T)/2:F+K\f()\m*Cos(K\f()\a);#
y1.d=G+K\f()\l*Sin(T)/2:G+K\f()\m*Sin(K\f()\a):Transform#Sp(4,x,y,ox.d,oy.d,J.d,
oy1.d,x1,y1):Display#Sp(4,0,0):ox=x:oy=y:J=x1:oy1=y1:N:If CB<0:CB=30;###########
T=K\f()\l-60:T=(U(T)-T/2):B\x=F+T*Cos(K\f()\a+#P):B\y=G+T*Sin(K\f()\a+#P):B\l=1;
E#If:If CS<0:CS=5:Last#H(S()):Add#H(S()):T=K\f()\l-60:T=(U(T)-T/2):S()\x=F+;####
T*Cos(K\f()\a+#P):S()\y=G+T*Sin(K\f()\a+#P):S()\v=100*Abs(T)/(K\f()\l/2-50);####
S()\l=1:E#If:If ListSize(K\f())>40:First#H(K\f()):K\x=K\x+K\f()\m*Cos(K\f()\a);#
K\y=K\y+K\f()\m*Sin(K\f()\a):Delete#H(K\f()):*o=Last#H(K\f()):E#If;#############
Until F<-200 Or F>1000 Or G<-200 Or G>800:StartDrawing(ScreenOutput());#########
For i=0 To 15:T=i*2*#PI/15:If Point(400+22*Cos(T),300+22*Sin(T)):CR=1:E#If:Next;
If Point(400+34*Cos(0.64+L\a),300+34*Sin(0.64+L\a)) Or Point(400+34*Cos(2.5+;###
L\a),300+34*Sin(2.5+L\a)):CR=1:E#If:If L\b:ForEach L\f():For i=-5 To 5:T=L\a+;##
L\f()\b+i/10:LineXY(L\x+L\f()\x,L\y+L\f()\y,L\x+L\f()\x-L\f()\m*Cos(T)/500,L\y+;
L\f()\y-L\f()\m*Sin(T)/500,$88FF):N:N:E#If:StopDrawing();#######################
DisplayTransparent#Sp(2,L\x-34,L\y-34):If B\l:If Sp#PixelCollision(1,B\x-7,B\y+;
-12,2,L\x-34,L\y-34):L\b+25000000:B\l=0:E#If:DisplayTransparent#Sp(1,B\x-7,B\y+;
-12):E#If:ForEach S():S()\x-L\u*Z:S()\y-L\v*Z:If S()\l:If Sp#PixelCollision(9,;#
S()\x-6,S()\y-3,2,L\x-34,L\y-34):S()\l=0:L\l+S()\v:E#If:DN(S()\v,S()\x-6,S()\y+;
-3):E#If:N:Display#Sp(6,352,5):DN(L\l,400,5): Display#Sp(7,360,19):DN(L\b/5000,;
400,19):If CR And CT%50<30:Display#Sp(8,294,282):E#If:FlipBuffers():ForEver;####
;################PURE#PUNCH###AOUT#2014###MOONLANDER#BY#GRAPH100################
_________________________________________________
My Website : CeriseCode (Warning : perpetual changes & not completed ;))
User avatar
glomph
User
User
Posts: 48
Joined: Tue Apr 27, 2010 1:43 am
Location: St. Elsewhere / Germany
Contact:

Re: PurePunch Contest July-August 2014

Post by glomph »

Hi,
I really like to read this topik
and thank all for that.

The Moonlander is fun!
User avatar
majikeyric
Enthusiast
Enthusiast
Posts: 187
Joined: Mon Oct 21, 2013 5:21 pm
Location: France
Contact:

Re: PurePunch Contest July-August 2014

Post by majikeyric »

Here is my first punch, the ultimate tool to compress ...

.......... your PB sources into punches ! :mrgreen:

It is supposed to be cross-platform, handling the different end of line formats (only tested on Windows)

It deletes useless space, comments and truncates long lines.

It only supports ASCII files and doesn't support labels.

Code: Select all

;*****************************************************************************
;*
;* July-August 2014 PurePunch contest
;* PureBasic 5.22
;* 50 lines of 80 chars, 2 months delay
;*
;* Name     : PurePunch Cruncher
;* Author   : Majikeyric
;* Date     : 22/07/2014
;* Notes    : A tool to crunch your PB sources without any effort and
;*            enter the PurePunch contest!
;*
;*****************************************************************************
Macro M:Macro:EndMacro:M CP:Compiler:EndMacro:M Z:Select:EndMacro:M Y:Case;;;;;;
EndMacro:M B:EndIf:EndMacro:M X:EndSelect:EndMacro:M W:CompilerCase:EndMacro;;;;
M PR:Procedure:EndMacro:M EP:EndProcedure:EndMacro:M SK:ReadAsciiCharacter(fe);;
EndMacro:M G:Gadget:EndMacro:M S1:String:EndMacro:M XY(t,k,d):Y k:Z et:Y #F;;;;;
c$=t#FileRequester("","","*.*|*.*",0):If c$<>"":Set#G#Text(d,c$):B:X:EndMacro;;;
M AE(s):AddElement(c()):c()\v=s:EndMacro:M RI(n,c):Right(I$,n)<>c:EndMacro;;;;;;
M MR(a,s):MessageRequester(a,s):EndMacro:#Q=34:#P=#PB_Any:#X=#PB_Compiler_OS;;;;
#W=#PB_OS_Windows:#M=#PB_OS_MacOS:#L=#PB_OS_Linux:#F=#PB_EventType_LeftClick;;;;
#Z=#PB_Window_SystemMenu|#PB_Window_ScreenCentered:#N=0:#Ch=1:#CC=2:#Co=3:#Es=4;
Global I$,L$:Global FS,Er,TLM,NCI,NL,Et:PR CEC(p,t.s):If p<=0 Or p>Len(t);;;;;;;
PR#Return 0:B:i=1:While i<=p:If Asc(Mid(t,i,1))=#Q:r!1:B:i+1:Wend:PR#Return r:EP
PR RPT(c$):Structure Re:v.s:p.i:EndStructure:NewList c.Re():AE(":"):AE("rO");;;;
AE("rOX"):AE("dnA"):AE(","):AE("+"):c$=Left(c$,TLM):ch$=c$:p=1:While p<=TLM;;;;;
If CEC(p,ch$):c$=Left(c$,p-1)+"-"+Mid(c$,p+1):B:p+1:Wend:c$=Reverse#S1(c$);;;;;;
ForEach c():p=Find#S1(c$,c()\v):If p<>0:p=TLM-p+1:B:c()\p=p:Next;;;;;;;;;;;;;;;;
SortStructuredList(c(),#PB_Sort_Descending,OffsetOf(Re\p),#PB_Integer);;;;;;;;;;
FirstElement(c()):PR#Return c()\p:EP:PR EI(ft=0):If I$<>"" Or ft:If Right(I$,;;;
1)<>"," And RI(1,"+") And RI(2,Chr(#Q)+"+") And RI(2,"Or") And RI(3,"XOr") And;;
RI(3,"And"):If L$="" Or I$="":s.s="":Else:s=":":B:L$=L$+s+I$:I$="";;;;;;;;;;;;;;
While Len(L$)>=TLM And Not Er:If Len(L$)=TLM:Write#S1#N(FS,L$):NL+1:L$="";;;;;;;
ElseIf Len(L$)>TLM:If CEC(TLM,L$) And CEC(TLM-1,L$) And CEC(TLM-2,L$);;;;;;;;;;;
Write#S1#N(FS,Left(L$,TLM-2)+Chr(#Q)+"+"):NL+1:L$=Chr(#Q)+Mid(L$,TLM-1):Else;;;;
p=RPT(L$):If p=0:Er=4:Else:If Mid(L$,p,1)=":":L$=Replace#S1(L$,":","",;;;;;;;;;;
#PB_#S1#_CaseSensitive,p,1):p-1:B:Write#S1#N(FS,LSet(Left(L$,p),TLM,";")):NL+1;;
NCI+TLM-Len(Left(L$,p)):L$=Trim(Mid(L$,p+1)):B:B:B:Wend:If ft And L$<>"";;;;;;;;
Write#S1#N(FS,LSet(L$,TLM,";")):NCI+TLM-Len(L$):NL+1:B:ElseIf Right(I$,;;;;;;;;;
2)=Chr(#Q)+"+":I$=Left(I$,Len(I$)-2):Et=#CC:B:B:EP:PR C(s$,t$,l):Er=0:NCI=0;;;;;
TLM=l:fe=ReadFile(#P,s$):If fe:FS=CreateFile(#P,t$):If FS:Et=#N:L$="":I$="":NL=0
While Not Eof(fe) And Not Er:o=ReadAsciiCharacter(fe):Z Et:Y #N:Z o:Y #Q:Et=#Ch;
I$+Chr(o):Y 59:EI():eac=Et:Et=#Co:Y 58:EI():Y 32,9:Et=#Es:CP#Z #X:W #W:Y $0d:SK;
W #M:Y $0d:W #L:Y $0a:CompilerEndSelect:EI():Default:I$+Chr(o):X:Y #Ch:Z o:Y #Q;
Et=#N:I$+Chr(o):Y $0d,$0a:Er=3:Default:I$+Chr(o):X:Y #CC:Z o:Y #Q:Et=#Ch:Y $0d,;
$0a:Er=3:X:Y #Co:CP#Z #X:W #W:If o=$0d:SK:W #M:If o=$0d:W #L:If o=$0a;;;;;;;;;;;
CompilerEndSelect:Et=eac:B:Y #Es:Z o:CP#Z #X:W #W:Y $0d:SK:W #M:Y $0d:W #L:Y $0a
CompilerEndSelect:Et=#N:EI():Y 59:EI():eac=Et:Et=#Co:Y 58:Et=#N:EI():Y 32,9;;;;;
Y 44,61,43,45,42,47,38,124,33,126,60,62,37,41:I$+Chr(o):Et=#N:Default:If I$<>"";
If Find#S1(",=+-*/&|!~<>%(",Right(I$,1)):I$+Chr(o):Else:I$+" "+Chr(o):EndIf:Else
I$=Chr(o):B:If o=#Q:Et=#Ch:Else:Et=#N:B:X:X:Wend:If Not Er:If L$<>"" Or I$<>"";;
EI(1):B:B:CloseFile(FS):Else:Er=2:B:CloseFile(fe):Else:Er=1:B:Z Er:Y 1:me$="Op"+
"en err":Y 2:me$="Write err":Y 3:me$="EOL in string":Y 4:me$="line>"+Str(TLM)+;;
" chars":X:If me$="":MR("","Lines:"+Str(NL)+",free chars:"+Str(NCI)):Else:MR("",
me$):B:EP:OpenWindow(0,0,0,360,103,"PurePunch Cruncher",#Z):Text#G(#P,10,12,70,;
25,"Source file :"):Text#G(#P,10,42,70,25,"Target file :"):ss=S1#G(#P,75,10,240,
20,""):st=S1#G(#P,75,40,240,20,""):bs=Button#G(#P,320,10,30,20,"...");;;;;;;;;;;
BT=Button#G(#P,320,40,30,20,"..."):bc=Button#G(#P,120,69,230,23,"Crunch");;;;;;;
Text#G(#P,10,72,100,20,"Line length :"):sl=String#G(#P,75,70,40,20,"80"):Repeat;
e=WaitWindowEvent():eg=Event#G():et=EventType():Z e:Y #PB_Event_CloseWindow:End;
Y #PB_Event_#G:Z eg:XY(Open,bs,ss):XY(Save,BT,st):Y bc:Z et:Y #F;;;;;;;;;;;;;;;;
s$=Get#G#Text(ss):t$=Get#G#Text(st):l$=Get#G#Text(sl):If s$="" Or t$="" Or l$=""
MR("","Empty!"):ElseIf s$=t$:MR("","S=T!"):Else:C(s$,t$,Val(l$)):B:X:X:X:ForEver
Last edited by majikeyric on Tue Jul 22, 2014 3:33 pm, edited 1 time in total.
User avatar
NicTheQuick
Addict
Addict
Posts: 1504
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: PurePunch Contest July-August 2014

Post by NicTheQuick »

graph100 wrote:If Not For a PB bug (TransformSprite() ), the code would work on PB 5.22 windows / linux / mac
Unfortunality 'TransformSprite()' does not work correctly on Linux. :(
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
said
Enthusiast
Enthusiast
Posts: 342
Joined: Thu Apr 14, 2011 6:07 pm

Re: PurePunch Contest July-August 2014

Post by said »

Hi All,

This competition is amazing :D :D :D I really enjoy what you guys can do in so many little lines :shock: :shock: I wish i could make something worth contributing with :cry: :cry:

Good luck to all
User avatar
Bananenfreak
Enthusiast
Enthusiast
Posts: 519
Joined: Mon Apr 15, 2013 12:22 pm

Re: PurePunch Contest July-August 2014

Post by Bananenfreak »

@said:
Mainproblem is to find an idea for a program :D
Image
User avatar
graph100
Enthusiast
Enthusiast
Posts: 115
Joined: Tue Aug 10, 2010 3:17 pm

Re: PurePunch Contest July-August 2014

Post by graph100 »

Bananenfreak wrote:@said:
Mainproblem is to find an idea for a program :D
Soooo very true :mrgreen:

I was thinking doing a landers clone, but in the end it ended like this !

@said : Just do something ! We are waiting to see it :D the more, the better

[EDIT] Here a linux adaptation of my moonlander, the code with the compilerIF / ENDIF took 51lignes, so I put it here...
And also, to be able to use sprite collision, I used the normal collision instead of the pixel one, because it does not work on linux (dunno if it's the clipsprite() that broke it ???)

Linux / Mac code : (use the same image than for the windows one)

Code: Select all

Macro M:Macro:EndMacro:M E:End:End#M:M St:Structure:End#M:M Sp:Sprite:End#M:C.d;
M H:Element:E#M:M Q:#PB_Key_:E#M:M R:Window:E#M:M U:Random:E#M:M Ke:Keyboard:E#M
Init#Sp():M SM:x.d:y.d:a.d:u.d:v.d:m.d:l.d:b.d:E#St:E#M:UsePNGImageDecoder():T.d
St Mo:SM:St Ob:w.d:I.d:List f.Mo():SM:K.Ob:B.Ob:L.Ob:Open#R(0,0,0,800,600,"M",;#
#PB_#R#_ScreenCentered|#PB_#R#_SystemMenu):Open#R#edScreen(R#ID(0),0,0,800,600);
Load#Sp(0,"M.png"):M N:Next:E#M:Init#Ke():x.d:y.d:M CC(i,x,y,k,l,b=2):Copy#Sp(0,
i,4):Clip#Sp(i,x,y,k,l):Zoom#Sp(i,k*b,l*b):E#M:Clip#Sp(0,2,21,55,42):CC(1,61,38,
15,25,1):For i=0 To 9:CC(10+i,80,3+i*6,5,7):N:CC(9,80,9,13,7):CC(6,56,3,25,7);##
CC(7,60,9,21,7):CC(8,1,9,53,9,4):Create#Sp(4,10,10):F.d:Procedure DN(L,x,y):i=0+
Int(Log10(L)):p=Pow(10,i):For j=0 To i:r=Int(L/p):L-r*p:p/10:Display#Sp(10+r,x,;
y):x+8:N:E#Procedure:DB: :NewList S.Ob():Clear#St(L,Ob):Initialize#St(L,Ob):D.d;
L\x=400:L\b=50000000:L\y=300:L\m=1206:L\I=43172:#P=#PI/2:*d.Mo=Add#H(L\f()):CR=0
*g.Mo=Add#H(L\f()):*d\a=0.715743:*d\l=30.479501:*c.Mo=Add#H(L\f()):*d\b=-#P:CS=5
*g\a=2.425849:*g\l=30.4:*g\b=-#P:Initialize#St(K,Ob):*o.Mo=Add#H(K\f()):*c\b=-#P
M El:ElapsedMilliseconds():E#M:K\x=-10:K\y=300:*c\m=0:*c\a=#P:*o\m=50:Ke#Mode(1)
CB=50:*c\l=5:*o\a=0:*o\l=300:ti=El:Repeat:*d\m=0:*g\m=0:Z.d=(El-ti)/1000:*c\m=0;
Repeat:EV=R#Event():If EV=#PB_Event_Close#R:E:E#If:Until EV=0:Examine#Ke():ti=El
If Ke#Pushed(Q#Escape):E:E#If:If CR:Z=0:If Ke#Pushed(Q#Space):Goto DB:E#If:Else;
If Ke#Pushed(Q#Up):*d\m=10000:*g\m=10000:D=0:E#If:If Ke#Pushed(Q#Left):*d\m+5000
E#If:A.d=0:If Ke#Pushed(Q#Right):*g\m+5000:E#If:If Ke#Pushed(Q#Down):*c\m=50000;
E#If:E#If:C=0:CT+1:ForEach L\f():*m.Mo=L\f():L\b-*m\m:If L\b<0:L\b=0:Break:E#If;
T=L\a+*m\a:*m\x=*m\l*Cos(T):G.d:*m\y=*m\l*Sin(T):T=L\a+*m\b:*m\u=*m\m*Cos(T);###
*m\v=*m\m*Sin(T):D+*m\x**m\v-*m\u**m\y:A+*m\u:C+*m\v:N:A/L\m:C/L\m+10:D/L\I:L\u+
A*Z:L\v+C*Z:L\w+D*Z:L\a+L\w*Z:T=L\u*Z:B\x-T:K\x-T:T=L\v*Z:B\y-T:ClearScreen(0);#
K\y-T:Rotate#Sp(0,L\a*90/#P,0):DisplayTransparent#Sp(0,L\x-27,L\y-21):Grab#Sp(2,
L\x-34,L\y-34,68,68,4):ClearScreen($FFFFFF):Repeat:If F>=-200 And F<=1000 And;##
G>=-200 And G<=800:x1.d:*e.Mo=Add#H(K\f()):*e\a=*o\a+(U(20)-10)/#P/20:*e\l=*o\l+
U(20)-10:If *e\l<100:*e\l=100:E#If:If *e\l>400:*e\l=400:E#If:CB-1:CS-1:*e\m=0+;#
U(20)+40:*e=*o:E#If:F=K\x:G=K\y:ForEach K\f():T=K\f()\a+#P:x=F+K\f()\l*Cos(T)/2;
y=G+K\f()\l*Sin(T)/2:T=K\f()\a-#P:x1=F+K\f()\l*Cos(T)/2:F+K\f()\m*Cos(K\f()\a);#
y1.d=G+K\f()\l*Sin(T)/2:G+K\f()\m*Sin(K\f()\a):If ListIndex(K\f())>0;###########
Transform#Sp(4,x1,y,ox.d,y-oy1.d+y1,J.d,y-oy.d+y1,x.d,y1):E#If:Display#Sp(4,0,0)
ox=x:oy=y:J=x1:oy1=y1:N:If CB<0:CB=30:T=K\f()\l-60:T=(U(T)-T/2):B\x=F+T*Cos(#P+;
K\f()\a):B\y=G+T*Sin(K\f()\a+#P):B\l=1:E#If:If CS<0:CS=5:Last#H(S()):Add#H(S());
T=K\f()\l-60:T=(U(T)-T/2):S()\x=F+T*Cos(K\f()\a+#P):S()\y=G+T*Sin(K\f()\a+#P);##
S()\v=100*Abs(T)/(K\f()\l/2-50):S()\l=1:E#If:If ListSize(K\f())>40;#############
First#H(K\f()):K\x=K\x+K\f()\m*Cos(K\f()\a):K\y=K\y+K\f()\m*Sin(K\f()\a);#######
Delete#H(K\f()):*o=Last#H(K\f()):E#If:Until F<-200 Or F>1000 Or G<-200 Or G>800;
StartDrawing(ScreenOutput()):For i=0 To 15:T=i*2*#PI/15:If Point(400+22*Cos(T),;
300+22*Sin(T)):CR=1:E#If:Next:If Point(400+34*Cos(0.64+L\a),300+34*Sin(0.64+;###
L\a)) Or Point(400+34*Cos(2.5+L\a),300+34*Sin(2.5+L\a)):CR=1:E#If:If L\b:;######
ForEach L\f():For i=-5 To 5:T=L\a+L\f()\b+i/10:LineXY(L\x+L\f()\x,L\y+L\f()\y,;#
L\x+L\f()\x-L\f()\m*Cos(T)/500,L\y+L\f()\y-L\f()\m*Sin(T)/500,$88FF):N:N:E#If:;#
StopDrawing():DisplayTransparent#Sp(2,L\x-34,L\y-34):If B\l:If Sp#Collision(1,;#
B\x-7,B\y-12,2,L\x-34,L\y-34):L\b+25000000:B\l=0:E#If:DisplayTransparent#Sp(1,;#
B\x-7,B\y-12):E#If:ForEach S():S()\x-L\u*Z:S()\y-L\v*Z:If S()\l:;###############
If Sp#Collision(9,S()\x-6,S()\y-3,2,L\x-34,L\y-34):S()\l=0:L\l+S()\v:E#If;######
DN(S()\v,S()\x-6,S()\y-3):E#If:N:Display#Sp(6,352,5):DN(L\l,400,5);#############
Display#Sp(7,360,19):DN(L\b/5000,400,19):If CR And CT%50<30:Display#Sp(8,294,;##
282):E#If:FlipBuffers():ForEver;#PURE#PUNCH##AOUT#2014###MOONLANDER#BY#GRAPH100#
_________________________________________________
My Website : CeriseCode (Warning : perpetual changes & not completed ;))
Post Reply