def __init__(self, screen, speedx, speedy, start_x, start_y, animation_speed = 60 ): GameObject.__init__(self, screen, speedx, speedy, start_x, start_y, animation_speed) self.image = pygame.image.load("assets/objects/shoots/laserGreen.png").convert_alpha() self.rect = self.image.get_rect() self.rect.bottom = start_y self.rect.centerx = start_x self.speedy = speedy
def __init__(self, name, xy, tiletype, can_be_eaten=True, hp_gain=0, mp_gain=0): GameObject.__init__(self, xy, tiletype, solid=False, draw_once_seen = False) self.name = name self.time_to_live = 10 self.can_be_eaten = can_be_eaten self.hp_gain = hp_gain self.mp_gain = mp_gain
def __init__(self, group, eff_group, speedx, speedy, start_x, start_y, animation_speed=60): GameObject.__init__(self, group, speedx, speedy, start_x, start_y, animation_speed) self.images = [] self.animation_step = 0 self.animation_len = 0 self.last_death = 0 self.elapsed = pygame.time.get_ticks() self.animation_speed = animation_speed self.effect_group = eff_group self.hp = 100 self.damage = 30 # Взрыв self.explosion = GameEffect(self.effect_group, 0, 0, start_x, self.rect.top) self.explosion.set_images([ "assets/objects/explosion/regularExplosion01.png", "assets/objects/explosion/regularExplosion02.png", "assets/objects/explosion/regularExplosion03.png", "assets/objects/explosion/regularExplosion04.png", "assets/objects/explosion/regularExplosion05.png", "assets/objects/explosion/regularExplosion06.png", "assets/objects/explosion/regularExplosion07.png", "assets/objects/explosion/regularExplosion08.png", ]) # удаляем из груп чтобы избежать отрисовки раньше времени self.effect_group.remove(self.explosion) self.is_destroyed = False
def __init__(self): GameObject.__init__(self) self.x = 0 self.y = 0 self.width = BLOCK_SIZE * 10 self.height = BLOCK_SIZE * 10 self.color = 0xFFFFFF self.shape = [ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], ] self.blocks = [] for row_index, row in enumerate(self.shape): myrow = [] for col_index, col in enumerate(row): if col == 1: myrow.append(Block(self, self.color, col_index * BLOCK_SIZE, row_index * BLOCK_SIZE)) self.blocks.append(myrow)
def __init__(self, position, facing, mass, height): self.mass = mass self.height = height orientation = array([0, 1, 0]) # Start upright self.forward = dot(array([1, 0, 0]), rotationMatrix(array([0, 1, 0]), facing)) self.velocity = array([0, 0, 0]) GameObject.__init__(self, position, orientation, facing)
def __init__(self, root, x, y): GameObject.__init__(self, root, x, y) self.lifeAlarm = 0 self.direction = 0 self.sprite = load_image("sprites/projectiles/shots/0.png") self.rect = self.sprite.get_rect()
def __init__(self, xy, name, type, variant=0, resources_left=1): GameObject.__init__(self, xy, type, solid=True, draw_once_seen=True) self.action = None self.view = make_rect(Pos(0,0), globals.SCREEN_SIZE) self.tile_variant = variant self.name = name self.resources_left = resources_left self.seen = False
def __init__(self, x, y, color, blocks_numb=4): w = BLC_W + 4 h = BLC_H * (blocks_numb + 0.5) GameObject.__init__(self, x, y, w, h) self.color = color self.blocks_numb = blocks_numb self.is_fulled = False self._blocks = deque([], maxlen=self.blocks_numb)
def __init__(self, game, position=(0, 0), angle=0, is_inside=True, radius=1, image='images/default.png', density=20, friction=8, name='Circle'): GameObject.__init__(self, game, position=position, angle=angle, is_inside=is_inside, image=image) size = self.surface.origin.get_size() self.name = name self.radius = ((size[0] + size[1]) / 4) / game.PPM self.body.CreateCircleFixture(radius=radius, density=density, friction=friction)
def __init__(self): GameObject.__init__(self) self.orientation = -1 # 0 = horizontal, 1=vertical self.graphic = 0 self.startPosition = [0,0] self.length = 0 self.portalList = [] self.wallExists = [] self.exteriorWallID = -1
def __init__(self): GameObject.__init__(self) self.orientation = -1 # 0 = horizontal, 1=vertical self.graphic = 0 self.startPosition = [0, 0] self.length = 0 self.portalList = [] self.wallExists = [] self.exteriorWallID = -1
def __init__(self, position, facing): orientation = array([0, 1, 0]) # Start upright # Work out the direction we're moving in # The unicycle starts vertical, so the "facing" angle is the angle from the x axis. self.forward = dot(array([1, 0, 0]), rotationMatrix(array([0, 1, 0]), facing)) self.isFallen = False GameObject.__init__(self, position, orientation, facing)
def __init__(self, name=None, position=None, texImg=None, specTexImg=None, radius=None, mass=None, spin=None, shininess=None, ka=None, kd=None, ks=None, program=None): GameObject.__init__(self, name=name, position=position, texImg=texImg, specTexImg=specTexImg, shininess=shininess, ka=ka, kd=kd, ks=ks, program=program) self.radius = radius self.mass = mass self.spin = spin self._initModel()
def __init__(self, game, brain, x, y): GameObject.__init__(self, game, x, y) game.creaturelist.append(self) self.size = 10 self.score = 0 self.direction = 0 self.brain = brain self.lefteye = eye.Eye(self, game) self.righteye = eye.Eye(self, game) self.leftimage = [] self.rightimage = []
def __init__(self, name = None, min = [0,0,0], max = [5,5,5]): self.name = name self.min = min self.max = max self.type = "Box" self.pointselection = -1 GameObject.__init__(self)
def __init__(self, name=None, min=[0, 0, 0], max=[5, 5, 5]): self.name = name self.min = min self.max = max self.type = "Box" self.pointselection = -1 GameObject.__init__(self)
def __init__(self, game, position=(0, 0), angle=0, is_inside=True, size=(1, 0.4), image='images/default.png', density=20, friction=8, name='Rect'): GameObject.__init__(self, game, position=position, angle=angle, is_inside=is_inside, image=image) width, height = size self.name = name self.body.CreatePolygonFixture( vertices=[(-width / 2, height / 2), (width / 2, height / 2), (width / 2, -height / 2), (-width / 2, -height / 2)], density=density, friction=friction)
def __init__(self): self.height = 0 self.width = 0 self.floorGraphic = 0 self.wall = [] self.roomID = 0 self.features = [] self.monsters = [] GameObject.__init__(self) self.map = None self.safeRoom = 0 self.name = "Dungeon Room"
def __init__(self): self.program = Program() self.vao = GLuint(0) self.vbuf = None self.ibuf = None self.vertices = [] self.normals = [] self.indices = [] self.uvs = [] # we should really be getting the camera not creating a new instance.. self.camera = Camera(800, 600) GameObject.__init__(self)
def __init__(self): GameObject.__init__(self) # Start Position is the top or left of the portal self.startPosition = 0 self.size = 0 # Destination is where the player goes if he goes PAST this portal. # destination: Container ID, Room ID, X offset, Y Offset # Destination is the offset from the portal's position in the first room to the portal's # equivalent position on the other side. self.destination = (0,0,0,0) self.doorID = -1 # No door = -1 self.secret = 0 # 1= secret, 2 = illusionary self.stateData = [] # For saved-game info
def __init__(self, name = None, x = 1, y = 1, z = 1): self.name = name self.x = x self.y = y self.z = z self.type = "Point" self.pointselection = -1 self.r = 1 GameObject.__init__(self)
def __init__(self, name=None, x=1, y=1, z=1): self.name = name self.x = x self.y = y self.z = z self.type = "Point" self.pointselection = -1 self.r = 1 GameObject.__init__(self)
def __init__(self, root, x, y): GameObject.__init__(self, root, x, y) self.owner = None self.firingSprite = None self.ammo = 0 self.maxAmmo = 0 self.justShot = False self.readyToShoot = True self.refireAlarm = 0 self.direction = 0
def __init__(self): GameObject.__init__(self) # Start Position is the top or left of the portal self.startPosition = 0 self.size = 0 # Destination is where the player goes if he goes PAST this portal. # destination: Container ID, Room ID, X offset, Y Offset # Destination is the offset from the portal's position in the first room to the portal's # equivalent position on the other side. self.destination = (0, 0, 0, 0) self.doorID = -1 # No door = -1 self.secret = 0 # 1= secret, 2 = illusionary self.stateData = [] # For saved-game info
def __init__(self, xy, item_type=None, pickup_description=None, on_pickup=None, dropped_this_turn=False): GameObject.__init__(self, xy, item_type.tile, solid=False, draw_once_seen=True) self.dropped_this_turn = dropped_this_turn self.item_type = item_type if item_type: if not pickup_description: self.pickup_description = (BABY_BLUE, "You pick up the ", WHITE, item_type.name, BABY_BLUE, ".") def on_pickup(player, _): player.add_item(item_type) self.on_pickup = on_pickup else: self.pickup_description = pickup_description self.on_pickup = on_pickup self.is_inv_item = False
def __init__(self, filename=None, program=None, texImg=None, specTexImg=None, normalMap=None, shininess=None, ka=None, kd=None, ks=None): GameObject.__init__(self, name=None, position=None, texImg=texImg, specTexImg=specTexImg, normalMap=normalMap, shininess=shininess, ka=ka, kd=kd, ks=ks, program=program) self.variables = dict([(x,True)for x in ["hAngle", "vAngle", "right"]]) self.oldhAngle = 0 self.oldvAngle = 0 self.zRotAngle = 0 self.xRotAngle = 0 self.vertices, self.normals, self.texCoords = loadObj(filename) self._initModel()
def __init__(self, name = None, min = [0,0,0], max = [5,5,5]): self.name = name self.min = min self.max = max self.type = "BoxAberration" self.scale = [1.0, 1.0, 1.0] self.pointselection = -1 GameObject.__init__(self) self.transparent = True
def __init__(self, name = None, x = 1, y = 1, z = 1, r = 1): self.name = name self.x = x self.y = y self.z = z self.r = r self.reflectivity = 0.0 self.type = "Sphere" self.pointselection = -1 GameObject.__init__(self)
def __init__(self, root): GameObject.__init__(self, root, 0, 0) self.flip = 0 self.onGround = False self.noclip = False self.noclip = True self.maxJumps = 1 self.currentJumps = 0 self.accel = 1000 self.moveSpeed = 120 self.jumpForce = 200 #was 80 #this should be based on the game, not on the character self.gravity = 400 #was 100
def __init__(self, pl_group, ef_group, screen, settings, speedx, speedy, start_x, start_y, animation_speed = 60): GameObject.__init__(self, pl_group, speedx, speedy, start_x, start_y, animation_speed) """Инициализирует корабль и задает его начальную позицию.""" # Загрузка изображения корабля и получение прямоугольника. self.image_neutral = pygame.image.load(settings.player_ship).convert_alpha() self.image_left = pygame.image.load(settings.player_ship_left).convert_alpha() self.image_right = pygame.image.load(settings.player_ship_right).convert_alpha() self.hp = 100 self.shield_hp = 100 self.damage = 30 self.effect_group = ef_group self.screen = screen self.screen_rect = self.screen.get_rect() self.image = self.image_neutral self.rect = self.image.get_rect() # Каждый новый корабль появляется у нижнего края экрана. self.rect.centerx = start_x self.rect.bottom = start_y # ДК, для анимации выстрела self.last_shot = pygame.time.get_ticks() self.blast = GameEffect(self.group, 0, 0, start_x, self.rect.top, 60); self.blast.set_images(["assets/objects/shoots/laserGreenShot.png"]) self.blast.set_y(self.rect.top - self.blast.get_height() + 10) # удаляем из груп чтобы избежать отрисовки раньше времени self.effect_group.remove(self.blast) # Щит self.shield = GameEffect(self.effect_group, 0, 0, start_x, self.rect.top, 150) self.shield.set_images([settings.player_shield]) self.last_damage = pygame.time.get_ticks() # Воccтановления щита, если 5 сек. без повреждений то восстанавливаем # 2 еденицы энергии каждые 5 сек self.last_damage = 0 self.shield_last_restore = pygame.time.get_ticks() self.shield_recahrge_period = 10000 self.shield_energy_restore = 5 self.shield_restore_delay = 1000 # Флаг перемещения self.moving_right = False self.moving_left = False self.speed = settings.player_speed self.center = float(self.rect.centerx)
def __init__(self, name=None, position=None, texImg=None, specTexImg=None, normalMap=None, radius=None, parent=None, mass=None, velocity=None, distance=None, spin=None, shininess=None, ka=None, kd=None, ks=None, program=None): GameObject.__init__(self, name=name, position=position, texImg=texImg, specTexImg=specTexImg, normalMap=normalMap, shininess=shininess, ka=ka, kd=kd, ks=ks, program=program) self.parent = parent self.radius = radius self.mass = mass self.velocity = velocity self.distance = distance self.spin = spin self.rot = 0 self._setRandomStartingPoint() self._initModel()
def __init__(self, game, position=(0, 0), angle=0, radius=10, n=3): GameObject.__init__(self, game, position, angle, image='images/default.png') self.center_box = self.game.world.CreateStaticBody( position=position, shapes=B2.b2PolygonShape(box=(0.5, 0.5)) ) for item in self.center_box.fixtures: item.filterData.maskBits = Bits.NOTHING_MASK item.filterData.categoryBits = Bits.NOTHING_BITS self.game.world.CreateRevoluteJoint(bodyA=self.body, bodyB=self.center_box, anchor=position) self.recreate(radius, n) for item in self.body.fixtures: item.filterData.maskBits = Bits.FULL_MASK item.filterData.categoryBits = Bits.FULL_BITS
def __init__(self, name=None, x=0, y=1, z=0, c=0): self.type = "Plane" self.name = name n = norm([x, y, z]) self.x = n[0] self.y = n[1] self.z = n[2] self.c = -c self.reflectivity = 0.0 self.extension = 1000 GameObject.__init__(self)
def __init__(self, game, position=(0, 0), angle=0, is_inside=True, image='images/default.png', vertices=[(-2, -1), (2, -1), (0, 1)], density=20, friction=8, name='Fixture'): self.density = density self.friction = friction self.name = name GameObject.__init__(self, game, position=position, angle=angle, is_inside=is_inside, image=image) self.body.CreatePolygonFixture( vertices=vertices, density=density, friction=friction)
def __init__(self, name=None, x=1, y=1, z=1, r=1): self.name = name self.x = x self.y = y self.z = z self.x2 = x + r * 4 self.y2 = y self.z2 = z self.r = r self.reflectivity = 0.0 self.type = "SpherePortal" self.pointselection = -1 GameObject.__init__(self)
def __init__(self, group, speedx, speedy, start_x, start_y, ttl=250, animation_speed=60): GameObject.__init__(self, group, speedx, speedy, start_x, start_y, animation_speed) self.images = [] # TTL - time to life, a time after will self remove from groups self.ttl = ttl self.last_appears = pygame.time.get_ticks() self.animation_step = 0 self.animation_len = 0 self.elapsed = pygame.time.get_ticks() self.animation_speed = animation_speed
def __init__(self): GameObject.__init__(self) self.enemies = [] self.enemies.append([ Enemy(self), Enemy(self), Enemy(self), Enemy(self), Enemy(self), Enemy(self), Enemy(self), Enemy(self), ]) for row in self.enemies: for enemy in row: self.children.append(enemy) self.buffer = 20 self.enemy_width = (BLOCK_SIZE * 10) + self.buffer self.enemy_height = (BLOCK_SIZE * 10) + self.buffer self.direction = Vector2(1, 0) for row_index, row in enumerate(self.enemies): for col_index, enemy in enumerate(row): enemy.Translate(col_index * self.enemy_width, row_index * self.enemy_height, 0.0) pyglet.clock.schedule_interval(self.move, 1)
def __init__(self, game, x, y): GameObject.__init__(self, game, x, y) game.foodlist.append(self) self.size = 5
def __init__(self, x, y, w, h, color, special_effect=None): GameObject.__init__(self, x, y, w, h) self.color = color self.special_effect = special_effect
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, xy, tile, strength, radius=3, time_to_live=50): GameObject.__init__(self, xy, tile, solid=False, draw_once_seen=True) self.strength = strength self.radius = radius self.time_to_live = time_to_live
def __init__(self, xy, tiletype, stats, team= TEAM_ENEMY): GameObject.__init__(self, xy, tiletype) self.team = team self.stats = stats
def __init__(self, x, y, w, h, color): GameObject.__init__(self, x, y, w, h) self.color = color
def __init__(self, x, y, dx, dy): GameObject.__init__(self, x, y) self._dx = dx self._dy = dy
def __init__(self, name): GameObject.__init__(self, name) self.renderer = Rectangle(WHITE, Vector2(10, 10)) self.target = Vector2(0, 0) self.velocity = self.transform.globalposition.normalize()