def __init__(self, screen, joysticks): Level.__init__(self, screen, joysticks) self.set_background_image('title.png') self.add_room_object(PlayButton(self, 425, 100)) self.add_room_object(QuitButton(self, 625, 100))
def __init__(self, screen): Level.__init__(self, screen) if Globals.winner == 'Red': winner = Globals.red_player colour = (255, 0, 0) elif Globals.winner == 'Blue': winner = Globals.blue_player colour = (0, 0, 255) else: winner = 'Draw' colour = (255, 255, 255) winner_text = TextObject(self, Globals.SCREEN_WIDTH / 3, Globals.SCREEN_HEIGHT / 3 * 2, winner, 80) winner_text.colour = colour winner_text.update_text() winner_text.x = Globals.SCREEN_WIDTH / 2 - winner_text.width / 2 self.add_room_object(winner_text) battle_text = TextObject(self, Globals.SCREEN_WIDTH / 3, Globals.SCREEN_HEIGHT / 3, 'Battle Winner', 80) battle_text.colour = colour battle_text.update_text() battle_text.x = Globals.SCREEN_WIDTH / 2 - battle_text.width / 2 self.add_room_object(battle_text) Globals.background_music.stop() break_sound = self.load_sound('rock_breaking.ogg') self.applause = self.load_sound('applause.wav') break_sound.play() self.set_timer(60, self.applaud) self.set_timer(240, self.end_game)
def __init__(self, screen, joysticks): Level.__init__(self, screen, joysticks) self.set_background_image('Start_BG.png') self.add_room_object(PlayButton(self, 225, 140)) self.add_room_object(QuitButton(self, 425, 140))
def __init__(self, screen, joysticks): Level.__init__(self, screen, joysticks) self.background_colour = (51, 43, 0) self.room_items = [] # - Set up maze, objects 32x32 - # room_objects = [ 'DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD', 'DBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBD', 'DB BD', 'DB BD', 'DB BD', 'DB BD', 'DB B BD', 'DB B BBBBBBBB B BD', 'DB B B B BD', 'DB B B B BD', 'DB B B B BD', 'DB BBBBBBB B B BD', 'DB BD', 'DB BD', 'DB BBBBBB BBBBBBB BD', 'DB B B BD', 'DB B P B BD', 'DB B B BD', 'DB B B BD', 'DB BBBBBBBBBBBB B BD', 'DB BBBBB BBBBBB BD', 'DB BD', 'DB BB BBBBBBBBBBB BD', 'DB B B BBBBBBBBBBBBBBBBB BD', 'DB B B B BD', 'DB B BBBBBBB B BD', 'DB B BBBBB BBBBBBBBBBBBBBBBBBBBB BD', 'DB B B B BD', 'DB B B B BD', 'DBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB BBBBBBD', 'DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDGGDDDDDDD' ] for i, row in enumerate(room_objects): for j, obj in enumerate(row): if obj == 'B': new_block = Block(self, j * 32 - 200, i * 32 - 200) self.add_room_object(new_block) self.room_items.append(new_block) elif obj == 'P': self.add_room_object( Player(self, j * 32 - 200, i * 32 - 200)) elif obj == 'G': new_goal = Goal(self, j * 32 - 200, i * 32 - 200) self.add_room_object(new_goal) self.room_items.append(new_goal) elif obj == 'D': new_dirt = Dirt(self, j * 32 - 200, i * 32 - 200) self.add_room_object(new_dirt) self.room_items.append(new_dirt)
def __init__(self, screen, joysticks): Level.__init__(self, screen, joysticks) self.set_background_image('ladybug_background.png') self.add_room_object(TextObject(self, 200, 200, 'Final Score')) self.add_room_object(TextObject(self, 250, 250, str(Globals.SCORE))) self.add_room_object(PlayButton(self, 200, 350))
def __init__(self, screen, joysticks): Level.__init__(self, screen, joysticks) # - Set Background image - # self.set_background_image("wood_background.jpg") # - Preload images from disk - # img_grnd_flat = self.load_image('Grass_Tile_Flat.png') img_grnd_left = self.load_image('Grass_Tile_Corner_Edge_l.png') img_grnd_right = self.load_image('Grass_Tile_Corner_Edge_r.png') img_grnd_under = self.load_image('Grass_Tile_lower.png') # - Set up maze, objects 32x32 25x17 - # room_objects = [ 'lmmmmmmmmmmmmmmmmmmmmmmmr', 'ug_________________M____u', 'u_______________________u', 'umrG ___________________u', 'u_______________________u', 'u_lmmr_lmmmmmr______lr__u', 'u_____________lmmmr_____u', 'u______________________lu', 'u__________M____________u', 'u__________________Glmmmu', 'u_____M________lr_______u', 'u_________lmmr___lr_____u', 'u_______________________u', 'ummmr__lr_______________u', 'u________lmmmr__________u', 'up______________________u', 'ummmmmmmmmmmmmmmmmmmmmmmu' ] for i, row in enumerate(room_objects): for j, obj in enumerate(row): if obj == 'm': self.add_room_object( Block(self, j * 32, i * 32, img_grnd_flat)) elif obj == 'l': self.add_room_object( Block(self, j * 32, i * 32, img_grnd_left)) elif obj == 'r': self.add_room_object( Block(self, j * 32, i * 32, img_grnd_right)) elif obj == 'u': self.add_room_object( Block(self, j * 32, i * 32, img_grnd_under)) elif obj == 'p': self.add_room_object(Player(self, j * 32, i * 32)) elif obj == 'g': self.add_room_object(Goal(self, j * 32, i * 32)) elif obj == 'G': self.add_room_object(Monster2(self, j * 32, i * 32)) elif obj == 'M': self.add_room_object(Monster(self, j * 32, i * 32)) # - Add Banner for game info (lives) 800x56 - # self.add_room_object(Banner(self, 0, 544)) # - Add Text - # self.score_text = TextObject(self, 20, 560, 'Lives: %i' % Globals.LIVES) self.score_text.depth = 1000 self.score_text.colour = (255, 255, 255) self.score_text.update_text() self.add_room_object(self.score_text)
def __init__(self, screen, joysticks): Level.__init__(self, screen, joysticks) self.set_background_image('ladybug_background.png') self.add_room_object(TextObject(self, 200, 200, 'Score')) self.add_room_object(TextObject(self, 250, 400, str(Globals.SCORE))) self.set_timer(150, self.endgame)
def __init__(self, screen, joysticks): Level.__init__(self, screen, joysticks) # - Set Background image - # self.set_background_image("background.jpg") # - Home location for the player - # self.home_x = 11 * 32 self.home_y = 7 * 32 # - Set up maze, objects 32x32 25x17 - # room_objects = [ 'bbbbbbbbbbbbbbbbbbbbbbbbb', 'b___________m___________b', 'b___bbbbb_d_bbbbbbbb__bdb', 'b___b___bb_bbb_____b___bb', 'b___b____b__b___b___b___b', 'b___bb___b__b___bbb__b__b', 'b____b___bp_b______b___mb', 'b____b___b__bbbb__b_____b', 'b____bbbbb_m___b__b_____b', 'b____m________b__bbbbbbbb', 'b____bbbb____b__b_______b', 'bbbbb_______b_b__b__bb__b', 'b_____bbbbb_b_b__b__bb__b', 'b_________b___b_____bb__b', 'bbbbbbbbbbbbbdbb__bbbb__b', 'b______g_______b_bb_____b', 'bbbbbbbbbbbbbbbbbbbbbbbbb' ] for i, row in enumerate(room_objects): for j, obj in enumerate(row): if obj == 'b': self.add_room_object(Block(self, j*32, i*32)) elif obj == 'd': self.add_room_object(BlockDoor(self, j * 32, i * 32)) elif obj == 'p': self.add_room_object(Player(self, j*32, i*32)) elif obj == 'g': self.add_room_object(Goal(self, j*32, i*32)) elif obj == 'm': self.add_room_object(Monster(self, j*32, i*32)) # - Add Banner for game info (lives) 800x56 - # self.add_room_object(Banner(self, 0, 544)) # - Add Text - # self.score_text = TextObject(self, 20, 560, 'Lives: %i' % Globals.LIVES) self.score_text.depth = 1000 self.score_text.colour = (255, 255, 255) self.score_text.update_text() self.add_room_object(self.score_text)
def __init__(self, screen, joysticks): Level.__init__(self, screen, joysticks) # - Set Background image - # self.set_background_image("background.jpg") # - Add Text - # self.GO_Text = GameOverText(self, Globals.SCREEN_WIDTH/4, Globals.SCREEN_HEIGHT/2 - 100, 'Game Over - Press Space') self.GO_Text.depth = 1000 self.GO_Text.colour = (0, 0, 0) self.GO_Text.update_text() self.add_room_object(self.GO_Text)
def __init__(self, screen, joysticks): Level.__init__(self, screen, joysticks) self.set_background_image('ladybug_background.png') self.add_room_object(TextObject(self, 150, 50, 'Type your name', 80)) self.name_text = EntryTextObject(self, 200, 200, 10) self.add_room_object(self.name_text) self.play_button = PlayButton(self, -300, 400) self.add_room_object(self.play_button) self.set_timer(10, self.check_valid_name)
def __init__(self, screen, joysticks): Level.__init__(self, screen, joysticks) # - Set Background image - # self.set_background_image("background.jpg") # - Add Text - # self.GO_Text = GameOverText(self, Globals.SCREEN_WIDTH / 4, Globals.SCREEN_HEIGHT / 2 - 100, 'Game Over - Press Space') self.GO_Text.depth = 1000 self.GO_Text.colour = (0, 0, 0) self.GO_Text.update_text() self.add_room_object(self.GO_Text)
def __init__(self, screen, joysticks): Level.__init__(self, screen, joysticks) # - Set Background image - # self.set_background_image("background.jpg") # - Home location for the player - # self.home_x = 11 * 32 self.home_y = 7 * 32 # - Set up maze, objects 32x32 25x17 - # room_objects = [ 'bbbbbbbbbbbbbbbbbbbbbbbbb', 'b___________m___________b', 'b___bbbbb_d_bbbbbbbb__bdb', 'b___b___bb_bbb_____b___bb', 'b___b____b__b___b___b___b', 'b___bb___b__b___bbb__b__b', 'b____b___bp_b______b___mb', 'b____b___b__bbbb__b_____b', 'b____bbbbb_m___b__b_____b', 'b____m________b__bbbbbbbb', 'b____bbbb____b__b_______b', 'bbbbb_______b_b__b__bb__b', 'b_____bbbbb_b_b__b__bb__b', 'b_________b___b_____bb__b', 'bbbbbbbbbbbbbdbb__bbbb__b', 'b______g_______b_bb_____b', 'bbbbbbbbbbbbbbbbbbbbbbbbb' ] for i, row in enumerate(room_objects): for j, obj in enumerate(row): if obj == 'b': self.add_room_object(Block(self, j * 32, i * 32)) elif obj == 'd': self.add_room_object(BlockDoor(self, j * 32, i * 32)) elif obj == 'p': self.add_room_object(Player(self, j * 32, i * 32)) elif obj == 'g': self.add_room_object(Goal(self, j * 32, i * 32)) elif obj == 'm': self.add_room_object(Monster(self, j * 32, i * 32)) # - Add Banner for game info (lives) 800x56 - # self.add_room_object(Banner(self, 0, 544)) # - Add Text - # self.score_text = TextObject(self, 20, 560, 'Lives: %i' % Globals.LIVES) self.score_text.depth = 1000 self.score_text.colour = (255, 255, 255) self.score_text.update_text() self.add_room_object(self.score_text)
def __init__(self, screen, joysticks): Level.__init__(self, screen, joysticks) # - Set Background image - # self.set_background_image('welcome_background.jpg') # - Add Text - # self.f1_text = F1Text(self, 20, 200, 'Press F1 to continue') self.f1_text.depth = 1000 self.f1_text.colour = (0, 0, 0) self.f1_text.update_text() self.add_room_object(self.f1_text) self.exit_text = ExitText(self, 20, 300, 'Press Esc to exit the game') self.exit_text.depth = 1000 self.exit_text.colour = (0, 0, 0) self.exit_text.update_text() self.add_room_object(self.exit_text)
def __init__(self, screen, joysticks): Level.__init__(self, screen, joysticks) self.set_background_image('ladybug_background.png') database = DataBaseController('game_data.sqlite') database.add_score(Globals.player_name, Globals.SCORE) names_scores = database.get_top_5() self.add_room_object(TextObject(self, 50, 10, 'Top 5 Scores', 80)) y_pos = 150 for person in names_scores: self.add_room_object(TextObject(self, 20, y_pos, person[0])) self.add_room_object(TextObject(self, 390, y_pos, str(person[1]))) y_pos += 70 self.set_timer(150, self.endgame)
def __init__(self, screen, joysticks): Level.__init__(self, screen, joysticks) self.set_background_image('floorboards.png') self.splat_sound = self.load_sound('Splat.wav') self.splat_image = self.load_image('splat.png') self.ant_image = self.load_image('ant_32x32.png') self.roach_image = self.load_image('cockroach_32x32.png') self.scorpion_image = self.load_image('scorpion_32x32.png') self.spider_image = self.load_image('spider_32x32.png') self.set_timer(60, self.add_ant) self.set_timer(120, self.add_roach) self.set_timer(180, self.add_scorpion) self.set_timer(240, self.add_spider) self.set_timer(1200, self.times_up)
def __init__(self, screen, joysticks): Level.__init__(self, screen, joysticks) self.set_background_image('background.png') self.games = [] self.curr_selection = 0 self.title = TitleText(self, 0, 0) self.add_room_object(self.title) curr_y_pos = 275 font_size = 60 for game in Globals.game_list: game_button = GameButtonText(self, 40, curr_y_pos, game[0], game[1], font_size) font_size -= 10 curr_y_pos += 60 self.add_room_object(game_button) self.games.append(game_button) self.games[0].colour = (0, 0, 0) self.games[0].update_text()
def __init__(self, screen, joysticks): Level.__init__(self, screen, joysticks) pygame.mouse.set_visible(False) # - Set Background image - # self.set_background_image('space_background.jpg') # - Add Bricks - # offset_x, offset_y = 15, 15 self.brick_count = 0 brick_layout = [ 'hhhhhsshhhhh', 'shhhhhhhhhhs', 'shshshhshshs', 'hhhhhhhhhhhh' ] for i in range(4): for j in range(12): if brick_layout[i][j] == 'b': self.add_room_object( Brick(self, j * 64 + offset_x, i * 32 + offset_y)) elif brick_layout[i][j] == 'h': self.add_room_object( BrickHard(self, j * 64 + offset_x, i * 32 + offset_y)) elif brick_layout[i][j] == 's': self.add_room_object( SpeedBrick(self, j * 64 + offset_x, i * 32 + offset_y)) self.brick_count += 1 # - Add Start Text - # self.start_text = PressToStart(self, 200, 300) self.add_room_object(self.start_text) # - Add Paddle - # self.add_room_object( Paddle(self, Globals.SCREEN_WIDTH / 2, Globals.SCREEN_HEIGHT - 45)) # - Add ball - # ball = Ball(self, Globals.SCREEN_WIDTH / 2, Globals.SCREEN_HEIGHT / 2) self.add_room_object(ball)
def __init__(self, screen, joysticks): Level.__init__(self, screen, joysticks) # - Set Background image - # self.set_background_image('ocean.png') self.set_background_scroll(4) self.add_room_object(Plane(self, 468, Globals.SCREEN_HEIGHT - 60)) self.add_room_object( Island1(self, random.randint(65, Globals.SCREEN_WIDTH - 130), -100)) self.add_room_object( Island2(self, random.randint(65, Globals.SCREEN_WIDTH - 130), -300)) self.add_room_object( Island3(self, random.randint(65, Globals.SCREEN_WIDTH - 130), -500)) # - Add Banner for game info (lives) 800x56 - # self.add_room_object(Banner(self, 0, 544)) # - Add Text - # self.score_text = TextObject(self, 20, 560, 'Lives: %i' % Globals.LIVES) self.score_text.depth = 200 # self.score_text.font = 'Arial' self.score_text.colour = (255, 255, 255) self.score_text.update_text() self.add_room_object(self.score_text) # Load Sounds self.fire_bullet_sound = self.load_sound("fire_bullet.wav") self.explosion_sound = self.load_sound("explosion.wav") # - Add first Enemy plane after 5 Seconds - # self.set_timer(150, self.add_enemy)
def __init__(self, screen, joysticks): Level.__init__(self, screen, joysticks) title = ResultsText(self, Globals.SCREEN_WIDTH / 3, Globals.SCREEN_HEIGHT / 3, 'Results', 60, 'Comic Sans MS', (255, 255, 255)) title.x = Globals.SCREEN_WIDTH / 2 - title.width / 2 self.add_room_object(title) ibm_logo = IBMLogo(self, Globals.SCREEN_WIDTH / 2 + 220, 0) self.add_room_object(ibm_logo) varsity_logo = VarsityLogo(self, Globals.SCREEN_WIDTH / 2 - 130, 0) self.add_room_object(varsity_logo) griff_logo = GriffLogo(self, Globals.SCREEN_WIDTH / 2 - 580, 0) self.add_room_object(griff_logo) soma_logo = SomaLogo(self, 80, Globals.SCREEN_HEIGHT - 140) self.add_room_object(soma_logo) little_phil_logo = LittlePhilLogo(self, Globals.SCREEN_WIDTH - 500, Globals.SCREEN_HEIGHT - 160) self.add_room_object(little_phil_logo)
def __init__(self, screen, joysticks): Level.__init__(self, screen, joysticks) title = VarsityText(self, Globals.SCREEN_WIDTH / 3, Globals.SCREEN_HEIGHT / 3, 'GF Capture the Flag', 80, 'Comic Sans MS', (255, 255, 255)) title.x = Globals.SCREEN_WIDTH / 2 - title.width / 2 self.add_room_object(title) ctf_text = TextObject(self, Globals.SCREEN_WIDTH / 3, Globals.SCREEN_HEIGHT / 3 + 100, '2020 Championships', 100, 'Comic Sans MS', (255, 255, 255)) ctf_text.x = Globals.SCREEN_WIDTH / 2 - ctf_text.width / 2 self.add_room_object(ctf_text) if not Globals.first_run: self.set_timer(30, self.start_battle) ibm_logo = IBMLogo(self, Globals.SCREEN_WIDTH / 2 + 220, 0) self.add_room_object(ibm_logo) varsity_logo = VarsityLogo(self, Globals.SCREEN_WIDTH / 2 - 130, 0) self.add_room_object(varsity_logo) griff_logo = GriffLogo(self, Globals.SCREEN_WIDTH / 2 - 580, 0) self.add_room_object(griff_logo) soma_logo = SomaLogo(self, 80, Globals.SCREEN_HEIGHT - 140) self.add_room_object(soma_logo) little_phil_logo = LittlePhilLogo(self, Globals.SCREEN_WIDTH - 500, Globals.SCREEN_HEIGHT - 160) self.add_room_object(little_phil_logo)
def __init__(self, screen): Level.__init__(self, screen) self.set_background_image("background.png") Globals.red_bots.append(Red1(self, Globals.SCREEN_WIDTH - 250, Globals.SCREEN_HEIGHT / 4)) Globals.blue_bots.append(Blue1(self, 108, Globals.SCREEN_HEIGHT / 3)) Globals.red_bots.append(Red2(self, Globals.SCREEN_WIDTH - 250, Globals.SCREEN_HEIGHT / 4 * 2)) Globals.blue_bots.append(Blue2(self, 108, Globals.SCREEN_HEIGHT / 3 * 2)) Globals.red_bots.append(Red3(self, Globals.SCREEN_WIDTH - 250, Globals.SCREEN_HEIGHT / 4 * 3)) Globals.blue_bots.append(Blue3(self, 228, Globals.SCREEN_HEIGHT / 4)) Globals.red_bots.append(Red4(self, Globals.SCREEN_WIDTH - 140, Globals.SCREEN_HEIGHT / 3)) Globals.blue_bots.append(Blue4(self, 228, Globals.SCREEN_HEIGHT / 4 * 2)) Globals.red_bots.append(Red5(self, Globals.SCREEN_WIDTH - 140, Globals.SCREEN_HEIGHT / 3 * 2)) Globals.blue_bots.append(Blue5(self, 228, Globals.SCREEN_HEIGHT / 4 * 3)) for i in range(len(Globals.red_bots)): self.add_room_object(Globals.red_bots[i]) for i in range(len(Globals.blue_bots)): self.add_room_object(Globals.blue_bots[i]) Globals.blue_bots[i].rotate(180) Globals.red_flag = RedFlag(self, 200, Globals.SCREEN_HEIGHT / 2 - 26) Globals.blue_flag = BlueFlag(self, Globals.SCREEN_WIDTH - 232, Globals.SCREEN_HEIGHT / 2 - 26) self.add_room_object(Globals.red_flag) self.add_room_object(Globals.blue_flag) self.red_danger_zone = DangerZone(self, 0, -150) self.blue_danger_zone = DangerZone(self, 0, -150) self.can_update_red_danger = True self.can_update_blue_danger = True self.add_room_object(self.red_danger_zone) self.add_room_object(self.blue_danger_zone) self.danger_siren = self.load_sound('danger_siren.ogg') Globals.background_music = self.load_sound('battle-music.ogg') Globals.background_music.play(-1) self.counter = 3600 self.seconds = 120 text_minutes = int(self.seconds / 60) text_seconds = self.seconds % 60 self.counter_text = TextObject(self, Globals.SCREEN_WIDTH/2 - 50, 10, "{}:{:02d}".format(text_minutes, text_seconds)) self.add_room_object(self.counter_text) self.counter_text.x = Globals.SCREEN_WIDTH / 2 - self.counter_text.width/2 self.blue_score_text = TextObject(self, Globals.SCREEN_WIDTH / 2 - 50, 10, str(Globals.blue_enemy_side_time), 30) self.add_room_object(self.blue_score_text) self.blue_score_text.x = Globals.SCREEN_WIDTH / 3 - self.counter_text.width / 2 self.red_score_text = TextObject(self, Globals.SCREEN_WIDTH / 2 - 50, 10, str(Globals.red_enemy_side_time), 30) self.add_room_object(self.red_score_text) self.red_score_text.x = Globals.SCREEN_WIDTH / 3 * 2 - self.counter_text.width / 2 self.set_timer(3600, self.timed_out) self.update_screen_text()
def __init__(self, screen, joysticks): Level.__init__(self, screen, joysticks) self.background_sound = self.load_sound('dramatic_event.ogg') self.background_sound.play() ibm_logo = IBMLogo(self, Globals.SCREEN_WIDTH / 2 + 220, 0) self.add_room_object(ibm_logo) varsity_logo = VarsityLogo(self, Globals.SCREEN_WIDTH / 2 - 130, 0) self.add_room_object(varsity_logo) griff_logo = GriffLogo(self, Globals.SCREEN_WIDTH / 2 - 580, 0) self.add_room_object(griff_logo) soma_logo = SomaLogo(self, 80, Globals.SCREEN_HEIGHT - 140) self.add_room_object(soma_logo) little_phil_logo = LittlePhilLogo( self, Globals.SCREEN_WIDTH - 500, Globals.SCREEN_HEIGHT - 160 ) self.add_room_object(little_phil_logo) red_team = TextObject(self, Globals.SCREEN_WIDTH / 4, Globals.SCREEN_HEIGHT / 4, 'Red : {}'.format(Globals.game_list[Globals.current_battle][1]), 70, 'Comic Sans MS', (255, 0, 0) ) red_team.x = Globals.SCREEN_WIDTH / 2 - red_team.width / 2 self.add_room_object(red_team) versus = TextObject(self, Globals.SCREEN_WIDTH / 3, Globals.SCREEN_HEIGHT / 2 - 70, 'Versus', 70, 'Comic Sans MS', (255, 255, 255) ) versus.x = Globals.SCREEN_WIDTH / 2 - versus.width / 2 self.add_room_object(versus) blue_team = TextObject(self, Globals.SCREEN_WIDTH / 4, Globals.SCREEN_HEIGHT / 4 * 3 - 140, 'Blue : {}'.format(Globals.game_list[Globals.current_battle][0]), 70, 'Comic Sans MS', (0, 0, 255) ) blue_team.x = Globals.SCREEN_WIDTH / 2 - blue_team.width / 2 self.add_room_object(blue_team) self.load_new_bots() self.set_timer(200, self.run_battle)