diff --git a/__pycache__/main.cpython-37.pyc b/__pycache__/main.cpython-37.pyc new file mode 100644 index 00000000..10ba16a0 Binary files /dev/null and b/__pycache__/main.cpython-37.pyc differ diff --git a/__pycache__/main.cpython-38.pyc b/__pycache__/main.cpython-38.pyc new file mode 100644 index 00000000..fac38fa6 Binary files /dev/null and b/__pycache__/main.cpython-38.pyc differ diff --git a/source/__pycache__/__init__.cpython-37.pyc b/source/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 00000000..1b45cb34 Binary files /dev/null and b/source/__pycache__/__init__.cpython-37.pyc differ diff --git a/source/__pycache__/__init__.cpython-38.pyc b/source/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 00000000..41564746 Binary files /dev/null and b/source/__pycache__/__init__.cpython-38.pyc differ diff --git a/source/__pycache__/constants.cpython-37.pyc b/source/__pycache__/constants.cpython-37.pyc new file mode 100644 index 00000000..695c7cd5 Binary files /dev/null and b/source/__pycache__/constants.cpython-37.pyc differ diff --git a/source/__pycache__/constants.cpython-38.pyc b/source/__pycache__/constants.cpython-38.pyc new file mode 100644 index 00000000..db957d8f Binary files /dev/null and b/source/__pycache__/constants.cpython-38.pyc differ diff --git a/source/__pycache__/main.cpython-37.pyc b/source/__pycache__/main.cpython-37.pyc new file mode 100644 index 00000000..be2ffd2a Binary files /dev/null and b/source/__pycache__/main.cpython-37.pyc differ diff --git a/source/__pycache__/main.cpython-38.pyc b/source/__pycache__/main.cpython-38.pyc new file mode 100644 index 00000000..9b99c860 Binary files /dev/null and b/source/__pycache__/main.cpython-38.pyc differ diff --git a/source/__pycache__/tool.cpython-37.pyc b/source/__pycache__/tool.cpython-37.pyc new file mode 100644 index 00000000..7c830d96 Binary files /dev/null and b/source/__pycache__/tool.cpython-37.pyc differ diff --git a/source/__pycache__/tool.cpython-38.pyc b/source/__pycache__/tool.cpython-38.pyc new file mode 100644 index 00000000..80f89a60 Binary files /dev/null and b/source/__pycache__/tool.cpython-38.pyc differ diff --git a/source/component/__pycache__/__init__.cpython-37.pyc b/source/component/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 00000000..8c3927c9 Binary files /dev/null and b/source/component/__pycache__/__init__.cpython-37.pyc differ diff --git a/source/component/__pycache__/__init__.cpython-38.pyc b/source/component/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 00000000..e8884c92 Binary files /dev/null and b/source/component/__pycache__/__init__.cpython-38.pyc differ diff --git a/source/component/__pycache__/map.cpython-37.pyc b/source/component/__pycache__/map.cpython-37.pyc new file mode 100644 index 00000000..0b6d0c1a Binary files /dev/null and b/source/component/__pycache__/map.cpython-37.pyc differ diff --git a/source/component/__pycache__/map.cpython-38.pyc b/source/component/__pycache__/map.cpython-38.pyc new file mode 100644 index 00000000..97edffc5 Binary files /dev/null and b/source/component/__pycache__/map.cpython-38.pyc differ diff --git a/source/component/__pycache__/menubar.cpython-37.pyc b/source/component/__pycache__/menubar.cpython-37.pyc new file mode 100644 index 00000000..47e71c13 Binary files /dev/null and b/source/component/__pycache__/menubar.cpython-37.pyc differ diff --git a/source/component/__pycache__/menubar.cpython-38.pyc b/source/component/__pycache__/menubar.cpython-38.pyc new file mode 100644 index 00000000..a8881a28 Binary files /dev/null and b/source/component/__pycache__/menubar.cpython-38.pyc differ diff --git a/source/component/__pycache__/plant.cpython-37.pyc b/source/component/__pycache__/plant.cpython-37.pyc new file mode 100644 index 00000000..573079ae Binary files /dev/null and b/source/component/__pycache__/plant.cpython-37.pyc differ diff --git a/source/component/__pycache__/plant.cpython-38.pyc b/source/component/__pycache__/plant.cpython-38.pyc new file mode 100644 index 00000000..d18f76be Binary files /dev/null and b/source/component/__pycache__/plant.cpython-38.pyc differ diff --git a/source/component/__pycache__/zombie.cpython-37.pyc b/source/component/__pycache__/zombie.cpython-37.pyc new file mode 100644 index 00000000..3309c347 Binary files /dev/null and b/source/component/__pycache__/zombie.cpython-37.pyc differ diff --git a/source/component/__pycache__/zombie.cpython-38.pyc b/source/component/__pycache__/zombie.cpython-38.pyc new file mode 100644 index 00000000..894504fe Binary files /dev/null and b/source/component/__pycache__/zombie.cpython-38.pyc differ diff --git a/source/component/plant.py b/source/component/plant.py index 684065b1..a62af766 100644 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -871,9 +871,7 @@ def handleMapYPosition(self): self.map_y = map_y1 def shouldChangeDirection(self): - if self.init_rect.centery <= c.MAP_OFFSET_Y: - return True - elif self.init_rect.bottom + 20 >= c.SCREEN_HEIGHT: + if self.init_rect.centery <= c.MAP_OFFSET_Y or self.init_rect.bottom + 20 >= c.SCREEN_HEIGHT: return True return False diff --git a/source/state/__pycache__/__init__.cpython-37.pyc b/source/state/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 00000000..b30e59df Binary files /dev/null and b/source/state/__pycache__/__init__.cpython-37.pyc differ diff --git a/source/state/__pycache__/__init__.cpython-38.pyc b/source/state/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 00000000..6bc8a2db Binary files /dev/null and b/source/state/__pycache__/__init__.cpython-38.pyc differ diff --git a/source/state/__pycache__/level.cpython-37.pyc b/source/state/__pycache__/level.cpython-37.pyc new file mode 100644 index 00000000..a66e5fd4 Binary files /dev/null and b/source/state/__pycache__/level.cpython-37.pyc differ diff --git a/source/state/__pycache__/level.cpython-38.pyc b/source/state/__pycache__/level.cpython-38.pyc new file mode 100644 index 00000000..cbaceb0e Binary files /dev/null and b/source/state/__pycache__/level.cpython-38.pyc differ diff --git a/source/state/__pycache__/mainmenu.cpython-37.pyc b/source/state/__pycache__/mainmenu.cpython-37.pyc new file mode 100644 index 00000000..27f04ab0 Binary files /dev/null and b/source/state/__pycache__/mainmenu.cpython-37.pyc differ diff --git a/source/state/__pycache__/mainmenu.cpython-38.pyc b/source/state/__pycache__/mainmenu.cpython-38.pyc new file mode 100644 index 00000000..970ee2df Binary files /dev/null and b/source/state/__pycache__/mainmenu.cpython-38.pyc differ diff --git a/source/state/__pycache__/screen.cpython-37.pyc b/source/state/__pycache__/screen.cpython-37.pyc new file mode 100644 index 00000000..b55315f5 Binary files /dev/null and b/source/state/__pycache__/screen.cpython-37.pyc differ diff --git a/source/state/__pycache__/screen.cpython-38.pyc b/source/state/__pycache__/screen.cpython-38.pyc new file mode 100644 index 00000000..de40f18e Binary files /dev/null and b/source/state/__pycache__/screen.cpython-38.pyc differ diff --git a/source/state/level.py b/source/state/level.py index 133cc28a..727b3ca7 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -107,7 +107,9 @@ def choose(self, mouse_pos, mouse_click): self.panel.checkCardClick(mouse_pos) if self.panel.checkStartButtonClick(mouse_pos): self.initPlay(self.panel.getSelectedCards()) - + + + #for when you're choosing your cards and setting up the beginning of the game def initPlay(self, card_list): self.state = c.PLAY if self.bar_type == c.CHOOSEBAR_STATIC: @@ -128,6 +130,8 @@ def initPlay(self, card_list): self.setupZombies() self.setupCars() + + #contains logic for clicking and dragging plants onto the level map. Also handles spawning and killing of zombies def play(self, mouse_pos, mouse_click): if self.zombie_start_time == 0: self.zombie_start_time = self.current_time @@ -163,7 +167,7 @@ def play(self, mouse_pos, mouse_click): self.addPlant() elif mouse_pos is None: self.setupHintImage() - + #rendering and updating sun power-ups in-game if self.produce_sun: if(self.current_time - self.sun_timer) > c.PRODUCE_SUN_INTERVAL: self.sun_timer = self.current_time @@ -185,7 +189,7 @@ def play(self, mouse_pos, mouse_click): self.checkPlants() self.checkCarCollisions() self.checkGameState() - + #implementation of function that creates zombies def createZombie(self, name, map_y): x, y = self.map.getMapGridPos(0, map_y) if name == c.NORMAL_ZOMBIE: @@ -202,7 +206,7 @@ def createZombie(self, name, map_y): def canSeedPlant(self): x, y = pg.mouse.get_pos() return self.map.showPlant(x, y) - + #function for adding a plant to a square on the map. def addPlant(self): pos = self.canSeedPlant() if pos is None: @@ -266,7 +270,7 @@ def addPlant(self): #print('addPlant map[%d,%d], grid pos[%d, %d] pos[%d, %d]' % (map_x, map_y, x, y, pos[0], pos[1])) def setupHintImage(self): - pos = self.canSeedPlant() + pos = self.canSeedPlant() #check if a grid square is empty or occupied if pos and self.mouse_image: if (self.hint_image and pos[0] == self.hint_rect.x and pos[1] == self.hint_rect.y): @@ -283,7 +287,7 @@ def setupHintImage(self): self.hint_plant = True else: self.hint_plant = False - + #renders image of selected plant def setupMouseImage(self, plant_name, select_plant): frame_list = tool.GFX[plant_name] if plant_name in tool.PLANT_RECT: @@ -316,6 +320,7 @@ def removeMouseImage(self): self.hint_image = None self.hint_plant = False + #collision detection between plant bullets and zombies. bullets dont explode if they collide with a dead zombie def checkBulletCollisions(self): collided_func = pg.sprite.collide_circle_ratio(0.7) for i in range(self.map_y_len): @@ -337,6 +342,7 @@ def checkZombieCollisions(self): for zombie in self.zombie_groups[i]: if zombie.state != c.WALK: continue + #check if the zombie collides with the bullet from the plant or the plant itself plant = pg.sprite.spritecollideany(zombie, self.plant_groups[i], collided_func) if plant: if plant.name == c.WALLNUTBOWLING: @@ -348,7 +354,8 @@ def checkZombieCollisions(self): plant.setAttack() elif plant.name != c.SPIKEWEED: zombie.setAttack(plant) - + + #for when hypno zombies and zombies run into each other for hypno_zombie in self.hypno_zombie_groups[i]: if hypno_zombie.health <= 0: continue @@ -408,7 +415,7 @@ def killPlant(self, plant): plant.kill() def checkPlant(self, plant, i): - zombie_len = len(self.zombie_groups[i]) + zombie_len = len(self.zombie_groups[i]) #i indexes to give number of zombies at y-co-ordinate i if plant.name == c.THREEPEASHOOTER: if plant.state == c.IDLE: if zombie_len > 0: diff --git a/source/tool.py b/source/tool.py index 1a319c8c..e90df3df 100644 --- a/source/tool.py +++ b/source/tool.py @@ -100,7 +100,7 @@ def load_image_frames(directory, image_name, colorkey, accept): tmp = {} # image_name is "Peashooter", pic name is 'Peashooter_1', get the index 1 index_start = len(image_name) + 1 - frame_num = 0; + frame_num = 0 for pic in os.listdir(directory): name, ext = os.path.splitext(pic) if ext.lower() in accept: