game_display module#
- class game_display.GameDisplay(simulation, scale, start_paused=False)#
Bases:
object
Displays the game
- Parameters:
simulation (Simulation) – Simulation to display
scale (float) – Scale of the display
start_paused (bool) – Whether the game should start paused
- apply_differences(step_info, last_step_info)#
Given two simulation steps, calculate the differences between them:
Change in elevator location and state
Spawning of new passenger
Removal of passenger
Passenger switched from floor to elevator
- Parameters:
step_info (SimulationStepInfo) – Current simulation step
last_step_info (SimulationStepInfo) – Previous simulation step
- get_floor_color(floor_index, floor_amount)#
Returns the floor color of a given floor
- Parameters:
floor_index (int) – Index of the floor
floor_amount (int) – Amount of floors
- Returns:
Color of the floor
- Return type:
tuple
- get_passenger_y_coord(passenger_info)#
Returns the absolute y-coordinate of a passenger.
- Parameters:
passenger_info (PassengerInfo) – Passenger information
- Returns:
Absolute y-coordinate of the passenger
- Return type:
int
- get_random_passenger_location(passenger_info)#
Returns the absolute coordinates of a passenger randomized in a floor or elevator.
- Parameters:
passenger_info (PassengerInfo) – Passenger information
- Returns:
Absolute coordinates of the passenger
- Return type:
tuple
- get_shaft_location(elevator_index)#
Returns the x-tile-coordinate of an elevator shaft, given the index of an elevator
- Parameters:
elevator_index (int) – Index of the elevator
- Returns:
X-tile-coordinate of the elevator shaft
- Return type:
int
- pause_button_pressed()#
Check whether the pause button has been pressed
- Returns:
Whether the pause button has been pressed
- Return type:
bool
- render_text(txt, loc, alignment=0)#
Renders text to screen
- Parameters:
txt (str) – String of content to display
loc (tuple) – Absolute display location to display
alignement – {-1: Left, 0: Center, 1: Right}
- set_background(time)#
Sets the background given the current time of day in seconds.
- Parameters:
time (int) – Time of day in seconds
- start_simulation(simulation, start_time, step_amount)#
Initializes a new simulation
- Parameters:
simulation (Simulation) – The simulation object to display
start_time (int) – Time in seconds of the time of day
step_amount (int) – Time in seconds of the duration
- step(simulation, time)#
A single frame update of the game display
- Parameters:
simulation (Simulation) – Simulation to display
time (int) – Current time of day in seconds
- class game_display.PassengerInfo(in_elevator, index, target)#
Bases:
object
Condenses the necessary information needed for the game display of a single passenger.
- Parameters:
in_elevator (bool) – Whether the passenger is in an elevator
index (int) – Index of the elevator or floor
target (int) – Target floor of the passenger
- equal(other)#
Indicates whether two PassengerInfo objects are equal
- Parameters:
other (PassengerInfo) – Other PassengerInfo object
- Returns:
Whether the two objects are equal
- Return type:
bool
- class game_display.SimulationStepInfo(building)#
Bases:
object
Condenses the necessary information needed for the game display of a single simulation step.
- Parameters:
building (Building) – Building of the simulation
- class game_display.Sprite(image_path, initial_position, sprite_size, color=(255, 255, 255))#
Bases:
Sprite
A single image displayed on the live display
- Parameters:
image_path (str) – Path to the image
initial_position (tuple) – Initial position of the image
sprite_size (tuple) – Size of the image
color (tuple) – Color of the image
- cache = {}#
- class game_display.SpriteEntity(front, back, screen_loc, sprite_size, front_color=(255, 255, 255), back_color=(255, 255, 255))#
Bases:
object
Wrapper class for two sprites, one in the foreground and one in the background.
- Parameters:
front (str) – Path to the front sprite
back (str) – Path to the back sprite
screen_loc (tuple) – Initial location of the sprite
sprite_size (tuple) – Size of the sprite
front_color (tuple) – Color of the front sprite
back_color (tuple) – Color of the back sprite
- update_screen_loc(screen_loc)#
Updates the screen location of the sprite
- Parameters:
screen_loc (tuple) – New screen location
- game_display.add(v1, v2)#
Adds two vectors
- Parameters:
v1 (tuple) – First vector
v2 (tuple) – Second vector
- Returns:
Sum of the two vectors
- Return type:
tuple
- game_display.format_time(seconds)#
Converts from seconds to a string of minutes and hours
- Parameters:
seconds (int) – Time in seconds
- Returns:
Formatted string of minutes and hours
- Return type:
str
- game_display.get_color_at_time(data, time)#
Given a time of day, returns the skycolor
- Parameters:
data (tuple) – Tuple of time in seconds, color
time (int) – Time of day in seconds
- Returns:
Color of the sky
- Return type:
tuple
- game_display.lerp(v1, v2, a)#
Performs linear interpolation between two vectors
- Parameters:
v1 (tuple) – First vector
v2 (tuple) – Second vector
a (float) – The interpolation factor
- Returns:
Resulting vector after interpolation
- Return type:
tuple
- game_display.mul(v1, c)#
Multiplies a vector by a scalar
- Parameters:
v1 (tuple) – Vector
c (float or int) – Scalar
- Returns:
Resulting vector after multiplication
- Return type:
tuple
- game_display.vround(v1)#
Rounds each component of a vector
- Parameters:
v1 (tuple) – Vector
- Returns:
Vector with each component rounded
- Return type:
tuple