-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathmain
More file actions
32 lines (28 loc) · 938 Bytes
/
main
File metadata and controls
32 lines (28 loc) · 938 Bytes
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
import pygame as pg
import logging
WIDTH = 720
HEIGHT = 720
BLUE = (0, 0, 255)
WHITE = (255, 255, 255)
try:
pg.init()
except:
logging.error('Pygame Initialization Error!!!')
pg.display.set_caption('Pygame Hello-World Hacktober Fest 2019')
background = pg.display.set_mode((WIDTH, HEIGHT))
helloimg = pg.image.load('./media/hello-world.png').convert_alpha()
helloimg = pg.transform.scale(helloimg, (300, 300))
pg.mixer.music.load('./media/hello-world.mp3')
hellofont = pg.font.SysFont('comicsansms', 30)
pg.mixer.music.play(-1)
while(True):
for event in pg.event.get():
if event.type == pg.QUIT:
exit()
background.fill(WHITE)
text = hellofont.render('HELLO WORLD!! (wait for the music...)', True, BLUE)
textRect = text.get_rect()
textRect.center = (WIDTH/2, HEIGHT/2)
background.blit(text, textRect)
background.blit(helloimg, (WIDTH/2-150, HEIGHT/2-300))
pg.display.update()