SHOW:
|
|
- or go back to the newest paste.
1 | import pygame | |
2 | ||
3 | #klasa pomocnicza obraz | |
4 | class Obraz(pygame.sprite.Sprite): | |
5 | def __init__(self, sciezka): | |
6 | super().__init__() | |
7 | self.obraz = pygame.image.load(sciezka) | |
8 | ||
9 | #klasa bazowa | |
10 | class Element(): | |
11 | def __init__(self, typ): | |
12 | #wskaźnik wybranego elementu ubioru | |
13 | self.wybrany = 0 | |
14 | #lista obrazów | |
15 | self.listaObrazow = [] | |
16 | #użycie pętli aby zaczytać wszystkie obrazu z folderu | |
17 | for i in range(1, 4): | |
18 | sciezka = f'images/{typ}{i}.png' | |
19 | wczytany_obraz = Obraz(sciezka) | |
20 | self.listaObrazow.append(wczytany_obraz) | |
21 | ||
22 | def wybierzNastepny(self): | |
23 | self.wybrany += 1 | |
24 | if self.wybrany > 2: | |
25 | self.wybrany = 0 | |
26 | ||
27 | def wybranyObraz(self): | |
28 | return self.listaObrazow[self.wybrany].obraz | |
29 | ||
30 | ||
31 | class NakrycieGlowy(Element): | |
32 | def __init__(self): | |
33 | super().__init__('head') | |
34 | ||
35 | class UbranieElement(Element): | |
36 | def __init__(self): | |
37 | super().__init__('body') | |
38 | ||
39 | class OczyElement(Element): | |
40 | def __init__(self): | |
41 | super().__init__('eye') | |
42 | ||
43 | class BronElement(Element): | |
44 | def __init__(self): | |
45 | super().__init__('weapon') |