def __init__(self, x, y): GameObject.__init__(self, x, y) self.renderer = Animation(["images/warning_sign.png"], loop=True) self.box_collider = BoxCollider(64, 64) self.count = FrameCounter(50) pygame.mixer.Channel(3).play( pygame.mixer.Sound("music/warning (1).wav"))
def __init__(self, current_ship, special=False): """ :param ._location_x: the vertical location of the torpedo. :param ._location_y: the horizontal location of the torpedo. :param ._speed_x: the vertical speed of the torpedo. :param ._speed_y: the horizontal speed of the torpedo. :param ._angle: the angle of the torpedo. :param ._special: boolean parameter which tells if the torpedo is special or not. :param ._life: how many iterations left for the torpedo to live. """ GameObject.__init__(self) self._location_x = current_ship.get_location_x() self._location_y = current_ship.get_location_y() self._speed_x = self._get_torpedo_speed_x\ (current_ship.get_speed_x(), current_ship.get_angle()) self._speed_y = self._get_torpedo_speed_y\ (current_ship.get_speed_y(), current_ship.get_angle()) self._angle = current_ship.get_angle() self._special = special self._radius = TORPEDO_RADIUS if special: self._life = TORPEDO_SPECIAL_MAX_LIFE else: self._life = TORPEDO_MAX_LIFE
def __init__(self, x: int, y: int, size: int, speed, backgroundWidth: int, backgroundHeight: int): GameObject.__init__(self, x, y, size, size, speed) self.backgroundWidth = backgroundWidth self.backgroundHeight = backgroundHeight self.actualTop = self.top self.actualLeft = self.left
def __init__(self): GameObject.__init__(self, 0, 0) self.counter_continue = FrameCounter(20) self.counter_blank = FrameCounter(game_object.blank_time) self.renderer = None self.is_spawning = True self.counter_blank.expired = True
def __init__(self, game, x, y, delay=1, hp=1, damage=0.5, behavior=ai.approach_player_smart): GameObject.__init__(self, game, x, y, layer=4) idle = SpriteSheet("images/bug.png", (2, 1), 2) self.sprite.add_animation({"Idle": idle}) self.sprite.start_animation("Idle") self.behavior = behavior self.game.movers += [self] self.hp = hp self.max_hp = hp self.damage = damage self.delay = delay self.map = game.map game.map.add_to_cell(self, (x, y)) self.countdown = random.randint(0, delay) self.enemy = True self.hittable = True self.heart = pygame.image.load("images/heart_small.png") self.eheart = pygame.image.load("images/empty_heart_small.png") self.heart_width = self.heart.get_width() self.width = TILE_SIZE / 2 self.hp_visible = True
def __init__(self, x, y): GameObject.__init__(self, x, y) self.input_manager = InputManager() self.left = pygame.image.load("images/left.png") self.right = pygame.image.load("images/right.png") self.all = pygame.image.load("images/all.png") self.image = self.all
def __init__(self, x, y): GameObject.__init__(self, x, y) self.image = pygame.image.load("images/player-bullet.png") self.box_collider = BoxCollider(40, 40) self.velocity = (0, 0) self.returning = False self.counter = FrameCounter(60)
def __init__(self, level_map, coord): GameObject.__init__(self, level_map, coord, False, True) self.obj_id = 'brazier' self.determine_initial_state() self.is_dead = False
def __init__(self, x, y, w, h, text, on_click=lambda x: None, padding=0): GameObject.__init__(self, x, y, w, h) self.state = 'normal' self.on_click = on_click self.text = TextObject(x + padding, y + padding, lambda: text, c.button_text_color, c.font_name, c.font_size)
def __init__(self, type, pos, width, height, priority, speed): GameObject.__init__(self, type, pos, width, height, priority) self.rect = self.create_rect(pos, width, height) self.speed = speed self.direction = 'UP' self.movement_status = 'NORMAL' self.last_move = QPoint(0, 0)
def __init__(self, x, y, input_manager): GameObject.__init__(self, x, y) self.image = pygame.image.load('image/player.png') self.input_manager = input_manager self.shoot_lock = False self.counter = FrameCounter(30) self.hp = 10
def __init__(self, world, obj_data): GameObject.__init__(self, world, obj_data) i = 0 for frame, layer, x, y in TileIter(self.art): self.art.set_color_at(frame, layer, x, y, TILE_COLORS[i], False) self.art.write_string(frame, layer, x, y, str(i + 1), 1) i += 1
def __init__(self, image, x, y, speed): # https://younglinux.info/pygame/image self.image_surface = pygame.image.load(image) rect = self.image_surface.get_rect() GameObject.__init__(self, x + rect.left, y + rect.top, rect.width, rect.height, speed) '''(random.randint(-5, -1), 0)'''
def __init__(self, x, y, w, h, color, offset): GameObject.__init__(self, x, y, w, h) self.color = color self.offset = offset self.moving_left = False self.moving_right = False
def __init__(self, x, y, input_manager): GameObject.__init__(self, x, y) self.input_manager = input_manager self.shoot_lock = False self.counter = FrameCounter(30) self.renderer = PlayerAnimator() self.dx = 0 self.dy = 0
def __init__(self, state, coord, player, obj_code): GameObject.__init__(self, state, coord, obj_code, player) self.owner_id = self.load_player_id(player) self.color = self.load_color(player) self.image = self.load_image(self.object_image_name()) self.change_color(PlayerGameObject.START_COLOR, self.color)
def __init__(self, x, y): GameObject.__init__(self,x ,y) self.overlap = False # 1 load image self.renderer = ImageRenderer("assets/images/sprite/gift/gift_close.png") self.width = 25 self.height = 25 self.box_collider = BoxCollider(self.width, self.height)
def __init__(self, x, y, hastighet_x, hastighet_y): GameObject.__init__(self, x, y, hastighet_x, hastighet_y, image=bullet_image, time_to_live=450)
def __init__(self, x, y, hastighet_x=0, hastighet_y=0, target=None): GameObject.__init__(self, x, y, hastighet_x, hastighet_y, image=enemy_image) self.target = target
def __init__(self): GameObject.__init__(self) self.load_anims("part", 11) # Load a random part and place it randomly on the conveyor belt. self.reset() self.rect.left = random.randint(0, 536) self.moved_once = False
def __init__(self, x, y, r, color, speed): GameObject.__init__(self, x - r, y - r, r * 2, r * 2, speed) self.radius = r self.diameter = r * 2 self.color = color
def __init__(self, x, y): GameObject.__init__(self, x, y) self.renderer = Animation([ "images/enemy/bacteria_dead1.png", "images/enemy/bacteria_dead2.png", "images/enemy/bacteria_dead3.png", "images/enemy/bacteria_dead4.png", "images/enemy/bacteria_dead5.png" ])
def __init__(self, game, x, y, path="", fps=4): GameObject.__init__(self, game, x, y, layer=ITEM_LAYER, fps=fps) static = SpriteSheet(path + "_small.png", (1, 1), 1) self.layer = ITEM_LAYER self.sprite.add_animation({"Static": static}) self.sprite.start_animation("Static") self.static = True self.map = game.map game.map.add_to_cell(self, (x, y))
def __init__(self, x, y): GameObject.__init__(self, x, y) self.shoot_lock = False self.counter = FrameCounter(30) self.box_collider = BoxCollider(60, 110) self.dx = 0 self.dy = 0 self.jump_speed = -22 self.renderer = PlayerAnimator()
def __init__(self, level_map, coord, hue_id): GameObject.__init__(self, level_map, coord, False, True) self.obj_id = 'crystal' self.image_component = ImageComponent(self, CRYSTAL) self.color_component = self.create_color_component(hue_id) self.color_source = ColorSource(level_map.color_map, hue_id, 5, self.coord) self.health = 3
def __init__(self, game, x, y, fps=4): GameObject.__init__(self, game, x, y, layer=0, fps=fps) self.layer = FLOOR_LAYER sprite_paths = [("default_tile" + str(a) + ".png") for a in ["", 0, 1, 2, 3, 4]] static = SpriteSheet(random.choice(sprite_paths), (1, 1), 1) self.sprite.add_animation({"Static": static}) self.sprite.start_animation("Static") self.static = True self.map = game.map game.map.add_to_cell(self, (x,y))
def __init__(self, game, pos): GameObject.__init__(self, game, 'player', pos) self.actions = Player.ACTIONS self.max_actions = Player.ACTIONS self.hop = 8 self.player_overlay = PlayerOverlay(self)
def __init__(self, x, y, input_manager): GameObject.__init__(self, x, y) self.input_manager = input_manager self.image = pygame.image.load("images/player/player1.png") self.counter1 = FrameCounter(120) self.counter2 = FrameCounter(120) self.has_shoot1 = True self.has_shoot2 = True self.dog_count = 0 self.box_collider = BoxCollider(70, 70)
def __init__(self, xml_data, driver): self.dmg = int(xml_data.get('dmg')) # call the super constructor GameObject.__init__(self, 0, 0, int(xml_data.get('width')), int(xml_data.get('height')), driver, image_path=xml_data.get('img'))
def __init__(self, position, angle, area, solids, objId=None): GameObject.__init__(self, position, angle, self.SIZE, self.TYPE, objId, area=area, solids=solids) self.health = self.HEALTH self.next_shot = 0 self.respPos = position self.msgs = [] self.currentMsg = None self.lastTimestamp = 0
def __init__(self, level_map, coord): GameObject.__init__(self, level_map, coord, True, True) self.state = Door.CLOSED self.obj_id = 'door' self.image_component = ImageComponent(self, self.load_tile_image(), animated=False) self.color_component = ColorComponent(self) self.is_dead = False
def __init__(self, projectile_list, x, y, max_side_move, max_down_move = 40): GameObject.__init__(self, x, y, 30, 30) self.speed = 0.05 self.direction = self.MOVING_RIGHT self.projectile_list = projectile_list self.max_down_move = max_down_move self.max_side_move = max_side_move self._moved = max_side_move self.fire_delay = 0
def __init__(self): GameObject.__init__(self, 425.0, 500.0, 60, 60) self.life = 5 self.score = 0 self.speed = 0.25 self.projectile_list = list() self.fire_delay = 15 self.move_right = self.move_left = self.fire_shot = False
def __init__(self, world, position): GameObject.__init__(self) self.world = world self.alignment = 0 self.neutralteam = NeutralTeam() self.team = self.neutralteam self.image = self.team.get_controlpoint_image() self.mask = pygame.mask.from_surface(self.image) self.rect = self.image.get_rect() self.rect.center = position self.layer = 1
def __init__(self, world): GameObject.__init__(self) self.world = world self.image = pygame.image.load('graphics/ammo.png').convert_alpha() self.rect = self.image.get_rect() self.mask = pygame.mask.from_surface(self.image) #spawn at random location while True: self.rect.center = ( utils.RANDOM.gauss(0.5,0.2)*self.world.level.WORLD_SIZE[0], utils.RANDOM.gauss(0.5,0.35)*self.world.level.WORLD_SIZE[1]) if len(self.world.touching_objects(self)) == 0: break
def __init__(self, name): GameObject.__init__(self, 425.0, 500.0, 60, 60) self.color = pygame.Color(255,255,255) self.life = 5 self.score = 0 self.speed = 0.25 self.projectile_list = list() self.fire_delay = 15 self.is_immune = True self.is_moving_right = self.is_moving_left = self.is_firing = False self.name = name
def __init__(self, arena, number, damping, token_type=MARKER_TOKEN): self._body = arena._physics_world.create_body(position=(0, 0), angle=0, linear_damping=damping, angular_damping=damping, type=pypybox2d.body.Body.DYNAMIC) GameObject.__init__(self, arena) self.marker_info = create_marker_info_by_type(token_type, number) self.grabbed = False WIDTH=0.08 self._body.create_polygon_fixture([(-WIDTH, -WIDTH), ( WIDTH, -WIDTH), ( WIDTH, WIDTH), (-WIDTH, WIDTH)], density=1, restitution=0.2, friction=0.3)
def __init__(self, simulator): self._body = None self.zone = 0 GameObject.__init__(self, simulator.arena) self.motors = [Motor(self)] make_body = simulator.arena._physics_world.create_body half_width = self.width * 0.5 with self.arena.physics_lock: self._body = make_body(position=(0, 0), angle=0, linear_damping=0.0, angular_damping=0.0, type=pypybox2d.body.Body.DYNAMIC) self._body.create_polygon_fixture([(-half_width, -half_width), ( half_width, -half_width), ( half_width, half_width), (-half_width, half_width)], density=500*0.12) # MDF @ 12cm thickness simulator.arena.objects.append(self)
def __init__(self, projectiles, x, amountOfInvadersSpawned): maxInvaders = 5 # check if there are destroyed invaders you can replace temp = amountOfInvadersSpawned / maxInvaders self.y = 50 * temp temp2 = temp * maxInvaders # amountOfInvadersOnThisLine aOIOTL = amountOfInvadersSpawned - temp2 self.x = 50 * aOIOTL GameObject.__init__(self, self.x, self.y, 30, 30) self.projectile_list = projectiles self.max_down_move = 200 self.max_side_move = 625 self.howManyMoves = self.max_side_move self.direction = self.movingRight self.mvmtSpeed = 4 self.shotDelay = random.randrange(1000, 3000) self.timeSinceLastShot = 0 """
def __init__(self, number, world, team): GameObject.__init__(self) self.collide = True self.dirty = 2 #always redraw self.number = number self.world = world self.team = team self.base_image = self.team.get_suit_image() self.rect = self.base_image.get_rect() self.mask = pygame.mask.from_surface(self.base_image) self.image = self.base_image self.font = pygame.font.SysFont("Arial", 9) self.observer = ObservationSprite(world, self, SIGHT) self.brain = self.team.get_brain() self.label = '' self.alive = False self.spawn()
def __init__(self, position, angle, owner=None, objId=None): GameObject.__init__(self, position, angle, self.SIZE, self.TYPE, objId, solid=False) if owner is not None: self.owner = owner.id
def __init__(self, position, angle, area, solids, objId=None): GameObject.__init__(self, position, angle, self.SIZE, self.TYPE, objId, area=area, solids=solids) self.health = self.HEALTH self.next_shot = 0 self.target = None
def __init__(self, arena, number): GameObject.__init__(self, arena) self.marker_info = create_marker_info_by_type(MARKER_TOKEN, number) self.grabbed = False
def __init__(self, arena, number, location=(0,0), heading=0): GameObject.__init__(self, arena) self.marker_info = create_marker_info_by_type(MARKER_ARENA, number) self.location = location self.heading = heading
def __init__(self, xpos, ypos, speed): GameObject.__init__(self, xpos, ypos, 5, 30) #self.x = xpos #self.y = ypos self.speed = speed self.dt = 5