-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbin.py
More file actions
48 lines (36 loc) · 1.49 KB
/
bin.py
File metadata and controls
48 lines (36 loc) · 1.49 KB
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
import pygame
import os
from pygame.locals import *
class Bin(pygame.sprite.Sprite):
def __init__(self, path, x, y, width, height, type):
super().__init__()
self.image = pygame.image.load(os.path.join("images/bins", path))
self.rect = self.image.get_rect()
self.type = type
self.rect.width = width
self.rect.height = height
self.rect.center = (x,y)
self.collision_rect = pygame.Rect(0, 0, width/3, height/2)
self.collision_rect.center = self.rect.x + width / 2, self.rect.y + height / 2
self.moving = False
def render(self, screen):
screen.blit(self.image, self.rect)
def eat(self):
pygame.mixer.music.load("sounds/pickupCoin.wav")
pygame.mixer.music.play()
def bad(self):
pygame.mixer.music.load("sounds/putInTrash.wav")
pygame.mixer.music.play()
class Bins:
def __init__(self):
self.plasticbin = Bin("plasticbin.png", 205, 525, 180, 256, 3)
self.metalbin = Bin("metalbin.png", 455, 525, 180, 256, 1)
self.glassbin = Bin("glassbin.png", 705, 525, 182, 255, 0)
self.paperbin = Bin("paperbin.png", 955, 525, 179, 255, 2)
self.trashbin = Bin("trashbin.png", 1205, 525, 180, 253, 4)
self.bins = (self.plasticbin, self.paperbin, self.metalbin, self.glassbin, self.trashbin)
def render(self, screen):
for bin in self.bins:
bin.render(screen)
def getBins(self):
return self.bins