πŸ“¦ Events

Overview of the Events module in JarEngine.


πŸ”Ή Overview

Events provides the classes and utilities related to event handling and input monitoring.

It includes:

  • Event watchers and dispatcher
  • Keyboard and mouse input codes
  • Runtime event management

πŸ”Ή Contents

Class Description
β€’>JEEvent<β€’πŸ“Ž Runtime event object
β€’>JEEventHandler<β€’πŸ“Ž Event dispatcher
β€’>JEEventCode<β€’πŸ“Ž Single event code
β€’>JEEventCodeGroup<β€’πŸ“Ž Event code group
β€’>JEEventWatcher<β€’πŸ“Ž Event callback watcher
β€’>JEKeyCode<β€’πŸ“Ž Single keyboard code
β€’>JEKeyCodeGroup<β€’πŸ“Ž Keyboard code group
β€’>JEKeyWatcher<β€’πŸ“Ž Keyboard input watcher
β€’>JEMouseCode<β€’πŸ“Ž Single mouse code
β€’>JEMouseCodeGroup<β€’πŸ“Ž Mouse code group
β€’>JEMouseWatcher<β€’πŸ“Ž Mouse input watcher

πŸ”Ή Usage

from jarengine import JEGame, JEEvtQuit, JEKey_Space, JETrue
from jarengine.events import Event, EventKeyboard

game = JEGame(use_input=JETrue)

# Create event callbacks
def on_quit(game, event):
    game.close()

def on_space(game, event):
    print("Space pressed")

# Register event watchers
game.event.add(
    Event.JEEventWatcher(
        JEEvtQuit,
        on_quit
    )
)

game.event.add(
    EventKeyboard.JEKeyWatcher(
        JEKey_Space,
        on_space
    )
)

while game.is_open:
    game.update()

Events are registered as watchers and automatically processed by the game’s event manager.


πŸ”Ή Notes

Useful information:

  • Event, keyboard and mouse codes can be combined into groups.
  • Runtime events are automatically generated from PyGame events.
  • Avoid creating custom runtime events manually.