core.components.ui package

class core.components.ui.UserInterface(images, position, animation_speed=0.2, animation_loop=False)[source]

Bases: object

A basic user interface object.

Parameters:
  • image (String or pygame.Surface) – Path to the image to load or surface.
  • position (List) – The [x, y] position to draw the UI element.
  • screen (pygame.Surface) – The pygame surface to draw the element on.
  • scale (Boolean) – Whether or not to scale the surface based on game’s scale.
draw(surface)[source]

Draws the UI element to the screen.

Parameters:surface – Surface to draw onto
Param:None
Type:None
fade_in(duration=1.0)[source]

Fades the object in.

Parameters:duration (Float) – Fade the object in over n seconds, defaults to 1.
fade_out(duration=1.0)[source]

Fades the object out.

Parameters:duration (Float) – Fade the object out over n seconds, defaults to 1.
move(destination, duration=1.0)[source]

Moves the object to position over n seconds.

Parameters:
  • destination (Tuple) – The (x, y) screen destination position to move to.
  • duration (Float) – Moves the object over n seconds, defaults to 1.
pause()[source]
play()[source]
scale(width_height)[source]
shake(intensity, direction='random')[source]

Shakes the object a given severity.

Parameters:
  • intensity (Int) – How much the object will shake.
  • direction (Int or String) – Direction to shake in degrees, defaults to “random”.
shake_once(destination, duration=0.3)[source]

Moves the object to a position and then back to its original position.

stop()[source]