-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.py
More file actions
35 lines (21 loc) · 749 Bytes
/
Player.py
File metadata and controls
35 lines (21 loc) · 749 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
import pygame
class Block(pygame.sprite.Sprite):
def __init__(self, window_size):
super(Block, self).__init__()
self.initialize = True
self.x = 200
self.y = 50
self.window_size = window_size
self.image = pygame.Surface((self.x, self.y))
self.image.fill(pygame.Color('red'))
self.rect = self.image.get_rect()
print(self.rect)
def handle_keys(self):
key = pygame.key.get_pressed()
dist = 1
if key[pygame.K_LEFT]:
self.x += dist
if key[pygame.K_RIGHT]:
self.x -= dist
def draw(self, surface):
surface.blit(self.image, (self.window_size[0]/2.0 - self.x / 2.0, self.window_size[1] - self.y))