Update Gaame with menu
parent
57c09ca181
commit
c0d65c7c1a
|
@ -75,10 +75,7 @@ class Tank(pygame.sprite.Sprite):
|
|||
self.TANK_SPEED /= self.boost_multiplier
|
||||
self.boosted = False
|
||||
|
||||
def move_forward(self):
|
||||
angle_rad = math.radians(self.angle + 270)
|
||||
self.rect.x += self.TANK_SPEED * math.cos(angle_rad)
|
||||
self.rect.y += self.TANK_SPEED * math.sin(angle_rad)
|
||||
|
||||
|
||||
def shoot(self):
|
||||
current_time = pygame.time.get_ticks()
|
||||
|
@ -94,8 +91,12 @@ class Tank(pygame.sprite.Sprite):
|
|||
bullet = PlayerBullet(self.rect.centerx + offset_x, self.rect.centery + offset_y, self.angle + 270)
|
||||
all_sprites.add(bullet)
|
||||
bullets.add(bullet)
|
||||
self.last_fire_time = current_time # Обновление времени последнего выстрела
|
||||
|
||||
self.last_fire_time = current_time
|
||||
# Обновление времени последнего выстрела
|
||||
def move_forward(self):
|
||||
angle_rad = math.radians(self.angle + 270)
|
||||
self.rect.x += self.TANK_SPEED * math.cos(angle_rad)
|
||||
self.rect.y += self.TANK_SPEED * math.sin(angle_rad)
|
||||
|
||||
# Определение класса снаряда игрока
|
||||
class PlayerBullet(pygame.sprite.Sprite):
|
||||
|
@ -278,6 +279,7 @@ def draw_menu():
|
|||
return quit_rect # Возвращаем прямоугольник для кнопки "Выйти"
|
||||
|
||||
|
||||
|
||||
def respawn_bot():
|
||||
# Создание нового экземпляра бота
|
||||
new_bot = Bot(random.randint(0, SCREEN_WIDTH), random.randint(0, SCREEN_HEIGHT))
|
||||
|
@ -308,6 +310,7 @@ while menu_active:
|
|||
clock = pygame.time.Clock()
|
||||
running = True
|
||||
paused = False # Флаг для отслеживания состояния паузы
|
||||
shooting_enabled = True # Флаг для отслеживания разрешения стрельбы
|
||||
|
||||
while running:
|
||||
player_bullets = []
|
||||
|
@ -318,7 +321,7 @@ while running:
|
|||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
running = False
|
||||
elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1: # Обработка левой кнопки мыши
|
||||
elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1 and shooting_enabled: # Обработка левой кнопки мыши
|
||||
player.shoot()
|
||||
|
||||
if event.type == pygame.KEYDOWN:
|
||||
|
@ -328,6 +331,10 @@ while running:
|
|||
last_meme_time = current_time # Обновление времени последнего воспроизведения звука
|
||||
elif event.key == pygame.K_ESCAPE: # Пауза по нажатию на Escape
|
||||
paused = not paused # Инвертируем состояние паузы
|
||||
if paused:
|
||||
shooting_enabled = False # При паузе отключаем стрельбу
|
||||
else:
|
||||
shooting_enabled = True # При возврате из паузы включаем стрельбу
|
||||
|
||||
if not paused:
|
||||
# Обновление всех спрайтов только в случае, если игра не на паузе
|
||||
|
|
Loading…
Reference in New Issue