From af54b7283f90030ee7d3857518eb164ce661c5f4 Mon Sep 17 00:00:00 2001 From: michalStarski Date: Tue, 19 Mar 2019 18:29:18 +0100 Subject: [PATCH] added landfill class --- game.py | 7 +++++++ images/{landfill_green.png => landfill_glass.png} | Bin images/{landfill_yellow.png => landfill_metal.png} | Bin images/{landfill_blue.png => landfill_plastic.png} | Bin sprites/landfill.py | 10 ++++++++++ 5 files changed, 17 insertions(+) rename images/{landfill_green.png => landfill_glass.png} (100%) rename images/{landfill_yellow.png => landfill_metal.png} (100%) rename images/{landfill_blue.png => landfill_plastic.png} (100%) create mode 100644 sprites/landfill.py diff --git a/game.py b/game.py index 7f89afb..60e654f 100644 --- a/game.py +++ b/game.py @@ -2,6 +2,7 @@ from pygame import * import sys, random from sprites.grass import Grass from sprites.house import House +from sprites.landfill import Landfill from pygame.locals import * import utils @@ -15,6 +16,7 @@ fps_clock = time.Clock() #Tu będzie zmienna do wybrania przez użytkownika na start/ do zmiany w trakcie "gry" home_amount = utils.set_home_amount() + #Obszar przeznaczony na płyki PLAY_WIDTH = (home_amount+1)*64 PLAY_HEIGHT = PLAY_WIDTH @@ -33,6 +35,11 @@ for x in range(PLAY_HEIGHT//64): grass = Grass(x,y) cells[x].append(grass) +for x in range(PLAY_HEIGHT//64): + cells.append([]) + for y in range(PLAY_HEIGHT//64): + grass = Grass(x,y) + cells[x].append(grass) #Losowanie domków i dodawanie je do mapy home_len = home_amount diff --git a/images/landfill_green.png b/images/landfill_glass.png similarity index 100% rename from images/landfill_green.png rename to images/landfill_glass.png diff --git a/images/landfill_yellow.png b/images/landfill_metal.png similarity index 100% rename from images/landfill_yellow.png rename to images/landfill_metal.png diff --git a/images/landfill_blue.png b/images/landfill_plastic.png similarity index 100% rename from images/landfill_blue.png rename to images/landfill_plastic.png diff --git a/sprites/landfill.py b/sprites/landfill.py new file mode 100644 index 0000000..20fc2c2 --- /dev/null +++ b/sprites/landfill.py @@ -0,0 +1,10 @@ +import pygame +import sys +from sprites.cell import Cell + +class Landfill(Cell): + def __init__(self, x, y, type): + types = ["plastic", "glass", "metal"] + self.type = types[type] + Cell.__init__(self,x,y) + self.image = pygame.image.load("images/landfill_%s.png" %(self.type))