-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.py
38 lines (35 loc) · 1.01 KB
/
player.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
import pygame
class player:
width, height = (60,20)
alive = True
x = 400
y = 20
score = 0
rect_speed = 5
touched = False
def __init__(self,screen,width,height):
self.score = self.score
self.x = self.x
self.y = self.y
self.alive = self.score
self.window = screen
self.width = width
self.height = height
self.touched = False
def draw(self,screen):
if self.x < -60:
self.x = 690
pygame.draw.rect(screen,pygame.Color(0,0,0), (self.x,480-21,60,20),0,3)
elif self.x > 750:
self.x = 0
pygame.draw.rect(screen,pygame.Color(0,0,0), (self.x,480-21,60,20),0,3)
else:
pygame.draw.rect(screen,pygame.Color(0,0,0), (self.x,480-21,60,20),0,3)
def update(self,score,row):
self.score = score
if row == "left":
self.x -= 3.2
elif row == "right":
self.x += 3.2
def setTouched(self,val):
self.touched = val