From c5b1d6b4b14bd1952b67e72d1fdb880cfbd97b38 Mon Sep 17 00:00:00 2001 From: Skullheadx <704277@pdsb.net> Date: Wed, 6 Jul 2022 12:36:04 -0400 Subject: [PATCH] added pets --- Game.py | 14 +++++++++----- Pet.py | 15 +++++++++++++++ game_doc.txt | 2 +- 3 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 Pet.py diff --git a/Game.py b/Game.py index 0cb2e3c..30fe35c 100644 --- a/Game.py +++ b/Game.py @@ -1,23 +1,26 @@ from Setup import * from Player import Player +from Pet import Pet from Enemy import Enemy from Block import Block class Game: def __init__(self): - self.collision_layer = {0:set(),1: set(), 2:set()} - self.player = Player(center, self.collision_layer[1], [self.collision_layer[2], self.collision_layer[0]]) + self.collision_layer = {"world":set(),"player": set(), "enemy":set(), "pet":set()} - self.enemies = [Enemy((SCREEN_WIDTH * 3 /4, 0),self.collision_layer[2], [self.collision_layer[1], self.collision_layer[0]])] - self.blocks = [Block((0, SCREEN_HEIGHT * 3 / 4),self.collision_layer[0]), + self.player = Player(center, self.collision_layer["player"], [self.collision_layer["enemy"], self.collision_layer["world"]]) + self.pet = Pet(center, self.collision_layer["pet"], [self.collision_layer["world"]]) + + self.enemies = [Enemy((SCREEN_WIDTH * 3 /4, 0),self.collision_layer["enemy"], [self.collision_layer["player"], self.collision_layer["world"]])] + self.blocks = [Block((0, SCREEN_HEIGHT * 3 / 4),self.collision_layer["world"])] # Block((SCREEN_WIDTH/2 - 50, SCREEN_HEIGHT * 3 / 4),self.collision_layer[0]), # Block((SCREEN_WIDTH/2 + 50, SCREEN_HEIGHT * 3 / 4),self.collision_layer[0]), - ] def update(self, delta): self.player.update(delta) + self.pet.update(delta, self.player) for enemy in self.enemies: enemy.update(delta, self.player) @@ -33,4 +36,5 @@ class Game: block.draw(surf) self.player.draw(surf) + self.pet.draw(surf) diff --git a/Pet.py b/Pet.py new file mode 100644 index 0000000..ca378e6 --- /dev/null +++ b/Pet.py @@ -0,0 +1,15 @@ +from Actors import Actor + +class Pet(Actor): + width,height = 75,50 + + def __init__(self, pos, collision_layer, collision_mask): + super().__init__(pos, collision_layer, collision_mask) + + def update(self, delta, target): + super().update(delta) + + self.follow_target(target) + + self.position, self.velocity = self.move_and_collide(self.position, self.velocity, delta) + diff --git a/game_doc.txt b/game_doc.txt index 8a67839..8d38e07 100644 --- a/game_doc.txt +++ b/game_doc.txt @@ -9,7 +9,7 @@ List of Dimensions: Gameplay: - dialogue between npcs -- combat, parkour, building, mining +- combat, exploration story - stars fall out of the sky and other people collected them including the player -- 2.54.0