;MR Blobs ;MR 21.04.2002 .TOP Graphics 640,480,16,1 SetBuffer BackBuffer() ;############################################################################################################ Local BMPFontName$="BMPFonts\Sage28" ;Sage30 Type bmpfont_type Field x,y,w End Type Dim bmpfontxyw.bmpfont_type (255) Local i For i=0 To 255 bmpfontxyw.bmpfont_type(i)=New bmpfont_type Next Global bmpfont_img=LoadImage(BMPFontName$+".bmp") MaskImage bmpfont_img,255,0,255 Local fh fh=ReadFile(BMPFontName$+".xyw") If fh Then For i=0 To 255 bmpfontxyw(i)\x=ReadInt(fh) bmpfontxyw(i)\y=ReadInt(fh) bmpfontxyw(i)\w=ReadInt(fh) Next CloseFile fh EndIf ;############################################################################################################ ;------------------------------------------------------- Font mFont=LoadFont("Tahoma",14,1) SetFont mFont ;############################################################################################################ ;------------------------------------------------------- Grafik Global hg=LoadImage ("Hintergrund.bmp") MaskImage hg,255,0,255 Global fg=LoadImage ("Spielfeld.bmp") MaskImage fg,255,0,255 Global img_schatten=LoadImage ("Schatten.bmp") MaskImage img_schatten,255,0,255 Global img_bl=LoadImage ("AlleBlobs.bmp") MaskImage img_bl,255,0,255 Global img_minibl=LoadImage ("MiniBlobs.bmp") MaskImage img_minibl,255,0,255 Global ti=LoadImage ("TitelBild.bmp") MaskImage ti,255,0,255 MidHandle ti Local tiw1#,tiw2# ;spielerei ;--------------------------------------- ;SetBuffer ImageBuffer(hg) ;DrawImage fg,0,0 ;DrawImage lb,GraphicsWidth()/2-ImageWidth(lb)/2,32*5 SetBuffer BackBuffer() ;SetBuffer FrontBuffer() ;------------------------------------------------------- SOUND .Sound Global snd_move =LoadSound ("move.wav" ) Global snd_drehen =LoadSound ("drehen.wav" ) Global snd_verbinden =LoadSound ("verbinden.wav" ) Global snd_auseinander1=LoadSound ("auseinander1.wav") Global snd_auseinander2=LoadSound ("auseinander2.wav") Global snd_player1 =LoadSound ("player1.wav" ) Global snd_player2 =LoadSound ("player2.wav" ) Global snd_atakke =LoadSound ("atakke.wav" ) Global snd_level =LoadSound ("level.wav" ) Global snd_gameover =LoadSound ("gameover.wav" ) SoundVolume snd_move,0.5 ;------------------------------------------------------- Types Type SplashType Field xs,ys ;Spielfeld Field p ;Spieler Field xc,yc ;von da aus Field c ;Counter Field r ;Radius Field Blob ;1-5 Field w# ;rotation Field wsp# ;rotation speed :-) Field mb ;0-2 MiniBlobs größe End Type ;------------------------------------------------------- Types Type SplashTypeFX Field xs,ys ;Spielfeld Field p ;Spieler Field xc,yc ;von da aus Field c ;Counter Field r ;Radius Field Blob ;1-5 Field w# ;rotation Field wsp# ;rotation speed :-) Field mb ;0-2 MiniBlobs größe End Type ;------------------------------------------------------- Global Splash.SplashType Global SplashFX.SplashTypeFX Dim Blobs (128,100,2) ; Step 2 (Blobs 1-5) , Level 1-100 , Spieler 1-2 Dim SpielerHiScore (2) ; Spieler 1-2 testen 0 oder True Dim SpielerName$ (2) ; Spieler 1-2 Dim SpielerPunkte(2) ; Spieler 1-2 Dim SpielerBlobs (2) ; Spieler 1-2 eingesammelter Blobs Dim SpielerLevel (2) ; Spieler 1-2 Dim SpielerXB1 (2) ; Spieler 1-2 Dim SpielerYB1 (2) ; Spieler 1-2 Dim SpielerBlob1 (2) ; Spieler 1-2 Dim SpielerBlob1absetzen (2) ; Spieler 1-2 Dim SpielerXB2 (2) ; Spieler 1-2 Dim SpielerYB2 (2) ; Spieler 1-2 Dim SpielerBlob2 (2) ; Spieler 1-2 Dim SpielerBlob2absetzen (2) ; Spieler 1-2 Dim SpielerNextBlob (2) ; Spieler 1-2 Dim SpielerGameOver (2) ; Spieler 1-2 Dim SpielerMoreSpeed(2) ; Spieler 1-2 Dim SpielerFallCount(2) ; Spieler 1-2 Dim SpielerFallImpulse(2) ; Spieler 1-2 Dim SpielerPause (2) ; Spieler 1-2 ;Pause Dim SpielerAnhalten (2) ; Spieler 1-2 ;Wenn Blobs fallen bleibt der Spieler stehen :-) Local a$,b$ SetBuffer FrontBuffer() DrawImage hg,0,0 Color 0,255,0 bmpText 4,0,"Name Spieler 1" Locate 4,bmpTextHeight() a$=Trim(Input()) If Len(a$)=0 Then a$="Spieler 1" bmpText 4,bmpTextHeight()*2,"Name Spieler 2" Locate 4,bmpTextHeight()*3 b$=Trim(Input()) If Len(b$)=0 Then b$="Spieler 2" SetBuffer BackBuffer() SpielerName$(1)=a$ SpielerName$(2)=b$ ; (7,16,2) ; X=1-6 , Y=3-15 , Spieler 1-2 Dim SpielFeld (7,16,2) Dim SpielFeld_TMP(7,16) Global BlobsTMP=0 ;Zum zählen der zusammenhängenden Blobs NewBlobs ;------------------------------------------------------- Global Blink =0 Global BlinkPL=0 Global BlinkL =0 Global BlinkCount =0 Global BlinkCountPL=0 Global BlinkCountL =0 Global Impulse_fallen=0 Global Impulse_fallen_Count=0 Global Sync=0 ;------------------------------------------------------- hx=0 hy=0 SpielerGameOver(1)=True SpielerGameOver(2)=True SpielFeld_RND 1 SpielFeld_RND 2 SpielerLevel(1)=1 SpielerLevel(2)=1 SpielerNextBlob(1)=0 SpielerNextBlob(2)=0 ;------------------------------------------------------- Type HiScoreType Field Name$ Field Punkte Field Blobs End Type Dim HiScore.HiScoreType (10) ;Local i For i=1 To 10 HiScore.HiScoreType(i) =New HiScoreType Next LoadHiScore ;------------------------------------------------------- FlushKeys .MainLoop Repeat Local x,y Sync=MilliSecs() Impulse_fallen_Count=Impulse_fallen_Count+1 : If Impulse_fallen_Count=16 Then Impulse_fallen_Count=0:Impulse_fallen=1 BlinkCount =BlinkCount +1 : If BlinkCount =32 Then BlinkCount =0:Blink =1-Blink BlinkCountPL =BlinkCountPL +1 : If BlinkCountPL =16 Then BlinkCountPL =0:BlinkPL=1-BlinkPL ;Spielerblinken BlinkCountL =BlinkCountL +1 : If BlinkCountL =96 Then BlinkCountL =0:BlinkL =1-BlinkL ;Hiscore & Beschriftung If SpielerGameOver(1)=True And SpielerGameOver(2)=True Then x=Sin(tiw1)*16+Cos(tiw2)*16 y=Cos(tiw1)*16+Sin(tiw2)*16 DrawImage hg,hx+x,hy+y Else DrawImage hg,hx,hy EndIf SpielFeldSchatten If KeyHit(2) And SpielerGameOver(1)=True Then PlayerStart 1 : PlaySound snd_player1 ;Taste 1 If KeyHit(3) Then ;Taste 2 If SpielerGameOver(1)=True And SpielerGameOver(2)=True Then NewBlobs : PlayerStart 1 : PlayerStart 2 :PlaySound snd_atakke If SpielerGameOver(1)=False And SpielerGameOver(2)=True Then PlayerStart 2 : PlaySound snd_player2 EndIf If KeyHit(4) And SpielerGameOver(2)=True Then PlayerStart 2 : PlaySound snd_player2;Taste 3 ;--------------------------------------------------------------- Pause If KeyHit(59) And SpielerGameOver(1)=0 Then ;Taste F1 SpielerPause(1)=1-SpielerPause(1) FlushKeys EndIf If KeyHit(60) And SpielerGameOver(2)=0 Then ;Taste F2 SpielerPause(2)=1-SpielerPause(2) FlushKeys EndIf ;--------------------------------------------------------------- Player 1 If SpielerGameOver(1)=0 And SpielerPause(1)=0 Then If KeyHit(30) Then ;A Left PlayerTurnLeft 1 EndIf If KeyHit(31) Then ;S Right PlayerTurnRight 1 EndIf If KeyHit(36) Then ;J PlayerMove -1,0,1 EndIf If KeyHit(38) Then ;L PlayerMove 1,0,1 EndIf If KeyDown(37) Then ;K schneller fallen mit Punkten ! SpielerMoreSpeed(1)=1 Else SpielerMoreSpeed(1)=0 EndIf EndIf ;--------------------------------------------------------------- Player 2 If SpielerGameOver(2)=0 And SpielerPause(2)=0 Then If KeyHit(82) Then ; Key 0 PlayerTurnLeft 2 EndIf If KeyHit(83) Then ; Key , PlayerTurnRight 2 EndIf If KeyHit(203) Then ; Key Left PlayerMove -1,0,2 EndIf If KeyHit(205) Then ; Key Right PlayerMove 1,0,2 EndIf If KeyDown(208) Then ; Key Down schneller fallen mit Punkten ! SpielerMoreSpeed(2)=1 Else SpielerMoreSpeed(2)=0 EndIf EndIf ;--------------------------------------------------------------- Local XP_Offs=0 For p=1 To 2 If SpielerBlob1(p)=0 And SpielerBlob2(p)=0 Then PlayerGetNextBlob p If p=1 Then XP_Offs=0 If p=2 Then XP_Offs=12*32 SpielerFallCount(p)=SpielerFallCount(p)+1 SpielerFallImpulse(p)=0 If SpielerMoreSpeed(p)=0 If SpielerFallCount(p)=>16-SpielerLevel(p)/2 Then SpielerFallCount(p)=0:SpielerFallImpulse(p)=1 Else If SpielerFallCount(p)=> 8 Then SpielerFallCount(p)=0:SpielerFallImpulse(p)=1 EndIf If SpielerFallImpulse(p)=1 And SpielerPause(p)=0 And SpielerAnhalten(p)=0 Then PlayerMove 0,1,p EndIf If Impulse_fallen=1 Then ;Blobs fallen laßen If SpielFeld_fallen(p)=True Then ;Blobs gefallen SpielerAnhalten(p)=True Else If SpielerAnhalten(p)=True Then SpielFeld_loeschen p SpielerAnhalten(p)=False EndIf EndIf EndIf ;Schatten If SpielerBlob1(p)>0 Then DrawImageRect img_bl,XP_Offs+SpielerXB1(p)*32+8,SpielerYB1(p)*32-2*32+8,SpielerBlob1(p)*32-32,2*32,32,32 If SpielerBlob2(p)>0 Then DrawImageRect img_bl,XP_Offs+SpielerXB2(p)*32+8,SpielerYB2(p)*32-2*32+8,SpielerBlob2(p)*32-32,2*32,32,32 SpielFeld_zeigen p SpielFeld_testen p ;Platz Blasen erzeugen :-) ;If sichtbar ... then ! If SpielerBlob1(p)>0 Then DrawImageRect img_bl,XP_Offs+SpielerXB1(p)*32,SpielerYB1(p)*32-2*32,SpielerBlob1(p)*32-32,BlinkPL*32,32,32 If SpielerBlob2(p)>0 Then DrawImageRect img_bl,XP_Offs+SpielerXB2(p)*32,SpielerYB2(p)*32-2*32,SpielerBlob2(p)*32-32, 0,32,32 Next DrawImage fg,0,0 If SpielerGameOver(1)=True And SpielerGameOver(2)=True Then If BlinkL=1 Then bmpText 32*10,32*14+16,"Drücke 2 für Start",True,True bmpText 32*10,32* 4+16,"N = Spieler Namen",True,True bmpText 32*10,32*10+16,"F1 Pause Spieler 1",True,True bmpText 32*10,32*11+16,"F2 Pause Spieler 2",True,True EndIf EndIf If SpielerGameOver(1)=0 Or SpielerGameOver(2)=0 Then bmpText GraphicsWidth()/2,32*11+16,"Punkte",True,True ;Einmal reicht :-) EndIf For p=1 To 2 If p=1 Then XP_Offs=0 If p=2 Then XP_Offs=12*32 If SpielerGameOver(p)=0 Or (SpielerGameOver(p)=True And BlinkL=1) Then bmpText XP_Offs+32*4,32*14+16,SpielerName$(p),True,True EndIf If SpielerGameOver(p)=True And BlinkL=0 Then If p=1 Then bmpText XP_Offs+32*4,32*14+16,"Drücke 1 für Start",True,True If p=2 Then bmpText XP_Offs+32*4,32*14+16,"Drücke 3 für Start",True,True EndIf If (SpielerPause(p)=1 And BlinkL=1 And p=1) Or (SpielerPause(p)=1 And BlinkL=0 And p=2) Then bmpText XP_Offs+32*4,16,"PAUSE",True,True EndIf If SpielerGameOver(p)=True Then If BlinkL=0 Then bmpText XP_Offs+32*4, 16 , "Spiel zu Ende",True,True PlayerHiScore p Else Color 0,255,255 If p=1 Then bmpText XP_Offs+32*4,16,"Tasten AS JKL",True,True If p=2 Then bmpText XP_Offs+32*4,16,"Tasten 0, <^>",True,True EndIf EndIf ZeigeSpielerPunkte p ZeigeSpielerBlobs p ZeigeSpielerLevel p ZeigeSpielerNextBlobs p Next bmpText GraphicsWidth()/2,32*5+16,"Level",True,True bmpText GraphicsWidth()/2,32*7+16,"Blobs",True,True Zerplatzen_zeigen ZerplatzenFX_zeigen If SpielerGameOver(1)=True And SpielerGameOver(2)=True Then x=Sin(tiw1)*64+Cos(tiw2)*32 y=Cos(tiw1)*8+Sin(tiw2)*8 tiw1=tiw1+2 :If tiw1>360 Then tiw1=tiw1-360 tiw2=tiw2+3 :If tiw2< 0 Then tiw2=tiw2+360 If BlinkL=0 Then TopTen x+GraphicsWidth()/2,y+GraphicsHeight()/4-48+ImageHeight(ti)/2+16 DrawImage ti,x+GraphicsWidth()/2,y+GraphicsHeight()/4-40 EndIf EndIf While Abs(MilliSecs()-Sync)<20 Wend Impulse_fallen=0 Flip ;---------------------------------------------------------------------- If KeyHit(49) Then ;Taste N FlushKeys SetBuffer FrontBuffer() DrawImage hg,0,0 Color 0,255,0 bmpText 4,0,"Name Spieler 1" Locate 4,bmpTextHeight() a$=Trim(Input()) If Len(a$)=0 Then a$="Spieler 1" bmpText 4,bmpTextHeight()*2,"Name Spieler 2" Locate 4,bmpTextHeight()*3 b$=Trim(Input()) If Len(b$)=0 Then b$="Spieler 2" SetBuffer BackBuffer() SpielerName$(1)=a$ SpielerName$(2)=b$ FlushKeys EndIf ;---------------------------------------------------------------------- If KeyHit(1) Then ;ESCAPE FlushKeys If SpielerGameOver(1)=False Then SpielerGameOver(1)=True : SpielerPause(1)=0 : SpielerHiScore(1)=True ElseIf SpielerGameOver(2)=False Then SpielerGameOver(2)=True : SpielerPause(2)=0 : SpielerHiScore(2)=True ElseIf SpielerGameOver(1)=True And SpielerGameOver(1)=True Then SpielerPause(1)=0 : SpielerPause(2)=0 :SpielerHiScore(1)=True : SpielerHiScore(2)=True Exit EndIf EndIf ;---------------------------------------------------------------------- If KeyHit(68) Then ;F10 SaveBuffer FrontBuffer(),"ScreenShot.bmp" EndIf ;---------------------------------------------------------------------- Forever ;---------------------------------------------------------------------- ENDE SPEZIAL :-) SaveHiScore SetBuffer FrontBuffer() Color 0,0,0 For y=0 To GraphicsHeight()-1 Step 2 Line 0,GraphicsHeight()-1-y,GraphicsWidth()-1,GraphicsHeight()-1-y Line 0,y,GraphicsWidth()-1,y VWait Next SetBuffer BackBuffer() Cls End ;############################################################################################################ Function TopTen(x,y) Local w1=0,w2=0,w3=0,w4=0 For i=1 To 10 xx$=Str(i) If bmpTextWidth(xx$)>w1 Then w1=bmpTextWidth(xx$) Next w1=w1+16 For i=1 To 10 xx$=HiScore(i)\Name$ If bmpTextWidth(xx$)>w2 Then w2=bmpTextWidth(xx$) Next w2=w2+16 For i=1 To 10 xx$=Str(HiScore(i)\Punkte) If bmpTextWidth(xx$)>w3 Then w3=bmpTextWidth(xx$) Next w3=w3+16 For i=1 To 10 xx$=Str(HiScore(i)\Blobs) If bmpTextWidth(xx$)>w4 Then w4=bmpTextWidth(xx$) Next Local w=(w1+w2+w3+w4) x=x-w/2 ;y=y-(11*32)/2 ;CenterY ;Color 0,0,0 ;Rect x-4,y-16,w+8,11*32,True Color 255,255,0 Rect x-4,y-16,w+8,11*32,0 bmpText x+w/2,y,"Die besten Spieler",True,True For i=1 To 10 xx$=Str(i) bmpText x ,y+i*32,xx$ ,0,True bmpText x+w1 ,y+i*32,HiScore(i)\Name$ ,0,True bmpText x+w1+w2 ,y+i*32,HiScore(i)\Punkte,0,True bmpText x+w1+w2+w3,y+i*32,HiScore(i)\Blobs ,0,True Next End Function ;############################################################################################################ Function PlayerHiScore(p) ;MR 21.04.2002 If SpielerHiScore(p)=0 Then Return SpielerHiScore(p)=0 Local Punkte=SpielerPunkte(p) Local Blobs =SpielerBlobs (p) Local Name$ =SpielerName$ (p) Local i,i1 For i=1 To 10 If Punkte => HiScore(i)\Punkte And Blobs=>HiScore(i)\Blobs Then If i<10 For i1=10-1 To i Step -1 HiScore(i1+1)\Name$ =HiScore(i1)\Name$ HiScore(i1+1)\Punkte=HiScore(i1)\Punkte HiScore(i1+1)\Blobs =HiScore(i1)\Blobs Next EndIf HiScore(i)\Name$ =Name$ HiScore(i)\Punkte=Punkte HiScore(i)\Blobs =Blobs Exit EndIf Next ;Abfragen End Function ;############################################################################################################ Function SaveHiScore() Local fh fh=WriteFile ("HiScore.TXT") WriteString fh,"Blobs HiScore Liste !" Local i For i=1 To 10 WriteString fh,HiScore(i)\Name WriteInt fh,HiScore(i)\Punkte WriteInt fh,HiScore(i)\Blobs Next CloseFile fh End Function ;############################################################################################################ Function LoadHiScore() Local fh Local a$ Local i If FileSize("HiScore.TXT")=0 Then For i=1 To 10 HiScore(i)\Name$="--------" HiScore(i)\Blobs=0 HiScore(i)\Punkte=0 Next Return EndIf fh=ReadFile ("HiScore.TXT") a$=ReadString (fh) For i=1 To 10 HiScore(i)\Name=ReadString (fh) HiScore(i)\Punkte=ReadInt (fh) HiScore(i)\Blobs=ReadInt (fh) Next CloseFile fh ;TEST !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! <--- ;For i=4 To 10 ; HiScore(i)\Name$="--------" ; HiScore(i)\Blobs=0 ; HiScore(i)\Punkte=0 ;Next End Function ;############################################################################################################ Function PlayerStart(p) SpielFeld_FX p SpielFeld_CLR p SpielerLevel(p)=1 SpielerPunkte(p)=0 SpielerBlobs(p)=0 SpielerHiScore(p)=0 SpielerMoreSpeed(p)=0 SpielerNextBlob(p)=0 PlayerGetNextBlob p SpielerGameOver(p)=False SpielerPause(p)=0 SpielerAnhalten(p)=0 End Function ;############################################################################################################ Function PlayerTurnLeft (p) If SpielerBlob1(p)=0 Then Return If SpielerXB1(p)=SpielerXB2(p) And SpielerXB1(p)=1 And (SpielerYB2(p)-SpielerYB1(p)=-1) Then PlayerMove( 1,0,p) ;An Wand If SpielerXB1(p)=SpielerXB2(p) And SpielerXB1(p)=6 And (SpielerYB2(p)-SpielerYB1(p)= 1) Then PlayerMove(-1,0,p) ;An Wand If SpielerBlob1(p)=0 Then Return Local x1,y1 Local x2,y2 Local xd,yd Local xn,yn x1=SpielerXB1(p) y1=SpielerYB1(p) x2=SpielerXB2(p) y2=SpielerYB2(p) xd=x1-x2 yd=y1-y2 xd=-xd yd=-yd Local ok=0 If xd= 0 And yd=-1 Then xn=-1 : yn= 0 : If ImSpielfeld(x1+xn,y1+yn) Then If SpielFeld(x1+xn,y1+yn,p)=0 Then ok=1 If xd= 1 And yd= 0 Then xn= 0 : yn=-1 : If ImSpielfeld(x1+xn,y1+yn) Then If SpielFeld(x1+xn,y1+yn,p)=0 Then ok=1 If xd= 0 And yd= 1 Then xn= 1 : yn= 0 : If ImSpielfeld(x1+xn,y1+yn) Then If SpielFeld(x1+xn,y1+yn,p)=0 Then ok=1 If xd=-1 And yd= 0 Then xn= 0 : yn= 1 : If ImSpielfeld(x1+xn,y1+yn) Then If SpielFeld(x1+xn,y1+yn,p)=0 Then ok=1 If ok=1 Then PlaySound snd_drehen SpielerXB2(p)=SpielerXB1(p)+xn SpielerYB2(p)=SpielerYB1(p)+yn If SpielerYB2(p)=15 Then PlayerBlob2absetzten p EndIf End Function ;############################################################################################################ Function PlayerTurnRight (p) If SpielerBlob1(p)=0 Then Return If SpielerXB1(p)=SpielerXB2(p) And SpielerXB1(p)=1 And (SpielerYB2(p)-SpielerYB1(p)= 1) Then PlayerMove( 1,0,p) ;An Wand Tiefer If SpielerXB1(p)=SpielerXB2(p) And SpielerXB1(p)=6 And (SpielerYB2(p)-SpielerYB1(p)=-1) Then PlayerMove(-1,0,p) ;An Wand Höher If SpielerBlob1(p)=0 Then Return Local x1,y1 Local x2,y2 Local xd,yd Local xn,yn x1=SpielerXB1(p) y1=SpielerYB1(p) x2=SpielerXB2(p) y2=SpielerYB2(p) xd=x1-x2 yd=y1-y2 xd=-xd yd=-yd Local ok=0 If xd= 0 And yd=-1 Then xn= 1 : yn= 0 : If ImSpielfeld(x1+xn,y1+yn) Then If SpielFeld(x1+xn,y1+yn,p)=0 Then ok=1 If xd= 1 And yd= 0 Then xn= 0 : yn= 1 : If ImSpielfeld(x1+xn,y1+yn) Then If SpielFeld(x1+xn,y1+yn,p)=0 Then ok=1 If xd= 0 And yd= 1 Then xn=-1 : yn= 0 : If ImSpielfeld(x1+xn,y1+yn) Then If SpielFeld(x1+xn,y1+yn,p)=0 Then ok=1 If xd=-1 And yd= 0 Then xn= 0 : yn=-1 : If ImSpielfeld(x1+xn,y1+yn) Then If SpielFeld(x1+xn,y1+yn,p)=0 Then ok=1 If ok=1 Then PlaySound snd_drehen SpielerXB2(p)=SpielerXB1(p)+xn SpielerYB2(p)=SpielerYB1(p)+yn If SpielerYB2(p)=15 Then PlayerBlob2absetzten p EndIf End Function ;############################################################################################################ Function ImSpielfeld(x,y) ;X 1-6 ;Y ;1 unsichtbar ;2 unsichtbar ;3 ;... ;15 If x< 1 Or x> 6 Then Return 0 If y< 3 Or y>15 Then Return 0 Return True End Function ;############################################################################################################ Function PlayerMove(x,y,p) If SpielerGameOver(p)=True Then Return Local move_sound=0 ;------------------------------------------------------------------------- X If SpielerBlob1(p)=>1 Then ;wenn noch da :-) If SpielFeld(SpielerXB1(p)-1,SpielerYB1(p),p)=0 And (SpielFeld(SpielerXB2(p)-1,SpielerYB2(p),p)=0 Or SpielerBlob2(p)=0) And x=-1 Then If SpielerXB1(p)>1 And SpielerXB2(p)>1 Then move_sound=1 SpielerXB1(p)=SpielerXB1(p)-1 SpielerXB2(p)=SpielerXB2(p)-1 SpielerFallCount(p)=0 ;Damit man sich weiter bewegen kann EndIf EndIf If SpielFeld(SpielerXB1(p)+1,SpielerYB1(p),p)=0 And (SpielFeld(SpielerXB2(p)+1,SpielerYB2(p),p)=0 Or SpielerBlob2(p)=0) And x= 1 Then If SpielerXB1(p)<6 And SpielerXB2(p)<6 Then move_sound=1 SpielerXB1(p)=SpielerXB1(p)+1 SpielerXB2(p)=SpielerXB2(p)+1 SpielerFallCount(p)=0 ;Damit man sich weiter bewegen kann EndIf EndIf EndIf ;------------------------------------------------------------------------- Y If SpielerYB1(p)>SpielerYB2(p) Then If PlayerMoveBlob1Y(y,p) Then move_sound=1 If PlayerMoveBlob2Y(y,p) Then move_sound=1 Else If PlayerMoveBlob2Y(y,p) Then move_sound=1 If PlayerMoveBlob1Y(y,p) Then move_sound=1 EndIf If move_sound=1 Then PlaySound snd_move End Function ;############################################################################################################ Function PlayerMoveBlob1Y(y,p) If SpielerBlob1absetzen(p)=True Then Return 0 Local verbinden=0 Local moved=0 ;------------------------------------------------------------------------- If SpielerBlob1(p)=>1 Then ;wenn noch da :-) If y=1 Then If SpielFeld(SpielerXB1(p),SpielerYB1(p)+1,p) =0 Then If SpielerYB1(p)<15 Then If SpielerMoreSpeed(p)=1 Then SpielerPunkte(p)=SpielerPunkte(p)+1 ;<--- Punkte +++ moved=1 SpielerYB1(p)=SpielerYB1(p)+1 If SpielerYB1(p)=15 Then SpielerBlob1absetzen(p)=True EndIf Else SpielerBlob1absetzen(p)=True EndIf EndIf EndIf ;------------------------------------------------------------------------- PlayerBlob1absetzten p ;------------------------------------------------------------------------- Return moved End Function Function PlayerMoveBlob2Y(y,p) If SpielerBlob2absetzen(p)=True Then Return 0 Local moved=0 ;------------------------------------------------------------------------- If SpielerBlob2(p)=>1 Then ;wenn noch da :-) If y=1 Then If SpielFeld(SpielerXB2(p),SpielerYB2(p)+1,p) =0 Then If SpielerYB2(p)<15 Then moved=1 SpielerYB2(p)=SpielerYB2(p)+1 If SpielerYB2(p)=15 Then SpielerBlob2absetzen(p)=True EndIf Else SpielerBlob2absetzen(p)=True EndIf EndIf EndIf ;------------------------------------------------------------------------- PlayerBlob2absetzten p ;------------------------------------------------------------------------- Return moved End Function ;############################################################################################################ Function PlayerBlob1absetzten (p) Local verbinden=0 If SpielerBlob1absetzen(p)=True Then SpielerBlob1absetzen(p)=0 If SpielerYB1(p)=2 Then SpielerGameOver(p)=True ;GameOVER SpielerHiScore(p)=True PlaySound snd_gameover EndIf If SpielFeld(SpielerXB1(p)-1,SpielerYB1(p) ,p)=SpielerBlob1(p) Then verbinden=True If SpielFeld(SpielerXB1(p) ,SpielerYB1(p)+1,p)=SpielerBlob1(p) Then verbinden=True If SpielFeld(SpielerXB1(p)+1,SpielerYB1(p) ,p)=SpielerBlob1(p) Then verbinden=True SpielFeld(SpielerXB1(p),SpielerYB1(p),p)=SpielerBlob1(p) SpielerBlob1(p)=0 If verbinden=True Then PlaySound snd_verbinden Else PlaySound snd_move EndIf End Function ;############################################################################################################ Function PlayerBlob2absetzten (p) Local verbinden=0 If SpielerBlob2absetzen(p)=True Then SpielerBlob2absetzen(p)=0 If SpielFeld(SpielerXB2(p)-1,SpielerYB2(p) ,p)=SpielerBlob2(p) Then verbinden=True If SpielFeld(SpielerXB2(p) ,SpielerYB2(p)+1,p)=SpielerBlob2(p) Then verbinden=True If SpielFeld(SpielerXB2(p)+1,SpielerYB2(p) ,p)=SpielerBlob2(p) Then verbinden=True SpielFeld(SpielerXB2(p),SpielerYB2(p),p)=SpielerBlob2(p) SpielerBlob2(p)=0 If verbinden=True Then PlaySound snd_verbinden Else PlaySound snd_move EndIf End Function ;############################################################################################################ Function PlayerGetNextBlob(p) SpielerXB2(p)=3 SpielerYB2(p)=1 SpielerXB1(p)=3 SpielerYB1(p)=2 SpielFeld_loeschen p SpielerBlob1absetzen(p)=0 SpielerBlob2absetzen(p)=0 SpielerBlob1(p)=Blobs(SpielerNextBlob(p) ,SpielerLevel(p),p) SpielerBlob2(p)=Blobs(SpielerNextBlob(p)+1,SpielerLevel(p),p) SpielerNextBlob(p)=SpielerNextBlob(p)+2 If SpielerNextBlob(p)+1>128 Then SpielerNextBlob(p)=0 SpielFeld_FX p SpielFeld_CLR p SpielerLevel(p)=SpielerLevel(p)+1 : PlaySound snd_level ;<--- neuer Level + If SpielerLevel(p)>99 Then SpielerLevel(p)=99 SpielerPunkte(p)=SpielerPunkte(p)+1000 ;<--- Punkte +++ EndIf End Function ;############################################################################################################ Function ZeigeSpielerPunkte(p) Color 255,255,0 If p=1 Then bmpText 32*8 ,32*13+16,"P1:"+SpielerPunkte(p),0,True If p=2 Then bmpText 32*8+16 ,32*12+16,"P2:"+SpielerPunkte(p),0,True ;DrawImage za,32*8-16,32*13 ;PL1 ;DrawImage za,32*8 ,32*12 ;PL2 End Function ;############################################################################################################ Function ZeigeSpielerNextBlobs(p) If SpielerGameOver(p)=True Then Return Local XP_Offs If p=1 Then XP_Offs=32*8 If p=2 Then XP_Offs=32*11 DrawImageRect img_bl,XP_Offs,32*2,Blobs(SpielerNextBlob(p)+1,SpielerLevel(p),p)*32-32,0,32,32 DrawImageRect img_bl,XP_Offs,32*3,Blobs(SpielerNextBlob(p) ,SpielerLevel(p),p)*32-32,0,32,32 End Function ;############################################################################################################ Function ZeigeSpielerBlobs(p) Color 255,255,0 If p=1 Then bmpText 32*8,32*8+16,"P1:"+SpielerBlobs(p),0,True If p=2 Then bmpText 32*8,32*9+16,"P2:"+SpielerBlobs(p),0,True End Function ;############################################################################################################ Function ZeigeSpielerLevel(p) Color 255,255,0 If p=1 Then bmpText 32*8 ,32*6+16,"P1:"+SpielerLevel(p),0,True If p=2 Then bmpText 32*8+32*2,32*6+16,"P2:"+SpielerLevel(p),0,True End Function ;############################################################################################################ Function NewBlobs() SeedRnd MilliSecs() Local i,blob Local l For l=0 To 100 ;Level 1-100 For i=0 To 128 Blob=Rnd(1,5) Blobs(i,l,1)=Blob Blobs(i,l,2)=Blob Next Next End Function ;############################################################################################################ Function SpielFeld_RND(p) ;Player 1-2 Local x,y ;1 unsichtbar ;2 unsichtbar ;3 ;... ;15 ;Damit sie einmal fallen :-))) For x=1 To 6 For y=10 To 14 SpielFeld(x,y,p)=Rnd(1,5) Next Next End Function ;############################################################################################################ Function SpielFeld_CLR(p) ;Player 1-2 Local x,y ;1 unsichtbar ;2 unsichtbar ;3 ;... ;15 For x=1 To 6 For y=1 To 15 ;unsichtbare Felder auch löschen !!! SpielFeld(x,y,p)=0 Next Next End Function ;############################################################################################################ Function SpielFeld_zeigen(p) ;Player 1-2 Local x,y Local Blob ;1-5 Local Y_Offs=0 ;1 unsichtbar ;2 unsichtbar ;3 ;... ;15 Local XP_Offs=0 If p=1 Then XP_Offs=0 If p=2 Then XP_Offs=12*32 For x=1 To 6 For y=3 To 15 Blob=SpielFeld(x,y,p) Y_Offs=0 If SpielFeld(x-1,y,p)<>Blob And SpielFeld(x+1,y,p)<>Blob And SpielFeld(x,y-1,p)<>Blob And SpielFeld(x,y+1,p)<>Blob Then Y_Offs= 0 If SpielFeld(x-1,y,p) =Blob And SpielFeld(x+1,y,p)<>Blob And SpielFeld(x,y-1,p)<>Blob And SpielFeld(x,y+1,p)<>Blob Then Y_Offs= 6 If SpielFeld(x-1,y,p)<>Blob And SpielFeld(x+1,y,p) =Blob And SpielFeld(x,y-1,p)<>Blob And SpielFeld(x,y+1,p)<>Blob Then Y_Offs= 7 If SpielFeld(x-1,y,p) =Blob And SpielFeld(x+1,y,p) =Blob And SpielFeld(x,y-1,p)<>Blob And SpielFeld(x,y+1,p)<>Blob Then Y_Offs= 8 If SpielFeld(x-1,y,p)<>Blob And SpielFeld(x+1,y,p)<>Blob And SpielFeld(x,y-1,p)<>Blob And SpielFeld(x,y+1,p) =Blob Then Y_Offs= 9 If SpielFeld(x-1,y,p)<>Blob And SpielFeld(x+1,y,p)<>Blob And SpielFeld(x,y-1,p) =Blob And SpielFeld(x,y+1,p)<>Blob Then Y_Offs=10 If SpielFeld(x-1,y,p)<>Blob And SpielFeld(x+1,y,p)<>Blob And SpielFeld(x,y-1,p) =Blob And SpielFeld(x,y+1,p) =Blob Then Y_Offs=11 If SpielFeld(x-1,y,p)<>Blob And SpielFeld(x+1,y,p) =Blob And SpielFeld(x,y-1,p) =Blob And SpielFeld(x,y+1,p)<>Blob Then Y_Offs=12 If SpielFeld(x-1,y,p)<>Blob And SpielFeld(x+1,y,p) =Blob And SpielFeld(x,y-1,p)<>Blob And SpielFeld(x,y+1,p) =Blob Then Y_Offs=13 If SpielFeld(x-1,y,p) =Blob And SpielFeld(x+1,y,p)<>Blob And SpielFeld(x,y-1,p)<>Blob And SpielFeld(x,y+1,p) =Blob Then Y_Offs=14 If SpielFeld(x-1,y,p) =Blob And SpielFeld(x+1,y,p)<>Blob And SpielFeld(x,y-1,p) =Blob And SpielFeld(x,y+1,p)<>Blob Then Y_Offs=15 If SpielFeld(x-1,y,p) =Blob And SpielFeld(x+1,y,p) =Blob And SpielFeld(x,y-1,p) =Blob And SpielFeld(x,y+1,p)<>Blob Then Y_Offs=16 If SpielFeld(x-1,y,p) =Blob And SpielFeld(x+1,y,p) =Blob And SpielFeld(x,y-1,p)<>Blob And SpielFeld(x,y+1,p) =Blob Then Y_Offs=17 If SpielFeld(x-1,y,p) =Blob And SpielFeld(x+1,y,p)<>Blob And SpielFeld(x,y-1,p) =Blob And SpielFeld(x,y+1,p) =Blob Then Y_Offs=18 If SpielFeld(x-1,y,p)<>Blob And SpielFeld(x+1,y,p) =Blob And SpielFeld(x,y-1,p) =Blob And SpielFeld(x,y+1,p) =Blob Then Y_Offs=19 If SpielFeld(x-1,y,p) =Blob And SpielFeld(x+1,y,p) =Blob And SpielFeld(x,y-1,p) =Blob And SpielFeld(x,y+1,p) =Blob Then Y_Offs=20 If Blob=>1 Then DrawImageRect img_bl,XP_Offs+x*32,y*32-2*32,Abs(Blob)*32-32,Y_Offs*32,32,32 Next Next End Function ;############################################################################################################ Function SpielFeld_testen(p) ;Player 1-2 Local rn Local x,y Local Blob ;1-5 Local XP_Offs=0 Local Y_Offs=0 ;1 unsichtbar ;2 unsichtbar ;3 ;... ;15 ;--------------------------------------------------------- If p=1 Then XP_Offs=0 If p=2 Then XP_Offs=12*32 For x=1 To 6 For y=3 To 15 Blob=SpielFeld(x,y,p) If Blob=>-5 And Blob<0 Then Splash.SplashType= New SplashType Splash\xs=x ;Spielfeld merken Splash\ys=y Splash\p=p SpielFeld(x,y,p)=-100 ;Wird gelöscht Splash\Blob=Abs(Blob) Splash\xc=XP_Offs+x*32 +16 Splash\yc= y*32-2*32+16 Splash\r=8 Splash\c=40 rn=Rnd(0,1) If rn=1 Then Splash\wsp=3.6 Else Splash\wsp=-3.6 EndIf Next Next ;--------------------------------------------------------- ; Local Leer=True ; For x=1 To 6 ; For y=3 To 15 ; If SpielFeld(x,y,p)<>0 Then Leer=False:Exit ; Next ; If Leer=False Then Exit ; Next ; If Leer=True Then ; SpielerLevel (p)=SpielerLevel (p)+1 ;<--- Level +++ ; SpielerPunkte(p)=SpielerPunkte(p)+500 ;<--- Player Punkte +++ ; SpielFeld_RND(p) ; EndIf ;--------------------------------------------------------- End Function ;############################################################################################################ Function SpielFeld_FX(p) ;Player 1-2 ;Return 0 ;Killt das Spielfeld :-) für Start oder nächsten Level Local rn Local x,y Local Blob ;1-5 Local XP_Offs=0 Local Y_Offs=0 ;1 unsichtbar ;2 unsichtbar ;3 ;... ;15 ;--------------------------------------------------------- If p=1 Then XP_Offs=0 If p=2 Then XP_Offs=12*32 For x=1 To 6 For y=3 To 15 Blob=SpielFeld(x,y,p) SplashFX.SplashTypeFX= New SplashTypeFX SplashFX\xs=x ;Spielfeld merken SplashFX\ys=y SplashFX\p=p ;SpielFeld(x,y,p)=0 ;Wird gelöscht SplashFX\Blob=Abs(Blob) SplashFX\xc=XP_Offs+x*32 +16 SplashFX\yc= y*32-2*32+16 SplashFX\r=8 SplashFX\c=60 rn=Rnd(0,1) If rn=1 Then SplashFX\wsp=1 Else SplashFX\wsp=-1 Next Next End Function ;############################################################################################################ Function SpielFeld_fallen(p) ;Player 1-2 Local x,y Local Blob ;1-5 ;1 unsichtbar ;2 unsichtbar ;3 ;... ;15 ;--------------------------------------------------------- Local Blob_gefallen=0 For x=1 To 6 For y=14 To 3 Step -1 ;Rückwärts sonnst werden alle direkt bis unten verschoben ! Blob=SpielFeld(x,y,p) If Blob>0 Then If SpielFeld(x,y+1,p)=0 And (x<>SpielerXB2(p) Or y+1<>SpielerYB2(p)) And (x<>SpielerXB1(p) Or y+1<>SpielerYB1(p)) Then ;Ist FREI Blob_gefallen=True SpielFeld(x,y ,p)=0 SpielFeld(x,y+1,p)=Blob EndIf EndIf Next Next ;--------------------------------------------------------- If Blob_gefallen=True Then Return True Else Return False EndIf ;--------------------------------------------------------- End Function ;############################################################################################################ Function Zerplatzen_zeigen() Local x,y,w Local Y_Offs=0 ;------------------------------------------------------------------------------------------------- For Splash.SplashType = Each SplashType If Splash\p=1 Then XP_Offs=0 If Splash\p=2 Then XP_Offs=12*32 Y_Offs=3 ;Große Augen If Splash\mb=0 Then DrawImageRect img_bl,XP_Offs+Splash\xs*32,Splash\ys*32-2*32,Splash\Blob*32-32,Y_Offs*32,32,32 EndIf Next ;------------------------------------------------------------------------------------------------- For Splash.SplashType = Each SplashType For w=0 To 360 Step 72 x=Splash\xc+Sin(w+Splash\w)*Splash\r y=Splash\yc+Cos(w+Splash\w)*Splash\r ;Color 255,255,0 ;Plot x,y If Splash\mb=0 Then Y_Offs=0 If Splash\mb=1 Then Y_Offs=1 If Splash\mb=2 Then Y_Offs=2 DrawImageRect img_minibl,x-8,y-8,Splash\Blob*16-16,Y_Offs*16,16,16 Next Splash\w=Splash\w+Splash\wsp Splash\r=Splash\r+2 Splash\c=Splash\c-1 If Splash\c=20 Then Splash\mb=1 If Splash\c=10 Then Splash\mb=2 If Splash\c=0 Then SpielFeld(Splash\xs,Splash\ys,Splash\p)=0 SpielerPunkte(Splash\p)=SpielerPunkte(Splash\p)+10 ;<--- Player Punkte +++ ZeigeSpielerPunkte p SpielerBlobs (Splash\p)=SpielerBlobs (Splash\p)+1 ;<--- Player Blobs +++ ZeigeSpielerBlobs p Delete Splash EndIf Next ;------------------------------------------------------------------------------------------------- End Function ;############################################################################################################ Function ZerplatzenFX_zeigen() ;Return 0 ;NUR FÜR START , NEUEN LEVEL oder GAME OVER Local x,y,w Local XP_Offs Local Y_Offs=0 ;------------------------------------------------------------------------------------------------- For SplashFX.SplashTypeFX = Each SplashTypeFX If SplashFX\p=1 Then XP_Offs=0 If SplashFX\p=2 Then XP_Offs=12*32 Y_Offs=3 ;Große Augen If SplashFX\mb=0 Then DrawImageRect img_bl,XP_Offs+SplashFX\xs*32,SplashFX\ys*32-2*32,SplashFX\Blob*32-32,Y_Offs*32,32,32 EndIf Next ;------------------------------------------------------------------------------------------------- For SplashFX.SplashTypeFX = Each SplashTypeFX For w=0 To 360 Step 36 x=SplashFX\xc+Sin(w+SplashFX\w)*SplashFX\r y=SplashFX\yc+Cos(w+SplashFX\w)*SplashFX\r ;Color 255,255,0 ;Plot x,y If SplashFX\mb=0 Then Y_Offs=0 If SplashFX\mb=1 Then Y_Offs=1 If SplashFX\mb=2 Then Y_Offs=2 DrawImageRect img_minibl,x-8,y-8,SplashFX\Blob*16-16,Y_Offs*16,16,16 Next SplashFX\w=SplashFX\w+SplashFX\wsp SplashFX\r=SplashFX\r+2 SplashFX\c=SplashFX\c-1 If SplashFX\c=30 Then SplashFX\mb=1 If SplashFX\c=15 Then SplashFX\mb=2 If SplashFX\c=0 Then Delete SplashFX EndIf Next ;------------------------------------------------------------------------------------------------- End Function ;############################################################################################################ Function SpielFeld_loeschen(p) ;Player 1-2 Local x,y Local Blob ;1 unsichtbar ;2 unsichtbar ;3 ;... ;15 ;--------------------------------------------------------- ; ... 4 er suchen und auf - Stellen und Sound abspielen ;--------------------------------------------------------- ; Noch Fehler drin wenn es zweimal nach unten geht !!! Local XP_Offs If p=1 Then XP_Offs=0 If p=2 Then XP_Offs=12*32 For y=3 To 15 For x=1 To 6 Blob=Spielfeld(x,y,p) If Blob>0 Then If Spielfeld_TMP_cls (Blob,p)=>4 Then BlobsTMP=0 SucheBlob (x,y) If BlobsTMP=>4 Then If BlobsTMP=4 Then PlaySound snd_auseinander1 ;<--- SOUND If BlobsTMP>4 Then PlaySound snd_auseinander2 ;<--- SOUND Spielfeld_TMP_Blobs_entfernen p EndIf EndIf ;Überhaupt 4 drin ? EndIf ;Blob>0 Next Next End Function ;############################################################################################################ Function SucheBlob(x,y) If Spielfeld_TMP(x,y)=1 Then Spielfeld_TMP(x,y)=2 BlobsTMP=BlobsTMP+1 End If If Spielfeld_TMP(x-1,y )=1 Then SucheBlob(x-1,y ) If Spielfeld_TMP(x+1,y )=1 Then SucheBlob(x+1,y ) If Spielfeld_TMP(x ,y-1)=1 Then SucheBlob(x ,y-1) If Spielfeld_TMP(x ,y+1)=1 Then SucheBlob(x ,y+1) End Function ;############################################################################################################ Function Spielfeld_TMP_cls(Blob,p) Local x,y Local Blobs=0 For x=1 To 6 For y=3 To 15 Spielfeld_TMP(x,y)=0 If Spielfeld(x,y,p)>0 And Spielfeld(x,y,p)=Blob Then Spielfeld_TMP(x,y)=1: Blobs=Blobs+1 Next Next Return Blobs End Function ;############################################################################################################ Function Spielfeld_TMP_Blobs_entfernen(p) Local x,y For x=1 To 6 For y=3 To 15 If Spielfeld_TMP(x,y)=2 Then Spielfeld(x,y,p)=-Spielfeld(x,y,p) Next Next ;And Spielfeld(x,y,p)>0 End Function ;############################################################################################################ Function InSpielfeld_TMP(x,y) ;X 1-6 ;Y ;1 unsichtbar ;2 unsichtbar ;3 ;... ;15 If x< 1 Or x> 6 Then Return 0 If y< 3 Or y>15 Then Return 0 Return Spielfeld_TMP(x,y) End Function ;############################################################################################################ Function SpielFeldSchatten() Local x,y x=1 For y=1 To 13 DrawImageRect img_schatten,x*32 ,y*32,0,0,32,32 ;PL1 DrawImageRect img_schatten,x*32+12*32,y*32,0,0,32,32 ;PL2 Next y=1 For x=2 To 6 DrawImageRect img_schatten,x*32 ,y*32,0,0,32,32 DrawImageRect img_schatten,x*32+12*32,y*32,0,0,32,32 Next End Function ;############################################################################################################ Function bmpText (x,y,t$,centerx=0,centery=0) If bmpfont_img=0 Then Return 0 If Len(t$)=0 Then Return 0 If centerx Then x=x-bmpTextWidth(t$)/2 If centery Then y=y-bmpfontxyw(0)\y/2 Local i,p For i=1 To Len(t$) p=Asc(Mid(t$,i,1)) DrawImageRect bmpfont_img,x,y,bmpfontxyw(p)\x,0,bmpfontxyw(p)\w,bmpfontxyw(p)\y x=x+bmpfontxyw(p)\w ;add FontSpace here +2 or so Next Return True End Function ;############################################################################################################ Function bmpTextWidth(t$) If Len(t$)=0 Then Return 0 Local i,p,x=0 For i=1 To Len(t$) p=Asc(Mid(t$,i,1)) x=x+bmpfontxyw(p)\w ;add FontSpace here +2 or so Next Return x End Function ;############################################################################################################ Function bmpTextHeight() Return bmpfontxyw(0)\y End Function ;############################################################################################################