Snake

Übersicht Sonstiges Smalltalk

Gehe zu Seite 1, 2  Weiter

Neue Antwort erstellen

blitzuser34

Betreff: Snake

BeitragFr, Jan 25, 2008 20:28
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi, ihr kennt sicher alle die Foren, wo jemand mit nem Wort anfängt und jeder ein Wort posten kann, und am Ende gibt's ne Geschichte.

Ich hab mir überlegt, sowas auch mit nem Spiel zu machen(nur so zum Spaß). Das Programm soll Snake werden. Jeder sollte den bisherigen Code+3- max. 10 neue Zeilen posten.

Wenn ihr was posten wollt, was aber zimlich lang ist, schreibt den Anfang, was ihr machen wollt, sodass der nächste daran weiter machen kann.

Ich fang mal an:
Code: [AUSKLAPPEN]
Graphics 800,600,32,2
Setbuffer Backbuffer()
Apptitle "Snake"

BigMaexle

BeitragFr, Jan 25, 2008 21:33
Antworten mit Zitat
Benutzer-Profile anzeigen
Ich find die Idee witzig Smile . Aber wenn programmieren nur so leicht wäre Razz

Grundgerüst, dann Hauptmenü, Optische feinheiten, Debugging. Alles das geht leider nich Zeile für Zeile fertig. du müsstest dir schon ein fertiges Snake Projekt ausdenken und 3 Zeilen Code davon schreiben. Auch müsstest du endlos lange Erklärungen an den nächsten abgeben, wozu man deine angefangene For-Next-Schliefe braucht und wie sie funktionieren soll. Dazu hab ich ehrlich gesagt keine Lust Wink

Elvis

BeitragFr, Jan 25, 2008 21:43
Antworten mit Zitat
Benutzer-Profile anzeigen
Ich bin auch in einem anderen Programmiererforum angemeldet, wo einmal eine ähnliche Aktion gestartet wurde. Der Unterschied bestand jedoch
darin, dass das Programm keinen Zweck erfüllen sollte, geschweige denn von einem festgelegten Ziel. Außerdem war nur immer eine zusätzliche
Zeile zulässig. Das hat ziemlich Spaß gemacht und war zum Schluss ein beachtlicher Haufen Code, der aber trotzdem recht übersichtlich war.
Das aber nur als kleinen Denkanstoß, sollte deinem Vorschlag keiner oder kaum einer nachkommen, wonach es im Moment schwer aussieht.


Grüße, Elvis
User posted image
Mehr Informationen...
 

Appart Graphiker

Gast

Betreff: Antwort

BeitragFr, Jan 25, 2008 22:04
Antworten mit Zitat
Ich finde die Idee gut und mache gleich mal weiter (einziges Problem sind die Bilder) :

Font1 = LoadFont("Arial",200,1,0,0)
SetFont font1
 

TeDy14

Gast

Betreff: Re: Snake

BeitragFr, Jan 25, 2008 23:22
Antworten mit Zitat
Code: [AUSKLAPPEN]
Graphics 800,600,32,2
Setbuffer Backbuffer()
Apptitle "Snake"
Font1 = LoadFont("Arial",200,1,0,0)
SetFont font1

Type Schwanz
field x
field y
field time



Warum Bilder ? ^^
Gibt doch so schöne zeichen befehle Very Happy

blitzuser34

BeitragSa, Jan 26, 2008 11:14
Antworten mit Zitat
Benutzer-Profile anzeigen
Schlange besteht ja meistens aus Rechtecken. Kann man ja Rect oder ne Funktion mit Writepixelfast machen.

Code: [AUSKLAPPEN]
Graphics 800,600,32,2
SetBuffer BackBuffer()
AppTitle "Snake"

Font1 = LoadFont("Arial",200,1,0,0)
SetFont font1

Type Schwanz
   Field x
   Field y
   Field time
End Type

While Not KeyHit(1)
Cls

Flip
Wend

Eingeproggt

BeitragSa, Jan 26, 2008 17:25
Antworten mit Zitat
Benutzer-Profile anzeigen
Irgendwie halt ich nix von dem Versuch, aber am Anfang is noch recht leicht, mitzumachen, also erlaub ich mir den Spass:

Code: [AUSKLAPPEN]
Graphics 800,600,32,2
SetBuffer BackBuffer()
AppTitle "Snake"

Font1 = LoadFont("Arial",200,1,0,0)
SetFont font1

Type Schwanz
   Field x
   Field y
   Field time
End Type

timer=CreateTimer(50)

While Not KeyHit(1)
  Cls
  For Schwanz.Schwanz=Each Schwanz
    Rect Schwanz\x,Schwanz\y,10,10,1
  Next
  Flip 0
  WaitTimer timer
Wend
Gewinner des BCC 18, 33 und 65 sowie MiniBCC 9
 

TeDy14

Gast

BeitragSa, Jan 26, 2008 17:30
Antworten mit Zitat
Code: [AUSKLAPPEN]
Graphics 800,600,32,2
SetBuffer BackBuffer()
AppTitle "Snake"

Font1 = LoadFont("Arial",200,1,0,0)
SetFont font1

Type Schwanz
   Field x
   Field y
   Field time
End Type

local kopf_x,kopf_y,Kopf_richtung

timer=CreateTimer(50)
While Not KeyHit(1)
  Cls
  Select Kopf_richtung
    case 1
     x=x+1
    case 2
     x=x-1
    case 3
     y=y+1
    case 4
     y=y-1
  End Select

  For Schwanz.Schwanz=Each Schwanz
    Rect Schwanz\x,Schwanz\y,10,10,1
  Next
  Flip 0
  WaitTimer timer
Wend


Ist aber ein netter zeitvertreib ^^

blitzuser34

BeitragSa, Jan 26, 2008 18:57
Antworten mit Zitat
Benutzer-Profile anzeigen
Code: [AUSKLAPPEN]
Graphics 800,600,32,2
SetBuffer BackBuffer()
AppTitle "Snake"

SetFont LoadFont("Arial",200,1,0,0) 

Type Schwanz
   Field x
   Field y
   Field time
End Type

Local kopf_x,kopf_y,Kopf_richtung

timer=CreateTimer(50)

While Not KeyHit(1)
WaitTimer timer
   Cls
      Select Kopf_richtung
         Case 1
            x=x+1
         Case 2
            x=x-1
         Case 3
            y=y+1
         Case 4
            y=y-1
      End Select
      
      If KeyHit(200) Then Kopf_richtung=4
      If KeyHit(208) Then Kopf_richtung=3
      If KeyHit(203) Then Kopf_richtung=2
      If KeyHit(205) Then Kopf_richtung=1
      
      For Schwanz.Schwanz=Each Schwanz
         Rect Schwanz\x,Schwanz\y,10,10,0
      Next
   Flip 0
Wend

Eingeproggt

BeitragSa, Jan 26, 2008 20:42
Antworten mit Zitat
Benutzer-Profile anzeigen
ähm.. Ich mach mal den ersten "Bugfix" ohne etwas dazu zu machen. (Weil mir grad das Konzept fehlt...)

Code: [AUSKLAPPEN]
Graphics 800,600,32,2
SetBuffer BackBuffer()
AppTitle "Snake"

SetFont LoadFont("Arial",200,1,0,0) 

Type Schwanz
   Field x
   Field y
   Field time
End Type

Local kopf_x,kopf_y,Kopf_richtung

timer=CreateTimer(50)

While Not KeyHit(1)
WaitTimer timer
   Cls
      Select Kopf_richtung
         Case 1
            kopf_x=kopf_x+1
         Case 2
            kopf_x=kopf_x-1
         Case 3
            kopf_y=kopf_y+1
         Case 4
            kopf_y=kopf_y-1
      End Select
       
      If KeyHit(200) Then Kopf_richtung=4
      If KeyHit(208) Then Kopf_richtung=3
      If KeyHit(203) Then Kopf_richtung=2
      If KeyHit(205) Then Kopf_richtung=1
       
      For Schwanz.Schwanz=Each Schwanz
         Rect Schwanz\x,Schwanz\y,10,10,0
      Next
   Flip 0
Wend
Gewinner des BCC 18, 33 und 65 sowie MiniBCC 9

ToeB

BeitragSa, Jan 26, 2008 20:58
Antworten mit Zitat
Benutzer-Profile anzeigen
Auch noch ein paar verbesserungen :

Code: [AUSKLAPPEN]
Graphics 800,600,32,2
SetBuffer BackBuffer()
AppTitle "Snake"

SetFont LoadFont("Arial",200,1,0,0)

Type Schwanz
Field x
Field y
Field time
End Type

Local kopf_x=100,kopf_y=100,Kopf_richtung =1
Local Schwanz_Anzahl=10

timer=CreateTimer(50)

While Not KeyHit(1)
WaitTimer timer
Cls
Select Kopf_richtung
Case 1
kopf_x=kopf_x+1
Case 2
kopf_x=kopf_x-1
Case 3
kopf_y=kopf_y+1
Case 4
kopf_y=kopf_y-1
End Select

If KeyHit(200) Then Kopf_richtung=4
If KeyHit(208) Then Kopf_richtung=3
If KeyHit(203) Then Kopf_richtung=2
If KeyHit(205) Then Kopf_richtung=1

Rect kopf_x,kopf_y,10,10,1

For Schwanz.Schwanz=Each Schwanz
Rect Schwanz\x,Schwanz\y,10,10,0
Next
Flip 0
Wend
End


Wink

mfg Crack93
Religiöse Kriege sind Streitigkeiten erwachsener Männer darum, wer den besten imaginären Freund hat.
Race-Project - Das Rennspiel der etwas anderen Art
SimpleUDP3.0 - Neuste Version der Netzwerk-Bibliothek
Vielen Dank an dieser Stelle nochmal an Pummelie, welcher mir einen Teil seines VServers für das Betreiben meines Masterservers zur verfügung stellt!
 

DennY

BeitragSa, Jan 26, 2008 21:00
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi,
ich find die Idee lustig und interessant! Ich hab auch weiter gemacht! den Kopf haben wir jetzt und mann kann rumschweben.
Code: [AUSKLAPPEN]
Graphics 800,600,32,2
SetBuffer BackBuffer()
AppTitle "Snake"

SetFont LoadFont("Arial",200,1,0,0)

Type Schwanz
Field x
Field y
Field time
End Type



Local kopf_x=400,kopf_y=300,Kopf_richtung=4
Local Schwanz_Anzahl=10

timer=CreateTimer(50)

Kopf.Schwanz=New Schwanz
Kopf\x=kopf_x
Kopf\y=kopf_y


While Not KeyHit(1)
   WaitTimer timer
   Cls
   
   
   Select Kopf_richtung
      Case 1
            Kopf\x=Kopf\x+1
      Case 2
            Kopf\x=Kopf\x-1
      Case 3
            Kopf\y=Kopf\y+1
      Case 4
            Kopf\y=Kopf\y-1
   End Select
   
   
   If KeyHit(200) Then Kopf_richtung=4
   If KeyHit(208) Then Kopf_richtung=3
   If KeyHit(203) Then Kopf_richtung=2
   If KeyHit(205) Then Kopf_richtung=1
   
   For Schwanz.Schwanz=Each Schwanz
      Rect Schwanz\x,Schwanz\y,10,10,0
   Next
           Rect kopf\x,kopf\y,10,10,1
   
   
   Flip 0
Wend


Mal sehen was ihr dazu packt Very Happy


Edit: lol da war wohl einer schneller Wink

Eingeproggt

BeitragSa, Jan 26, 2008 21:24
Antworten mit Zitat
Benutzer-Profile anzeigen
Um solche Überschneidungen zu vermeiden sollten wirs vlt so machen, dass jeder hier her schribt "Ich mach die nächsten Zeilen" und dann, wenn er fertig is, den Code dazueditiert.

Außerdem stört mich die 200er-Font. hectic hatte erst kürzlich Probleme mit großen Fonts. Daraus könnten wir doch lernen Wink

Code: [AUSKLAPPEN]
Graphics 800,600,32,2
SetBuffer BackBuffer()
AppTitle "Snake"

SetFont LoadFont("Arial",48,1,0,0)

Type Schwanz
   Field x
   Field y
   Field time
End Type
Local Schwanz.Schwanz


Local kopf_x=400,kopf_y=300,Kopf_richtung=4
Local Schwanz_Anzahl=10

Local timer=CreateTimer(50)

Local Kopf.Schwanz=New Schwanz
Kopf\x=kopf_x
Kopf\y=kopf_y


While Not KeyHit(1)
   WaitTimer timer
   Cls
   
   
   Select Kopf_richtung
      Case 1
            Kopf\x=Kopf\x+1
      Case 2
            Kopf\x=Kopf\x-1
      Case 3
            Kopf\y=Kopf\y+1
      Case 4
            Kopf\y=Kopf\y-1
   End Select
   
   
   If KeyHit(200) Then Kopf_richtung=4
   If KeyHit(208) Then Kopf_richtung=3
   If KeyHit(203) Then Kopf_richtung=2
   If KeyHit(205) Then Kopf_richtung=1
   
   For Schwanz.Schwanz=Each Schwanz
      Rect Schwanz\x,Schwanz\y,10,10,0
   Next
   Rect Kopf\x,Kopf\y,10,10,1
   
   
   Flip 0
Wend
End


hmmm.. Ich weiß nicht, warum ich da eig mitmache, wo ich doch vorhin sagte, dass ich nicht viel davon halte Smile
Gewinner des BCC 18, 33 und 65 sowie MiniBCC 9
 

Hahninator

BeitragSo, Jan 27, 2008 11:44
Antworten mit Zitat
Benutzer-Profile anzeigen
Ich gebe auch mal meinen Senf dazu und habe den den Stein Reingeproggt^^

Code: [AUSKLAPPEN]

Graphics 800,600,32,2
SetBuffer BackBuffer()
AppTitle "Snake"

SetFont LoadFont("Arial",48,1,0,0)
SeedRnd MilliSecs()


Type Schwanz
   Field x
   Field y
   Field time
End Type
Local Schwanz.Schwanz


Global Stein_X = Rand(80) * 10
Global Stein_Y = Rand(60) * 10
Local kopf_x=400,kopf_y=300,Kopf_richtung=4
Local Schwanz_Anzahl=10

Local timer=CreateTimer(50)

Local Kopf.Schwanz=New Schwanz
Kopf\x=kopf_x
Kopf\y=kopf_y


While Not KeyHit(1)
   WaitTimer timer
   Cls
   
   
   Select Kopf_richtung
      Case 1
            Kopf\x=Kopf\x+1
      Case 2
            Kopf\x=Kopf\x-1
      Case 3
            Kopf\y=Kopf\y+1
      Case 4
            Kopf\y=Kopf\y-1
   End Select
   
   
   If KeyHit(200) Then Kopf_richtung=4
   If KeyHit(208) Then Kopf_richtung=3
   If KeyHit(203) Then Kopf_richtung=2
   If KeyHit(205) Then Kopf_richtung=1
   
   For Schwanz.Schwanz=Each Schwanz
      Rect Schwanz\x,Schwanz\y,10,10,0
   Next
   Color 255,255,255
   Rect Kopf\x,Kopf\y,10,10,1
   Color 255,0,0
   Rect Stein_X, Stein_Y,10,10,1
   
   Flip 0
Wend
End
 

Marek

BeitragSo, Jan 27, 2008 12:37
Antworten mit Zitat
Benutzer-Profile anzeigen
Kleine Verbesserung zu den Steinen:

Code: [AUSKLAPPEN]
Graphics 800,600,32,2
SetBuffer BackBuffer()
AppTitle "Snake"

SetFont LoadFont("Arial",48,1,0,0)
SeedRnd MilliSecs()

Global temp,cur

Type Schwanz
   Field x
   Field y
   Field time
End Type

Type Stein
   Field x
   Field y
End Type

Local Schwanz.Schwanz

Local Ein.Stein=New Stein
Ein\x=Rand(80) * 10
Ein\y=Rand(60) * 10

Local kopf_x=400,kopf_y=300,Kopf_richtung=4
Local Schwanz_Anzahl=10

Local timer=CreateTimer(50)

Local Kopf.Schwanz=New Schwanz
Kopf\x=kopf_x
Kopf\y=kopf_y

While Not KeyHit(1)
   WaitTimer timer
   Cls
   
   Select Kopf_richtung
      Case 1
            Kopf\x=Kopf\x+1
      Case 2
            Kopf\x=Kopf\x-1
      Case 3
            Kopf\y=Kopf\y+1
      Case 4
            Kopf\y=Kopf\y-1
   End Select
   
   If KeyHit(200) Then Kopf_richtung=4
   If KeyHit(208) Then Kopf_richtung=3
   If KeyHit(203) Then Kopf_richtung=2
   If KeyHit(205) Then Kopf_richtung=1
   
   For Schwanz.Schwanz=Each Schwanz
      Rect Schwanz\x,Schwanz\y,10,10,0
   Next
   Color 255,255,255
   Rect Kopf\x,Kopf\y,10,10,1
   Color 255,0,0
   For Ein.Stein=Each Stein
      Rect Ein\x, Ein\y,10,10,1
    Next
   Flip 0
Wend
End


MfG Marek
Wer lesen kann ist klar im Vorteil...
 

TeDy14

Gast

BeitragSo, Jan 27, 2008 13:32
Antworten mit Zitat
Schwanz stücke müssen auch erstellt werden Wink
Code: [AUSKLAPPEN]
Graphics 800,600,32,2
SetBuffer BackBuffer()
AppTitle "Snake"

SetFont LoadFont("Arial",48,1,0,0)
SeedRnd MilliSecs()

Global temp,cur

Type Schwanz
   Field x
   Field y
   Field time
End Type

Type Stein
   Field x
   Field y
End Type

Local Schwanz.Schwanz

Local Ein.Stein=New Stein
Ein\x=Rand(80) * 10
Ein\y=Rand(60) * 10

Local kopf_x=400,kopf_y=300,Kopf_richtung=4
Local Schwanz_Anzahl=10

Local timer=CreateTimer(50)

Local Kopf.Schwanz=New Schwanz
Kopf\x=kopf_x
Kopf\y=kopf_y

While Not KeyHit(1)
   WaitTimer timer
   Cls

        Schwanz.Schwanz=New Schwanz
         Schwanz\x=Kopf\x
         Schwanz\y=Kopf\y
         Schwanz\time=10 

 
   Select Kopf_richtung
      Case 1
            Kopf\x=Kopf\x+1
      Case 2
            Kopf\x=Kopf\x-1
      Case 3
            Kopf\y=Kopf\y+1
      Case 4
            Kopf\y=Kopf\y-1
   End Select
   
   If KeyHit(200) Then Kopf_richtung=4
   If KeyHit(208) Then Kopf_richtung=3
   If KeyHit(203) Then Kopf_richtung=2
   If KeyHit(205) Then Kopf_richtung=1
   
   For Schwanz.Schwanz=Each Schwanz
                Rect Schwanz\x,Schwanz\y,10,10,0
                Schwanz\time=Schwanz\time-1
      If Schwanz\time=0 Then Delete Schwanz
   Next
   Color 255,255,255
   Rect Kopf\x,Kopf\y,10,10,1
   Color 255,0,0
   For Ein.Stein=Each Stein
      Rect Ein\x, Ein\y,10,10,1
    Next
   Flip 0
Wend
End

Eingeproggt

BeitragSo, Jan 27, 2008 14:15
Antworten mit Zitat
Benutzer-Profile anzeigen
Irgendwo in die Hauptschleife einzufügen:

Code: [AUSKLAPPEN]
If Kopf\x<0 Or Kopf\x>800 Or Kopf\y<0 Or Kopf\y>600 Then
   Text 400,300,"Verloren!",1,1
   Flip 0
   WaitKey()
   End
EndIf


(Macht echt langsam Spass^^)
Gewinner des BCC 18, 33 und 65 sowie MiniBCC 9
 

Shark

BeitragSo, Jan 27, 2008 14:22
Antworten mit Zitat
Benutzer-Profile anzeigen
Sorry Eingeproggt hab das gerade anders gebaut Laughing

Code: [AUSKLAPPEN]
Graphics screen_w,screen_h,32,2
SetBuffer BackBuffer()
AppTitle "Snake"

Const screen_w%=800,screen_h%=600
Const schlange_speed% = 1
SetFont LoadFont("Arial",48,1,0,0)
SeedRnd MilliSecs()

Global temp,cur

Type Schwanz
   Field x
   Field y
   Field time
End Type

Type Stein
   Field x
   Field y
End Type

Local Schwanz.Schwanz

Local Ein.Stein=New Stein
Ein\x=Rand(80) * 10
Ein\y=Rand(60) * 10

Local kopf_x=400,kopf_y=300,Kopf_richtung=4
Local Schwanz_Anzahl=10

Local timer=CreateTimer(50)

Local Kopf.Schwanz=New Schwanz
Kopf\x=kopf_x
Kopf\y=kopf_y


While Not KeyHit(1)
   WaitTimer timer
   Cls
   
   Select Kopf_richtung
      Case 1
            Kopf\x=Kopf\x+schlange_speed
      Case 2
            Kopf\x=Kopf\x-schlange_speed
      Case 3
            Kopf\y=Kopf\y+schlange_speed
      Case 4
            Kopf\y=Kopf\y-schlange_speed
   End Select
   
   If KeyHit(200) Then Kopf_richtung=4
   If KeyHit(208) Then Kopf_richtung=3
   If KeyHit(203) Then Kopf_richtung=2
   If KeyHit(205) Then Kopf_richtung=1
   
   For Schwanz.Schwanz=Each Schwanz
      Rect Schwanz\x,Schwanz\y,10,10,0
     If Schwanz\x < 0 Then Schwanz\x = screen_w
     If Schwanz\x > screen_w Then Schwanz\x = 0
     If Schwanz\y < 0 Then Schwanz\y = screen_h
     If Schwanz\y > screen_h Then Schwanz\y = 0
   Next
   Color 255,255,255
   Rect Kopf\x,Kopf\y,10,10,1
   Color 255,0,0
   For Ein.Stein=Each Stein
      Rect Ein\x, Ein\y,10,10,1
    Next
   Flip 0
Wend
End
 

Marek

BeitragSo, Jan 27, 2008 14:34
Antworten mit Zitat
Benutzer-Profile anzeigen
So, hab mal beide Codes zusammengebastelt und Kolisionen mit den steinen hinzugefügt...

Code: [AUSKLAPPEN]
Graphics screen_w,screen_h,32,2
SetBuffer BackBuffer()
AppTitle "Snake"

Const screen_w%=800,screen_h%=600
Const schlange_speed% = 1
SetFont LoadFont("Arial",48,1,0,0)
SeedRnd MilliSecs()

Global temp,cur

Type Schwanz
   Field x
   Field y
   Field time
End Type

Type Stein
   Field x
   Field y
End Type

Local Schwanz.Schwanz

Local Ein.Stein=New Stein
Ein\x=Rand(80) * 10
Ein\y=Rand(60) * 10

Local kopf_x=400,kopf_y=300,Kopf_richtung=4
Local Schwanz_Anzahl=10

Local timer=CreateTimer(50)

Local Kopf.Schwanz=New Schwanz
Kopf\x=kopf_x
Kopf\y=kopf_y


While Not KeyHit(1)
   WaitTimer timer
   Cls
   
   Schwanz.Schwanz=New Schwanz
   Schwanz\x=Kopf\x
   Schwanz\y=Kopf\y
   Schwanz\time=10
   
   Select Kopf_richtung
      Case 1
            Kopf\x=Kopf\x+schlange_speed
      Case 2
            Kopf\x=Kopf\x-schlange_speed
      Case 3
            Kopf\y=Kopf\y+schlange_speed
      Case 4
            Kopf\y=Kopf\y-schlange_speed
   End Select
   
   If KeyHit(200) Then Kopf_richtung=4
   If KeyHit(208) Then Kopf_richtung=3
   If KeyHit(203) Then Kopf_richtung=2
   If KeyHit(205) Then Kopf_richtung=1
   
   For Schwanz.Schwanz=Each Schwanz
      If Schwanz\x < 0 Then Schwanz\x = screen_w
      If Schwanz\x > screen_w Then Schwanz\x = 0
      If Schwanz\y < 0 Then Schwanz\y = screen_h
      If Schwanz\y > screen_h Then Schwanz\y = 0
      Rect Schwanz\x,Schwanz\y,10,10,0
      Schwanz\time=Schwanz\time-1
      If Schwanz\time=0 Then Delete Schwanz
   Next
   Color 255,255,255
   Rect Kopf\x,Kopf\y,10,10,1
   Color 255,0,0
   For Ein.Stein=Each Stein
      Rect Ein\x, Ein\y,10,10,1
      If Kopf\x>(Ein\x-10) And Kopf\x<(Ein\x+10) Then
         If Kopf\y>(Ein\y-10) And Kopf\y<(Ein\y+10) Then
            Text 400,300,"Verloren!",1,1
            Flip 0
            WaitKey()
            End
         EndIf
      EndIf
    Next
   Flip 0
   FlushKeys()
Wend
End
Wer lesen kann ist klar im Vorteil...
 

TeDy14

Gast

BeitragSo, Jan 27, 2008 14:47
Antworten mit Zitat
Code: [AUSKLAPPEN]

Const screen_w%=800,screen_h%=600
Graphics screen_w,screen_h,32,2
SetBuffer BackBuffer()
AppTitle "Snake"

Const schlange_speed% = 1
SetFont LoadFont("Arial",48,1,0,0)
SeedRnd MilliSecs()

Global temp,cur

Type Schwanz
   Field x
   Field y
   Field time
End Type

Type Stein
   Field x
   Field y
End Type

Local Schwanz.Schwanz

Local Ein.Stein=New Stein
Ein\x=Rand(80) * 10
Ein\y=Rand(60) * 10

Local kopf_x=400,kopf_y=300,Kopf_richtung=4
Local Schwanz_Anzahl=10

Local timer=CreateTimer(50)

Local Kopf.Schwanz=New Schwanz
Kopf\x=kopf_x
Kopf\y=kopf_y


While Not KeyHit(1)
   WaitTimer timer
   Cls
   
   Schwanz.Schwanz=New Schwanz
   Schwanz\x=Kopf\x
   Schwanz\y=Kopf\y
   Schwanz\time=10
   
   Select Kopf_richtung
      Case 1
            Kopf\x=Kopf\x+schlange_speed
      Case 2
            Kopf\x=Kopf\x-schlange_speed
      Case 3
            Kopf\y=Kopf\y+schlange_speed
      Case 4
            Kopf\y=Kopf\y-schlange_speed
   End Select
   
   If KeyHit(200) Then Kopf_richtung=4
   If KeyHit(208) Then Kopf_richtung=3
   If KeyHit(203) Then Kopf_richtung=2
   If KeyHit(205) Then Kopf_richtung=1
   
   For Schwanz.Schwanz=Each Schwanz
      Rect Schwanz\x,Schwanz\y,10,10,0
      Schwanz\time=Schwanz\time-1
      If Schwanz\time=0 Then Delete Schwanz
   Next
   Color 255,255,255
   Rect Kopf\x,Kopf\y,10,10,1
   Color 255,0,0
   For Ein.Stein=Each Stein
      Rect Ein\x, Ein\y,10,10,1
      If Kopf\x>(Ein\x-10) And Kopf\x<(Ein\x+10) Then
         If Kopf\y>(Ein\y-10) And Kopf\y<(Ein\y+10) Then
            Text 400,300,"Verloren!",1,1
            Flip 0
            WaitKey()
            End
         EndIf
      EndIf
    Next
   Flip 0
   FlushKeys()
Wend
End


Fehler beseitigt und den Code mit den Schwanzteilen außerhalb des Bildschirmes gelöscht...
War unsinnig da man eh tot geht....

Gehe zu Seite 1, 2  Weiter

Neue Antwort erstellen


Übersicht Sonstiges Smalltalk

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group