示例#1
0
 def __init__(self, pos, kierunek):
     if(kierunek=="prawo"):
         self.velX = 12
         self.velY = 0
     elif(kierunek=="lewo"):
         self.velX = -12
         self.velY = 0
     elif(kierunek=="prawogora"):
         self.velX = 12
         self.velY = 12
     elif(kierunek=="lewogora"):
         self.velX = -12
         self.velY = 12
     self.image = pyglet.image.load("resources/fireball.png")
     image_gride = pyglet.image.ImageGrid(self.image,8,8,item_width=64,item_height=64)
     self.animation=pyglet.image.Animation.from_image_sequence(image_gride[24:32],0.1,True)
     self.sprite = Sprite(self.animation)
     self.sprite.position = pos
     self.sprite.scale = 1
     self.sprite.rotation = 0
     self.liveTime = 10
     self.sprite.cshape = cm.AARectShape(
                     self.sprite.position,
                 self.sprite.width/3,
             self.sprite.height/3
     )
示例#2
0
 def __init__(self):
     super(Bullet, self).__init__("img/bullet.png")
     self.scale = 0.5
     # self.schedule_interval(self.run_bullet,0.01)
     pygame.mixer.init()
     self.bullet_sound = pygame.mixer.Sound('sounds/bullet.ogg')
     self.cshape = collision.AARectShape(collision.eu.Vector2(0, 0),
                                         self.width // 2, self.height // 2)
 def update_position(self, dt):  #同步隐藏点的坐标到皮肤上
     if not block[self.num]:
         self.skin.position = self.spr.position
         x, y = self.skin.position
         self.life_bar.position = (x, y + 160)
         self.life_bar.scale_x = self.life / 100
         self.cshape = cm.AARectShape(eu.Vector2(*self.skin.position), 65,
                                      136)
示例#4
0
    def __init__(self):
        super().__init__("img/player.png")
        self.position = 700, 600
        self.life = 100
        self.cshape = cm.AARectShape(eu.Vector2(*self.position),
                                     self.width / 2, self.height / 2)

        self.do(Repeat(MoveTo((100, 500), 4) + MoveTo((1000, 500), 4)))
    def _update_position(self):
        super(destroyableObject, self)._update_position()

        self.cshape = cm.AARectShape(
            self.position,
            self.width // 2,
            self.height // 2
        )
示例#6
0
 def __init__(self, position, image):
     self.sprite = cocos.sprite.Sprite(image)
     self.sprite.position = position
     self.sprite.rotation = 180
     self.lifeTime = 120
     self.terminate = False
     self.sprite.cshape = cm.AARectShape(self.sprite.position,
                                         self.sprite.width / 2,
                                         self.sprite.height / 2)
示例#7
0
    def __init__(self, image, center_x, center_y):
        super().__init__(image)
        self.position = (center_x, center_y)
        half_width = self.width / 2
        half_height = self.height / 2

        self.cshape = cm.AARectShape(self.position, half_width, half_height)
        self.schedule(self.loop)
        self.schedule(self.update_shape)
    def __init__(self, image, x, y):
        super(Actor, self).__init__(image)
        pos = eu.Vector2(x, y)

        # self.position is defined in cocos.sprite.Sprite with type (int, int)
        # assigning self.position type eu.Vector2(int,int) seems to assign the type (int,int)
        self.position = pos
        self.cshape = cm.AARectShape(self.position, self.width / 2,
                                     self.height / 2)
示例#9
0
    def __init__(self, id=0, position=(0, 0), rotation=0, clan=1):
        super(Center, self).__init__(id=id,
                                     position=position,
                                     rotation=rotation,
                                     clan=clan)

        self.scale = 0.7
        self.cshape = cm.AARectShape(self.position, self.width // 2,
                                     self.height // 2)
示例#10
0
 def __init__(self, x, image):
     self.sprite = cocos.sprite.Sprite(image)
     self.sprite.position = x, 700
     self.sprite.scale = 2
     self.time = 0
     self.canMove = True
     self.sprite.cshape = cm.AARectShape(self.sprite.position,
                                         self.sprite.width / 2,
                                         self.sprite.height / 2)
示例#11
0
 def __init__(self, image):
     super(EnemyBase, self).__init__(image)
     self.fj_image = image
     self.scale = 0.6
     self.cshape = collision.AARectShape(
         collision.eu.Vector2(*self.position), self.width // 2,
         self.height // 2)
     self.reset_position()
     self.schedule(self.run)
 def __init__(self, id=0, position=(0,0), rotation=0, clan=1):
     super(MiniGunTower, self).__init__(id=id, position=position, rotation=rotation, clan=clan)
     self.weapon = MiniGunWeapon()
     self.scale = 0.3
     self.cshape = cm.AARectShape(
         self.position,
         self.width // 2,
         self.height // 2
     )
    def __init__(self):
        super().__init__("img/car.png")
        self.position = 200, 200
        self.velocity = (0, 0)

        self.cshape = cm.AARectShape(eu.Vector2(*self.position),
                                     self.width / 2, self.height / 2)

        self.do(Mover())
 def __init__(self, enemy_id, position):
     super().__init__("images/swin_right/Fall.png")
     self.position = position
     self.enemy_id = enemy_id
     self.cshape = cm.AARectShape(eu.Vector2(*self.position),
                                  self.width / 2, self.height / 2)
     self.alive = True
     self.state = 'passive'
     self.right = True
     self.activity = 'idle'
示例#15
0
    def __init__(self, position=(0, 0), rotation=0, fired_tank=None):
        super().__init__(self.spriteName)
        self.start_position = position
        self.position = position
        self.last_update_time = time()
        self.rotation = rotation
        self.fired_tank = fired_tank

        self.cshape = cm.AARectShape(self.position, self.width // 2,
                                     self.height // 2)
示例#16
0
 def __init__(self, hud, position, settings):
     super(CentralBase, self).__init__(position, settings)
     self.tag = 'CentralBase'
     self.hud = hud
     self.cshape = cm.AARectShape(self.position, self.width * 0.5,
                                  self.height * 0.5)
     self.cshape.center = eu.Vector2(self.position[0], self.position[1])
     self.capacity = 1000
     self.storage = {'copper': 200, 'iron': 70, 'titanium': 0}
     self.hud.update_resource(self.storage)
示例#17
0
    def __init__(self, x, y, r, g, b):

        super(Paddle, self).__init__('rectangle.png', color=(r, g, b), scale=.2)
        self.position = x, y
        center = eu.Vector2(x, y)
        self.cshape = cm.AARectShape(center, self.width/2, self.height/2)
        self.velocity = 0
        self.accleration = 0
        self.direction = 0
        self.maxspeed = 100   
    def checkCollisionsWithObjects(self):
        self.target.cshape = cm.AARectShape(self.target.position,
                                            self.target.width // 2,
                                            self.target.height // 2)
        collisions = CollisionManager.objs_colliding(self.target)

        if collisions:
            return True

        return False
示例#19
0
    def __init__(self):
        self.Gun = Gun(self.spriteGunName, self)
        super(Tank, self).__init__(self.spriteName)
        self.scale = self.Gun.scale = 0.5

        self.healthHelper = HealthSprite()
        self.updateHealthPosition()

        self.cshape = cm.AARectShape(self.position, self.width // 2,
                                     self.height // 2)
示例#20
0
    def __init__(self):
        super().__init__(anim, scale=.33)

        self.position = 800, 360
        self.velocity = (0, 0)

        self.cshape = cm.AARectShape(eu.Vector2(*self.position),
                                     self.width / 4, self.height / 1.9)

        self.do(Mover())
示例#21
0
 def __init__(self, image, x, y, timeleft=6):
     super(Powerup, self).__init__(image)
     self.position = (x, y)
     self.time_left = timeleft  # amount of time player has to pick up
     self.cshape = cm.AARectShape(self.position, self.width // 2,
                                  self.height // 2)
     self.speed = 100
     self.shield = 50
     self.bonus_time_left = 5
     self.is_active = False
     self.player = None
 def __init__(self, filename, position):
     super().__init__()
     img = pyglet.image.load(address + filename)
     spr = cocos.sprite.Sprite(img)
     spr.position = position[0], position[1]
     self.add(spr)
     self.life = 100
     self.life_bar = cocos.sprite.Sprite("img/yellow_bar.png")
     self.life_bar.position = position[0], position[1] + 70
     self.add(self.life_bar)
     self.cshape = cm.AARectShape(eu.Vector2(*spr.position), 65, 136)
示例#23
0
    def __add_enemy(self, name, x, y, scale):
        sprite = cocos.sprite.Sprite('images/spaceship.png')
        sprite.scale = scale
        sprite.position = x, y
        sprite.btype = 'enemy'

        sprite.on_collide = lambda: self.remove(sprite)
        sprite.cshape = cm.AARectShape(center=eu.Vector2(x, y),
                                       half_width=sprite.image.width * 0.5,
                                       half_height=sprite.image.height * 0.5)
        self.add(sprite, name=name)
示例#24
0
 def __init__(self):
     image = 'imgs/bullet.png'
     super(Bullet, self).__init__(image)
     self.scale = 0.5
     # 是否可以重新使用了
     self.reuseable = False
     # cshape
     self.cshape = collision.AARectShape(collision.eu.Vector2(0, 0),
                                         self.width // 2, self.height // 2)
     audio.pygame.mixer.init()
     self.audio = audio.pygame.mixer.Sound('sounds/bullet.ogg')
     self.schedule(self.move)
示例#25
0
 def __init__(self, position, settings):
     super(SupplyBase, self).__init__(position, settings)
     self.tag = 'SupplyBase'
     self.cshape = cm.AARectShape(self.position, self.width * 0.5,
                                  self.height * 0.5)
     self.cshape.center = eu.Vector2(self.position[0], self.position[1])
     self.receive_structure = None
     self.send_structure = None
     self.transporting_resource = None
     self.tempStorage = 0
     self.transport_delay = 12
     self.transport_count = 0
示例#26
0
 def init_image(self):
     frames = []
     for x in range(1, 3):
         texure = pyglet.resource.image('img/hero/hero%d.png' % x)
         frames.append(texure)
     anim = Animation.from_image_sequence(frames, 0.05)
     super(Hero, self).__init__(anim)
     self.scale = 0.5
     self.position = config.WINDOS_WIDTH // 2, 200
     self.cshape = collision.AARectShape(
         collision.eu.Vector2(*self.position), self.width // 4,
         self.height // 4)
示例#27
0
 def __init__(self, position):
     super().__init__('assets/corgi1.png')
     self.position = position
     self.starting_position = position
     self.cshape = cm.AARectShape(position, self.width/6, self.height/12)
     self.update_cshape()
     self.lives = 3
     self.jump_range = 150
     self.speed = 0
     self.max_speed = 4.5
     self.acceleration = 0.15
     self.image_load()
     self.may_jump = True
示例#28
0
 def __init__(self, e):
     super(EnemyObject, self).__init__(e[0].R.ENEMY[e[1]])
     #X(axis)-Location for enemy
     self.e = e
     self.isDead = False
     self.scale = 0.7
     self.position = (director._window_virtual_width,
                      random.randint(30,director._window_virtual_height - 34 - self.height/2))
     self.velocity = (-100, 0)
     self.deadtemplate = Delay(0.5) + CallFunc(self.destroy)
     self.do(Move())
     #Collision Shape
     self.cshape = CollisionModel.AARectShape(self.position, self.width/2, self.height/2)
示例#29
0
    def __init__(self, position: Vector2, block_color, scale=1, b_type=""):
        self.block_color = block_color
        self.b_type = b_type

        image = get_img_by_color(block_color)
        Sprite.__init__(self, image=image, position=position, scale=scale)

        if (not b_type == ''):
            #retangulo para calculo de colisao, como coodenadas realtivas a layer do jogo principal
            pos = game_controller.game_controller.main_game.point_to_local(
                (self.x, self.y))
            self.cshape = collision_model.AARectShape(pos, self.width / 2,
                                                      self.height / 2)
示例#30
0
    def addImg(self, src, type):
        land = None

        if type == 'background': land = BackgroundSprite(src)
        if type == 'objects': land = ObjectSprite(src)
        if type == 'undestroyable_objects': land = UndestroyableObject(src)
        if type == 'unmovable_background': land = UnmovableBackground(src)
        assert land is not None, 'Land is none! type is undefined!'
        land.cshape = cm.AARectShape(land.position, land.width // 2,
                                     land.height // 2)
        land.src = src
        self.add(land)
        self.collisions.add(land)