SHOW:
|
|
- or go back to the newest paste.
1 | import pygame | |
2 | ||
3 | SZEROKOSC_EKRANU = 1024 | |
4 | WYSOKOSC_EKRANU = 800 | |
5 | ||
6 | class Platforma(pygame.sprite.Sprite): | |
7 | def __init__(self): | |
8 | super(Platforma, self).__init__() | |
9 | self.obraz = pygame.image.load("images/pad.png") | |
10 | self.porusza_sie = 0 | |
11 | self.zresetuj_pozycje() | |
12 | ||
13 | #resetowanie pozycji | |
14 | def zresetuj_pozycje(self): | |
15 | self.rect = pygame.Rect(SZEROKOSC_EKRANU/2-70, WYSOKOSC_EKRANU-100, 140, 30) | |
16 | ||
17 | #poruszanie platformą | |
18 | def ruszaj_platforma(self, wartosc): | |
19 | predkosc = 10 | |
20 | self.rect.move_ip(wartosc*predkosc, 0) | |
21 | self.porusza_sie = wartosc | |
22 | if self.rect.left <= 0: self.rect.x = 0 | |
23 | if self.rect.right >= SZEROKOSC_EKRANU: self.rect.x = SZEROKOSC_EKRANU-140 | |
24 | ||
25 | #aktualizacja | |
26 | def aktualizuj(self): | |
27 | self.porusza_sie = 0 | |
28 |