'-----------------------------------------------------------------------------------------'preload some gfx'-----------------------------------------------------------------------------------------Path="http://smallbasic.com/drop/soko"background=ImageList.LoadImage(Path+"/sokocuteff.png")image["A"]=ImageList.LoadImage(Path+"/sokocute0a.png")image["B"]=ImageList.LoadImage(Path+"/sokocute0b.png")image["7"]=ImageList.LoadImage(Path+"/sokocute07.png")image["6"]=ImageList.LoadImage(Path+"/sokocute06.png")image["5"]=ImageList.LoadImage(Path+"/sokocute05.png")image["4"]=ImageList.LoadImage(Path+"/sokocute04.png")image["3"]=ImageList.LoadImage(Path+"/sokocute03.png")image["2"]=ImageList.LoadImage(Path+"/sokocutegg.png")image["1"]=ImageList.LoadImage(Path+"/sokocutess.png")image["0"]=ImageList.LoadImage(Path+"/sokocute00.png")star=ImageList.LoadImage(Path+"/sokocutels.png")heart=ImageList.LoadImage(Path+"/sokocutelh.png")'GraphicsWindow.DrawText(100,100, Program.Directory)GraphicsWindow.DrawImage(background,0,0)'-----------------------------------------------------------------------------------------'init the keys'-----------------------------------------------------------------------------------------leftKey="Left"rightKey="Right"forwardKey="Up"backKey="Down"fireKey="Space"returnKey="Return"escapeKey="Escape"pauseKey="P"resetKey="R"pluskey="F1"minusKey="F2"'important var for moving the crystalskorrx=36'init any other varanimtime=1500status="start"game="gamearray"block="blockArray"true=1false=0stage=0

'move the playerIfnewmove<25Thennewmove=newmove+1xplayer=xplayer+movexyplayer=yplayer+moveyShapes.Move(player1,xplayer,yplayer)Shapes.Move(player2,xplayer,yplayer)EndIf

'blinking crystals when level is doneIffreecells=0AndClock.ElapsedMilliseconds-blinktime>350thenFori=0to(cryst-1)x1=Shapes.GetLeft(crystalimg[i])y1=Shapes.GetTop(crystalimg[i])x2=Shapes.GetLeft(crystalbnk[i])y2=Shapes.GetTop(crystalbnk[i])Shapes.Move(crystalimg[i],x2,y2)Shapes.Move(crystalbnk[i],x1,y1)EndForblink=blink+1blinktime=Clock.ElapsedMillisecondsEndIf

' end level if crystals changed color 10 times Ifblink=10thenLevelExplosion()stage=stage+1ifstage<>10thenstatus="reset"resettime=Clock.ElapsedMillisecondsGraphicsWindow.BrushColor="#3975e5"GraphicsWindow.FillRectangle(70,690,170,80)GraphicsWindow.FillRectangle(800,690,224,85)endif

' show time and fpsIfClock.ElapsedMilliseconds-endtime>1000Andstatus="game"Thengametime=Clock.ElapsedMilliseconds-starttimeGraphicsWindow.BrushColor="#3975e5"GraphicsWindow.FontName="COMIC SANS MS"GraphicsWindow.FontSize=25GraphicsWindow.FillRectangle(800,690,224,85)GraphicsWindow.BrushColor="white"tsecgesamt=Math.Round(gametime/1000)tsec=Math.Remainder(tsecgesamt,60)tmingesamt=Math.Floor(tsecgesamt/60)tmin=Math.Remainder(tmingesamt,60)thour=Math.Floor(tmingesamt/60)Iftsec<10thenstrSec=Text.Append(":0",tsec)ElsestrSec=Text.Append(":",tsec)EndIfIftmin<10thenstrMin=Text.Append("0",tmin)ElsestrMin=Text.Append("",tmin)EndIf

IfGraphicsWindow.LastKey=pluskeythenLevelExplosion()'stage = stage + 1 'uncomment this line to cheat with F1status="reset"resettime=Clock.ElapsedMillisecondsEndIf

IfGraphicsWindow.LastKey=minuskeythen'KeyUp()LevelExplosion()'stage = stage - 1 'uncomment this line to cheat with F2status="reset"resettime=Clock.ElapsedMillisecondsEndIf

'reload title after IfGraphicsWindow.LastKey=returnKeyandstatus="start"thenShapes.Animate(titleshape,140,-350,2000)Shapes.Animate(txtstart,305,1220,1600)status="reset"resettime=Clock.ElapsedMillisecondsEndIf

ifblockcode=2thenground[i][p-1]=0elseifblockcode="C"then'crystal on grasground[i][p-1]="A"elseifblockcode="D"then'crystal on wood ground[i][p-1]="B"elseground[i][p-1]=blockcodeendif

EndForEndFor

'load the water firstFori=0To15Forp=1ToText.GetLength(block[stage][i])blockcode=Text.GetSubText(block[stage][i],p,1)Ifblockcode=3Thenlevelshapes[i][p-1]=Shapes.AddImage(image[blockcode])angle=Math.GetRandomNumber(360)xv=Math.Cos(angle*0.0174)*1000yv=Math.Sin(angle*0.0174)*550Shapes.Move(levelshapes[i][p-1],xv+512,yv+350)Shapes.animate(levelshapes[i][p-1],(p-1)*50+korrx,(i)*40-0,animtime)EndifEndForEndFor

ifblockcode="C"thenlevel[i][p-1]=2elseifblockcode="D"thenlevel[i][p-1]=2elselevel[i][p-1]=blockcodeendifIfblockcode="C"Then'crystal on graslevelshapes[i][p-1]=Shapes.AddImage(image["A"])angle=Math.GetRandomNumber(360)xv=Math.Cos(angle*0.0174)*1200yv=Math.Sin(angle*0.0174)*600Shapes.Move(levelshapes[i][p-1],xv+512,yv+350)Shapes.animate(levelshapes[i][p-1],(p-1)*50+korrx,(i)*40-0,animtime)elseIfblockcode="D"Then'crystal on woodlevelshapes[i][p-1]=Shapes.AddImage(image["B"])angle=Math.GetRandomNumber(360)xv=Math.Cos(angle*0.0174)*1200yv=Math.Sin(angle*0.0174)*600Shapes.Move(levelshapes[i][p-1],xv+512,yv+350)Shapes.animate(levelshapes[i][p-1],(p-1)*50+korrx,(i)*40-0,animtime)elseIfblockcode<2Thenlevelshapes[i][p-1]=Shapes.AddImage(image[blockcode])angle=Math.GetRandomNumber(360)xv=Math.Cos(angle*0.0174)*1200yv=Math.Sin(angle*0.0174)*600Shapes.Move(levelshapes[i][p-1],xv+512,yv+350)Shapes.Animate(levelshapes[i][p-1],(p-1)*50+korrx,(i)*40-0,animtime)ElseIfblockcode=2Thenlevelshapes[i][p-1]=Shapes.AddImage(image["0"])angle=Math.GetRandomNumber(360)xv=Math.Cos(angle*0.0174)*1200yv=Math.Sin(angle*0.0174)*600Shapes.Move(levelshapes[i][p-1],xv+512,yv+350)Shapes.animate(levelshapes[i][p-1],(p-1)*50+korrx,(i)*40-0,animtime)endifEndForEndFor

'tried to fix strange shapes.animate behaviors if there are too many shapes flying around - no real success... loopdelay=(1600)*loopmssecnum=0While(num<loopdelay)num=num+1endwhile

'load lower player shape first. it has to be behind the walls Shapes.Move(player1,(posx)*50+korrx,(posy)*40-0)

LoadShadow()'------------------------------------------------------------'load the wallsFori=0To15Forp=1ToText.GetLength(block[stage][i])blockcode=Text.GetSubText(block[stage][i],p,1)Ifblockcode>=4Thenlevelshapes[i][p-1]=Shapes.AddImage(image[blockcode])angle=Math.GetRandomNumber(360)xv=Math.Cos(angle*0.0174)*1000yv=Math.Sin(angle*0.0174)*550Shapes.Move(levelshapes[i][p-1],xv+512,yv+350)Shapes.animate(levelshapes[i][p-1],(p-1)*50+korrx,(i)*40-0,animtime)EndifEndForEndFor

'load players face at last. It has always to be in front of the wallsplayer2=Shapes.AddImage(Path+"/sokocutep1.png")Shapes.Move(player2,(posx)*50+korrx,(posy)*40-0)xplayer=Shapes.GetLeft(player1)yplayer=Shapes.GetTop(player1)

block[9][0]=" AAAAA A A AAAA "block[9][1]=" A A A A "block[9][2]=" A AAAAA AAA "block[9][3]=" A A A A "block[9][4]=" A A A AAAA "block[9][5]=" "block[9][6]=" AAAA A A AAA "block[9][7]=" A AA A A A "block[9][8]=" AAA A A A A A "block[9][9]=" A A AA A A "block[9][10]=" AAAA A A AAA "block[9][11]=" "block[9][12]=" "block[9][13]=" 4444444444444444 "block[9][14]=" 40X0020000000104 "block[9][15]=" 4444444444444444 "