-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase.py
43 lines (38 loc) · 1.08 KB
/
base.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
39
40
41
42
43
import pygame
import os
class Base:
"""
Represnts the moving floor of the game
"""
def __init__(self, y):
"""
Initialize the object
:param y: int
:return: None
"""
base_img = pygame.transform.scale2x(pygame.image.load(os.path.join("assets","base.png")).convert_alpha())
self.vel = 5
self.width = base_img.get_width()
self.img = base_img
self.y = y
self.x1 = 0
self.x2 = self.width
def move(self):
"""
move floor so it looks like its scrolling
:return: None
"""
self.x1 -= self.vel
self.x2 -= self.vel
if self.x1 + self.width < 0:
self.x1 = self.x2 + self.width
if self.x2 + self.width < 0:
self.x2 = self.x1 + self.width
def draw(self, win):
"""
Draw the floor. This is two images that move together.
:param win: the pygame surface/window
:return: None
"""
win.blit(self.img, (self.x1, self.y))
win.blit(self.img, (self.x2, self.y))