-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuntitled.py
44 lines (34 loc) · 1.67 KB
/
untitled.py
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
import pygame
from sys import exit
pygame.init() # strarting the engine. Just turn the key not neep to worry about the gears
screen = pygame.display.set_mode((800, 400)) # creating display surface
pygame.display.set_caption("Runner") # set window title
clock = pygame.time.Clock() # create clock object
test_font = pygame.font.Font('./font/Pixeltype.ttf', 50)
# test_surface = pygame.Surface((100, 200)) # create regular test surface
sky_surf = pygame.image.load('./graphics/Sky.png').convert()
ground_surf = pygame.image.load('./graphics/ground.png').convert()
ground_rect = ground_surf.get_rect(topleft = (0, 300))
text_surf = test_font.render('My Game', False, 'Black').convert()
snail_surface = pygame.image.load('./graphics/snail/snail1.png').convert_alpha()
snail_rect = snail_surface.get_rect(bottomleft = (600, 300))
player_surf = pygame.image.load('./graphics/Player/player_walk_1.png')
player_rect = player_surf.get_rect(bottomleft = (80, 300))
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit() # opposite of pygame.init
exit()
# draw all our elements
# update everything
screen.blit(sky_surf,(0, 0)) # block image transfer / 1 surface on top of another
screen.blit(ground_surf,ground_rect)
screen.blit(text_surf,(300, 50))
snail_rect.left -= 4
if snail_rect.right < -100: snail_rect.left = 800
screen.blit(snail_surface,snail_rect)
player_rect.left += 1
screen.blit(player_surf, player_rect)
pygame.display.update() # update screen
# if run now wont be able to close the window as it is not checking for user inputs. closing is also a user input
clock.tick(60)