Bug beim zeichnen von Bildern

Übersicht BlitzBasic Allgemein

Neue Antwort erstellen

Keine64MB

Betreff: Bug beim zeichnen von Bildern

BeitragSa, Mai 12, 2012 13:18
Antworten mit Zitat
Benutzer-Profile anzeigen
Hallo
Auf der Basis meines alten Pacman Programms, das net fertig wurde mache ich jetzt ein neues maze. Ich bin so gut wie fertig, aber es tritt ein kleiner bug auf:
Arrow Man kann sich bewegen, hinterlässt jedoch eine spur, die man nicht mehr betreten kann.
Arrow Wenn man jetzt gleichzeitig nach oben und links drückt wird nich t auf jedem feld das bild für
die spur gezeichnet, sonder nur als "Diagonale"
Arrow Sonst passiert das nicht
ier der gesamte quellcode:
Code: [AUSKLAPPEN]
Graphics 800, 825, 16, 2
SetBuffer BackBuffer()
AppTitle "DungeonSlime"
Global wall = LoadImage("gfx\wall.bmp")
Global muenze = LoadImage("gfx\money.bmp")
Global boden = LoadImage("gfx\floor.bmp")
Global spawn = LoadImage("gfx\spawn.bmp")
Global ziel = LoadImage("gfx\target.bmp")
Global trap = LoadImage("gfx\trap.bmp")
Global spur = LoadImage("gfx\slimeprint.bmp")
Global Slimebild_oben = LoadImage("gfx\slime_oben.bmp")
Global Slimebild_unten = LoadImage("gfx\slime_unten.bmp")
Global Slimebild_links = LoadImage("gfx\slime_links.bmp")
Global Slimebild_rechts = LoadImage("gfx\slime_rechts.bmp")
Global logo = LoadImage("gfx\logo.bmp")
Global background = LoadImage("gfx\hintergrund.bmp")
Global Aktives_bild = Slimebild_oben
Global geld = 0
Global leben = 1
timer = CreateTimer(30)
file = ReadFile("maps\map.txt")
font = LoadFont("Arial",25,1)
SetFont font
Dim karte$(31, 31)
For i = 1 To 32
   x$ = ReadLine(file)
   For j = 1 To 32
      karte(i-1, j-1) = Mid(x$, j, 1)
   Next
Next
CloseFile(file)
Global position_x
Global position_y
For i = 0 To 31
   For j = 0 To 31
      If karte(i, j) = "B"
         position_x = i*25
         position_y = j*25
      EndIf
   Next
Next      
Global coord_x = position_x/25
Global coord_y = position_y/25
Function vorspann()
   DrawImage(logo, 0,0)
   Delay(3000)   
End Function
Function menu()
   DrawImage(background, 0,0)
End Function   
Function drawmap()
   For i = 0 To 31
      For j = 0 To 31
         If karte(i, j) = "A" Then DrawImage wall, i*25, j*25
         If karte(i, j) = "D" Then DrawImage muenze, i*25, j*25
         If karte(i, j) = " " Then DrawImage boden, i*25, j*25
         If karte(i, j) = "B" Then DrawImage spawn, i*25, j*25
         If karte(i, j) = "C" Then DrawImage ziel, i*25, j*25
         If karte(i, j) = "F" Then DrawImage trap, i*25, j*25
         If karte(i, j) = "X" Then DrawImage spur, i*25, j*25
      Next
     Next
End Function
Function move()
   If KeyDown(200)
      Aktives_bild = Slimebild_oben
      If karte(coord_x, coord_y-1) = " " Or karte(coord_x, coord_y-1) = "D" Or karte(coord_x, coord_y+1) = "F" Or karte(coord_x, coord_y-1) = "C"
         For x = 1 To 25
            Cls
            position_y = position_y-1
            ;coord_x = position_x / 25
               ;coord_y = position_y / 25
            karte(coord_x, coord_y) = "X"
            drawmap()
            DrawImage(Aktives_bild, position_x, position_y)   
            Text 10, 800, "Geld:" + geld      
            Flip
         Next
      EndIf
   EndIf
   If KeyDown(208)
      Aktives_Bild = Slimebild_unten
      If karte(coord_x, coord_y+1) = " " Or karte(coord_x, coord_y+1) = "D"  Or karte(coord_x, coord_y+1) = "F" Or karte(coord_x, coord_y+1) = "C"
         For x =1 To 25
            Cls
            position_y = position_y+1
            coord_x = position_x / 25
               coord_y = position_y / 25
            karte(coord_x, coord_y) = "X"
            drawmap()
            DrawImage(Aktives_bild, position_x, position_y)
            Text 10, 800, "Geld:" + geld
            Flip
         Next
      EndIf
   EndIf
   If KeyDown(203)
      Aktives_Bild = Slimebild_links
      If karte(coord_x-1, coord_y) = " " Or karte(coord_x-1, coord_y) = "D" Or karte(coord_x-1, coord_y) = "F" Or karte(coord_x-1, coord_y) = "C"
         For x = 1 To 25
            Cls
            position_x = position_x-1
            ;coord_x = position_x / 25
               ;coord_y = position_y / 25
            karte(coord_x, coord_y) = "X"            
            drawmap()
            DrawImage(Aktives_bild, position_x, position_y)
            Text 10, 800, "Geld:" + geld
            Flip
         Next
      EndIf
   EndIf
   If KeyDown(205)
      Aktives_Bild = Slimebild_rechts
      If karte(coord_x+1, coord_y) = " " Or karte(coord_x+1, coord_y-1) = "D" Or karte(coord_x+1, coord_y) = "F" Or karte(coord_x+1, coord_y) = "C"
         For x =1 To 25
            Cls
            position_x = position_x+1
            coord_x = position_x / 25
               coord_y = position_y / 25
            karte(coord_x, coord_y) = "X"
            drawmap()
            DrawImage(Aktives_bild, position_x, position_y)
            Text 10, 800, "Geld:" + geld
            Flip
         Next
      EndIf
   EndIf
If karte(coord_x, coord_y) = "D"
   karte(coord_x, coord_y) = " "
   geld = geld + 1
EndIf
If karte(coord_x, coord_y) = "C"
   leben = leben - 1
EndIf
karte(coord_x, coord_y) = "X"
;If karte(coord_x,  coord_y) = "F"
;   leben = leben - 1
;EndIf
End Function
vorspann()                        
While Not KeyHit(1) Or leben = 0   
   Cls
   coord_x = position_x/25
   coord_y = position_y / 25
   drawmap()
   DrawImage(Aktives_bild, position_x, position_y)
   move()
   Text 10, 800, "Geld:" + geld
   WaitTimer timer
   ;If leben = 0
   ;   Text 100, 100, "Du hast verloren", 1 , 1
   ;EndIf
   Flip
Wend

 

Danke im voraus für eure Lösungsvorschläge!
Keine64MB

Xeres

Moderator

BeitragSa, Mai 12, 2012 13:23
Antworten mit Zitat
Benutzer-Profile anzeigen
Strings als Karte sind nicht empfehlenswert, da der Vergleich viel länger dauert, als Zahlen zu benutzen (Konstanten sind empfohlen).
Dann gibt es in der Funktion move cls/drawmap/flip ... was hat das da zu suchen? Wenn du nicht Bewegung von Grafik trennst, sind solche Bugs zu erwarten.
Win10 Prof.(x64)/Ubuntu 16.04|CPU 4x3Ghz (Intel i5-4590S)|RAM 8 GB|GeForce GTX 960
Wie man Fragen richtig stellt || "Es geht nicht" || Video-Tutorial: Sinus & Cosinus
T
HERE IS NO FAIR. THERE IS NO JUSTICE. THERE IS JUST ME. (Death, Discworld)

Neue Antwort erstellen


Übersicht BlitzBasic Allgemein

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group