Page 1 of 2

Zen Puzzle

Posted: Fri Dec 08, 2017 1:42 pm
by pf shadoko
my first SB game
this is a classic puzzle game.
it doesn't work yet on touch screens (but it shouldn't be very complicated to manage)
if you have suggestions or if you see bugs, do not hesitate to report it to me.

http://cg.racine.free.fr/puzzle/

Re: Zen Puzzle

Posted: Fri Dec 08, 2017 2:38 pm
by Comtois
waouh !

C'est du 100% SpiderBasic ou y'a des gros morceaux de JavaScript là dedans ?

En tout cas, chapeau, tes démos et jeux sont toujours propres, ça donne envie. Je vais commencer par 20 pièces pour me détendre :)

1000 pièces ça doit rendre nerveux, pas zen


wow!

Is it 100% SpiderBasic ?

Anyway, your demos and games are always clean. I'll start with 20 pieces to relax:)

1000 pieces must make you nervous, not Zen.

Re: Zen Puzzle

Posted: Fri Dec 08, 2017 3:09 pm
by pf shadoko
Yes, it's SB.
just the minimum of javascript for what is not yet taken into account: full screen/local storage/...
but it only represents a few lines
on the other hand, I had to redo the lib "VectorDrawing" which is not really usable for games (slowness problem)
I posted my version on
http://forums.spiderbasic.com/viewtopic.php?f=9&t=1272

Re: Zen Puzzle

Posted: Mon Dec 11, 2017 8:49 am
by Dirk Geppert
@pf shadoko: Very impressive - well done!

Re: Zen Puzzle

Posted: Tue Dec 12, 2017 10:41 am
by SparrowhawkMMU
Just played a game. Excellent! :)

One suggestion: as it is supposed to be a Zen game, an option to disable/hide the timer would be good.

Re: Zen Puzzle

Posted: Tue Dec 12, 2017 11:27 am
by pf shadoko
it's just

Re: Zen Puzzle

Posted: Wed Dec 13, 2017 7:40 am
by Dirk Geppert
@pf shadoko: can you give me a tip please, on how to create the puzzle pieces?

Re: Zen Puzzle

Posted: Wed Dec 13, 2017 1:57 pm
by pf shadoko
@ Dirk Geppert :

i use this code :

Code: Select all

Macro cola(col,a=$ff):(col|(a<<24)):EndMacro

Procedure piece(type,l.f,sh.f,sd.f,sb.f,sg.f)
    Protected dx,dy
    
    Macro forme(l,sh,sd,sb,sg,dec)
        dx=2*l+dec
        dy=2*l+dec
        MovePathCursor(dx-l,dy-l)
        AddPathCurve(dx,dy+(-1-sh)*l, dx,dy+ (-1+sh)*l,dx+ l,dy-l)
        AddPathCurve(dx+(1+sd)*l,dy,dx+ (1-sd)*l, dy, dx+l,dy+ l)
        AddPathCurve( dx,dy+ (1+sb)*l, dx,dy+ (1-sb)*l,dx -l,dy+l)
        AddPathCurve( dx+(-1-sg)*l, dy,dx+ (-1+sg)*l, dy, dy-l,dy -l)
        ClosePath()
    EndMacro
       
    la=1
    VectorSourceColor(cola($888888)):FillVectorOutput()    
    forme(l,sh,sd,sb,sg,0):ClipPath():DrawVectorImage(ImageID(0))
    forme(l,sh,sd,sb,sg, la):VectorSourceColor(cola($ffffff,$44)):StrokePath(la*2)    
    forme(l,sh,sd,sb,sg,-la):VectorSourceColor(cola($000000,$44)):StrokePath(la*2)
    
EndProcedure

ex=800
ey=600
OpenWindow(0, 0, 0, ex,ey, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 0, 0, ex,ey)

CreateImage(0,200,200,32,$ff888888)
StartVectorDrawing(ImageVectorOutput(0))
For i=0 To 100:AddPathCircle(Random(200),Random(200),Random(50)):VectorSourceColor(Random($ffffffff)):FillPath():Next
StopVectorDrawing()

StartVectorDrawing(CanvasVectorOutput(0))
piece(0,64,0.5,0.5,0.5,0.5)
StopVectorDrawing()

CompilerIf #PB_Compiler_OS <> #PB_OS_Web
    Repeat:Event = WaitWindowEvent():Until Event = #PB_Event_CloseWindow
CompilerEndIf
work with PB but don't work with SB
(no ClipPath() function in VectorDrawing lib )

use instead my version :
http://forums.spiderbasic.com/viewtopic.php?f=9&t=1272
(remove exemple part)

Re: Zen Puzzle

Posted: Fri Dec 15, 2017 7:54 am
by Dirk Geppert
Hi pf shadoko, thank you for your support! But how do you create the puzzle pieces, every single one of them?
How to remove the unwanted parts of the pixels for each piece of the puzzle?
You know what I mean? :-)

Re: Zen Puzzle

Posted: Fri Dec 15, 2017 12:01 pm
by pf shadoko
i add some comments :

Code: Select all

XIncludeFile("...") ;<--- my vectordrawing lib

Macro cola(col,a=$ff):(col|(a<<24)):EndMacro

Procedure piece(type,li.f,lp.f,sh.f,sd.f,sb.f,sg.f,x,y)
    Protected dx,dy
    
    Macro forme(l,sh,sd,sb,sg,dec)
        dx=lp+dec
        dy=lp+dec
        MovePathCursor(dx-li,dy-li)
        AddPathCurve(dx,dy+(-1-sh)*li, dx,dy+ (-1+sh)*li,dx+ li,dy-li)
        AddPathCurve(dx+(1+sd)*li,dy,dx+ (1-sd)*li, dy, dx+li,dy+ li)
        AddPathCurve( dx,dy+ (1+sb)*li, dx,dy+ (1-sb)*li,dx -li,dy+li)
        AddPathCurve( dx+(-1-sg)*li, dy,dx+ (-1+sg)*li, dy, dy-li,dy -li)
        ClosePath()
    EndMacro
       
    la=1
    VectorSourceColor(cola($888888)):FillVectorOutput()    
    forme(li,sh,sd,sb,sg,0):ClipPath():MovePathCursor(-x,-y):DrawVectorImage(ImageID(0))
    forme(li,sh,sd,sb,sg, la):VectorSourceColor(cola($ffffff,$44)):StrokePath(la*2)    
    forme(li,sh,sd,sb,sg,-la):VectorSourceColor(cola($000000,$44)):StrokePath(la*2)
    
EndProcedure

ex=800
ey=600
OpenWindow(0, 0, 0, ex,ey, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ImageGadget(0, 0, 0, ex,ey,0)

; image source
CreateImage(0,256,256,32,$ff888888)
StartVectorDrawing(ImageVectorOutput(0))
For i=0 To 100:AddPathCircle(Random(256),Random(256),Random(20)+20):VectorSourceColor(Random($ffffffff)):FillPath():Next
StopVectorDrawing()

limage=128          ; image width
lpiece=limage*1.2   ; piece width (+20 %) 
posx=100            ; position x inside image
posy=100            ; position y inside image

Ipiece=CreateImage(-1,lpiece,lpiece,32,#PB_Image_Transparent)
StartVectorDrawing(ImageVectorOutput(ipiece))
piece(0,limage/2,lpiece/2,0.5,0.5,0.5,0.5,posx,posy)
StopVectorDrawing()
SetGadgetState(0,ImageID(ipiece))

CompilerIf #PB_Compiler_OS <> #PB_OS_Web
    Repeat:Event = WaitWindowEvent():Until Event = #PB_Event_CloseWindow
CompilerEndIf