Modules Guide

This module defines the MenuWidget class which handles the game’s menu system.

class menu.MenuWidget(**kw)[source]

Bases: RelativeLayout

MenuWidget manages the main game menu and detects user interactions.

__module__ = 'menu'
on_touch_down(touch)[source]

Handle touch events when the user interacts with the menu.

Parameters:

touch (Touch) – The touch event.

Returns:

Whether the touch was handled by the menu.

Return type:

bool

This module contains functions to handle 2D and perspective transformations.

transforms.transform(self, x, y)[source]

Apply 3D transformation to coordinates.

Parameters:
  • x (float) – X-coordinate.

  • y (float) – Y-coordinate.

  • z (float) – Z-coordinate.

Returns:

Transformed (x, y, z) coordinates.

Return type:

tuple

transforms.transform_2D(self, x, y)[source]

Apply 2D transformation to coordinates.

Parameters:
  • x (float) – X-coordinate.

  • y (float) – Y-coordinate.

Returns:

Transformed (x, y) coordinates.

Return type:

tuple

transforms.transform_perspective(self, x, y)[source]

Apply perspective transformation to coordinates.

Parameters:
  • x (float) – X-coordinate.

  • y (float) – Y-coordinate.

  • perspective (float) – Perspective value.

Returns:

Transformed coordinates with perspective applied.

Return type:

tuple

This module defines functions that respond to user keyboard and touch events.

user_action.keyboard_closed(self)[source]

Handle event when the keyboard is closed.

user_action.on_keyboard_down(self, keyboard, keycode, text, modifiers)[source]

Handle event when a key is pressed.

user_action.on_keyboard_up(self, keyboard, keycode)[source]

Handle event when a key is released.

user_action.on_touch_down(self, touch)[source]

Handle event when a screen touch is detected.

Parameters:

touch (Touch) – The touch event.

user_action.on_touch_up(self, touch)[source]

Handle event when a screen touch ends.

Parameters:

touch (Touch) – The touch event.