Esempio n. 1
0
    def onload(self):
        # we don't need the default 60fps for a whack-a-mole !
        melonjs.sys.fps = 30;

        # Initialize the video.
        settings = { "wrapper" : "screen", "scale": "auto" }
        if (not melonjs.video.init(self.width, self.height, settings)):
            window.alert("Your browser does not support HTML5 canvas.")
            return

        # initialize the "sound engine"
        melonjs.audio.init("mp3,ogg")

        # set all ressources to be loaded
        # melonjs.loader.preload(self.resources, self.loaded.bind(self.onload))
        melonjs.loader.preload(self.resources, self.loaded)
Esempio n. 2
0
def on_click(ev):
    if done:  # if done, stop
        return

    idx = next(idx for idx, i in enumerate(grid) if ev.target.inside(i))
    target = grid[idx]

    if target.text:  # if tile taken, stop
        return

    # set text of UI element, then change turns
    target.text = turns[0]
    turns[:] = turns[1], turns[0]

    # check for win
    for i in check_pattern:
        if grid[i[0]].text and grid[i[0]].text == grid[i[1]].text == grid[
                i[2]].text:
            window.alert(f'{turns[1]} has won!')
            done.append(True)  # the game is over, no more playing
Esempio n. 3
0
def keyboard_help_button_handler(event=None) -> None:
    window.alert(keyboard_help_text)
Esempio n. 4
0
def show_instructions(evt):
    window.alert(
        "Use the arrow keys to move and press spacebar to pause the game.")