diff --git a/game.py b/game.py index 8efef09..7e75b51 100644 --- a/game.py +++ b/game.py @@ -1,26 +1,34 @@ import pygame +pygame.init() + class Smieciarka(pygame.sprite.Sprite): def __init__(self, x, y): self.x = x self.y = y self.image = pygame.image.load('smieciarka.png') + self.ruch = 0 pygame.sprite.Sprite.__init__(self) - self.rect = pygame.Rect(self.x * WIDTH + MARGIN * self.x + - MARGIN, self.y * HEIGHT + MARGIN * self.y, WIDTH, HEIGHT) + self.rect = pygame.Rect(self.x * WIDTH + MARGIN * self.x + MARGIN, self.y * HEIGHT + MARGIN * self.y, WIDTH, + HEIGHT) def w_lewo(self): if self.x > 0: self.x -= 1 self.rect.x = MARGIN + self.x * WIDTH + self.x * MARGIN - self.image = pygame.image.load('smieciarka.png') + if self.ruch == 2: + self.image = pygame.image.load('smieciarka.png') + self.ruch = 1 def w_prawo(self): if self.x < 14: self.x += 1 self.rect.x = MARGIN + self.x * WIDTH + self.x * MARGIN - self.image = pygame.image.load('smieciarka_odwrocona.png') + if self.ruch == 1: + self.image = pygame.transform.flip( + smieciarka.image, True, False) + self.ruch = 2 def w_gore(self): if self.y > 0: @@ -33,12 +41,22 @@ class Smieciarka(pygame.sprite.Sprite): self.rect.y = self.y * HEIGHT + self.y * MARGIN +class Kontener(pygame.sprite.Sprite): + def __init__(self, x, y): + self.x = x + self.y = y + pygame.sprite.Sprite.__init__(self) + self.rect = pygame.Rect(self.x * WIDTH + MARGIN * self.x + MARGIN, self.y * HEIGHT + MARGIN * self.y + MARGIN, + WIDTH, HEIGHT) + + # Define some colors BLACK = (0, 0, 0) WHITE = (255, 255, 255) GREEN = (0, 255, 0) RED = (255, 0, 0) BLUE = (0, 0, 255) +GREY = (128, 128, 128) # This sets the WIDTH and HEIGHT of each grid location WIDTH = 60 @@ -61,9 +79,6 @@ for row in range(100): # column numbers start at zero.) grid[0][0] = 1 -# Initialize pygame -pygame.init() - # Set the HEIGHT and WIDTH of the screen WINDOW_SIZE = [980, 980] screen = pygame.display.set_mode(WINDOW_SIZE) @@ -78,12 +93,26 @@ done = False clock = pygame.time.Clock() smieciarka = Smieciarka(10, 10) +kontener_plastik = Kontener(0, 0) +kontener_plastik.image = pygame.image.load("pojemnik_plastik.png") +kontener_metal = Kontener(0, 4) +kontener_metal.image = pygame.image.load("pojemnik_metal.png") +kontener_organiczne = Kontener(2, 2) +kontener_organiczne.image = pygame.image.load("pojemnik_organiczne.png") +kontener_papier = Kontener(4, 0) +kontener_papier.image = pygame.image.load("pojemnik_papier.png") +kontener_szklo = Kontener(4, 4) +kontener_szklo.image = pygame.image.load("pojemnik_szklo.png") +kontener_list = pygame.sprite.Group() smieciarka_list = pygame.sprite.Group() all_sprites_list = pygame.sprite.Group() +kontener_list.add(kontener_plastik, kontener_metal, + kontener_organiczne, kontener_papier, kontener_szklo) smieciarka_list.add(smieciarka) -all_sprites_list.add(smieciarka) +all_sprites_list.add(kontener_plastik, kontener_metal, + kontener_organiczne, kontener_papier, kontener_szklo, smieciarka) # -------- Main Program Loop ----------- while not done: @@ -115,16 +144,17 @@ while not done: # Draw the grid for row in range(15): for column in range(15): - color = WHITE - if grid[row][column] == 1: - color = BLUE + color = GREY + # if grid[row][column] == 1: + # color = BLUE pygame.draw.rect(screen, color, [(MARGIN + WIDTH) * column + MARGIN, (MARGIN + HEIGHT) * row + MARGIN, WIDTH, HEIGHT]) - all_sprites_list.draw(screen) + screen.blit(pygame.image.load("wysypisko.jpg"), (5, 5)) + all_sprites_list.draw(screen) # Limit to 60 frames per second clock.tick(60) diff --git a/pojemnik_metal.png b/pojemnik_metal.png new file mode 100644 index 0000000..6abb130 Binary files /dev/null and b/pojemnik_metal.png differ diff --git a/pojemnik_organiczne.png b/pojemnik_organiczne.png new file mode 100644 index 0000000..18704a0 Binary files /dev/null and b/pojemnik_organiczne.png differ diff --git a/pojemnik_papier.png b/pojemnik_papier.png new file mode 100644 index 0000000..fa2c446 Binary files /dev/null and b/pojemnik_papier.png differ diff --git a/pojemnik_plastik.png b/pojemnik_plastik.png new file mode 100644 index 0000000..deebda7 Binary files /dev/null and b/pojemnik_plastik.png differ diff --git a/pojemnik_szklo.png b/pojemnik_szklo.png new file mode 100644 index 0000000..03a02bb Binary files /dev/null and b/pojemnik_szklo.png differ diff --git a/smieciarka.png b/smieciarka.png index dd9ed3e..6c4cb0f 100644 Binary files a/smieciarka.png and b/smieciarka.png differ diff --git a/smieciarka_odwrocona.png b/smieciarka_odwrocona.png index ac4a734..ae7990e 100644 Binary files a/smieciarka_odwrocona.png and b/smieciarka_odwrocona.png differ diff --git a/wysypisko.jpg b/wysypisko.jpg new file mode 100644 index 0000000..a287979 Binary files /dev/null and b/wysypisko.jpg differ