Exemplo n.º 1
0
    def __init__(self, x, y):
        pygame.sprite.Sprite.__init__(self)
        if random.randint(0, 2) == 0:
            filename = "tree" + str(random.randint(1, 6)) + ".png"
            self.image = load_image(filename, 'sprites/trees', -1)
            self.tree = True
        else:
            filename = "grass" + str(random.randint(1, 4)) + ".png"
            self.image = load_image(filename, 'sprites/trees', -1)
            self.tree = False

        scale = (random.random() / 2) + 0.7
        self.image = pygame.transform.scale(
            self.image, (int(self.image.get_width() * scale),
                         int(self.image.get_height() * scale)))
        if random.randint(0, 1) == 0:
            self.image = pygame.transform.flip(self.image, True, False)
        self.rect = self.image.get_rect(midbottom=(x, y))
        self.damage = 0
        self.fallen = False
        self.rotating = False
        self.angle = 0
        self.angle_adjustment = 0
        self.base_image = self.image
        self.base_rect = self.rect.copy()
Exemplo n.º 2
0
    def __init__(self):
        self.screen = pygame.display.get_surface()
        self.image = load_image('panel.png', 'sprites', -1)
        self.timer_image = load_image('timer.png', 'sprites/effects', (255,255,255,255))
        self.wind_image = load_image('wind.png', 'sprites/effects', (255,255,255,255))
        self.barrel_powder_image = load_image('barrel_powder.png', 'sprites/effects', (255,255,255,255))
        self.rect = self.image.get_rect(topleft = (0, 0))
        self.display = True
        self.font = pygame.font.Font(os.path.join('data', 'misc', 'COOPBL.TTF'), 36)
        self.font_timer = pygame.font.Font(os.path.join('data', 'misc', 'COOPBL.TTF'), 30)
        self.player_timer = time.time()
        self.highlight_button = False
        self.button_shadowed = pygame.Surface((34,34))
        self.button_shadowed.fill((60,60,60))
        self.button_timer = time.time()
        self.timer_digit1 = time.time()
        self.timer_digit2 = time.time()
        self.spy_cam = pygame.Surface((194,94))
        self.spy_cam_static = load_image('static.png', 'sprites/effects', 0)
        self.spy_cam_good_signal = True
        self.glare = load_image('glare.png', 'sprites/effects', (255,255,255,255))

        self.player_rect = {}
        self.player_rect["left"] = pygame.Rect(33,62,34,34)
        self.player_rect["right"] = pygame.Rect(243,62,34,34)
        self.button_up_barrel_rect = pygame.Rect(193,84,34,34)
        self.button_down_barrel_rect = pygame.Rect(83,84,34,34)
        self.barrel_rect = pygame.Rect(122,84,66,34)
        self.button_up_powder_rect = pygame.Rect(682,84,34,34)
        self.button_down_powder_rect = pygame.Rect(572,84,34,34)
        self.powder_rect = pygame.Rect(611,84,66,34)
        self.button_fire_rect = pygame.Rect(732,23,34,73)
        self.wind_rect = pygame.Rect(650,23,66,34)
Exemplo n.º 3
0
    def __init__(self, x, y):
        pygame.sprite.Sprite.__init__(self)
        if random.randint(0,2) == 0:
            filename = "tree"+str(random.randint(1,6))+".png"
            self.image = load_image(filename, 'sprites/trees', -1)
            self.tree = True
        else:
            filename = "grass"+str(random.randint(1,4))+".png"
            self.image = load_image(filename, 'sprites/trees', -1)
            self.tree = False

        scale = (random.random()/2) + 0.7
        self.image = pygame.transform.scale(self.image, (int(self.image.get_width()*scale), int(self.image.get_height()*scale)))
        if random.randint(0,1) == 0:
            self.image = pygame.transform.flip(self.image, True, False)
        self.rect = self.image.get_rect(midbottom = (x, y))
        self.damage = 0
        self.fallen = False
        self.rotating = False
        self.angle = 0
        self.angle_adjustment = 0
        self.base_image = self.image
        self.base_rect = self.rect.copy()
Exemplo n.º 4
0
 def __init__(self, position, Game):
     pygame.sprite.Sprite.__init__(self)
     if Gun.image is None:
         Gun.image = load_image('gun.png', 'sprites', -1)
     self.image = Gun.image
     self.rect = self.image.get_rect()
     self.position = position
     self.ground = Game.ground
     self.angle = 00
     self.powder = 40
     if self.position == "left":
         self.rect.center = (122,584-self.ground[80])
     elif self.position == "right":
         self.rect.center = (680,584-self.ground[680])
         self.image = pygame.transform.flip(self.image, 1, 0)
     self.base_image = self.image
Exemplo n.º 5
0
 def __init__(self, position, Game):
     pygame.sprite.Sprite.__init__(self)
     if Gun.image is None:
         Gun.image = load_image('gun.png', 'sprites', -1)
     self.image = Gun.image
     self.rect = self.image.get_rect()
     self.position = position
     self.ground = Game.ground
     self.angle = 00
     self.powder = 40
     if self.position == "left":
         self.rect.center = (122,584-self.ground[80])
     elif self.position == "right":
         self.rect.center = (680,584-self.ground[680])
         self.image = pygame.transform.flip(self.image, 1, 0)
     self.base_image = self.image
Exemplo n.º 6
0
 def __init__(self, tank, ground):
     pygame.sprite.Sprite.__init__(self)
     if Shell.image is None:
         Shell.image = load_image('shell.png', 'sprites', -1)
     self.image = Shell.image
     self.rect = self.image.get_rect()
     self.from_tank = tank
     self.target = tank.ennemy
     if tank.position == "left":
         self.rect.center = tank.gun.rect.topright
         self.speed_x = math.sin(math.radians(90-tank.gun.angle)) * (float(tank.gun.powder+5)/9)
         self.speed_y = (0 - math.cos(math.radians(90-tank.gun.angle))) * (float(tank.gun.powder+5)/9)
     elif tank.position == "right":
         self.rect.center = tank.gun.rect.topleft
         self.speed_x = (0 - math.sin(math.radians(90-tank.gun.angle))) * (float(tank.gun.powder+5)/9)
         self.speed_y = (0 - math.cos(math.radians(90-tank.gun.angle))) * (float(tank.gun.powder+5)/9)
     self.pos_x = self.rect.centerx
     self.pos_y = self.rect.centery
     self.weight = 55
Exemplo n.º 7
0
 def __init__(self, tank, ground):
     pygame.sprite.Sprite.__init__(self)
     if Shell.image is None:
         Shell.image = load_image('shell.png', 'sprites', -1)
     self.image = Shell.image
     self.rect = self.image.get_rect()
     self.from_tank = tank
     self.bounce_pos = 0
     self.target = tank.ennemy
     if tank.position == "left":
         self.rect.center = tank.gun.rect.topright
         self.speed_x = math.sin(math.radians(90-tank.gun.angle)) * (float(tank.gun.powder+5)/9)
         self.speed_y = (0 - math.cos(math.radians(90-tank.gun.angle))) * (float(tank.gun.powder+5)/9)
     elif tank.position == "right":
         self.rect.center = tank.gun.rect.topleft
         self.speed_x = (0 - math.sin(math.radians(90-tank.gun.angle))) * (float(tank.gun.powder+5)/9)
         self.speed_y = (0 - math.cos(math.radians(90-tank.gun.angle))) * (float(tank.gun.powder+5)/9)
     self.pos_x = self.rect.centerx
     self.pos_y = self.rect.centery
     self.weight = 55
Exemplo n.º 8
0
    def __init__(self, position, Game):
        pygame.sprite.Sprite.__init__(self)
        self.image = load_image('tank.png', 'sprites', -1)
        self.rect = self.image.get_rect()
        self.ground = Game.ground
        self.position = position
        self.time_to_fire = 14
        self.damage = 0
        self.damaged = False

        #self.intro_image = Tank.image.copy()
        #self.intro_image.blit(load_image('gun.png', 'sprites', -1), (38,4))
        #self.base_intro_image = self.intro_image
        
        if self.position == "left":
            self.rect.bottomleft = (71,600-self.ground[81])
        elif self.position == "right":
            self.rect.bottomleft = (671,600-self.ground[681])
            self.image = pygame.transform.flip(self.image, 1, 0)
            #self.intro_image = pygame.transform.flip(self.intro_image, 1, 0)
        self.base_image = self.image
Exemplo n.º 9
0
    def __init__(self, position, Game):
        pygame.sprite.Sprite.__init__(self)
        self.image = load_image('tank.png', 'sprites', -1)
        self.rect = self.image.get_rect()
        self.ground = Game.ground
        self.position = position
        self.time_to_fire = 14
        self.damage = 0
        self.damaged = False

        #self.intro_image = Tank.image.copy()
        #self.intro_image.blit(load_image('gun.png', 'sprites', -1), (38,4))
        #self.base_intro_image = self.intro_image
        
        if self.position == "left":
            self.rect.bottomleft = (71,600-self.ground[81])
        elif self.position == "right":
            self.rect.bottomleft = (671,600-self.ground[681])
            self.image = pygame.transform.flip(self.image, 1, 0)
            #self.intro_image = pygame.transform.flip(self.intro_image, 1, 0)
        self.base_image = self.image
Exemplo n.º 10
0
    def __init__(self):
        self.screen = pygame.display.get_surface()
        self.image = load_image('panel.png', 'sprites', -1)
        self.timer_image = load_image('timer.png', 'sprites/effects',
                                      (255, 255, 255, 255))
        self.wind_image = load_image('wind.png', 'sprites/effects',
                                     (255, 255, 255, 255))
        self.barrel_powder_image = load_image('barrel_powder.png',
                                              'sprites/effects',
                                              (255, 255, 255, 255))
        self.rect = self.image.get_rect(topleft=(0, 0))
        self.display = True
        self.font = pygame.font.Font(
            os.path.join('data', 'misc', 'coopbl.ttf'), 36)
        self.font_timer = pygame.font.Font(
            os.path.join('data', 'misc', 'coopbl.ttf'), 30)
        self.player_timer = time.time()
        self.highlight_button = False
        self.button_shadowed = pygame.Surface((34, 34))
        self.button_shadowed.fill((60, 60, 60))
        self.button_timer = time.time()
        self.timer_digit1 = time.time()
        self.timer_digit2 = time.time()
        self.spy_cam = pygame.Surface((194, 94))
        self.spy_cam_static = load_image('static.png', 'sprites/effects', 0)
        self.spy_cam_good_signal = True
        self.glare = load_image('glare.png', 'sprites/effects',
                                (255, 255, 255, 255))

        self.player_rect = {}
        self.player_rect["left"] = pygame.Rect(33, 62, 34, 34)
        self.player_rect["right"] = pygame.Rect(243, 62, 34, 34)
        self.button_up_barrel_rect = pygame.Rect(193, 84, 34, 34)
        self.button_down_barrel_rect = pygame.Rect(83, 84, 34, 34)
        self.barrel_rect = pygame.Rect(122, 84, 66, 34)
        self.button_up_powder_rect = pygame.Rect(682, 84, 34, 34)
        self.button_down_powder_rect = pygame.Rect(572, 84, 34, 34)
        self.powder_rect = pygame.Rect(611, 84, 66, 34)
        self.button_fire_rect = pygame.Rect(732, 23, 34, 73)
        self.wind_rect = pygame.Rect(650, 23, 66, 34)