-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBackground_cls.py
39 lines (30 loc) · 1003 Bytes
/
Background_cls.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Dec 5 12:06:37 2019
@author: kristyna
"""
# =============================================================================
# Class Background for moving sky
# =============================================================================
import pygame
import os
BG_IMG = pygame.transform.scale(pygame.image.load(os.path.join("imgs", "Nebe.png")), (1200,700))
class Background:
BG_WIDTH = BG_IMG.get_width()
BG_IMG = BG_IMG
def __init__(self,y):
self.y = y
self.x1 = 0
self.x2 = self.BG_WIDTH
def move(self, vel):
self.vel = vel
self.x1 -= vel/5
self.x2 -= vel/5
if self.x1 + self.BG_WIDTH < 0:
self.x1 = self.x2 + self.BG_WIDTH
if self.x2 + self.BG_WIDTH < 0:
self.x2 = self.x1 + self.BG_WIDTH
def draw(self, win):
win.blit(self.BG_IMG, (self.x1, self.y))
win.blit(self.BG_IMG, (self.x2, self.y))