def __init__(self, display, clock): State.__init__(self, display, clock) self.player = Player() self.map = Map(self.player) self.forwardData = {} self.speed = getSettingForName(SettingNames.SPEED).val self.initResources()
def __init__(self, window, state=State.GAME_STATE): State.__init__(self, state, window) self.substate = state self.penguin = Penguin(window.width / 3, window.height / 2) self.entities = [] ice_boundary = IceBoundary(window.width, window.height) self.entities = self.entities + ice_boundary.floor + ice_boundary.ceiling self.game_count = 0 # AI needs this info self.closest_gap_range = (0,window.height) self.closest_x_distance_to_penguin = window.width - self.penguin.x self.old_state = None self.environment_state = None self.reward = 0 # Score message self.score = 0 self.score_text_surf, self.score_text_rect = Text.text_objects(str(self.score), Text.small_font) self.score_text_rect.center = ((self.window.width * 4 / 5), (self.window.height / 6)) # Game start screen self.game_started = False self.spacebar_text_surf, self.spacebar_text_rect = Text.text_objects("To begin and to flap, hit the (Spacebar)", Text.tiny_font) self.spacebar_text_rect.center = ((self.window.width / 2), (self.window.height / 3)) self.p_to_pause_text_surf, self.p_to_pause_text_rect = Text.text_objects("(P) to pause", Text.tiny_font) self.p_to_pause_text_rect.center = ((self.window.width / 2), (self.window.height * 2 / 3)) # Quit text self.quit_text_surf , self.quit_text_rect = Text.text_objects("(Q)uit to menu", Text.tiny_font) self.quit_text_rect.center = ((self.window.width / 2), (self.window.height * 2 / 3)) # Unpause text self.unpause_text_surf, self.unpause_text_rect = Text.text_objects("(U)npause", Text.small_font) self.unpause_text_rect.center = ((self.window.width / 2), (self.window.height / 3)) # Restart text self.restart_text_surf, self.restart_text_rect = Text.text_objects("(P)lay Again", Text.small_font) self.restart_text_rect.center = ((self.window.width / 2), (self.window.height / 3)) self.update_score() if self.substate == State.AI_GAME_STATE: self.game_started = True
def __init__(self, window): State.__init__(self, State.MENU_STATE, window) center_x = self.window.width / 2 self.title_text_surf, self.title_text_rect = Text.text_objects( "Penguino.ai", Text.large_font) self.title_text_rect.center = (center_x, (self.window.height / 6)) self.instructions_text_surf, self.instructions_text_rect = Text.text_objects( "Type the letter in () to select an option", Text.tiny_font) self.instructions_text_rect.center = (center_x, (self.window.height * 2 / 6)) self.play_text_surf, self.play_text_rect = Text.text_objects( "(P)lay", Text.small_font) self.play_text_rect.center = (center_x, (self.window.height * 3 / 6)) self.ai_text_surf, self.ai_text_rect = Text.text_objects( "(A)I Model", Text.small_font) self.ai_text_rect.center = (center_x, (self.window.height * 4 / 6))
def __init__(self, display, clock): State.__init__(self, display, clock) self.selectedId = 0 self.initResources()
def __init__(self, display, clock, gamedata): State.__init__(self, display, clock) self.gamedata = gamedata self.initResources()