Trash Piles & Trackers
The following is part of a bi-weekly update we would be required to do as we worked on our final projects. Some things may require context that is not included or some original post content may be excluded.
Last week I had added more trash pile variants (different sprites and trash piles that require higher beam strengths), refined the Trash Tracker a little more (starting area can be trackable; leaving an area will make the tracker go blank until you enter a different area or reenter an area), made the second area able to be unlocked, and I started work on the Trash Compass upgrade.
Starting with the new trash piles: I made a Condensed Trash Pile which is essentially a Trash Pile that requires beam strength level 2 and breaks down into more trash. Since trash piles function very similarly to each other (with the only difference really being the art, the level they need to be broken down, how much trash they drop, and some other minor things), I just made the Condensed Trash Pile inherit from the Trash Pile. Because of how the Trash Pile script is set up, updating the stats works much like setting variables through the editor in Unity or Unreal.
The Trash Pile scene. The editable variables are on the right side.
The Condensed Trash Pile scene that inherits from Trash Pile. You can tell the variables have been changed because next to the value is an undo/revert button.
I also made it so the trash piles have visual variations. Once they're fully loaded into the main game scene, their _ready function has code that makes them their sprite into a random frame in AnimatedSprite2D.
The _ready function in the Trash Pile script. A random number is chosen from the amount of frames there are and the AnimatedSprite2D's frame variable is updated to be that random number.
The different trash pile variations in-game.
With the Trash Compass, it functions a little like the player's trash beam visually(?) for lack of better words. However, how it works is that the Trash Compass's root scene is a Area2D. This way it'll detect Trash and TrashPile bodies that is within its area/hitbox, which then the Trash Compass is attached to the player so it'll detect trash bodies that are around the player.
Area2D has a function that returns an array of bodies its overlapping with, so using that, I iterated through each overlapping body and checked their distance from the Trash Compass's global position. Whichever is the closest body will be stored in a _closest_trash variable.
The TrashCompass _process function. The first part of it shows the iteration of the overlapping bodies and storing the closest trash.
Once the closest trash to the player is decided, the TrashCompass will update its Sprite2D so that it in goes in and faces the direction of the closest piece of trash to the player.
The Sprite2D's x-offset is set to the length of the distance to the closest trash, limited to an offset of 25. 5 is taken from the minimum result so that the Trash Compass does not hover directly on top of the trash. The Sprite2D look_at function is called so that it rotates towards the trash's position.
What I want to work on now is to fix that issue with the trash pile shake animations. I currently have it so that the animation loops, but as you can see, that means it'll keep shaking even if the player isn't actively damaging the trash pile which is misleading. I also want to make the trash compass more transparent the farther the player is from the closest trash to them. I also need to update the trash compass to only detect trash piles that the player can actually destroy. After completing those, I may work on the final trash variant (one that requires the final beam strength upgrade) and the third area, or start trying to add some SFX to the game because up to this point, there's been no auditory feedback for the player.
Get ECO-Keeper
ECO-Keeper
Play as a little robot tasked to clean the planet!
Status | Prototype |
Author | StarsproutGames |
Genre | Adventure |
More posts
- Save/Load Functionality4 days ago
- Save Slot Menu4 days ago
- The Main Menu4 days ago
- Finishing the Settings Menu4 days ago
- Making a Settings Menu4 days ago
- Tutorial Level & Menus4 days ago
- Fabricator & Player Upgrades4 days ago
- First Unlockable Area4 days ago
- Start of a New Project4 days ago