Skip to content

refactor(sprites.py-file)#117

Merged
Davidek523 merged 19 commits intomainfrom
refactor(sprites.py-file)
Mar 31, 2025
Merged

refactor(sprites.py-file)#117
Davidek523 merged 19 commits intomainfrom
refactor(sprites.py-file)

Conversation

@ultimateownsz
Copy link
Collaborator

Pull Request Template

Type of Pull Request

Only check one box per pull request.

  • 🛠️ Code—Changes to the codebase.
  • 🔄 Revert—Reverts a previously merged commit or PR.
  • 📄 Documentation—Updates to documentation files.
  • 🎵 Audio—Changes to audio files.
  • 🎨 Asset—Updates to design or visual assets.

Summary

This PR refactors sprites.py and divides the code in different directories:

  • add src/sprites directory
  • inside the sprites directory you can find new directories:
    • camera, entities, shop and tiles.

Camera Group logic

  • the sprites dir has one abstract BaseSprite class that the rest of the sprites classes us as parent class.
  • the camera sprites directory has also an abstract base class AllSprites that is used to make further implementation of newer camera groups easier.
  • Old AllSprites class is refactored to make place of the child class PlayerCamera which gives more control and readability what the pygame.sprite.Group does.

Small changes

  • Removed old GUI code which is not available.
  • fix docs\Guides\InventoryGuide.md some small errors and add more context to the codebase paths.

Docstrings notes
In some files, I added some docstrings to make it easier to read and understand what the class, args etc. do.

Small shop.py refactor

  • No code is changed
  • Only the logic of the state is moved to its own shop_state.py state and the sprite logic is moved to its own src/sprites/shop directory.

Related Issues

This PR issue(s)


✅ Checklist:

  • Tested the changes locally.
  • Verified that no breaking changes are introduced.
  • Updated documentation (if applicable).

🏷️ Labels:

type:refactor, priority:high

…o changed the correct path where the `src/inventory_gui.py` is now located in.
- Also changed the `src/sprites.py` file name to `src/sprites/base.py` since we might want to adapt the sprites classes to inherit from a base Sprite class later on, it also helps to make the file not too big and easier to navigate.
- Changed the reference of sprites.py to base.py in game_running.py
- Created an abstract class called BaseSprite, that has Sprite as argument. It's referred to pygame.sprite.Sprite.
-Each new sprite class that will be made, must inherit BaseSprite class
…e it to this, but I have AllSprites still as reference and in use for this abstract class.

- Moved the current working player camera to make it more clear what the purpose of the camera is.
- Fixed the imports of the codebase with the changes I made from the old sprites.py file.
- Moved class to the entities directory inside the sprites directory.
@ultimateownsz ultimateownsz added type:refactor For code cleanup or optimization without changing functionality priority:high Urgent or critical changes that need immediate review labels Mar 29, 2025
ultimateownsz and others added 2 commits March 30, 2025 21:33
- move inventory_gui.py to `gui` directory.
- add type hints to file
- size of extract icon was set to 16, is now TILE_SIZE.
Copy link
Collaborator

@Davidek523 Davidek523 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approve these changes

@Davidek523 Davidek523 merged commit ef6692f into main Mar 31, 2025
1 check passed
@ultimateownsz ultimateownsz deleted the refactor(sprites.py-file) branch May 29, 2025 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:high Urgent or critical changes that need immediate review type:refactor For code cleanup or optimization without changing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments