-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathplayer.py
More file actions
46 lines (38 loc) · 1.21 KB
/
player.py
File metadata and controls
46 lines (38 loc) · 1.21 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
"""
Use sprites to collect blocks.
Sample Python/Pygame Programs
Simpson College Computer Science
http://programarcadegames.com/
http://simpson.edu/computer-science/
Explanation video: http://youtu.be/4W2AqUetBi4
"""
import pygame
from block import Block
class Player(Block):
"""
This class represents the ball.
It derives from the "Sprite" class in Pygame.
"""
def __init__(self, color, width, height):
#Block.__init__(self, color, width, height)
super(self.__class__, self,).__init__(color, width, height)
self.move_ticker = 0
self.gravity=True
def moveleft(self,screen_width):
if self.move_ticker == 0:
self.move_ticker = 10
self.rect.x -= self.width*self.speed
if self.rect.x == -1:
self.rect.x = 0
def moveright(self,screen_width):
if self.move_ticker == 0:
self.move_ticker = 10
self.rect.x+=self.width*self.speed
if self.rect.x >= screen_width:
self.rect.x = screen_width
def jump(self):
#move player up their height
pass
pass
def flush(self):
self.move_ticker=0