Seite 1 von 1

Leere Fehlermeldung -> nichts geht mehr

Verfasst: 27.10.2004 16:20
von benpicco
Ich hab grad ein Spiel (pong) vertigprogrammiert und will´s tsten, da kommt ne Fehlermeldung:
In der Fenstername der Fehlermeldung: "P..." (könnte Purebasic heißen)
Im Fester: {X} (großes rotes Fehlerkreuz)
darunter: [Ok] (wenn ich darufdrücke, bin ich wieder im code)
Auser dem Kreuz und dem [Ok] steht nichts im Fehlerfenster!!!
Kleine Info: Ich hab die demoversion von PureBasic, aber da steht, das der code auf 800 zeile beschränkt ist, meiner ist aber bei 603 und selbst wenn ich 4 entferne, kommt derselbe fehler!
Der fehler kam, nachdem ich das gemacht hab:

Code: Alles auswählen

...
  If exist = 4 
    For y = 1 To #max
    nochmal:
    BewegX(y) = Random(4)-Random(8)
    BewegY(y) = Random(4)-Random(8)
      If BewegX(y)=0 And BewegY(y)=0
      Goto nochmal
      EndIf  
    Next 
    exist = 0 
  EndIf
  If exist = 5
    v = Random(v+3)-Random(v+6)
    If v = 0
      v = 2
      EndIf
    exist = 0
  EndIf  
...
ist da ein Fehler drin???
Wenn ja, wo?
Wer es schafft, das zum laufen zu bringen: ich weiß noch nicht ob die items 4 und 5 funktionieren, wie sie sollen, ich konnt´s ja noch nicht testen ;)
Wer den ganzen code haben will, hier ist er:
(die dateien dazu und nochmal den code gibt´s unter http://mitglied.lycos.de/benpicco/pongsrc.zip)

Code: Alles auswählen

InitSprite() 
InitKeyboard() 
InitSound() 
OpenScreen(640,480,16,"Pong Deluxe") 
#max = 10 
Dim BallX.w(#max) 
Dim BallY.w(#max) 
Dim ballexist.b(#max) 
Global SchlaegerX.w 
Global SchlaegerY.w 
Global SchlaegerX2.w 
Global SchlaegerY2.w 
Dim BewegX.w(#max) 
Dim BewegY.w(#max) 
Global Player1.b 
Global Player2.b 
Global up.w 
Global up2.w 
Global down.w 
Global down2.w 
Global key.w 
Global v.b 
Global max.b 
Global size1.w 
Global size2.w 
Global x.b 
Global y.b 
Global exist.b 
Global itemX.w 
Global itemY.w 
Global gesamtexist.b 
Dim beruehr.b(#max) 
ballexist(1) = 1 
For x = 1 To 5 
  LoadSprite(x,"items\item"+Str(x)+".bmp") 
Next 
size1 = 30 
size2 = 30 
V = 2 
OpenFile(1, "control") 
up=Readword() 
down=Readword() 
up2=Readword() 
down2=ReadWord() 
V = ReadByte() 
max = ReadByte() 
CloseFile(1) 
LoadSound(1,"pop.wav") 
LoadSound(2,"laugh.wav") 
player1 = 0 
player2 = 0 
LoadFont(1,"Arial",15,#PB_Font_Bold) 
LoadFont(2,"Arial",40,#PB_Font_Bold | #PB_Font_Underline) 
LoadFont(3,"Arial",10,#PB_Font_Italic)    
menue: 
wahl1: 
Delay(100) 
StartDrawing(ScreenOutput()) 
DrawingMode(1) 
ClearScreen(0,0,0) 
DrawingFont(UseFont(2)) 
FrontColor($7B,$7B,$7B) 
Locate(200,100) 
DrawText("PONG") 
FrontColor(255,255,255) 
DrawingFont(UseFont(3)) 
Locate(200,160) 
DrawText("by BenpiccoSoft") 
Locate(200,180) 
DrawText("former source by Martin Jässing") 
DrawingFont(UseFont(1)) 
FrontColor($1B,$1E,$E4) 
Locate(200,210) 
DrawText("Start") 
FrontColor(255,255,255) 
Locate(200,230) 
DrawText("Setup") 
FrontColor(255,255,255) 
Locate(200,250) 
DrawText("Former game from the PB Tutorium") 
Locate(200,270) 
DrawText("Exit To Windows") 
StopDrawing() 
FlipBuffers() 
Repeat 
  ExamineKeyboard() 
  If KeyboardPushed(200) 
    Goto wahl3 
  Else 
    If KeyboardPushed(208) 
      Goto wahl2 
    EndIf 
  EndIf 
Until KeyboardPushed(28) 
Goto start 
wahl2: 
Delay(100) 
StartDrawing(ScreenOutput()) 
DrawingMode(1) 
ClearScreen(0,0,0) 
DrawingFont(UseFont(2)) 
FrontColor($7B,$7B,$7B) 
Locate(200,100) 
DrawText("PONG") 
FrontColor(255,255,255) 
DrawingFont(UseFont(3)) 
Locate(200,160) 
DrawText("by BenpiccoSoft") 
Locate(200,180) 
DrawText("former source by Martin Jässing") 
DrawingFont(UseFont(1)) 
FrontColor(255,255,255) 
Locate(200,210) 
DrawText("Start") 
FrontColor($1B,$1E,$E4) 
Locate(200,230) 
DrawText("Setup") 
FrontColor(255,255,255) 
Locate(200,250) 
DrawText("Former game from the PB Tutorium") 
FrontColor(255,255,255) 
Locate(200,270) 
DrawText("Exit To Windows") 
StopDrawing() 
FlipBuffers() 
Repeat 
  ExamineKeyboard() 
  If KeyboardPushed(200) 
    Goto wahl1 
  Else 
    If KeyboardPushed(208) 
      Goto wahl4 
    EndIf 
  EndIf 
Until KeyboardPushed(28) 
Goto setup 
setup: 
ClearScreen(0,0,0) 
FlipBuffers() 
up: 
Repeat 
  ClearScreen(0,0,0) 
  StartDrawing(ScreenOutput()) 
  DrawingMode(1) 
  FrontColor(255,255,255) 
  Locate(200,200) 
  DrawText("Player one, press key For up") 
  FlipBuffers() 
  StopDrawing() 
  Delay(100) 
  key = 0 
  ExamineKeyboard() 
  Repeat 
    If KeyboardPushed(key) 
      up =key 
      Goto down 
    EndIf 
    key = key+1 
  Until key=257 
Until KeyboardPushed(1) 
Goto up 
down: 
Delay(500) 
Repeat 
  ClearScreen(0,0,0) 
  StartDrawing(ScreenOutput()) 
  DrawingMode(1) 
  FrontColor(255,255,255) 
  Locate(200,200) 
  DrawText("Player one, press key For down") 
  FlipBuffers() 
  StopDrawing() 
  Delay(100) 
  key = 0 
  ExamineKeyboard() 
  Repeat 
    If KeyboardPushed(key) 
      down = key 
      Goto up2 
    EndIf 
    key = key+1 
  Until key=257 
Until KeyboardPushed(1) 
Goto down 
up2: 
Delay(500) 
Repeat 
  ClearScreen(0,0,0) 
  StartDrawing(ScreenOutput()) 
  DrawingMode(1) 
  Locate(200,200) 
  FrontColor(255,255,255) 
  DrawText("Player two, press key For up") 
  FlipBuffers() 
  StopDrawing() 
  Delay(100) 
  key = 0 
  ExamineKeyboard() 
  Repeat 
    If KeyboardPushed(key) 
      up2 = key 
      Goto down2 
    EndIf 
    key = key+1 
  Until key=257 
Until KeyboardPushed(1) 
Goto up2 
down2: 
Delay(500) 
Repeat 
  ClearScreen(0,0,0) 
  StartDrawing(ScreenOutput()) 
  DrawingMode(1) 
  Locate(200,200) 
  FrontColor(255,255,255) 
  DrawText("Player two, press key For down") 
  FlipBuffers() 
  StopDrawing() 
  Delay(100) 
  key = 0 
  ExamineKeyboard() 
  Repeat 
    If KeyboardPushed(key) 
      down2 = key 
      Goto speed: 
    EndIf 
    key = key+1 
  Until key=257 
Until KeyboardPushed(1) 
Goto down2 
speed: 
Delay(500) 
Repeat 
  ClearScreen(0,0,0) 
  StartDrawing(ScreenOutput()) 
  DrawingMode(1) 
  Locate(200,200) 
  FrontColor(255,255,255) 
  DrawText("Chose game speed(1=slow 2=normal 3=fast) No numpad") 
  FlipBuffers() 
  StopDrawing() 
  Delay(100) 
  key = 0 
  ExamineKeyboard() 
  Repeat 
    If KeyboardPushed(key) 
      v = key -1 
      Goto max 
    EndIf 
    key = key +1 
  Until key = 10 
Until KeyboardPushed(1) 
max: 
Repeat 
  ClearScreen(0,0,0) 
  StartDrawing(ScreenOutput()) 
  DrawingMode(1) 
  Locate(200,200) 
  FrontColor(255,255,255) 
  DrawText("Points to win") 
  Locate(200,220) 
  DrawText(Str(max)) 
  FlipBuffers() 
  StopDrawing() 
  Delay(100) 
  ExamineKeyboard() 
  If KeyboardPushed(#PB_Key_Up) 
    max = max +1 
  EndIf 
  If KeyboardPushed(#PB_Key_Down) And max > 1 
    max = max -1 
  EndIf              
Until KeyboardPushed(#PB_Key_Return) 
Delay(100) 
write: 
ClearScreen(0,0,0) 
FlipBuffers() 
ClearScreen(0,0,0) 
FlipBuffers() 
OpenFile(1,"control") 
UseFile(1) 
WriteWord(up) 
WriteWord(down) 
WriteWord(up2) 
WriteWord(down2) 
WriteByte(v) 
WriteByte(max) 
WriteString("Do not change this file!") 
CloseFile(1) 
Delay(100) 
Goto wahl2 
wahl3: 
Delay(100) 
StartDrawing(ScreenOutput()) 
ClearScreen(0,0,0) 
DrawingMode(1) 
DrawingFont(UseFont(2)) 
FrontColor($7B,$7B,$7B) 
Locate(200,100) 
DrawText("PONG") 
FrontColor(255,255,255) 
DrawingFont(UseFont(3)) 
Locate(200,160) 
DrawText("by BenpiccoSoft") 
Locate(200,180) 
DrawText("former source by Martin Jässing") 
DrawingFont(UseFont(1)) 
Locate(200,210) 
DrawText("Start") 
FrontColor(255,255,255) 
Locate(200,230) 
DrawText("Setup") 
Locate(200,250) 
DrawText("Former game from the PB Tutorium") 
FrontColor($1B,$1E,$E4) 
Locate(200,270) 
DrawText("Exit To Windows") 
StopDrawing() 
FlipBuffers() 
Repeat 
  ExamineKeyboard() 
  If KeyboardPushed(200) 
    Goto wahl4 
  Else 
    If KeyboardPushed(208) 
      Goto wahl1 
    EndIf 
  EndIf 
Until KeyboardPushed(28) 
End 
wahl4: 
Delay(100) 
StartDrawing(ScreenOutput()) 
DrawingMode(1) 
ClearScreen(0,0,0) 
DrawingFont(UseFont(2)) 
FrontColor($7B,$7B,$7B) 
Locate(200,100) 
DrawText("PONG") 
FrontColor(255,255,255) 
DrawingFont(UseFont(3)) 
Locate(200,160) 
DrawText("by BenpiccoSoft") 
Locate(200,180) 
DrawText("former source by Martin Jässing") 
DrawingFont(UseFont(1)) 
FrontColor(255,255,255) 
Locate(200,210) 
DrawText("Start") 
FrontColor(255,255,255) 
Locate(200,230) 
DrawText("Setup") 
FrontColor($1B,$1E,$E4) 
Locate(200,250) 
DrawText("Former game from the PB Tutorium") 
FrontColor(255,255,255) 
Locate(200,270) 
DrawText("Exit To Windows") 
StopDrawing() 
FlipBuffers() 
Repeat 
  ExamineKeyboard() 
  If KeyboardPushed(200) 
    Goto wahl2 
  Else 
    If KeyboardPushed(208) 
      Goto wahl3 
    EndIf 
  EndIf 
Until KeyboardPushed(28) 
Goto game  
start: 
BallX(1) = Int(Random(400)+100) 
BallY(1) = Int(Random(300)+100) 
For x = 1 To #max 
  If Int(Random(2))=1 
    BewegX(x) = -v 
  Else 
    BewegX(x) = v 
  EndIf 
  If Int(Random(2))=1 
    BewegY(x) = -v 
  Else 
    BewegY(x) = v 
  EndIf 
Next 
ballexist(1) = 1 
SchlaegerX = 639 - 10 
SchlaegerY = 239 - (30 / 2) 
SchlaegerX2 = 1 
SchlaegerY2= 239-(30-2) 
Repeat 
  weiter: 
  ; 2. Grafik setzen 
  ClearScreen(0,0,0) 
  If Random(500) = Random(500) And exist = 0 
    x = Random(4)+1 
    itemX=(Random(400)+50) 
    itemY=(Random(200)+50) 
    DisplaySprite(x,itemX,itemY) 
    exist = x 
  EndIf 
  If exist <> 0 
    DisplaySprite(exist,itemX,itemY) 
  EndIf 
  StartDrawing(ScreenOutput()) 
  For x = 1 To #max 
    If ballexist(x)=1 
      Circle(BallX(x)-1,BallY(x)-1,3,RGB(Random(255),Random(255),Random(255))) 
    EndIf 
  Next 
  FrontColor(255,255,255) 
  DrawingMode(1) 
  Box(10,0,620,5) 
  Box(10,475,620,480) 
  Box(SchlaegerX,SchlaegerY,10,size1) 
  Box(SchlaegerX2,SchlaegerY2,10,size2) 
  DrawingFont(UseFont(1)) 
  Locate(10,10) 
  DrawText(Str(Player1)) 
  Locate(618,10) 
  DrawText(Str(Player2)) 
  StopDrawing() 
  FlipBuffers() 
  ; 3. Abfrage der Benutzer Eingaben 
  ExamineKeyboard() 
  If KeyboardPushed(up) 
    SchlaegerY - v 
  EndIf 
  If KeyboardPushed(down) 
    SchlaegerY + v 
  EndIf 
  UseFont(1) 
  If SchlaegerY < 6 
    SchlaegerY = 5 
  ElseIf SchlaegerY > 475 - size1 
    SchlaegerY = 475 - size1 
  EndIf 
  ExamineKeyboard() 
  If KeyboardPushed(up2) 
    SchlaegerY2 - v 
  EndIf 
  If KeyboardPushed(down2) 
    SchlaegerY2 + v 
  EndIf 
  If SchlaegerY2 < 6 
    SchlaegerY2 = 5 
  ElseIf SchlaegerY2 > 475 - size2 
    SchlaegerY2 = 475 - size2 
  EndIf 
  ; 4. Bewegung des Balles 
  For x = 1 To #max 
    If ballexist(x) = 1 
      BallX(x) + BewegX(x) 
      BallY(x) + BewegY(x) 
    EndIf 
  Next 
  ; 5. Kollision 
  For x = 1 To #max 
    If BallY(x) < 5 And ballexist(x) <> 0 
      BewegY(x) = v 
      SoundVolume(1,50) 
      SoundPan(1,0) 
      PlaySound(1)  
    EndIf 
    If BallY(x) > 475 And ballexist(x) <> 0 
      BewegY(x) = -v 
      SoundVolume(1,50) 
      SoundPan(1,0) 
      PlaySound(1) 
    EndIf 
    If exist <> 0 And beruehr(x) = 1 And BallX(x) <= itemX + 65 And BallY(x) <= itemY+65 And BallY(x) >= itemY And BallX(x) >= itemX And ballexist(x) = 1 
      If exist = 1 
        size1 = size1 +10 
      EndIf 
      If exist = 2 And size1 > 10 
        size1 = size1 -10 
      EndIf 
      If exist = 3 
        For y = 1 To #max 
          If ballexist(y) = 0 
            ballexist(y) = 1 
            BallX(y) = Int(Random(400)+100) 
            BallY(y) = Int(Random(300)+100) 
            exist = 0 
            Goto weiter 
          EndIf 
        Next 
      EndIf 
      If exist = 4 
        For y = 1 To #max 
          nochmal: 
          BewegX(y) = Random(4)-Random(8) 
          BewegY(y) = Random(4)-Random(8) 
          If BewegX(y)=0 And BewegY(y)=0 
            Goto nochmal 
          EndIf  
        Next 
        exist = 0 
      EndIf 
      If exist = 5 
        v = Random(v+3)-Random(v+6) 
        If v = 0 
          v = 2 
        EndIf 
        exist = 0 
      EndIf  
    EndIf 
    If exist <> 0 And beruehr(x) = 2 And BallX(x) <= itemX + 65 And BallY(x) <= itemY+65 And BallY(x) >= itemY And BallX(x) >= itemX And ballexist(x) = 1 
      If exist = 1 
        size2 = size2 +10 
      EndIf 
      If exist = 2 And size2 > 10 
        size2 = size2 - 10 
      EndIf 
      If exist = 3 
        For y = 1 To #max 
          If ballexist(y) = 0 
            ballexist(y) = 1 
            BallX(y) = Int(Random(400)+100) 
            BallY(y) = Int(Random(300)+100) 
            exist = 0 
            Goto weiter 
          EndIf 
        Next 
      EndIf 
      If exist = 4 
        For y = 1 To #max 
          nochmal2: 
          BewegX(y) = Random(4)-Random(8) 
          BewegY(y) = Random(4)-Random(8) 
          If BewegX(y)=0 And BewegY(y)=0 
            Goto nochmal2 
          EndIf  
        Next 
        exist = 0 
      EndIf 
      If exist = 5 
        v = Random(v+3)-Random(v+6) 
        If v = 0 
          v = 2 
        EndIf 
        exist = 0 
      EndIf  
    EndIf 
    If BallX(x) > SchlaegerX And BallX(x) < SchlaegerX + 10 And BallY(x) > SchlaegerY And BallY(x) < SchlaegerY + size1 And ballexist(x) <> 0 
      BewegX(x) = -v 
      SoundVolume(1,100) 
      SoundPan(1,100) 
      PlaySound(1) 
      beruehr(x) = 1 
    EndIf 
    If BallX(x) > SchlaegerX2 And BallX(x) < SchlaegerX2 + 10 And BallY(x) > SchlaegerY2 And BallY(x) < SchlaegerY2 + size2 And ballexist(x) <> 0 
      BewegX(x) = v 
      SoundVolume(1,100) 
      SoundPan(1,-100) 
      PlaySound(1) 
      beruehr(x) = 2 
    EndIf 
    If (BallX(x) > 640 And ballexist(x) <> 0) Or (BallX(x) < 0 And ballexist(x) <> 0) 
      If BewegX(x) = v 
        SoundPan(2,100) 
        PlaySound(2) 
        Player1 = Player1 +1 
      EndIf 
      If BewegX(x) = -v 
        SoundPan(2,-100) 
        PlaySound(2) 
        Player2 = Player2 + 1 
      EndIf 
      beruehr(x) = 0 
      ballexist(x) = 0 
      gesamtexist = 0 
      For y = 1 To #max 
        gesamtexist = gesamtexist + ballexist(y) 
      Next 
      If gesamtexist = 0 
        exist = 0 
        Goto start 
      EndIf 
    EndIf 
  Next 
Until KeyboardPushed(1) Or Player1=max Or Player2=max 
CloseScreen() 
If Player1>Player2 
  MessageRequester("Game Over","Player 1 wins with "+Str(Player1)+" Points!",0) 
  End 
Else 
  If Player1<Player2 
    MessageRequester("Game Over","Player 2 wins with "+Str(Player2)+" Points!",0) 
    End 
  EndIf 
  If Player1=Player2 
    MessageRequester("Game Over","Nobody wins...",0) 
    End 
  EndIf 
  End 
EndIf 
game: 
CloseScreen() 
MessageRequester("Info","This game is from a tutorial I got from www.purebasic.de. With this I learned the language. This game was na example for something. It was made by Martin Jässing") 
IncludeFile("Beispiel7_1.pb") 
Wer es schafft, das zum laufen zu bringen: ich weiß noch nicht ob die items 4 und 5 funktionieren, wie sie sollen, ich konnt´s ja noch nicht testen ;)

Edit by NicTheQuick: Code eingerückt

Verfasst: 29.10.2004 20:56
von Maurizio555
Auf dem ersten Blick würde ich sagen, du versuchst außerhalb des Arraybereiches zu schreiben. Dadurch wird irgendedwas im Speicher überschrieben. Nur so könnte ich mir eine Fehlermeldung erklären, die kein Text enthält.

Verfasst: 29.10.2004 20:59
von Maurizio555
Dim BewegX.w(#max)
Dim BewegY.w(#max)

Damit erzeugst du ein Array mit #max Felder. Das heisst: von 0 bis
#max-1

dann schreibst du mit for... 1 to #max in den Array.
Bei Schritt #max bist du um 1 Feld über den arraybereich.

Verfasst: 29.10.2004 21:03
von remi_meier
Nein bei Dim gehts von 0 - #max. Das ist nur bei statischen Arrays in Strukturen so!
Also:
Dim a(#max) ;0 bis und mit #max
structure
a[#max] ;0 bis #max - 1
endstructure

greetz
remi

Verfasst: 29.10.2004 21:05
von Maurizio555
Ok, habs mit C++ verwechselt... :)

Verfasst: 31.10.2004 17:43
von benpicco
Nein, mit Arrys hat das nix zu tun.
Eher aber mit der DEMO von Purebasic. Da steht zwar code limitation (ca. 800 lines), sobald ich aber über ca. 590 komme, kommt eben das. Ich hab das Problem jetzt gelöst indem ich was mit include Dateien gemacht hab. :mrgreen:
Da hätten die von Purebasic auch nochmal die 800 lines nachzählen können ^^