Ich weis nicht, ich hab es so gemacht wie du es beschrieben hast.
mit z.B. Gosub Hauptmenü.
...
Irgentwie geht das nicht. Weis ich auch nicht, ich schreibs am besten in meinen Code hinein damit du dir das besser vorstellen kannst.
Code: Alles auswählen
; Hier werden die folgenden sachen getestet
If InitSprite() = 0 Or InitKeyboard() = 0 Or InitSound() = 0 Or InitMouse() = 0
End
EndIf
;Hier werden die einzelnen sachen wie Sound Decoder usw. geladen
UseOGGSoundDecoder()
; Hier wird das Scren für das ganze spiel gestartet
If OpenScreen(800, 600, 32, "noname")
;---------------------------------------------------------------------------
; --------HAUPTMENÜ----------
;---------------------------------------------------------------------------
Hauptmenu: ; Die SPRUNGMARKE ----------------------------------------
; HIER ERDEN DIE DATEIEN FÜR DAS HAUPTMENÜ GELADEN
LoadSprite(0, "Gfx\mainback.bmp", 0)
LoadSprite(1, "Gfx\play.bmp", 0)
LoadSprite(4, "Gfx\exit.bmp", 0)
LoadSprite(5, "Gfx\pointer.bmp", 0)
; Hier wird der Hintergrund sound des Hauptmenüs geladen
LoadSound(0, "Sfx\background.ogg")
SoundVolume(0, 50)
PlaySound(0, 1)
Delay(2000)
; Hier fängt das Hauptmenü an
Repeat
ExamineKeyboard()
ExamineMouse()
FlipBuffers()
ClearScreen(0, 0, 0)
DisplaySprite(0, 0, 0)
DisplayTransparentSprite(1, 550, 150)
DisplayTransparentSprite(4, 550, 250)
; der Mauszeider wird eingeblendet
mx = MouseX()
my = MouseY()
DisplayTransparentSprite(5, mx, my)
If MouseButton(1) And SpritePixelCollision(5, mx, my, 1, 550, 150)
play = 1
EndIf
If MouseButton(1) And SpritePixelCollision(5, mx, my, 4, 550, 250)
exit = 1
EndIf
Until exit = 1 Or play = 1
If exit = 1
End
EndIf
If play = 1
;^^ Das EndIF für das Play ist ganz unten im Programm beschrieben
;----------------------------------------------------------
; Kapitel 1 Die Freilassung aus dem Kerker
;-----------------------------------------------------------
FreeSprite(0)
FreeSprite(4)
FreeSprite(5)
FreeSound(0)
LoadSprite(0, "Gfx\schlossboden.bmp", 0)
LoadSprite(1, "Gfx\schlossmauerquer1.bmp", 0)
LoadSprite(2, "Gfx\schlossmauerlang1.bmp", 0)
LoadSprite(3, "Gfx\schlossmauerquer2.bmp", 0)
LoadSprite(4, "Gfx\schlossmauerlang2.bmp", 0)
LoadSprite(5, "Gfx\up.bmp", 0)
LoadSprite(6, "Gfx\down.bmp", 0)
LoadSprite(7, "Gfx\left.bmp", 0)
LoadSprite(8, "Gfx\right.bmp", 0)
LoadSprite(9, "Gfx\stand.bmp", 0)
LoadSprite(10, "Gfx\sichtfenster.bmp", 0)
LoadSprite(11, "Gfx\stopquer.bmp", 0)
LoadSprite(12, "Gfx\stoplang.bmp", 0)
LoadSprite(13, "Gfx\turm.bmp", 0)
LoadSprite(14, "Gfx\burgtor.bmp", 0)
LoadSprite(15, "Gfx\brunnen.bmp", 0)
LoadSprite(16, "Gfx\stopkleinlang.bmp", 0)
LoadSprite(17, "Gfx\stepin.bmp", 0)
LoadSprite(18, "Gfx\incomplete.bmp", 0)
; Der Ritter 1
LoadSprite(19, "Gfx\ritter2left.bmp", 0) ; Der Ritter kann nur nach rechts oder links laufen
LoadSprite(20, "Gfx\ritter2right.bmp", 0)
LoadSound(0, "Sfx\leute.wav")
SoundVolume(0, 50)
PlaySound(0, 1)
x = 372
y = 272
direction = up
;Das erste Trainingslevel
ritter2x = 500
ritterx = 200
Repeat
ExamineKeyboard()
FlipBuffers()
ClearScreen(0, 0, 0)
DisplaySprite(0, wx, wy) ;Den Booden darstellen
; Die Burgmauern anzeigen
;Oben
For m1=0 To 720 Step 80
DisplaySprite(1, wx+m1, wy)
Next
DisplaySprite(11, wx, wy+80)
; Unten
For m2=0 To 720 Step 80
DisplaySprite(3, wx+m2, wy+520)
Next
DisplaySprite(11, wx, wy+520)
; Links
For m3=0 To 520 Step 80
DisplaySprite(2, wx, wy+m3)
Next
DisplaySprite(12, wx+80, wy)
;Rechts wirn Manuell gemacht
; Die zwei Mauern über- und unterhalb vom tor manuel anzeigen
;oben
DisplaySprite(4, wx+720, wy+80)
;unten
DisplaySprite(4, wx+720, wy+440)
; Die Kollisionen
DisplaySprite(16, wx+720, wy+80)
DisplaySprite(16, wx+720, wy+440)
; HIER WERDEN GEBÄUDE WIE EIN TURM ANGEZEIGT
; Die vier Wachtürme
DisplayTransparentSprite(13, wx-12, wy-15)
DisplayTransparentSprite(13, wx-10, wy+510)
DisplayTransparentSprite(13, wx+710, wy-15)
DisplayTransparentSprite(13, wx+710, wy+510)
; Das Burgtor
DisplayTransparentSprite(14, wx+735, wy+160)
; Der Brunnen
DisplayTransparentSprite(15, wx+400, wy+256)
;Hier noch die Stepp inns
DisplaySprite(17, wx+710, wy+270)
If KeyboardPushed(#PB_Key_Up) = 0 And KeyboardPushed(#PB_Key_Down) = 0 And KeyboardPushed(#PB_Key_Left) = 0 And KeyboardPushed(#PB_Key_Right) = 0
DisplayTransparentSprite(9, x, y)
EndIf
; DIE TASTEN ZUR BEWEGUNG
If KeyboardPushed(#PB_Key_W)
If SpritePixelCollision(5, x, y, 11, wx, wy+80) Or SpriteCollision(5, x, y, 16, wx+720, wy+80) Or SpriteCollision(5, x, y, 16, wx+720, wy+440) Or SpriteCollision(5, x, y, 14, wx+725, wy+160) Or SpriteCollision(5, x, y, 15, wx+400, wy+256)
wy-4
EndIf
wy+2
DisplayTransparentSprite(5, x, y)
EndIf
If KeyboardPushed(#PB_Key_S)
If SpritePixelCollision(6, x, y, 11, wx, wy+520) Or SpriteCollision(6, x, y, 16, wx+720, wy+80) Or SpriteCollision(6, x, y, 16, wx+720, wy+440) Or SpriteCollision(6, x, y, 14, wx+725, wy+160) Or SpriteCollision(6, x, y, 15, wx+400, wy+256)
wy+4
EndIf
wy-2
DisplayTransparentSprite(6, x, y)
EndIf
If KeyboardPushed(#PB_Key_A)
If SpritePixelCollision(7, x, y, 12, wx+80, wy) Or SpriteCollision(7, x, y, 16, wx+720, wy+80) Or SpriteCollision(7, x, y, 16, wx+720, wy+440) Or SpriteCollision(7, x, y, 14, wx+725, wy+160) Or SpriteCollision(7, x, y, 15, wx+400, wy+256)
wx-4
EndIf
wx+2
DisplayTransparentSprite(7, x, y)
EndIf
If KeyboardPushed(#PB_Key_D)
If SpriteCollision(8, x, y, 16, wx+720, wy+80) Or SpriteCollision(8, x, y, 16, wx+720, wy+440) Or SpriteCollision(8, x, y, 14, wx+725, wy+160) Or SpriteCollision(8, x, y, 15, wx+400, wy+256)
wx+4
EndIf
wx-2
DisplayTransparentSprite(8, x, y)
EndIf
If KeyboardPushed(#PB_Key_E) And SpritePixelCollision(9, x, y, 17, wx+710, wy+270) And done = 3
nextlevel = 1
Else
DisplaySprite(18, 0, 0)
EndIf
; Hier wird der Ritter1 bewegt
If SpritePixelCollision(19, ritterx+wx, wy+40, 13, wx+710, wy-15)
back = 1
EndIf
If SpritePixelCollision(20, ritterx+wx, wy+40, 13, wx-12, wy-15)
back = 0
EndIf
If back = 1
ritterx-1
DisplayTransparentSprite(19, ritterx+wx, wy+40)
EndIf
If back = 0
ritterx+1
DisplayTransparentSprite(20, ritterx+wx, wy+40)
EndIf
; Hier ein Cheat das das Sichtfenster weggeht!!! :D
If KeyboardPushed(#PB_Key_P)
cheat = 1
EndIf
If KeyboardPushed(#PB_Key_O)
cheat = 0
EndIf
If cheat = 0
DisplayTransparentSprite(10, 0, 0) ; Damit man nich die gesammte Insel im Blick hat! :D Wird vorerst noch weggelassenDisplayTransparentSprite(5, 0, 0) ; Damit man nich die gesammte Insel im Blick hat! :D Wird vorerst noch weggelassen
EndIf
; Die abfrage ins nächste Level
If KeyboardPushed(#PB_Key_E) And SpritePixelCollision(9, x, y, 17, wx+710, wy+270)
; Hier kommt rein was passieren soll wenn man vor dem Burgtor in das rote feld reinläuft
EndIf
Until KeyboardPushed(#PB_Key_Escape)
Gosub Hauptmenu ; Hier sollte das Programm zur Sprungm. ganz oben im Code gelangen!!
EndIf
; Dieses End if gilt dem "play" nach dem Hauptmenü
EndIf