Title Screen/Game Over Screen
-
Hey all!
Loving FUZE! I’ve always wanted to get into programming as a hobby and Fuze on switch has made it really easy to get started.I’m working on customizing the asteroid type game from the sprite game tutorial. I’m wanting to add a title screen and game over screen. I’ve looked at a few example projects and I THINK that the best course of action is to create some custom functions that will print the screens. That’s simple enough I guess, but what do I then do with the main game loop? Can I jump from the title screen function to the main game loop? Or do I need to make a custom function that holds the main game loop in it. A little confused here.
I’ve coded some title screens in basic before but that fairly simple because of GOTO and return.
Thanks for the help.
-
Your main loop can just call the relevant functions e.g.:
screen = 0 loop clear() c = controls(0) screen = c.a // Press the A key to change screen if screen == 0 then screen0() endif if screen == 1 then screen1() endif update() repeat function screen0() printat(twidth() / 2, theight() /2, "Screen 0") return void function screen1() printat(twidth() / 2, theight() /2, "Screen 1") return void
-
where would you put this code at the beginning or can you pop it anywhere?
-
@waldron it's up to you really any code outside of the functions will be executed in turn. I prefer to have my main program loop at the top and the functions below but it is a matter of choice
-
@pianofire thanks, so if i put it below my main game loop it would work
-
@waldron The loop ... repeat in this example is the main game loop
-
@pianofire theight? Not thight? Right ?
-
@waldron Well spotted!
-
Ok iv put my code in, where do I put the functions,
Function screen0()
And
Function screen1()
Figure I need something in the brackets maybe?... -
@waldron Sorry I don't understand the question. Can you send us a screenshot?
-
I'll send them later, but at the minute I'm
Running the game but gos to a black screen with screen0, then screen1 when I press ARunning it with the amuse gothicmania sample project
-
@waldron That's what it is supposed to do. It is only an example to show how you could to have multiple screens. You will probably want something more like this:
screen = 0 loop clear() c = controls(0) if screen == 0 then titleScreen() // check for start button press and set screen = 1 endif if screen == 1 then gameScreen() // if game over set screen = 2 endif if screen == 2 then gameOverScreen() // check for button press and set screen = 0 endif update() repeat function titleScreen() // draw title screen here return void function gameScreen() // draw game screen here return void function gameOverScreen() // draw game over screen here return void
-
@pianofire perfect thanks