QBASIC :-)
Posted: 02. Jan 2002 5:01
Hi!
Ja, ich habe auch mal in QBASIC programmiert. Es war sogar meine erste Sprache, doch alle schlechten Angewohnheiten habe ich mir wieder abtrainiert. Ich habe gerade ein paar alte Programme auf einer Diskette gefunden, deren Etikett schon etwas vergilbt war. <img src="http://www.pl-forum.de/UltraBoard/Images/Wilk.gif" border="0" align="middle">
Das folgende Programm zeigt (glaube ich) einen herumspringenden Ball an. Ich weiß, dass ich damals sehr stolz darauf war. Daher möchte ich es nun der Allgemeinheit unter der GNU GPL zur Verfügung stellen. Hier ist der Code. Die Einrückungen fehlen im Original (natürlich) auch.
<blockquote><pre><font size="1" face="">code:</font><hr><font face="Courier New" size="2">
DEFINT A-Z
RANDOMIZE TIMER
DIM GrafikPuffer(1000)
SCREEN 9
Max.X = 625: Min.X = 0
Max.Y = 345: Min.Y = 0
SizeOfBall = 15
Start.X = 15
Start.Y = 15
CIRCLE (Start.X, Start.Y), SizeOfBall, 12
PAINT (Start.X, Start.Y), 6, 12
GET (Start.X - SizeOfBall, Start.Y - SizeOfBall)-(Start.X + SizeOfBall, Start.Y + SizeOfBall), GrafikPuffer
AktuellePosition.X = AltePosition.X = Start.X
AktuellePosition.Y = AltePosition.Y = Start.Y
Richtung.X = 1
Richtung.Y = 1
PSET (0, 0)
DRAW "d349r639u349l639"
DO
PUT (AltePosition.X, AltePosition.Y), GrafikPuffer
Inkrement.X = 5
IF AktuellePosition.X + Inkrement.X + 30 > Max.X THEN Richtung.X = -1: PLAY "<<<l32c>>>"
IF AktuellePosition.X - Inkrement.X < Min.Y THEN Richtung.X = 1: PLAY "<<<l32c>>>"
AktuellePosition.X = AktuellePosition.X + (Inkrement.X * Richtung.X)
Inkrement.Y = 5
IF AktuellePosition.Y + Inkrement.Y + 30 > Max.Y THEN Richtung.Y = -1: PLAY "<<l32c>>"
IF AktuellePosition.Y - Inkrement.Y < Min.Y THEN Richtung.Y = 1: PLAY "<<l32c>>"
AktuellePosition.Y = AktuellePosition.Y + (Inkrement.Y * Richtung.Y)
PUT (AktuellePosition.X, AktuellePosition.Y), GrafikPuffer
PLAY "p64"
AltePosition.X = AktuellePosition.X
AltePosition.Y = AktuellePosition.Y
LOOP UNTIL INKEY$ <> ""
CLS
</font><hr></pre></blockquote>
Cheers,
GNU/Wolfgang
Ja, ich habe auch mal in QBASIC programmiert. Es war sogar meine erste Sprache, doch alle schlechten Angewohnheiten habe ich mir wieder abtrainiert. Ich habe gerade ein paar alte Programme auf einer Diskette gefunden, deren Etikett schon etwas vergilbt war. <img src="http://www.pl-forum.de/UltraBoard/Images/Wilk.gif" border="0" align="middle">
Das folgende Programm zeigt (glaube ich) einen herumspringenden Ball an. Ich weiß, dass ich damals sehr stolz darauf war. Daher möchte ich es nun der Allgemeinheit unter der GNU GPL zur Verfügung stellen. Hier ist der Code. Die Einrückungen fehlen im Original (natürlich) auch.
<blockquote><pre><font size="1" face="">code:</font><hr><font face="Courier New" size="2">
DEFINT A-Z
RANDOMIZE TIMER
DIM GrafikPuffer(1000)
SCREEN 9
Max.X = 625: Min.X = 0
Max.Y = 345: Min.Y = 0
SizeOfBall = 15
Start.X = 15
Start.Y = 15
CIRCLE (Start.X, Start.Y), SizeOfBall, 12
PAINT (Start.X, Start.Y), 6, 12
GET (Start.X - SizeOfBall, Start.Y - SizeOfBall)-(Start.X + SizeOfBall, Start.Y + SizeOfBall), GrafikPuffer
AktuellePosition.X = AltePosition.X = Start.X
AktuellePosition.Y = AltePosition.Y = Start.Y
Richtung.X = 1
Richtung.Y = 1
PSET (0, 0)
DRAW "d349r639u349l639"
DO
PUT (AltePosition.X, AltePosition.Y), GrafikPuffer
Inkrement.X = 5
IF AktuellePosition.X + Inkrement.X + 30 > Max.X THEN Richtung.X = -1: PLAY "<<<l32c>>>"
IF AktuellePosition.X - Inkrement.X < Min.Y THEN Richtung.X = 1: PLAY "<<<l32c>>>"
AktuellePosition.X = AktuellePosition.X + (Inkrement.X * Richtung.X)
Inkrement.Y = 5
IF AktuellePosition.Y + Inkrement.Y + 30 > Max.Y THEN Richtung.Y = -1: PLAY "<<l32c>>"
IF AktuellePosition.Y - Inkrement.Y < Min.Y THEN Richtung.Y = 1: PLAY "<<l32c>>"
AktuellePosition.Y = AktuellePosition.Y + (Inkrement.Y * Richtung.Y)
PUT (AktuellePosition.X, AktuellePosition.Y), GrafikPuffer
PLAY "p64"
AltePosition.X = AktuellePosition.X
AltePosition.Y = AktuellePosition.Y
LOOP UNTIL INKEY$ <> ""
CLS
</font><hr></pre></blockquote>
Cheers,
GNU/Wolfgang