fb:porticula NoPaste
Nibbles-Vorlage
Uploader: | PMedia |
Datum/Zeit: | 09.09.2007 21:49:43 |
#include "fbgfx.bi"
Dim PunktX(0 to 25) As Short
Dim PunktY(0 to 25) As Short
Dim Length As Short
Dim FutterX As Short
Dim FutterY As Short
Dim Richtung As Short
Dim i As Short
Dim d As Single
Screen 0
Width 80, 25
locate 1,1,0
? string(80, chr(219));
for i = 0 to 22
? chr(219) + string(78, Chr(32)) + chr(219);
next
? string(80, chr(219));
Randomize Timer
FutterX = (rnd*77) + 2
FutterY = (rnd*22) + 2
PunktX(0) = (rnd*77) + 2
PunktY(0) = (rnd*22) + 2
Length = 1
For I = 1 to 25
PunktX(i) = PunktX(0)
PunktY(i) = PunktY(0)
next
Locate FutterY, FutterX
Print "*";
Do
'Steuerung abfragen:
if multikey(fb.sc_left) then
Richtung = 1
elseif multikey(fb.sc_up) then
Richtung = 2
elseif multikey(fb.sc_right) then
Richtung = 3
elseif multikey(fb.sc_down) then
Richtung = 4
end if
'Punkte löschen:
For I = 0 to Length
Locate PunktY(i), PunktX(i)
Print Chr(32);
next
'Punkte "durchrutschen" lassen
for i = 24 to 0 step -1
punktx(i+1) = punktx(i)
punkty(i+1) = punkty(i)
next
'Ersten Punkt bewegen:
If Richtung = 1 then 'Links
punktx(0) -= 1
ElseIf Richtung = 2 then 'oben
punkty(0) -= 1
ElseIf Richtung = 3 then 'rechts
punktx(0) += 1
ElseIf Richtung = 4 then 'unten
punkty(0) += 1
end if
'Kollision prüfen:
For I = 0 to length
If PunktX(i) < 1 then
beep
Locate 1, 36
Print "Game Over"
sleep
end
ElseIf PunktX(i) > 79 then
beep
Locate 1, 36
Print "Game Over"
sleep
end
ElseIf PunktX(i) < 1 then
beep
Locate 1, 36
Print "Game Over"
sleep
end
ElseIf PunktY(i) > 24 then
beep
Locate 1, 36
Print "Game Over"
sleep
end
else
Locate PunktY(i), PunktX(i)
Print Chr(177+Sin(D));
end if
If PunktX(i) = FutterX AND PunktY(i) = FutterY then
FutterX = (rnd*77) + 2
FutterY = (rnd*22) + 2
Length += 1
Locate FutterY, FutterX
Print "*";
end if
next
Locate FutterY, FutterX
Print "*";
Sleep 500 - (length*10)
d += 0.1
loop until multikey(fb.sc_escape)
end