def __init__(self, start_position, ready=False): MenuObject.__init__(self, start_position) self.ready = False if not ready else True # Import ready status indicator images. ready_status_indicator_sheet = SpriteSheet('resources/images/ready_status_indicators.png') ready_status_image_list = [ready_status_indicator_sheet.imageAt(pygame.Rect(0, 0, 15, 15)), ready_status_indicator_sheet.imageAt(pygame.Rect(15, 0, 15, 15))] self.image_list = ready_status_image_list
def __init__(self, parent, start_position=Vector2(0.0, 0.0)): self.width = globals.screen.get_width() self.height = globals.screen.get_height() self.font = pygame.font.SysFont('arial', 12) UIFrame.__init__(self, start_position, self.width, self.height, parent) #WorldObject.__init__(self, start_position, self.screen_size_x, self.screen_size_y, velocity, image_list) #self.pause_menu = PauseMenu(font, self.screen_size_x, self.screen_size_y, screen) # # Make a chat box. # self.chat_box = ChatBox(player_heads_up_display=self) # Load sprite sheets. self.health = 0 self.max_health = 0 crosshair_sheet = SpriteSheet("resources/images/Crosshair Sheet.png") sprite_sheet = SpriteSheet("resources/images/Sprite Sheet1.png") # Load crosshair. self.crosshair = BlitData( crosshair_sheet.imageAt(pygame.Rect(176, 158, 46, 48))) # load health bar info self.hp_overlay = BlitData( sprite_sheet.imageAt(pygame.Rect(652, 373, 290, 90)), (0, 0)) self.hp_bar = BlitData( sprite_sheet.imageAt(pygame.Rect(722, 485, 213, 40)), (64, 22)) self.mana_bar = BlitData( sprite_sheet.imageAt(pygame.Rect(722, 529, 146, 20)), (68, 65), (0, 0, 159, 20)) # set colorkey so black pixels will be transparent # self.image.set_colorkey(BLACK) # set black to transparent # self.image.fill(BLACK) # ammo and weapon data self.ammo_string = "send me text" self.weapon_string = "send me text" self.ammo_string_surface = self.font.render(self.ammo_string, True, [255, 255, 255]) self.weapon_string_surface = self.font.render(self.weapon_string, True, [255, 255, 255]) self.ammo_blit = BlitData(self.ammo_string_surface, (globals.screen.get_width() / 1.16, globals.screen.get_height() / 1.11)) self.weapon_blit = BlitData(self.weapon_string_surface, (globals.screen.get_width() / 1.16, globals.screen.get_height() / 1.066)) # order this list in which one you want blit first. top picture = last in the list. #self.blit_list = [self.hp_overlay, self.hp_bar, self.ammo_blit, self.weapon_blit, self.crosshair] self.blit_list = [ self.hp_overlay, self.hp_bar, self.mana_bar, self.ammo_blit, self.weapon_blit, self.crosshair ]
def __init__(self, always_visible=False, x_offset=0, y_offset=0, box_width=None, box_height=None, max_chars=65, player_heads_up_display=None, screen=None): self.screen = screen self.always_visible = always_visible self.max_chars = max_chars self.view_offset = 0 # The part of the text log you're viewing. 0 is the most recent on the bottom. # These values move the ChatBox from it's default position at the bottom left hand corner of the screen. self.x_offset = x_offset self.y_offset = y_offset self.hidden = not self.always_visible # while this is true the ChatBox shouldn't be displayed. self.alpha = 255 self.delaying_to_fade = False self.is_fading = False # while this is true, the ChatBox text is fading to transparency. self.fade_delay = 3 # seconds after the ChatBox is deselected until the text starts to fade. self.fade_time = 2 # seconds that it fades for after the fadeDelay self.last_deselect_time = 0 # time that the fade process started. self.last_fade_start_time = 0 self.selected = False self.fade_proportion = 0 # This will hold the proportion to convert the time to terms of opacity (0-255) self.font = pygame.font.SysFont('arial', 12) self.cursor_blink_time = 1.5 # the cursor will change every half of this number self.last_cursor_blink = 0 self.cursor_is_blinking = False self.cursor_surface = self.font.render("|", True, [255, 255, 255]) self.text_content = [] # list of strings. lower index = older self.input = None # a string of input to send to the textBox. self.surface_content = [] # a list of surface slices. lower index = older self.border_offset = 14 # offset text by ten pixels to account for the border of the chatBox self.blit_dict = {} self.alpha_blit_dict = {} temp_sprite_sheet = SpriteSheet("resources/images/Sprite Sheet1.png") self.box_image = temp_sprite_sheet.imageAt(pygame.Rect(5, 15, 370, 135)) # this image is cursed to never change color. self.unfocused_image = temp_sprite_sheet.imageAt(pygame.Rect(6, 158, 368, 130)) if box_width is not None and box_height is not None: self.box_image = pygame.transform.scale(self.box_image, (box_width, box_height)) self.unfocused_image = pygame.transform.scale(self.box_image, (box_width, box_height)) self.image = self.box_image # everything will be blit onto here. self.shift_is_pressed = False if hasattr(globals, 'online_game'): self.last_message_received = 0 self.get_new_messages_thread = RepeatTask(1, self.get_new_messages) self.get_new_messages_thread.start() self.player_heads_up_display = player_heads_up_display self.last_paused = datetime.now()
def __init__(self, start_position, ready=False): MenuObject.__init__(self, start_position) self.ready = False if not ready else True # Import ready status indicator images. ready_status_indicator_sheet = SpriteSheet( 'resources/images/ready_status_indicators.png') ready_status_image_list = [ ready_status_indicator_sheet.imageAt(pygame.Rect(0, 0, 15, 15)), ready_status_indicator_sheet.imageAt(pygame.Rect(15, 0, 15, 15)) ] self.image_list = ready_status_image_list
def init(): global camera global current_screen global online_game global screen #menu images global button_img_list global join_game_img_list global forward_button_img_list global back_button_img_list global text_field_img_list global ready_button_img_list global small_forward_button_img_list global small_back_button_img_list global close_button_img_list #cycle button contents global map_names #sounds global button_1_sound current_screen = "main menu" screen_size = pygame.display.list_modes()[0] screen = pygame.display.set_mode(screen_size, DOUBLEBUF) #import button images button_sheet = SpriteSheet("resources/images/ButtonSpriteSheet.png") button_img_list = [button_sheet.imageAt(pygame.Rect(475, 306, 80, 19), None)] join_game_img_list = [button_sheet.imageAt(pygame.Rect(497, 281, 33, 10))] forward_button_img_list = [button_sheet.imageAt(pygame.Rect(0, 76, 50, 278), None)] back_button_img_list = [button_sheet.imageAt(pygame.Rect(54, 76, 50, 278), None)] small_forward_button_img_list = [button_sheet.imageAt(pygame.Rect(494, 226, 18, 15)), button_sheet.imageAt(pygame.Rect(494, 243, 18, 15))] small_back_button_img_list = [button_sheet.imageAt(pygame.Rect(516, 242, 18, 15)), button_sheet.imageAt(pygame.Rect(516, 225, 18, 15))] text_field_img_list = [button_sheet.imageAt(pygame.Rect(479, 278, 75, 12), None), button_sheet.imageAt(pygame.Rect(479, 293, 75, 12), None)] ready_button_img_list = [button_sheet.imageAt(pygame.Rect(0, 0, 157, 38), None), button_sheet.imageAt(pygame.Rect(0, 38, 157, 38), None)] close_button_img_list = [button_sheet.imageAt(pygame.Rect(108, 77, 44, 44), None)] #populate cycle_button elements map_names = [Label(euclid.Vector2(0, 0), "Matt World"), Label(euclid.Vector2(0, 0), "Fun Zone"), Label(euclid.Vector2(0, 0), "Snake Juice")] #sounds button_1_sound = pygame.mixer.Sound("resources/sounds/menu_button.wav")
def __init__(self, bullet_image_list): bullet_velocity = 800 sprite_sheet_1 = SpriteSheet("resources/images/Sprite Sheet1.png") image_list = [ sprite_sheet_1.imageAt(pygame.Rect(966, 332, 35, 21)), sprite_sheet_1.imageAt(pygame.Rect(471, 93, 102, 40)) ] gun_x_position = 7.0 gun_y_position = 0.0 delay = 1 damage = 5 ammo = 30 max_ammo = 30 reload_time = 2.0 accuracy = .07 width = 35 height = 21 look_left_offset = -16 Gun.__init__(self, bullet_velocity, delay, damage, ammo, max_ammo, reload_time, accuracy, image_list, gun_x_position, gun_y_position, width, height, look_left_offset) ServerShotgun.__init__(self) self.bullet_image_list = bullet_image_list
def __init__(self, bullet_image_list): sprite_sheet_1 = SpriteSheet("resources/images/Sprite Sheet1.png") image_list = [ sprite_sheet_1.imageAt(pygame.Rect(732, 316, 58, 30)), sprite_sheet_1.imageAt(pygame.Rect(811, 315, 84, 40)) ] reload_time = 2 accuracy = .1 damage = 10 ammo = 30 max_ammo = 30 delay = .8 bullet_velocity = 1000 width = 58 height = 30 look_left_offset = 16 gun_x_position = -9.0 gun_y_position = -13.0 Gun.__init__(self, bullet_velocity, delay, damage, ammo, max_ammo, reload_time, accuracy, image_list, gun_x_position, gun_y_position, width, height, look_left_offset) ServerPistol.__init__(self) self.bullet_image_list = bullet_image_list
def __init__(self, parent, start_position=Vector2(0.0, 0.0)): self.width = globals.screen.get_width() self.height = globals.screen.get_height() self.font = pygame.font.SysFont('arial', 12) UIFrame.__init__(self, start_position, self.width, self.height, parent) #WorldObject.__init__(self, start_position, self.screen_size_x, self.screen_size_y, velocity, image_list) #self.pause_menu = PauseMenu(font, self.screen_size_x, self.screen_size_y, screen) # # Make a chat box. # self.chat_box = ChatBox(player_heads_up_display=self) # Load sprite sheets. self.health = 0 self.max_health = 0 crosshair_sheet = SpriteSheet("resources/images/Crosshair Sheet.png") sprite_sheet = SpriteSheet("resources/images/Sprite Sheet1.png") # Load crosshair. self.crosshair = BlitData(crosshair_sheet.imageAt(pygame.Rect(176, 158, 46, 48))) # load health bar info self.hp_overlay = BlitData(sprite_sheet.imageAt(pygame.Rect(652, 373, 290, 90)), (0, 0)) self.hp_bar = BlitData(sprite_sheet.imageAt(pygame.Rect(722, 485, 213, 40)), (64, 22)) self.mana_bar = BlitData(sprite_sheet.imageAt(pygame.Rect(722, 529, 146, 20)), (68, 65), (0, 0, 159, 20)) # set colorkey so black pixels will be transparent # self.image.set_colorkey(BLACK) # set black to transparent # self.image.fill(BLACK) # ammo and weapon data self.ammo_string = "send me text" self.weapon_string = "send me text" self.ammo_string_surface = self.font.render(self.ammo_string, True, [255, 255, 255]) self.weapon_string_surface = self.font.render(self.weapon_string, True, [255, 255, 255]) self.ammo_blit = BlitData(self.ammo_string_surface, (globals.screen.get_width() / 1.16, globals.screen.get_height() / 1.11)) self.weapon_blit = BlitData(self.weapon_string_surface, (globals.screen.get_width() / 1.16, globals.screen.get_height() / 1.066)) # order this list in which one you want blit first. top picture = last in the list. #self.blit_list = [self.hp_overlay, self.hp_bar, self.ammo_blit, self.weapon_blit, self.crosshair] self.blit_list = [self.hp_overlay, self.hp_bar, self.mana_bar, self.ammo_blit, self.weapon_blit, self.crosshair]
def __init__(self, bullet_image_list): #load image for bigbertha image_list = [] # override gun's image list sprite_sheet_1 = SpriteSheet("resources/images/Sprite Sheet1.png") image_list.append( sprite_sheet_1.imageAt(pygame.Rect(726, 131, 146, 34))) image_list.append( sprite_sheet_1.imageAt(pygame.Rect(726, 187, 146, 34))) bullet_velocity = 1100 delay = .8 damage = 420 ammo = 10 max_ammo = 10 reload_time = 1.5 accuracy = 0.2 Gun.__init__(self, bullet_velocity, delay, damage, ammo, max_ammo, reload_time, accuracy, image_list) ServerGrenadeLauncher.__init__(self) self.bullet_image_list = bullet_image_list
def __init__(self, bullet_image_list): #load image for bigbertha image_list = [] # override gun's image list sprite_sheet_1 = SpriteSheet("resources/images/Sprite Sheet1.png") image_list.append(sprite_sheet_1.imageAt(pygame.Rect(726, 131, 146, 34))) image_list.append(sprite_sheet_1.imageAt(pygame.Rect(726, 187, 146, 34))) bullet_velocity = 1100 delay = .8 damage = 420 ammo = 10 max_ammo = 10 reload_time = 1.5 accuracy = 0.2 Gun.__init__(self, bullet_velocity, delay, damage, ammo, max_ammo, reload_time, accuracy, image_list) ServerGrenadeLauncher.__init__(self) self.bullet_image_list = bullet_image_list
def __init__(self, bullet_image_list): bullet_velocity = 800 sprite_sheet_1 = SpriteSheet("resources/images/Sprite Sheet1.png") image_list = [sprite_sheet_1.imageAt(pygame.Rect(966, 332, 35, 21)), sprite_sheet_1.imageAt(pygame.Rect(471, 93, 102, 40))] gun_x_position = 7.0 gun_y_position = 0.0 delay = 1 damage = 5 ammo = 30 max_ammo = 30 reload_time = 2.0 accuracy = .07 width = 35 height = 21 look_left_offset = -16 Gun.__init__(self, bullet_velocity, delay, damage, ammo, max_ammo, reload_time, accuracy, image_list, gun_x_position, gun_y_position, width, height, look_left_offset) ServerShotgun.__init__(self) self.bullet_image_list = bullet_image_list
def __init__(self, bullet_image_list): sprite_sheet_1 = SpriteSheet("resources/images/Sprite Sheet1.png") image_list = [sprite_sheet_1.imageAt(pygame.Rect(732, 316, 58, 30)), sprite_sheet_1.imageAt(pygame.Rect(811, 315, 84, 40))] reload_time = 2 accuracy = .1 damage = 10 ammo = 30 max_ammo = 30 delay = .8 bullet_velocity = 1000 width = 58 height = 30 look_left_offset = 16 gun_x_position = -9.0 gun_y_position = -13.0 Gun.__init__(self, bullet_velocity, delay, damage, ammo, max_ammo, reload_time, accuracy, image_list, gun_x_position, gun_y_position, width, height, look_left_offset) ServerPistol.__init__(self) self.bullet_image_list = bullet_image_list
def load_sprite_images(self): """ gets images from sprite sheets """ # sprite sheets effectSheet = SpriteSheet("resources/images/Effects Spritesheet.png") explosionSheet = SpriteSheet("resources/images/explosion.png") lunar_pioneer_sheet = SpriteSheet("resources/images/lunar pioneer.png") background_objects_sheet = SpriteSheet("resources/images/grandfather clock.png") dust_sheet = SpriteSheet("resources/images/Dust Spritesheet.png") #lightning self.lightning_animation = [effectSheet.imageAt(pygame.Rect(654, 886, 34, 14)), effectSheet.imageAt(pygame.Rect(705, 885, 32, 14)), effectSheet.imageAt(pygame.Rect(750, 872, 62, 40)), effectSheet.imageAt(pygame.Rect(826, 871, 68, 37)), effectSheet.imageAt(pygame.Rect(911, 881, 72, 29))] #putting explosion into big bertha berthaImage.append(explosionSheet.imageAt(pygame.Rect(22, 115, 72, 63))) berthaImage.append(explosionSheet.imageAt(pygame.Rect(110, 108, 99, 81))) berthaImage.append(explosionSheet.imageAt(pygame.Rect(384, 116, 103, 88))) berthaImage.append(explosionSheet.imageAt(pygame.Rect(509, 27, 110, 80))) berthaImage.append(explosionSheet.imageAt(pygame.Rect(650, 29, 84, 72))) #lunar pioneer images self.lunar_pioneer_images = [lunar_pioneer_sheet.imageAt(pygame.Rect(35, 25, 20, 20)), lunar_pioneer_sheet.imageAt(pygame.Rect(101, 26, 20, 20))] #grandfather clock images self.grandfather_clock = [background_objects_sheet.imageAt(pygame.Rect(7, 12, 18, 71)), background_objects_sheet.imageAt(pygame.Rect(39, 12, 18, 71)), background_objects_sheet.imageAt(pygame.Rect(71, 12, 18, 71)), background_objects_sheet.imageAt(pygame.Rect(39, 12, 18, 71))] #spawn images self.spawn_animation = [effectSheet.imageAt(pygame.Rect(291, 695, 2, 217)), effectSheet.imageAt(pygame.Rect(281, 695, 2, 217)), effectSheet.imageAt(pygame.Rect(270, 695, 2, 217)), effectSheet.imageAt(pygame.Rect(270, 695, 2, 217)), effectSheet.imageAt(pygame.Rect(260, 695, 4, 217)), effectSheet.imageAt(pygame.Rect(242, 695, 12, 216)), effectSheet.imageAt(pygame.Rect(215, 695, 22, 217)), effectSheet.imageAt(pygame.Rect(180, 695, 30, 217)), effectSheet.imageAt(pygame.Rect(148, 695, 22, 217)), effectSheet.imageAt(pygame.Rect(108, 695, 30, 217)), effectSheet.imageAt(pygame.Rect(53, 695, 48, 217)), effectSheet.imageAt(pygame.Rect(4, 695, 46, 217))] self.spawn_animation = normalize_rects(self.spawn_animation) #dust cloud #dust_sheet.imageAt(pygame.Rect(544, 250, 82, 17)) # this image is just broken for no reason. self.dust_cloud = [dust_sheet.imageAt(pygame.Rect(156, 28, 150, 41)), dust_sheet.imageAt(pygame.Rect(351, 20, 189, 58)), dust_sheet.imageAt(pygame.Rect(2, 130, 196, 61)), dust_sheet.imageAt(pygame.Rect(257, 141, 194, 57)), dust_sheet.imageAt(pygame.Rect(3, 230, 198, 57)), dust_sheet.imageAt(pygame.Rect(257, 253, 197, 57))]
def __init__(self, always_visible=False, x_offset=0, y_offset=0, box_width=None, box_height=None, max_chars=65, player_heads_up_display=None, screen=None): self.screen = screen self.always_visible = always_visible self.max_chars = max_chars self.view_offset = 0 # The part of the text log you're viewing. 0 is the most recent on the bottom. # These values move the ChatBox from it's default position at the bottom left hand corner of the screen. self.x_offset = x_offset self.y_offset = y_offset self.hidden = not self.always_visible # while this is true the ChatBox shouldn't be displayed. self.alpha = 255 self.delaying_to_fade = False self.is_fading = False # while this is true, the ChatBox text is fading to transparency. self.fade_delay = 3 # seconds after the ChatBox is deselected until the text starts to fade. self.fade_time = 2 # seconds that it fades for after the fadeDelay self.last_deselect_time = 0 # time that the fade process started. self.last_fade_start_time = 0 self.selected = False self.fade_proportion = 0 # This will hold the proportion to convert the time to terms of opacity (0-255) self.font = pygame.font.SysFont('arial', 12) self.cursor_blink_time = 1.5 # the cursor will change every half of this number self.last_cursor_blink = 0 self.cursor_is_blinking = False self.cursor_surface = self.font.render("|", True, [255, 255, 255]) self.text_content = [] # list of strings. lower index = older self.input = None # a string of input to send to the textBox. self.surface_content = [ ] # a list of surface slices. lower index = older self.border_offset = 14 # offset text by ten pixels to account for the border of the chatBox self.blit_dict = {} self.alpha_blit_dict = {} temp_sprite_sheet = SpriteSheet("resources/images/Sprite Sheet1.png") self.box_image = temp_sprite_sheet.imageAt(pygame.Rect( 5, 15, 370, 135)) # this image is cursed to never change color. self.unfocused_image = temp_sprite_sheet.imageAt( pygame.Rect(6, 158, 368, 130)) if box_width is not None and box_height is not None: self.box_image = pygame.transform.scale(self.box_image, (box_width, box_height)) self.unfocused_image = pygame.transform.scale( self.box_image, (box_width, box_height)) self.image = self.box_image # everything will be blit onto here. self.shift_is_pressed = False if hasattr(globals, 'online_game'): self.last_message_received = 0 self.get_new_messages_thread = RepeatTask(1, self.get_new_messages) self.get_new_messages_thread.start() self.player_heads_up_display = player_heads_up_display self.last_paused = datetime.now()
def load_sprite_images(self): """ gets images from sprite sheets """ # sprite sheets effectSheet = SpriteSheet("resources/images/Effects Spritesheet.png") explosionSheet = SpriteSheet("resources/images/explosion.png") lunar_pioneer_sheet = SpriteSheet("resources/images/lunar pioneer.png") background_objects_sheet = SpriteSheet( "resources/images/grandfather clock.png") dust_sheet = SpriteSheet("resources/images/Dust Spritesheet.png") #lightning self.lightning_animation = [ effectSheet.imageAt(pygame.Rect(654, 886, 34, 14)), effectSheet.imageAt(pygame.Rect(705, 885, 32, 14)), effectSheet.imageAt(pygame.Rect(750, 872, 62, 40)), effectSheet.imageAt(pygame.Rect(826, 871, 68, 37)), effectSheet.imageAt(pygame.Rect(911, 881, 72, 29)) ] #putting explosion into big bertha berthaImage.append(explosionSheet.imageAt(pygame.Rect(22, 115, 72, 63))) berthaImage.append( explosionSheet.imageAt(pygame.Rect(110, 108, 99, 81))) berthaImage.append( explosionSheet.imageAt(pygame.Rect(384, 116, 103, 88))) berthaImage.append( explosionSheet.imageAt(pygame.Rect(509, 27, 110, 80))) berthaImage.append(explosionSheet.imageAt(pygame.Rect(650, 29, 84, 72))) #lunar pioneer images self.lunar_pioneer_images = [ lunar_pioneer_sheet.imageAt(pygame.Rect(35, 25, 20, 20)), lunar_pioneer_sheet.imageAt(pygame.Rect(101, 26, 20, 20)) ] #grandfather clock images self.grandfather_clock = [ background_objects_sheet.imageAt(pygame.Rect(7, 12, 18, 71)), background_objects_sheet.imageAt(pygame.Rect(39, 12, 18, 71)), background_objects_sheet.imageAt(pygame.Rect(71, 12, 18, 71)), background_objects_sheet.imageAt(pygame.Rect(39, 12, 18, 71)) ] #spawn images self.spawn_animation = [ effectSheet.imageAt(pygame.Rect(291, 695, 2, 217)), effectSheet.imageAt(pygame.Rect(281, 695, 2, 217)), effectSheet.imageAt(pygame.Rect(270, 695, 2, 217)), effectSheet.imageAt(pygame.Rect(270, 695, 2, 217)), effectSheet.imageAt(pygame.Rect(260, 695, 4, 217)), effectSheet.imageAt(pygame.Rect(242, 695, 12, 216)), effectSheet.imageAt(pygame.Rect(215, 695, 22, 217)), effectSheet.imageAt(pygame.Rect(180, 695, 30, 217)), effectSheet.imageAt(pygame.Rect(148, 695, 22, 217)), effectSheet.imageAt(pygame.Rect(108, 695, 30, 217)), effectSheet.imageAt(pygame.Rect(53, 695, 48, 217)), effectSheet.imageAt(pygame.Rect(4, 695, 46, 217)) ] self.spawn_animation = normalize_rects(self.spawn_animation) #dust cloud #dust_sheet.imageAt(pygame.Rect(544, 250, 82, 17)) # this image is just broken for no reason. self.dust_cloud = [ dust_sheet.imageAt(pygame.Rect(156, 28, 150, 41)), dust_sheet.imageAt(pygame.Rect(351, 20, 189, 58)), dust_sheet.imageAt(pygame.Rect(2, 130, 196, 61)), dust_sheet.imageAt(pygame.Rect(257, 141, 194, 57)), dust_sheet.imageAt(pygame.Rect(3, 230, 198, 57)), dust_sheet.imageAt(pygame.Rect(257, 253, 197, 57)) ]