cursor change
parent
20089ccd0e
commit
b9db4684b8
23
bla.py
23
bla.py
|
@ -18,6 +18,7 @@ FIRE_DELAY = 1000 # Задержка между выстрелами в мил
|
||||||
WHITE = (255, 255, 255)
|
WHITE = (255, 255, 255)
|
||||||
BLACK = (0, 0, 0)
|
BLACK = (0, 0, 0)
|
||||||
score = 0
|
score = 0
|
||||||
|
|
||||||
# Инициализация Pygame
|
# Инициализация Pygame
|
||||||
pygame.init()
|
pygame.init()
|
||||||
|
|
||||||
|
@ -45,6 +46,10 @@ explosion_images = [pygame.image.load(f"explosion_{i}.png") for i in range(1, 48
|
||||||
stoneexplosion_images = [pygame.image.load(f"stoneexplosion_{i}.png") for i in range(1, 6)]
|
stoneexplosion_images = [pygame.image.load(f"stoneexplosion_{i}.png") for i in range(1, 6)]
|
||||||
menu_background = pygame.transform.scale(pygame.image.load("menu_background.jpg"), (SCREEN_WIDTH, SCREEN_HEIGHT))
|
menu_background = pygame.transform.scale(pygame.image.load("menu_background.jpg"), (SCREEN_WIDTH, SCREEN_HEIGHT))
|
||||||
|
|
||||||
|
cursor = pygame.image.load("cursor.png")
|
||||||
|
pygame.mouse.set_visible(False)
|
||||||
|
cursor_offset_x = cursor.get_width() // 2
|
||||||
|
cursor_offset_y = cursor.get_height() // 2
|
||||||
|
|
||||||
class Explosion(pygame.sprite.Sprite):
|
class Explosion(pygame.sprite.Sprite):
|
||||||
def __init__(self, x, y):
|
def __init__(self, x, y):
|
||||||
|
@ -352,6 +357,9 @@ def draw_menu():
|
||||||
quit_rect = quit_text.get_rect(center=(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2 + 100))
|
quit_rect = quit_text.get_rect(center=(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2 + 100))
|
||||||
screen.blit(quit_text, quit_rect)
|
screen.blit(quit_text, quit_rect)
|
||||||
|
|
||||||
|
x, y = pygame.mouse.get_pos()
|
||||||
|
screen.blit(cursor, (x - cursor_offset_x, y - cursor_offset_y))
|
||||||
|
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
|
|
||||||
return start_rect, settings_rect, quit_rect
|
return start_rect, settings_rect, quit_rect
|
||||||
|
@ -379,12 +387,16 @@ def draw_settings_menu():
|
||||||
|
|
||||||
# Рисуем кнопку для управления музыкой
|
# Рисуем кнопку для управления музыкой
|
||||||
if pygame.mixer.music.get_busy():
|
if pygame.mixer.music.get_busy():
|
||||||
music_text = font.render("Music Off", True, WHITE)
|
|
||||||
else:
|
|
||||||
music_text = font.render("Music On", True, WHITE)
|
music_text = font.render("Music On", True, WHITE)
|
||||||
|
else:
|
||||||
|
music_text = font.render("Music Off", True, WHITE)
|
||||||
music_rect = music_text.get_rect(center=(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2 - 100))
|
music_rect = music_text.get_rect(center=(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2 - 100))
|
||||||
screen.blit(music_text, music_rect)
|
screen.blit(music_text, music_rect)
|
||||||
|
|
||||||
|
x, y = pygame.mouse.get_pos()
|
||||||
|
screen.blit(cursor, (x - cursor_offset_x, y - cursor_offset_y))
|
||||||
|
|
||||||
|
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
|
|
||||||
return quit_rect, music_rect
|
return quit_rect, music_rect
|
||||||
|
@ -447,6 +459,9 @@ while running:
|
||||||
|
|
||||||
if not paused: # If not paused, update game state
|
if not paused: # If not paused, update game state
|
||||||
# Update sprites
|
# Update sprites
|
||||||
|
x, y = pygame.mouse.get_pos()
|
||||||
|
screen.blit(cursor, (x - cursor_offset_x, y - cursor_offset_y))
|
||||||
|
|
||||||
all_sprites.update()
|
all_sprites.update()
|
||||||
|
|
||||||
# Проверка столкновений пуль с танками
|
# Проверка столкновений пуль с танками
|
||||||
|
@ -561,6 +576,10 @@ while running:
|
||||||
pygame.draw.rect(screen, (0, 255, 0), (
|
pygame.draw.rect(screen, (0, 255, 0), (
|
||||||
score_rect.topleft, (score_rect.width, score_rect.height))) # Draw a green rectangle behind the score
|
score_rect.topleft, (score_rect.width, score_rect.height))) # Draw a green rectangle behind the score
|
||||||
screen.blit(score_text, score_rect.topleft)
|
screen.blit(score_text, score_rect.topleft)
|
||||||
|
|
||||||
|
x, y = pygame.mouse.get_pos()
|
||||||
|
screen.blit(cursor, (x - cursor_offset_x, y - cursor_offset_y))
|
||||||
|
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
clock.tick(FPS)
|
clock.tick(FPS)
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
Loading…
Reference in New Issue