diff --git a/__pycache__/eb_engine.cpython-314.pyc b/__pycache__/eb_engine.cpython-314.pyc index 3d46e2b..7fc20b4 100644 Binary files a/__pycache__/eb_engine.cpython-314.pyc and b/__pycache__/eb_engine.cpython-314.pyc differ diff --git a/__pycache__/eb_objects.cpython-314.pyc b/__pycache__/eb_objects.cpython-314.pyc index 7537c2e..5017241 100644 Binary files a/__pycache__/eb_objects.cpython-314.pyc and b/__pycache__/eb_objects.cpython-314.pyc differ diff --git a/eb_engine.py b/eb_engine.py index ccf29fa..33a8a4d 100644 --- a/eb_engine.py +++ b/eb_engine.py @@ -8,7 +8,8 @@ import eb_creature_objects import gc, psutil, os cell_classes = {"grass_small": eb_terrain_objects.Ground, - "sword_default": eb_objects.Item, "elf_watching": eb_creature_objects.Unit} + "sword_default": eb_objects.Item, "elf_watching": eb_creature_objects.Unit, + "rock_small": eb_terrain_objects.Rock} main_dir = os.path.dirname(os.path.abspath(__file__)) sprites_dir = os.path.join(main_dir, "res", "sprites") @@ -40,6 +41,8 @@ class Map: cam_y: int = 0 cell_dist: int = 1 + #action_time_multiplier + def __post_init__(self): self.cells = {} with open(self.name, 'r') as file: @@ -57,6 +60,23 @@ class Map: self.cells[line].append(final_cell) + def move_obj(self, type, s_x, s_y, d_x, d_y): + if d_y >= len(self.cells) or d_x >= len(self.cells[s_y]) or s_y >= len(self.cells) or s_x >= len(self.cells[s_y]): + return False + source_cell = self.cells[s_y][s_x] + dest_cell = self.cells[d_y][d_x] + obj = getattr(source_cell, type) + + if obj is None: + return False + + setattr(source_cell, type, None) + setattr(dest_cell, type, obj) + return True + + def get_way(self, s_x, s_y, d_x, d_y): + pass + def draw_map(self, screen, current_frame, grid = True): for j in range(len(self.cells)): for i, cell in enumerate(self.cells[j]): @@ -212,11 +232,12 @@ class Engine: if event.type == pygame_gui.UI_TEXT_ENTRY_FINISHED and event.ui_element == input_entry: user_text = input_entry.get_text() - #print(user_text) + exec(user_text) if user_text.strip(): output_log += f">>> {user_text}\n" output_box.set_text(output_log) input_entry.set_text("") + user_text = "" console_active = False console_active = bool(input_entry.get_text().strip()) @@ -244,7 +265,6 @@ class Engine: easy_map.draw_map(self.screen, current_frame + 1) manager.draw_ui(self.screen) - #print(easy_map.cells[0][0].item_obj.sprite_cache) if not console_active: keys = pygame.key.get_pressed() @@ -278,6 +298,6 @@ class Engine: if global_counter % 10 == 0: current_fps = clock.get_fps() - print(f"Current FPS: {current_fps:.2f}") + #print(f"Current FPS: {current_fps:.2f}") pygame.quit() \ No newline at end of file diff --git a/eb_objects.py b/eb_objects.py index c072815..17321fd 100644 --- a/eb_objects.py +++ b/eb_objects.py @@ -7,6 +7,9 @@ class Object: sprite_name: str sprite_state: int = 0 + # weight + # effects = {} + def draw(self, draw_data): if draw_data["spr_up"] == 0: if self.sprite_state == len(draw_data["sprites"][self.sprite_name]) - 1: @@ -18,23 +21,36 @@ class Object: rect = sp.get_rect(center = (draw_data["x"] + draw_data["w"] /2, draw_data["y"] + draw_data["h"]/ 2)) draw_data["screen"].blit(sp, rect) - + def update(self): + pass + @dataclass class Terrain(Object): pass @dataclass class Creature(Object): - pass - #status - #actions - #tasks - #items + current_action: int = 0 + quick_actions: list = field(default_factory = list) + tasks: list = field(default_factory = list) + inventory: dict = field(default_factory = dict) + + def update(self): + pass + @dataclass class Item(Object): + # passive_abilities = {} + # active_abilities = {} pass +@dataclass +class Container(Item): + # content = {} + pass + + @dataclass class Building(Object): pass \ No newline at end of file diff --git a/main.py b/main.py index 00c3a6c..f63a54d 100644 --- a/main.py +++ b/main.py @@ -29,7 +29,6 @@ if __name__ == "__main__": # pydantic instead of dataclasses? # почитать про Surface, Display, доку к pygame-gui # проверить дефолтдикт field и None = None - # техдолг - draw_data to dd # изучить pypmler # настроить логирование всего # SLOP: load_sprites diff --git a/res/sprites/grass_small_2.png b/res/grass_small_2.png similarity index 100% rename from res/sprites/grass_small_2.png rename to res/grass_small_2.png diff --git a/res/rocks-2.jpg b/res/rocks-2.jpg new file mode 100644 index 0000000..dc4cb03 Binary files /dev/null and b/res/rocks-2.jpg differ diff --git a/res/sprites/rock_small_1.png b/res/sprites/rock_small_1.png new file mode 100644 index 0000000..b516109 Binary files /dev/null and b/res/sprites/rock_small_1.png differ