-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtsunami_rush.py
More file actions
103 lines (83 loc) · 2.86 KB
/
tsunami_rush.py
File metadata and controls
103 lines (83 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import pygame
from hero import Player
from Menu import PygameMenu
from game import Game
from gameOver import GameOver
from agent import AIPlayer
pygame.init()
# create game window
SCREEN_WIDTH = 1100
SCREEN_HEIGHT = 600
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption("Tsunami Rush")
test_font = pygame.font.Font("font/VT323-Regular.ttf", 25)
# Create instances of Game, PygameMenu, and GameOver
game = Game(0,0)
menu = PygameMenu(screen, ["1 PLAYER", "2 PLAYERS", "EXIT"])
game_over = GameOver(screen, 0, 0) # Initialize with score and high score
# Game state variables
in_menu = True
in_game_one_player = False
in_game_two_player = False
# Timer variables
return_to_menu_timer = 0
return_to_menu_duration = 2 # Set the duration in seconds
True
# musica
pygame.mixer.music.load("sounds/8-bit-game-music-122259.mp3")
pygame.mixer.music.set_volume(0.5)
# Game loop
run = True
while run:
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
if in_menu:
menu.run()
if menu.selected_option == 0:
pygame.mixer.music.play(-1)
in_menu = False
in_game_one_player = True
in_game_two_player = False
elif menu.selected_option == 1:
pygame.mixer.music.play(-1)
in_menu = False
in_game_one_player = False
in_game_two_player = True
elif menu.selected_option == 2:
run = False
elif in_game_one_player:
game.two_players = False
done, score, hi_score = game.step()
if done == 0:
pygame.mixer.music.stop()
if game.score > game.hi_score:
game.hi_score = game.score
game.reset()
for i in range(100):
#atualiza a tela e mostra game over por alguns segundos
pygame.display.flip()
game_over.draw_game_over_screen(score,hi_score)
in_menu = True
in_game_one_player = False
elif in_game_two_player:
game.two_players = True
#game.agent = AIPlayer(400,520,'sprites/ai_player', 0.05, 0, state_size=4, action_size=2)
while True:
done, score, hi_score = game.step()
if done == 0:
pygame.display.flip()
if game.score > game.hi_score:
game.hi_score = game.score
pygame.mixer.music.stop()
game.reset()
for i in range(100):
pygame.display.flip()
#atualiza a tela e mostra game over por alguns segundos
game_over.draw_game_over_screen(score,hi_score)
game_over.high_score = game.hi_score
break
in_menu = True
in_game_two_player = False
in_game_one_player = False
pygame.quit()