Hauptmenü

Übersicht BlitzBasic Beginners-Corner

Neue Antwort erstellen

 

Roggi

Betreff: Hauptmenü

BeitragMi, Okt 26, 2005 14:35
Antworten mit Zitat
Benutzer-Profile anzeigen
Hab mir ein Hauptmenü hier aus einen Thread kopiert und bei mir eingefügt. Wie kann ich dort jetzt mein Spiel einfügen. Hier ist der Code:
BlitzBasic: [AUSKLAPPEN]
Graphics 1024,768,16,2 
SetBuffer BackBuffer()

SetFont(LoadFont(\"Comic Sans MS\",30,1))

Const game_pause = 1
Const game_menue = 2
Const game_haupt = 3
Const game_over = 4

Global game_zustand = game_menue


;Wichtig. Hauptschleife. Hier wird das ganze Spiel verwaltet.

Repeat


Select game_zustand
Case game_menue
GameMenue()
Case game_haupt
GameHaupt()
Case game_pause
GamePause()
End Select


Until game_zustand = game_over
End





Function GameMenue()

Local temp_zustand = game_zustand

FlushMouse()
FlushKeys()

Repeat
ClsColor 0,0,0
Cls
Color 0,0,255
Text GraphicsWidth()/2,100,\"ICH BIN DAS MENUE!!!\",1,1


Color 255,255,255
Text GraphicsWidth()/2,400,\"START\"

Color 255,255,255
Text GraphicsWidth()/2,500,\"ENDE\"


If MouseHit(1)
If RectsOverlap(MouseX(),MouseY(),1,1,GraphicsWidth()/2,400,StringWidth(\"START\"),StringHeight(\"START\"))
game_zustand = game_haupt
ElseIf RectsOverlap(MouseX(),MouseY(),1,1,GraphicsWidth()/2,500,StringWidth(\"ENDE\"),StringHeight(\"ENDE\"))
game_zustand = game_over
EndIf
EndIf


If KeyHit(1)
End
EndIf

Flip
Until game_zustand<>temp_zustand

End Function





Function GameHaupt()

Local temp_zustand = game_zustand
Local x = GraphicsWidth()/2
Local y = GraphicsHeight()/2
Local h = 0

FlushKeys()
FlushMouse()

Repeat
ClsColor 200,200,200
Cls


If KeyHit(57)
game_zustand = game_pause
EndIf


If KeyHit(1)
game_zustand = game_menue
EndIf

Flip
Until game_zustand<>temp_zustand

End Function






Function GamePause()

Local temp_zustand = game_zustand

FlushKeys()
FlushMouse()

Repeat
ClsColor 255,0,0
Cls

Color 0,0,255
Text GraphicsWidth()/2,GraphicsHeight()/2,\"ICH BIN DIE PAUSE!!!\",1,1

If KeyHit(57)
game_zustand = game_haupt
EndIf

Flip
Until game_zustand<>temp_zustand

End Function


Und hier der vom Spiel:
BlitzBasic: [AUSKLAPPEN]
Const links = 203
Const rechts = 205
Const runter = 208
Const hoch = 200

Graphics 800,600,32,1

Global start=LoadImage(\"Grafik\start.bmp\");Startbilschirm
DrawImage start,1,1
Delay 2500
Cls

Global start2=LoadImage(\"Grafik\start2.bmp\")
DrawImage start2,1,1
WaitKey

SetBuffer BackBuffer()
AppTitle (\"Die Autofahrt-Tom 10.05\");das was im Task steht


Global Auto=LoadImage(\"Grafik\Auto1.bmp\");lädt auto und Stadt
Global spielbild = LoadImage(\"Grafik\Map.bmp\")
Global Post=LoadImage(\"Grafik\Post.bmp\")

Global xs = 300; Wo das Auto steht
Global ys = 450



Repeat
Cls

;------------------------- Bewegung des Spielers -----------------------
If KeyDown(hoch) And ys > -2 Then ys = ys - 1
If KeyDown(runter) And ys < 570 Then ys = ys + 1
If KeyDown(rechts) And xs < 770 Then xs = xs + 1
If KeyDown(links) And xs > -2 Then xs = xs - 1


TileBlock spielbild, 1, 1

DrawImage Auto, xs, ys
MaskImage Auto,255,255,255
Flip


Until KeyHit(1)
End

Xaron

BeitragMi, Okt 26, 2005 14:38
Antworten mit Zitat
Benutzer-Profile anzeigen
Ganz einfach, kopiere Deinen Code in die Funktion "GameHaupt()", natürlich ohne den Graphics-Befehl.
Die Key-Abfragen, die den game_zustand ändern, musst Du natürlich drin lassen.

Gruß - Xaron
Cerberus X - Monkey X Reloaded!

Neue Antwort erstellen


Übersicht BlitzBasic Beginners-Corner

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group