-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrame_1.py
More file actions
74 lines (61 loc) · 2.29 KB
/
Copy pathFrame_1.py
File metadata and controls
74 lines (61 loc) · 2.29 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
import pygame
import os
import sprites
# GLOBAL VARIABLES
BLACK = (0, 0, 0)
FPS = 30
WIDTH = 700
HEIGHT = 600
COUNT = 0
# initializing PyGame module and mixer module
pygame.init()
pygame.mixer.init()
# allowing access to the various files
game_folder = os.path.dirname(__file__)
img_folder = os.path.join(game_folder, "Images Files")
music_folder = os.path.join(game_folder, "Music Files")
# creating the screen, which is also a surface
screen = pygame.display.set_mode((WIDTH, HEIGHT))
# entering the while loop
run = True
clock = pygame.time.Clock()
# run the music
music = pygame.mixer.music.load(os.path.join(music_folder,
"bensound-newdawn.wav"))
pygame.mixer.music.play(-1)
# create dragon sprite and a sprite group
dragon1 = sprites.Dragon((WIDTH - 600, HEIGHT - 200))
dragon2 = sprites.Dragon((WIDTH - 100, HEIGHT - 200))
dragon3 = sprites.Dragon((WIDTH - 300, HEIGHT - 150))
dragon_group = pygame.sprite.Group()
dragon_group.add(dragon1, dragon2, dragon3)
# load background image
background = pygame.image.load(os.path.join(img_folder, "resized.png"))
# set font and then create text
font = pygame.font.SysFont("Algerian", 60, False)
text = pygame.font.Font.render(font, "Dragon Knight", True, (255, 0, 0))
font = pygame.font.SysFont("Algerian", 25, False)
text_2 = pygame.font.Font.render(font, "Press enter to start game", True, (255, 255, 255))
while run:
# screen is the surface on which to blit the image
clock.tick(FPS)
screen.blit(background, (0, 0))
dragon_group.draw(screen)
screen.blit(text, (WIDTH/2 - text.get_rect().width/2, text.get_rect().height - 20))
screen.blit(text_2, (WIDTH/2 - text_2.get_rect().width/2,
text.get_rect().height + text_2.get_rect().height + 20))
pygame.display.update()
dragon_group.update()
pygame.display.update()
# key functionality
for event in pygame.event.get():
if event.type == pygame.QUIT:
quit()
if pygame.key.get_pressed()[pygame.K_RETURN]:
# call frame 2
count = 1
music = pygame.mixer.music.load(os.path.join(music_folder,
"bensound-birthofahero.mp3"))
pygame.mixer.music.play(-1)
os.system('Frame_2.py')
count = 0