-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.py
More file actions
53 lines (37 loc) · 1.09 KB
/
base.py
File metadata and controls
53 lines (37 loc) · 1.09 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
47
48
49
50
51
52
53
'''
Implementation of the Base (Floor of the window).
'''
import pygame
BASE_IMGS = pygame.transform.scale2x(pygame.image.load('imgs/base.png'))
'''
Class attributes :
VEL : How fast the base is moving
WIDTH : The width of the base
IMG : The image of the Base
'''
class Base :
VEL = 5
WIDTH = BASE_IMGS.get_width()
IMG = BASE_IMGS
'''
Instance attributes :
(Param) y : y-position of the base
x1 : left side of the base
x2 : right side of the base
'''
def __init__(self,y):
self.y = y
self.x1 = 0
self.x2 = self.WIDTH
def move(self):
self.x1 -= self.VEL
self.x2 -= self.VEL
# Resets the position of the Base image once its off screen
if self.x1 + self.WIDTH < 0:
self.x1 = self.x2 + self.WIDTH
if self.x2 + self.WIDTH < 0 :
self.x2 = self.x1 + self.WIDTH
# Draw the base in the screen
def draw(self,win):
win.blit(self.IMG,(self.x1,self.y))
win.blit(self.IMG,(self.x2,self.y))