pyxen.screen

Access screen size information from the engine.

screen = pyxen.screen

The screen module provides:

  • Current screen width
  • Current screen height

All properties are read-only.


Properties

PropertyTypeDescription
widthintScreen width in pixels
heightintScreen height in pixels

width

w = pyxen.screen.width

Returns the current screen width in pixels.

Example:

player.x = pyxen.screen.width / 2

height

h = pyxen.screen.height

Returns the current screen height in pixels.

Example:

player.y = pyxen.screen.height / 2

Common Patterns


Centering an Entity

e = world.spawn(
    x=pyxen.screen.width / 2,
    y=pyxen.screen.height / 2
)

Keeping UI on Screen Edge

ui.x = pyxen.screen.width - 20
ui.y = 20

Screen-Relative Layout

margin = 16

panel_width = pyxen.screen.width - margin * 2
panel_height = pyxen.screen.height - margin * 2

Interaction with Camera

pyxen.screen represents the physical render surface.

It does not account for:

  • Camera position
  • Camera rotation
  • Camera zoom

Camera transforms affect world rendering.

Screen size defines the projection boundaries.


Read-Only Safety

All properties are read-only:

pyxen.screen.width = 100  # ❌ Raises ValueError

Screen size is managed internally by the engine.