### Navigation

- index
- next |
- previous |
- Pygame SGE 0.7.0 documentation »
- Classes »

# sge.Room

class `sge.``Room`(objects=(), width=None, height=None, views=None, background=None, background_x=0, background_y=0)

  Class for rooms.

  This class stores the settings and objects found in a room. Rooms are used to create separate parts of the game, such as levels and menu screens.

  Every game must have at least one room.

  `width`

    The width of the room in pixels. If set to `None`, `sge.game.width` is used.

  `height`

    The height of the room in pixels. If set to `None`, `sge.game.height` is used.

  `views`

    A list containing all `sge.View` objects in the room.

  `background`

    The `sge.Background` object used.

  `background_x`

    The horizontal position of the background in the room.

  `background_y`

    The vertical position of the background in the room.

  `objects`

    A list containing all `sge.StellarClass` objects in the room. (Read-only)

  `objects_by_class`

    A dictionary of lists containing all `sge.StellarClass` objects in the room, separated by class. The dictionary keys are classes that have been registered with `sge.Game.register_class()`, and the lists contain only those objects which are instances of the class indicated by the respective key. (Read-only)

  `room_number`

    The index of this room in the game, where `0` is the first room, or `None` if this room has not been added to a game. (Read-only)

## sge.Room Methods

`Room.``__init__`(objects=(), width=None, height=None, views=None, background=None, background_x=0, background_y=0)

  Constructor method.

  Arguments:

  - `views` – A list containing all `sge.View` objects in the room. If set to `None`, a new view will be created with `x=0`, `y=0`, and all other arguments unspecified, which will become the first view of the room.
  - `background` – The `sge.Background` object used. If set to `None`, a new background will be created with no layers and the color set to `"black"`.

  All other arguments set the respective initial attributes of the room. See the documentation for `sge.Room` for more information.

`Room.``add`(obj)

  Add a StellarClass object to the room.

  Arguments:

  - `obj` – The `sge.StellarClass` object to add.

`Room.``start`()

  Start the room.

  If the room has been changed, reset it to its original state.

`Room.``resume`()

  Continue the room from where it left off.

  If the room is unchanged (e.g. has not been started yet), this method behaves in the same way that `sge.Room.start()` does.

`Room.``end`(next_room=None, resume=True)

  End the current room.

  Arguments:

  - `next_room` – The room number of the room to go to next. If set to `None`, the room after this one is chosen.
  - `resume` – Whether or not to resume the next room instead of restarting it.

  If the room chosen as the next room does not exist, the game is ended.

  This triggers this room’s `sge.Room.event_room_end()` and resets the state of this room.

`Room.``project_dot`(x, y, z, color)

  Project a single-pixel dot onto the room.

  Arguments:

  - `x` – The horizontal location relative to the room to project the dot.
  - `y` – The vertical location relative to the room to project the dot.
  - `z` – The Z-axis position of the projection in the room.

  See the documentation for `sge.Sprite.draw_dot()` for more information.

`Room.``project_line`(x1, y1, x2, y2, z, color, thickness=1, anti_alias=False)

  Project a line segment onto the room.

  Arguments:

  - `x1` – The horizontal location relative to the room of the first endpoint of the projected line segment.
  - `y1` – The vertical location relative to the room of the first endpoint of the projected line segment.
  - `x2` – The horizontal location relative to the room of the second endpoint of the projected line segment.
  - `y2` – The vertical location relative to the room of the second endpoint of the projected line segment.
  - `z` – The Z-axis position of the projection in the room.

  See the documentation for `sge.Sprite.draw_line()` for more information.

`Room.``project_rectangle`(x, y, z, width, height, fill=None, outline=None, outline_thickness=1)

  Project a rectangle onto the room.

  Arguments:

  - `x` – The horizontal location relative to the room to project the rectangle.
  - `y` – The vertical location relative to the room to project the rectangle.
  - `z` – The Z-axis position of the projection in the room.

  See the documentation for `sge.Sprite.draw_rectangle()` for more information.

`Room.``project_ellipse`(x, y, z, width, height, fill=None, outline=None, outline_thickness=1, anti_alias=False)

  Project an ellipse onto the room.

  Arguments:

  - `x` – The horizontal location relative to the room to position the imaginary rectangle containing the ellipse.
  - `y` – The vertical location relative to the room to position the imaginary rectangle containing the ellipse.
  - `z` – The Z-axis position of the projection in the room.
  - `width` – The width of the ellipse.
  - `height` – The height of the ellipse.
  - `fill` – The color of the fill of the ellipse.
  - `outline` – The color of the outline of the ellipse.
  - `outline_thickness` – The thickness of the outline of the ellipse.
  - `anti_alias` – Whether or not anti-aliasing should be used.

  See the documentation for `sge.Sprite.draw_ellipse()` for more information.

`Room.``project_circle`(x, y, z, radius, fill=None, outline=None, outline_thickness=1, anti_alias=False)

  Project a circle onto the room.

  Arguments:

  - `x` – The horizontal location relative to the room to position the center of the circle.
  - `y` – The vertical location relative to the room to position the center of the circle.
  - `z` – The Z-axis position of the projection in the room.

  See the documentation for `sge.Sprite.draw_circle()` for more information.

`Room.``project_sprite`(sprite, image, x, y, z, blend_mode=None)

  Project a sprite onto the room.

  Arguments:

  - `x` – The horizontal location relative to the room to project `sprite`.
  - `y` – The vertical location relative to the room to project `sprite`.
  - `z` – The Z-axis position of the projection in the room.

  See the documentation for `sge.Sprite.draw_sprite()` for more information.

`Room.``project_text`(font, text, x, y, z, width=None, height=None, color='black', halign=2, valign=8, anti_alias=True)

  Project text onto the room.

  Arguments:

  - `x` – The horizontal location relative to the room to project the text.
  - `y` – The vertical location relative to the room to project the text.
  - `z` – The Z-axis position of the projection in the room.

  See the documentation for `sge.Sprite.draw_text()` for more information.

## sge.Room Event Methods

`Room.``event_room_start`()

  Room start event.

  Called when the room starts. It is always called after any game start events and before any object create events occurring at the same time.

`Room.``event_room_resume`()

  Room resume event.

  Called when the room resumes without being reset to its original state (i.e. via `sge.Room.resume()`).

  By default, this calls `sge.Room.event_room_start()`.

`Room.``event_room_end`()

  Room end event.

  Called when the room ends. It is always called before any game end events occurring at the same time.

`Room.``event_step`(time_passed)

  Room step event.

  See the documentation for `sge.Game.event_step()` for more information.

`Room.``event_key_press`(key, char)

  Key press event.

  See the documentation for `sge.Game.event_key_press()` for more information.

`Room.``event_key_release`(key)

  Key release event.

  See the documentation for `sge.Game.event_key_release()` for more information.

`Room.``event_mouse_move`(x, y)

  Mouse move event.

  See the documentation for `sge.Game.event_mouse_move()` for more information.

`Room.``event_mouse_button_press`(button)

  Mouse button press event.

  See the documentation for `sge.Game.event_mouse_button_press()` for more information.

`Room.``event_mouse_button_release`(button)

  Mouse button release event.

  See the documentation for `sge.Game.event_mouse_button_release()` for more information.

`Room.``event_joystick_axis_move`(name, ID, axis, value)

  Joystick axis move event.

  See the documentation for `sge.Game.event_joystick_axis_move()` for more information.

`Room.``event_joystick_hat_move`(name, ID, hat, x, y)

  Joystick HAT move event.

  See the documentation for `sge.Game.event_joystick_hat_move()` for more information.

`Room.``event_joystick_trackball_move`(name, ID, ball, x, y)

  Joystick trackball move event.

  See the documentation for `sge.Game.event_joystick_trackball_move()` for more information.

`Room.``event_joystick_button_press`(name, ID, button)

  Joystick button press event.

  See the documentation for `sge.Game.event_joystick_button_press()` for more information.

`Room.``event_joystick_button_release`(name, ID, button)

  Joystick button release event.

  See the documentation for `sge.Game.event_joystick_button_release()` for more information.

`Room.``event_gain_keyboard_focus`()

  Gain keyboard focus event.

  See the documentation for `sge.Game.event_gain_keyboard_focus()` for more information.

`Room.``event_lose_keyboard_focus`()

  Lose keyboard focus event.

  See the documentation for `sge.Game.event_lose_keyboard_focus()` for more information.

`Room.``event_gain_mouse_focus`()

  Gain mouse focus event.

  See the documentation for `sge.Game.event_gain_mouse_focus()` for more information.

`Room.``event_lose_mouse_focus`()

  Lose mouse focus event.

  See the documentation for `sge.Game.event_lose_mouse_focus()` for more information.

`Room.``event_close`()

  Close event.

  See the documentation for `sge.Game.event_close()` for more information. This is always called before any game close events occurring at the same time.

`Room.``event_paused_key_press`(key, char)

  Key press event when paused.

  See the documentation for `sge.Game.event_key_press()` for more information.

`Room.``event_paused_key_release`(key)

  Key release event when paused.

  See the documentation for `sge.Game.event_key_release()` for more information.

`Room.``event_paused_mouse_move`(x, y)

  Mouse move event when paused.

  See the documentation for `sge.Game.event_mouse_move()` for more information.

`Room.``event_paused_mouse_button_press`(button)

  Mouse button press event when paused.

  See the documentation for `sge.Game.event_mouse_button_press()` for more information.

`Room.``event_paused_mouse_button_release`(button)

  Mouse button release event when paused.

  See the documentation for `sge.Game.event_mouse_button_release()` for more information.

`Room.``event_paused_joystick_axis_move`(name, ID, axis, value)

  Joystick axis move event when paused.

  See the documentation for `sge.Game.event_joystick_axis_move()` for more information.

`Room.``event_paused_joystick_hat_move`(name, ID, hat, x, y)

  Joystick HAT move event when paused.

  See the documentation for `sge.Game.event_joystick_hat_move()` for more information.

`Room.``event_paused_joystick_trackball_move`(name, ID, ball, x, y)

  Joystick trackball move event when paused.

  See the documentation for `sge.Game.event_joystick_trackball_move()` for more information.

`Room.``event_paused_joystick_button_press`(name, ID, button)

  Joystick button press event when paused.

  See the documentation for `sge.Game.event_joystick_button_press()` for more information.

`Room.``event_paused_joystick_button_release`(name, ID, button)

  Joystick button release event when paused.

  See the documentation for `sge.Game.event_joystick_button_release()` for more information.

`Room.``event_paused_gain_keyboard_focus`()

  Gain keyboard focus event when paused.

  See the documentation for `sge.Game.event_gain_keyboard_focus()` for more information.

`Room.``event_paused_lose_keyboard_focus`()

  Lose keyboard focus event when paused.

  See the documentation for `sge.Game.event_lose_keyboard_focus()` for more information.

`Room.``event_paused_gain_mouse_focus`()

  Gain mouse focus event when paused.

  See the documentation for `sge.Game.event_gain_mouse_focus()` for more information.

`Room.``event_paused_lose_mouse_focus`()

  Lose mouse focus event when paused.

  See the documentation for `sge.Game.event_lose_mouse_focus()` for more information.

`Room.``event_paused_close`()

  Close event when paused.

  See the documentation for `sge.Game.event_close()` for more information.

### Navigation

- index
- next |
- previous |
- Pygame SGE 0.7.0 documentation »
- Classes »