-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
69 lines (54 loc) · 1.55 KB
/
test.py
File metadata and controls
69 lines (54 loc) · 1.55 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
# import pygame
import pygame
# initialize game engine
pygame.init()
window_width=600
window_height=600
animation_increment=10
clock_tick_rate=20
# Open a window
size = (window_width, window_height)
screen = pygame.display.set_mode(size)
# Set title to the window
pygame.display.set_caption("Game")
dead=False
clock = pygame.time.Clock()
background_image = pygame.image.load("pic.png").convert()
win = pygame.display.set_mode((600,600))
x = 275
y = 275
width = 50
height = 50
while(dead==False):
for event in pygame.event.get():
pygame.time.delay(120)
# iterate over the list of Event objects
# that was returned by pygame.event.get() method.
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
# nth
keys = pygame.key.get_pressed()
pygame.draw.rect(win,(255,0,0),(x,y,width,height))
pygame.image.load("pic.png").convert()
pygame.display.update()
if keys[pygame.K_LEFT] and x>60 and x<600:
# decrement in x co-ordinate
x -= 120
# nth
if keys[pygame.K_RIGHT] and x<500:
# increment in x co-ordinate
x += 120
# nth
if keys[pygame.K_UP] and y>60 and y<600:
# decrement in y co-ordinate
y -= 120
if keys[pygame.K_DOWN] and y<500:
# increment in y co-ordinate
y += 120
pygame.display.update()
if event.type == pygame.QUIT:
dead = True
screen.blit(background_image, [0, 0])
#pygame.display.flip()
#clock.tick(clock_tick_rate)