Seite 1 von 1
Drawstart: Null Value (?!?) - (Titel-Thema geändert)
Verfasst: 17.10.2005 21:35
von PB42
Hallo,
hier stand erst etwas anderes, aber das hat sich mittlerweile erledigt. Jetzt geht es mir um das Problem Null Value bei Drawstart, denn ich kann nirgendwo herausfinden, was das soll und wie man das verhindert.
PB42
Verfasst: 17.10.2005 21:52
von PB42
Hier stand erst etwas anderes, aber das hat sich mittlerweile erledigt.
PB42
Verfasst: 17.10.2005 22:31
von spacewalker
Ich verstehe nicht wirklich was du meinst

intuitiv - versuch mal KeyboardReleased(), wenn ich dein problem auch nur ansatzweise verstanden habe, was ich allerdings stark bezweifle

Verfasst: 17.10.2005 23:51
von PB42
Das Problem hat sich mittlerweile erledigt, da war ich einfach zu voreilig mit meiner Frage, aber was mich immernoch gewaltig nervt und wofür ich auch die Ursache nicht weiß, ist die Melung Null Value bei StartDrawing. Wie kann man diese Fehlermeldung vermeiden? Das würde mich interessieren. Danke.
PB42
Verfasst: 17.10.2005 23:58
von Deeem2031
Wann kommt die Meldung denn und was hast du bei StartDrawing() als Parameter angegeben?
Verfasst: 18.10.2005 00:20
von PB42
Die Meldung kommt in folgender Schleife, in welcher in meinem Programm erstmals der StartDrawing(screenOutput())-Befehl erscheint:
Code: Alles auswählen
Repeat
ClearScreen(0,200,0)
StartDrawing(ScreenOutput())
ExamineKeyboard()
FrontColor(0,0,0)
Box(x1,y1,x2,y2) ;Schläger
Circle(xb,yb,5,RGB(0,0,200)) ;Ball
FrontColor(0,0,255)
DrawingMode(1)
Locate(1,0)
DrawText("Tempostufe vorwählen: 1,2,3,4")
If KeyboardPushed(#PB_key_1)
a = 2
bewegx = -a
bewegy = -a
Goto B
EndIf
If KeyboardPushed(#PB_key_2)
a = 3
bewegx = -a
bewegy = -a
Goto B
EndIf
If KeyboardPushed(#PB_key_3)
a = 4
bewegx = -a
bewegy = -a
Goto B
EndIf
If KeyboardPushed(#PB_key_4)
a = 5
bewegx = -a
bewegy = -a
Goto B
EndIf
StopDrawing()
FlipBuffers()
If KeyboardPushed(#PB_key_Escape)
End
EndIf
ForEver
Wieso schreibt einem PB vor, ob man StartDrawing verwenden darf oder nicht?
PB42
Verfasst: 18.10.2005 00:51
von PB42
Ergänzung: Die Fehlermeldung kommt immer erst, nachdem ich 1, 2, 3, oder 4 gedrückt habe, Tschuldigung, daß ich das nicht früher gemerkt habe. Also liegt der Hase erst später im Pfeffer. Der Fehler wird jedoch in obiger Schleife angezeigt. Das ganze hat nur dann Zwck, wenn ich mal den Gesamtcode poste und hier ist er:
Code: Alles auswählen
A:
InitSprite()
InitKeyboard()
OpenScreen(640,480,32,"Ballspiel")
x2 = 15 ;Dicke des Schlägers
y2 = 50 ;Länge des Schlägers
x1 = 635 - x2 ;Koordinaten
y1 = 240 - Y2/2 ;für den Schläger linke obere Ecke
kp = 5 ;Tempostufe Schlägerbewegung
w = 0 ;Start-Verzögerung 2,5 sec.
Zaehler = 0 ;für Punkte-Anzeige am Spielende
xb = Random(550) ;Ausgangsposition
yb = Random(480) ;Ball
a = 1
bewegx = -a
bewegy = -a
Repeat
Delay(10)
Repeat
ClearScreen(0,200,0)
StartDrawing(ScreenOutput())
FrontColor(0,0,0)
Box(x1,y1,x2,y2) ;Schläger
Circle(xb,yb,5,RGB(0,0,200)) ;Ball
FrontColor(0,0,255)
DrawingMode(1)
Locate(1,0)
DrawText("Tempostufe vorwählen: 1,2,3,4")
ExamineKeyboard()
If KeyboardPushed(#PB_key_1)
a = 2
bewegx = -a
bewegy = -a
Goto B
EndIf
ExamineKeyboard()
If KeyboardPushed(#PB_key_2)
a = 3
bewegx = -a
bewegy = -a
Goto B
EndIf
ExamineKeyboard()
If KeyboardPushed(#PB_key_3)
a = 4
bewegx = -a
bewegy = -a
Goto B
EndIf
ExamineKeyboard()
If KeyboardPushed(#PB_key_4)
a = 5
bewegx = -a
bewegy = -a
Goto B
EndIf
StopDrawing()
FlipBuffers()
If KeyboardPushed(#PB_key_Escape)
End
EndIf
ForEver
B:
StopDrawing()
FlipBuffers()
ClearScreen(0,200,0)
StartDrawing(ScreenOutput())
FrontColor(0,0,0)
Box(x1,y1,x2,y2) ;Schläger
Circle(xb,yb,5,RGB(0,0,200)) ;Ball
If w = 0
w = 1
Delay(1500)
EndIf
xb = xb + bewegx ;Ballbewegung in x-Richtung
yb = yb + bewegy ;Ballbewegung in y-Richtung
If xb < 0 ;Ball-Anschlag linke Bande
bewegx = a ;Bewegungsumkehr
EndIf
If yb < 0 ;Ball-Anschlag obere Bande
bewegy = a ;Bewegungsumkehr
EndIf
If yb > 480 ;Ball-Anschlag untere Bande
bewegy = -a ;Bewegungsumkehr
EndIf
ExamineKeyboard()
If KeyboardPushed(#PB_key_up)
y1 - kp
If y1 < 0
y1 = 0
EndIf
EndIf
ExamineKeyboard()
If KeyboardPushed(#PB_key_down)
y1 + kp
If y1 > (480 - y2)
y1 = 480 - y2
EndIf
EndIf
If xb >= x1 And yb > y1 And yb < (y1 + y2) ;y2 = Konstante für Schlägerlänge
bewegx = -a
Zaehler = Zaehler + 1
EndIf
If xb > 680
Repeat
ClearScreen(0,200,0)
StartDrawing(ScreenOutput())
DrawingMode(1)
Locate(1,0)
FrontColor(0,0,255)
DrawText(Str(Zaehler * 10) + " Punkte")
FrontColor(0,0,255)
Locate(1,20)
DrawText("Neus Spiel: F1")
FrontColor(0,0,255)
Locate(1,40)
DrawText("Abbrechen: ESC")
StopDrawing()
Delay(10)
FlipBuffers()
ExamineKeyboard()
If KeyboardPushed(#PB_key_escape)
End
EndIf
ExamineKeyboard()
If KeyboardPushed(#PB_key_F1)
CloseScreen()
Goto A
EndIf
ForEver
EndIf
If KeyboardPushed(#PB_key_escape)
End
EndIf
ForEver
Wenn ich einmal verstanden habe, WIESO es zu Null Value bei StartDrawing kommt, ist das ein Meilenstein für mich. Danke.
PB42
Verfasst: 18.10.2005 01:32
von Deeem2031
Erstmal solltest du das ganze ein wenig formatieren:
Code: Alles auswählen
A:
InitSprite()
InitKeyboard()
OpenScreen(640,480,32,"Ballspiel")
x2 = 15 ;Dicke des Schlägers
y2 = 50 ;Länge des Schlägers
x1 = 635 - x2 ;Koordinaten
y1 = 240 - Y2/2 ;für den Schläger linke obere Ecke
kp = 5 ;Tempostufe Schlägerbewegung
w = 0 ;Start-Verzögerung 2,5 sec.
Zaehler = 0 ;für Punkte-Anzeige am Spielende
xb = Random(550) ;Ausgangsposition
yb = Random(480) ;Ball
a = 1
bewegx = -a
bewegy = -a
Repeat
Delay(10)
Repeat
ClearScreen(0,200,0)
StartDrawing(ScreenOutput())
FrontColor(0,0,0)
Box(x1,y1,x2,y2) ;Schläger
Circle(xb,yb,5,RGB(0,0,200)) ;Ball
FrontColor(0,0,255)
DrawingMode(1)
Locate(1,0)
DrawText("Tempostufe vorwählen: 1,2,3,4")
ExamineKeyboard()
If KeyboardPushed(#PB_Key_1)
a = 2
bewegx = -a
bewegy = -a
Goto B
EndIf
ExamineKeyboard()
If KeyboardPushed(#PB_Key_2)
a = 3
bewegx = -a
bewegy = -a
Goto B
EndIf
ExamineKeyboard()
If KeyboardPushed(#PB_Key_3)
a = 4
bewegx = -a
bewegy = -a
Goto B
EndIf
ExamineKeyboard()
If KeyboardPushed(#PB_Key_4)
a = 5
bewegx = -a
bewegy = -a
Goto B
EndIf
StopDrawing()
FlipBuffers()
If KeyboardPushed(#PB_Key_Escape)
End
EndIf
ForEver
B:
StopDrawing()
FlipBuffers()
ClearScreen(0,200,0)
StartDrawing(ScreenOutput())
FrontColor(0,0,0)
Box(x1,y1,x2,y2) ;Schläger
Circle(xb,yb,5,RGB(0,0,200)) ;Ball
If w = 0
w = 1
Delay(1500)
EndIf
xb = xb + bewegx ;Ballbewegung in x-Richtung
yb = yb + bewegy ;Ballbewegung in y-Richtung
If xb < 0 ;Ball-Anschlag linke Bande
bewegx = a ;Bewegungsumkehr
EndIf
If yb < 0 ;Ball-Anschlag obere Bande
bewegy = a ;Bewegungsumkehr
EndIf
If yb > 480 ;Ball-Anschlag untere Bande
bewegy = -a ;Bewegungsumkehr
EndIf
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Up)
y1 - kp
If y1 < 0
y1 = 0
EndIf
EndIf
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Down)
y1 + kp
If y1 > (480 - y2)
y1 = 480 - y2
EndIf
EndIf
If xb >= x1 And yb > y1 And yb < (y1 + y2) ;y2 = Konstante für Schlägerlänge
bewegx = -a
Zaehler = Zaehler + 1
EndIf
If xb > 680
Repeat
ClearScreen(0,200,0)
StartDrawing(ScreenOutput())
DrawingMode(1)
Locate(1,0)
FrontColor(0,0,255)
DrawText(Str(Zaehler * 10) + " Punkte")
FrontColor(0,0,255)
Locate(1,20)
DrawText("Neus Spiel: F1")
FrontColor(0,0,255)
Locate(1,40)
DrawText("Abbrechen: ESC")
StopDrawing()
Delay(10)
FlipBuffers()
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape)
End
EndIf
ExamineKeyboard()
If KeyboardPushed(#PB_Key_F1)
CloseScreen()
Goto A
EndIf
ForEver
EndIf
If KeyboardPushed(#PB_Key_Escape)
End
EndIf
ForEver
Nun kann man schon den Code etwas besser lesen.
Und dann ist mir auch gleich aufgefallen das du nach B: zuerst StopDrawing() dann wieder StartDrawing() aber kein weiteres StopDrawing() benutzt. Wenn der Code bis zur unteren Schleife durchläuft wird zweimal nacheinander StartDRawing() aufgerufen, was durchaus den Fehler hervorrufen kann.
Verfasst: 18.10.2005 15:00
von PB42
Vielen Dank, Deeem2031, ich muß mich da nochmal richtig reindenken. Das tue ich jetzt.
PB42
Re: Drawstart: Null Value (?!?) - (Titel-Thema geändert)
Verfasst: 18.10.2005 15:05
von freedimension
PB42 hat geschrieben:Hallo,
hier stand erst etwas anderes, aber das hat sich mittlerweile erledigt. Jetzt geht es mir um das Problem Null Value bei Drawstart, denn ich kann nirgendwo herausfinden, was das soll und wie man das verhindert.
PB42
Öhm, wie wäre es einfach einen neuen Thread aufzumachen anstatt sämtliche Antworten die auf die alte Frage hin gegeben worden der Bedeutungslosigkeit preiszugeben indem sie aus dem Kontext gerissen werden???