if sys.platform == "emscripten":
if 'wasm' in __import__('platform').machine():
import asyncio
import pygame
# init pygame here
def menu():
#draw
pass
def play():
#draw
pass
game_state = menu
async def main():
global game_state
# or init pygame here
while game_state:
game_state()
pygame.display.update()
await asyncio.sleep(0)
# Closing the game. not strictly required neither on desktop
pygame.quit()
sys.exit()
if __name__ == "__main__":
asyncio.run(main())
if __import__("sys").platform == "emscripten":
import platform.window as window
backup : ` window.localStorage.setItem(“mygame”, str(myvalue) )`
restore : ` myvalue = window.localStorage.getItem(“mygame”)`
import sys
import platform
# document may not exist on non-emscripten platforms
if sys.platform == "emscripten":
platform.document.body.style.background = "#404040"
TODO
TODO
TODO
TODO
TODO