exit the game loop back to title screen
-
iv tried naming boxes in the map, get map area ect to no avail just looking for an easy way to loop back into the title screen if the player falls
-
So you could do something like this:
screen = 0 textSize(50) while screen < 3 loop if screen == 0 then titleScreen() endif if screen == 1 then gameScreen() endif if screen == 2 then endScreen() endif repeat function titleScreen() oldc = controls(0) while screen == 0 loop clear() c = controls(0) if c.a and c.a != oldc.a then screen = 1 endif oldc = c message = "Title Screen : Press A to continue" printAt((twidth() - len(message)) / 2, theight() / 2, message) update() repeat return void function gameScreen() oldc = controls(0) while screen == 1 loop clear() c = controls(0) if c.a and c.a != oldc.a then screen = 2 endif oldc = c message = "Game Screen : Press A to continue" printAt((twidth() - len(message)) / 2, theight() / 2, message) update() repeat return void function endScreen() oldc = controls(0) while screen == 2 loop clear() c = controls(0) if c.a and c.a != oldc.a then screen = 0 endif if c.x then screen = 3 endif oldc = c message = "End Screen : Press A to continue (X to eXit)" printAt((twidth() - len(message)) / 2, theight() / 2, message) update() repeat return void
Here the game loop calls 3 different function each with it's own loop and swaps between them
-
@pianofire cheers! how would it know if the player has fell ? i already have a title screen with press a to continue just need to loop back to the in my case " dointro()"
just tired of seeing the player fall for eternity -
@waldron I guess that you could test if they were off the screen i.e. y position > gHeight() or you could add a collision box below the screen and test for collision with that?
-
Yeah I can get the height pos when I want it to execute its just executing the action I'm clueless about lol
-
If player pos height - 260 then
Dointro()
EndifMy coding is terrible
-
In my example above
if playerPosHeight < 260 then screen = 2 endif
The loop condition takes care of the rest
-
@pianofire thank you il try it now :)
-
@pianofire think il leave it, its not recognising PlrPosHeight once i enter the game loop
-
@waldron Is it a global variable (declared outside the functions)?
-
@pianofire i have no idea honestly im terrible at coding, it will probably click and il figure it eventually but for now il leave it
-
Ok no problem
-
@pianofire thats not to say i haven't learnt and il come back to this when it does click
thanks man, about to submit my game jam entry....