-
Notifications
You must be signed in to change notification settings - Fork 0
/
sprites.py
99 lines (80 loc) · 2.96 KB
/
sprites.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import pygame
class DinosaurSpriteRun(pygame.sprite.Sprite):
def __init__(self):
super(DinosaurSpriteRun,self).__init__()
self.images = []
self.images.append(pygame.image.load('./sprites/dino2.png'))
self.images.append(pygame.image.load('./sprites/dino3.png'))
self.framesBySprite = 5
self.frameCounter = 0
self.index = 0
self.image = self.images[self.index]
self.rect = pygame.Rect(0,0,88,94)
def update(self,x,y):
self.rect.x = x
self.rect.bottom = y
if self.frameCounter >= self.framesBySprite:
self.index += 1
if self.index >= len(self.images):
self.index = 0
self.image = self.images[self.index]
self.frameCounter = 0
else:
self.frameCounter += 1
class DinosaurSpriteDown(pygame.sprite.Sprite):
def __init__(self):
super(DinosaurSpriteDown,self).__init__()
self.images = []
self.images.append(pygame.image.load('./sprites/dino_down_0.png'))
self.images.append(pygame.image.load('./sprites/dino_down_1.png'))
self.framesBySprite = 5
self.frameCounter = 0
self.index = 0
self.image = self.images[self.index]
self.rect = pygame.Rect(0,0,117,60)
def update(self,x,y):
self.rect.x = x
self.rect.bottom = y
if self.frameCounter >= self.framesBySprite:
self.index += 1
if self.index >= len(self.images):
self.index = 0
self.image = self.images[self.index]
self.frameCounter = 0
else:
self.frameCounter += 1
class CactusSprite(pygame.sprite.Sprite):
def __init__(self,type):
super(CactusSprite,self).__init__()
if type == "small":
self.image = pygame.image.load('./sprites/cactus_small_0.png')
self.size = (34,70)
else:
self.image = pygame.image.load('./sprites/cactus_big_0.png')
self.size = (50,94)
self.rect = pygame.Rect(0,0,self.size[0],self.size[1])
def update(self,x,y):
self.rect.x = x
self.rect.bottom = y
class WazoSprite(pygame.sprite.Sprite):
def __init__(self):
super(WazoSprite,self).__init__()
self.images = []
self.images.append(pygame.image.load('./sprites/wazo0.png'))
self.images.append(pygame.image.load('./sprites/wazo1.png'))
self.framesBySprite = 5
self.frameCounter = 0
self.index = 0
self.image = self.images[self.index]
self.rect = pygame.Rect(0,0,92,68)
def update(self,x,y):
self.rect.x = x
self.rect.bottom = y
if self.frameCounter >= self.framesBySprite:
self.index += 1
if self.index >= len(self.images):
self.index = 0
self.image = self.images[self.index]
self.frameCounter = 0
else:
self.frameCounter += 1