4 line pong :o)

Miscellaneous Forums/Blitz Showcase/4 line pong :o)

Thought i'd post this in here :o)

Mousebuttons for the 2nd bat and arrow keys for the 1st bat.

Couldn't get the pixel shaders to work, so your stuck with the gfx i'm afraid :o)

Graphics 640,480,16,2      ;Graphics3d for 3d ;)


x=20:y=240:a=620:b=y:j=1:k=1:Global m,n,o,p,l=200,h=400:u=10:v=30:Gosub q:SetBuffer BackBuffer():.st:DebugLog 22:Cls:If KeyDown(200):y=y-2:End If:If y<10:y=10:End If:If KeyDown(208):y=y+2:End If:If y>470:y=470:End If:If MouseDown(1):b=b-2:End If:If b<10:b=10:End If:If MouseDown(2):b=b+2:End If:If b>470:b=470:End If:If RectsOverlap(x,y,u,v,m,n,6,6) Or RectsOverlap(a,b,u,v,m,n,6,6):j=j*-1:End If:m=m+j:n=n+k:If n<10 Or n>470:k=k*-1:End If:If m<5:p=p+1:Gosub q:End If:If m>635:o=o+1:Gosub q:End If:Rect x,y,u,v:Rect a,b,u,v:Oval m,n,6,6:Text l,u,o+" - "+p:Flip:Goto st:.q:m=Rnd(l,h):n=Rnd(l,h):Delay h:Return

WaitKey
End


hehe, excelent work :D

Cool! ...But you obviously are still learning to code because I was able to optimize it easily so that it's now *1* line long only instead of 4 - savings of whopping 75%! Talk about bloat-ware you had there... I was also able to keep the performance exactly like it was, not even 1 fps drop. So here you go, optimized 1 line PONG:

Graphics 640,480,16,2:x=20:y=240:a=620:b=y:j=1:k=1:Global m,n,o,p,l=200,h=400:u=10:v=30:Gosub q:SetBuffer BackBuffer():.st:DebugLog 22:Cls:If KeyDown(200):y=y-2:End If:If y<10:y=10:End If:If KeyDown(208):y=y+2:End If:If y>470:y=470:End If:If MouseDown(1):b=b-2:End If:If b<10:b=10:End If:If MouseDown(2):b=b+2:End If:If b>470:b=470:End If:If RectsOverlap(x,y,u,v,m,n,6,6) Or RectsOverlap(a,b,u,v,m,n,6,6):j=j*-1:End If:m=m+j:n=n+k:If n<10 Or n>470:k=k*-1:End If:If m<5:p=p+1:Gosub q:End If:If m>635:o=o+1:Gosub q:End If:Rect x,y,u,v:Rect a,b,u,v:Oval m,n,6,6:Text l,u,o+" - "+p:Flip:Goto st:.q:m=Rnd(l,h):n=Rnd(l,h):Delay h:Return:WaitKey:End


:)

That doesn't look like it would work - but i'll try it out.

lol @ mustang :o)

The 4 lines were the template given from the code challenge in the MISC section ;) Cheeky git :P lol

Graphics 640,480,16,2      ;Graphics3d for 3d ;)
x=20:y=240:a=620:b=y:j=1:k=1:Global m,n,o,p,l=200,h=400:u=10:v=30:Gosub q:SetBuffer BackBuffer():.st:DebugLog 22:Cls:If KeyDown(200):y=y-2:End If:If y<10:y=10:End If:If KeyDown(208):y=y+2:End If:If y>470:y=470:End If:If MouseDown(1):b=b-2:End If:If b<10:b=10:End If:If MouseDown(2):b=b+2:End If:If b>470:b=470:End If:If RectsOverlap(x,y,u,v,m,n,6,6) Or RectsOverlap(a,b,u,v,m,n,6,6):j=j*-1:End If:m=m+j:n=n+k:If n<10 Or n>470:k=k*-1:End If:If m<5:p=p+1:Gosub q:End If:If m>635:o=o+1:Gosub q:End If:Rect x,y,u,v:Rect a,b,u,v:Oval m,n,6,6:Text l,u,o+" - "+p:Flip:Goto st:.q:m=Rnd(l,h):n=Rnd(l,h):Delay h:Return
WaitKey
End


That will settle everything...

Sadly, no AI