|
@@ -0,0 +1,63 @@
|
|
|
|
|
+from operator import pos
|
|
|
|
|
+import pygame
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ # pygame setup
|
|
|
|
|
+pygame.init()
|
|
|
|
|
+screen = pygame.display.set_mode((1280, 720))
|
|
|
|
|
+clock = pygame.time.Clock()
|
|
|
|
|
+running = True
|
|
|
|
|
+dt = 0
|
|
|
|
|
+smer = "none"
|
|
|
|
|
+pos = pygame.Vector2(screen.get_width() / 2, screen.get_height() / 2)
|
|
|
|
|
+obrazek = pygame.image.load("raketa.png").convert_alpha()
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+while running:
|
|
|
|
|
+ # poll for events
|
|
|
|
|
+ # pygame.QUIT event means the user clicked X to close your window
|
|
|
|
|
+ for event in pygame.event.get():
|
|
|
|
|
+ if event.type == pygame.QUIT:
|
|
|
|
|
+ running = False
|
|
|
|
|
+
|
|
|
|
|
+ # fill the screen with a color to wipe away anything from last frame
|
|
|
|
|
+ screen.fill("darkblue")
|
|
|
|
|
+
|
|
|
|
|
+ screen.blit(obrazek, pos)
|
|
|
|
|
+
|
|
|
|
|
+ keys = pygame.key.get_pressed()
|
|
|
|
|
+ if keys[pygame.K_w]:
|
|
|
|
|
+ smer = "up"
|
|
|
|
|
+ obrazek = pygame.image.load("raketa.png").convert_alpha()
|
|
|
|
|
+ if keys[pygame.K_s]:
|
|
|
|
|
+ smer = "down"
|
|
|
|
|
+ obrazek = pygame.image.load("raketa.png").convert_alpha()
|
|
|
|
|
+ obrazek = pygame.transform.rotate(obrazek, 180)
|
|
|
|
|
+ if keys[pygame.K_a]:
|
|
|
|
|
+ smer = "left"
|
|
|
|
|
+ obrazek = pygame.image.load("raketa.png").convert_alpha()
|
|
|
|
|
+ obrazek = pygame.transform.rotate(obrazek, 90)
|
|
|
|
|
+ if keys[pygame.K_d]:
|
|
|
|
|
+ smer = "right"
|
|
|
|
|
+ obrazek = pygame.image.load("raketa.png").convert_alpha()
|
|
|
|
|
+ obrazek = pygame.transform.rotate(obrazek, 270)
|
|
|
|
|
+ if keys[pygame.K_SPACE]:
|
|
|
|
|
+ smer = "none"
|
|
|
|
|
+ if smer == "up":
|
|
|
|
|
+ pos.y -= 300 * dt
|
|
|
|
|
+ if smer == "down":
|
|
|
|
|
+ pos.y += 300 * dt
|
|
|
|
|
+ if smer == "left":
|
|
|
|
|
+ pos.x -= 300 * dt
|
|
|
|
|
+ if smer == "right":
|
|
|
|
|
+ pos.x += 300 * dt
|
|
|
|
|
+
|
|
|
|
|
+ # flip() the display to put your work on screen
|
|
|
|
|
+ pygame.display.flip()
|
|
|
|
|
+
|
|
|
|
|
+ # limits FPS to 60
|
|
|
|
|
+ # dt is delta time in seconds since last frame, used for framerate-
|
|
|
|
|
+ # independent physics.
|
|
|
|
|
+ dt = clock.tick(60) / 1000
|
|
|
|
|
+
|
|
|
|
|
+pygame.quit()
|