Seite 1 von 1
Nächstes Problem mit Exe-Datei
Verfasst: 24.10.2005 13:11
von PB42
Hallo,
Mein Ball-Spiel lief in der Demo-Version 3.0 einwandfrei und macht jetzt auf der Demo-Version 3.94 Probleme, denn Init-Sprite läßt sich nun luxoriöserweise nur noch einmal aufrufen, aber ich möchte ja schließlich das Programm nach "Game Over" neu starten können. Dies tue ich über "Closescreen" und Goto Programmbeginn, welcher mit "Initsprite" beginnt. Mit der Demo-Version 3.0 klappte das einwandfrei.
PB42
Verfasst: 24.10.2005 13:20
von MVXA
> Goto Programmbeginn, welcher mit "Initsprite" beginnt. Mit der Demo-Version 3.0 klappte das einwandfrei.
Dir ist klar, dass du die Sprungmarke auch hinter dem InitSprite()
legen kannst? Außerdem sind Gotos ein gaaaaaaaaanz dickes Pfui.
Ich hab leider nicht genug Geld für eine Kristallkugel und ohne Code
lässt sich leider nicht erklären warum dein Spiel nach einem Druck auf
die F1 Taste abbricht. Deswegen: immer fleißig Code posten. Danke.
Verfasst: 24.10.2005 13:37
von PB42
Natürlich ist mir klar, daß ich die Sprungmarke auch später legen kann, aber dann kommt ebenfalls eine Fehlermeldung nach der anderen.
Hier ist der Code, welcher auf 3.0 einwandfrei lief:
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ägerrunung
w = 0 ;Start-Verzögerung 2,5 sec.
Zaehler = 0 ;für Punkte-Anzeige am Spielende
runx = 0
runy = 0
f = 0
D:
xb = Random(550) ;Ausgangsposition
yb = Random(455) ;Ball
If xb < 25 Or yb < 25
Goto D
EndIf
arial = LoadFont(#PB_Any, "Arial", 15, #PB_Font_HighQuality)
Repeat
ClearScreen(0,180,0)
StartDrawing(ScreenOutput())
ExamineKeyboard()
FrontColor(240,255,255)
Box(0,0,20,480)
Box(20,0,640,20)
Box(20,460,620,20)
FrontColor(0,0,0)
Box(x1,y1,x2,y2) ;Schläger
Circle(xb,yb,4,RGB(0,0,200))
If f=1
Goto C
EndIf
Locate(25,21)
DrawingMode(1)
DrawingFont(UseFont(arial))
DrawText("Tempo wählen mit 1, 2, 3")
ExamineKeyboard()
C:
StopDrawing()
FlipBuffers()
If f=0
If KeyboardPushed(#PB_key_1)
p=1
f=1
a = 3
runx = -a
ar = Random(1) + 1
Select ar
Case 1
runy = a
Case 2
runy = -a
Default
EndSelect
EndIf
If KeyboardPushed(#PB_key_2)
p=2
f=1
a = 4
runx = -a
ar = Random(1) + 1
Select ar
Case 1
runy = a
Case 2
runy = -a
Default
EndSelect
EndIf
If KeyboardPushed(#PB_key_3)
p=3
f=1
a = 5
runx = -a
ar = Random(1) + 1
Select ar
Case 1
runy = a
Case 2
runy = -a
Default
EndSelect
EndIf
EndIf
xb = xb + runx ;Ballrunung in x-Richtung
yb = yb + runy
If xb < 23 ;Ball-Anschlag linke Bande
runx = a ;runungsumkehr
EndIf
If yb < 23 ;Ball-Anschlag obere Bande
runy = a ;runungsumkehr
EndIf
If yb > 457 ;Ball-Anschlag untere Bande
runy = -a ;runungsumkehr
EndIf
If KeyboardPushed(#PB_key_up)
y1 = y1 - kp
If y1 < 20
y1 = 20
EndIf
EndIf
If KeyboardPushed(#PB_key_down)
y1 = y1 + kp
If y1 > (460 - y2)
y1 = 460 - y2
EndIf
EndIf
If xb > 620 And xb < 627 And yb > y1-5 And yb < (y1 + y2+5)
runx = -a
Zaehler = Zaehler + 1
EndIf
If xb > 653
Repeat
ClearScreen(0,180,0)
StartDrawing(ScreenOutput())
FrontColor(240,255,255)
Box(0,0,20,480)
Box(20,0,640,20)
Box(20,460,620,20)
FrontColor(0,0,0)
Box(x1,y1,x2,y2) ;Schläger
DrawingMode(0)
Locate(25,25)
FrontColor(0,0,255)
DrawingFont(UseFont(arial))
DrawText("GAME OVER")
DrawingMode(1)
Locate(25,60)
FrontColor(0,0,255)
DrawText(Str(Zaehler * 10) + " Punkte mit Tempo " + Str(p) + " erreicht")
Locate(25,85)
FrontColor(0,0,255)
DrawText("Nochmal starten: F1")
Locate(25,110)
FrontColor(0,0,255)
DrawText("Spiel beenden: ESC")
StopDrawing()
FlipBuffers()
ExamineKeyboard()
If KeyboardPushed(#PB_key_escape)
End
EndIf
If KeyboardPushed(#PB_key_F1)
CloseScreen()
Goto A:
EndIf
ForEver
EndIf
If KeyboardPushed(#PB_key_escape)
End
EndIf
ForEver
Wie bekommt man denn dieses Programm für 3.94 zum laufen? Danke.
PB42
Verfasst: 24.10.2005 13:49
von ts-soft
Wenn Du den Anfang so änderst, funzt es schon mal, jedenfalls bei mir:
Code: Alles auswählen
InitSprite()
InitKeyboard()
A:
OpenScreen(640,480,32,"Ballspiel")
Verfasst: 24.10.2005 13:54
von MVXA
das hier funkt:
Code: Alles auswählen
InitSprite()
InitKeyboard()
arial = LoadFont(#PB_Any, "Arial", 15, #PB_Font_HighQuality)
OpenScreen(640,480,32,"Ballspiel")
A:
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ägerrunung
w = 0 ;Start-Verzögerung 2,5 sec.
Zaehler = 0 ;für Punkte-Anzeige am Spielende
runx = 0
runy = 0
f = 0
D:
xb = Random(550) ;Ausgangsposition
yb = Random(455) ;Ball
If xb < 25 Or yb < 25
Goto D
EndIf
Repeat
ClearScreen(0,180,0)
StartDrawing(ScreenOutput())
ExamineKeyboard()
FrontColor(240,255,255)
Box(0,0,20,480)
Box(20,0,640,20)
Box(20,460,620,20)
FrontColor(0,0,0)
Box(x1,y1,x2,y2) ;Schläger
Circle(xb,yb,4,RGB(0,0,200))
If f=1
Goto C
EndIf
Locate(25,21)
DrawingMode(1)
DrawingFont(UseFont(arial))
DrawText("Tempo wählen mit 1, 2, 3")
ExamineKeyboard()
C:
StopDrawing()
FlipBuffers()
If f=0
If KeyboardPushed(#PB_Key_1)
p=1
f=1
a = 3
runx = -a
ar = Random(1) + 1
Select ar
Case 1
runy = a
Case 2
runy = -a
Default
EndSelect
EndIf
If KeyboardPushed(#PB_Key_2)
p=2
f=1
a = 4
runx = -a
ar = Random(1) + 1
Select ar
Case 1
runy = a
Case 2
runy = -a
Default
EndSelect
EndIf
If KeyboardPushed(#PB_Key_3)
p=3
f=1
a = 5
runx = -a
ar = Random(1) + 1
Select ar
Case 1
runy = a
Case 2
runy = -a
Default
EndSelect
EndIf
EndIf
xb = xb + runx ;Ballrunung in x-Richtung
yb = yb + runy
If xb < 23 ;Ball-Anschlag linke Bande
runx = a ;runungsumkehr
EndIf
If yb < 23 ;Ball-Anschlag obere Bande
runy = a ;runungsumkehr
EndIf
If yb > 457 ;Ball-Anschlag untere Bande
runy = -a ;runungsumkehr
EndIf
If KeyboardPushed(#PB_Key_Up)
y1 = y1 - kp
If y1 < 20
y1 = 20
EndIf
EndIf
If KeyboardPushed(#PB_Key_Down)
y1 = y1 + kp
If y1 > (460 - y2)
y1 = 460 - y2
EndIf
EndIf
If xb > 620 And xb < 627 And yb > y1-5 And yb < (y1 + y2+5)
runx = -a
Zaehler = Zaehler + 1
EndIf
If xb > 653
Repeat
ClearScreen(0,180,0)
StartDrawing(ScreenOutput())
FrontColor(240,255,255)
Box(0,0,20,480)
Box(20,0,640,20)
Box(20,460,620,20)
FrontColor(0,0,0)
Box(x1,y1,x2,y2) ;Schläger
DrawingMode(0)
Locate(25,25)
FrontColor(0,0,255)
DrawingFont(UseFont(arial))
DrawText("GAME OVER")
DrawingMode(1)
Locate(25,60)
FrontColor(0,0,255)
DrawText(Str(Zaehler * 10) + " Punkte mit Tempo " + Str(p) + " erreicht")
Locate(25,85)
FrontColor(0,0,255)
DrawText("Nochmal starten: F1")
Locate(25,110)
FrontColor(0,0,255)
DrawText("Spiel beenden: ESC")
StopDrawing()
FlipBuffers()
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Escape)
End
EndIf
If KeyboardPushed(#PB_Key_F1)
Goto A:
EndIf
ForEver
EndIf
If KeyboardPushed(#PB_Key_Escape)
End
EndIf
ForEver
Verfasst: 24.10.2005 13:58
von PB42
Tatsächlich, bei mir funzt das auch. Danke Thomas. Meine Laune bessert sich nun deutlich.
PB42
Verfasst: 24.10.2005 14:02
von PB42
Danke auch an MVXA, das ist super, weil der screen dann immer aufbleibt und dadurch dann das Neustarten besonders schnell erfolgen kann.
PB42
Verfasst: 24.10.2005 14:10
von freedimension
Statt
Code: Alles auswählen
D:
xb = Random(550) ;Ausgangsposition
yb = Random(455) ;Ball
If xb < 25 Or yb < 25
Goto D
EndIf
kannst du übrigens auch ganz einfach
schreiben

Verfasst: 24.10.2005 14:25
von PB42
Stimmt: Clever!
PB42