-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpygame_test.py
More file actions
40 lines (35 loc) · 847 Bytes
/
pygame_test.py
File metadata and controls
40 lines (35 loc) · 847 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
33
34
35
36
37
38
39
40
import pygame
def main():
pygame.init() #Activa recursos
roca = pygame.image.load("enemigo.bmp")
h = roca.get_height()
w = roca.get_width()
t = w
ventana = pygame.display.set_mode((8*w,8*h))
estado = True
while estado:
for event in pygame.event.get():
if event.type == pygame.QUIT:
estado = False
mov()
actualizar(ventana,roca,i,j)
pygame.quit()
def mov():
global i,j
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT]:
i = i - 2
if keys[pygame.K_RIGHT]:
i = i + 2
if keys[pygame.K_UP]:
j = j - 2
if keys[pygame.K_DOWN]:
j = j + 2
def actualizar(ventana,roca,i,j):
ventana.fill((0,0,0))
ventana.blit(roca,(i,j))
pygame.display.flip()
pygame.time.delay(10)
i = 0
j = 0
main()