Re: pygame

Well you make your own stack and just add or remove them.
Because pygame doesn't allow you to listen for different events you need to catch them in the for loop. So what the screen stack would look like is something like:
screens = []

for screen in reversed(screens):
    if screen(events):
        break

and a screen function would look something like:

def screen1(events):
    """I don't like doing pygame's event system, but that is what you would use here. I like pyaudiogame's event system because it is just a dict of events."""
    if events['key'] == 'space":
        spk("You are on the moon!")
        return True

def screen2(events):
    if events['key'] == "a":
        spk("you hit a ")
    elif events['key'] == "escape":
        screens.pop()
    return True

If you have in screens:
[screen1, screen2]
Then what will happen is the for loop will run screens2 first, check if it returned True and if it did, stop. If it didn't return True, then it will move on to the next screen (screen1) and do the same.
So in the above setup if I hit a, it would give me a message. If I hit space, nothing would happen. If I hit escape I wouldn't see anything, but if I then hit a, nothing would happen. But if I now hit space, I would get a message.
Does this help?

_______________________________________________
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Kyleman123 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Kyleman123 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Kyleman123 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : SoundMUD via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : frastlin via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Kyleman123 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Kyleman123 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Kyleman123 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : frastlin via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : frastlin via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : frastlin via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : dhruv via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : frastlin via Audiogames-reflector

Reply via email to