#How can I fix coding myself into a corner in my roguelike?

1 messages · Page 1 of 1 (latest)

cedar nest
#

You should be coding classes such as they only have code for a single purpose.
Then when you need an object with several functionalities, you make it a "manager" of all the classes it needs.

For example, a character could manage a gravity node, a gun node, a jump node, etc.

dim arrow
#

i know you think its at worst rewrite, but you will learn a ton doing so

dawn basin
#
  • "Classes" - Very specific and exacly for the repeating stuff (special jobs, Car, Enemy, Door...)
  • "Manager" - Script to guide people (data/scenes) like a busines from the outside, while leaving them the autonomy they need.
  • "Signals" - To scream around, and someone maybe listening
  • "JSON" - Sort of structured way to write things down (saving). But there are even simpler ways (txt, tres, res, cfg, etc..)
#

5 Examples, but depending on your game/scope/budget this could be overkill. Or you might even need some other manager that is specific to your game. Maybe you have lots of birds, then you might need a BirdManager to do all your bird calculations 🐦

SceneManager
The SceneManager is responsible for loading, switching, and managing different scenes in the game. It can handle transitions between levels, manage loading screens, and keep track of the current active scene.

InputManager
The InputManager centralizes input handling, making it easier to manage user inputs from various devices (keyboard, mouse, gamepad). This manager can also handle input mapping and provide a unified interface for checking input states.

AudioManager
The AudioManager handles all audio-related tasks, including background music, sound effects, and volume control. This manager can help manage audio resources efficiently and ensure that sounds are played at the right times.

GameStateManager
The GameStateManager keeps track of the overall state of the game, such as whether the game is paused, in a menu, or in gameplay. This manager can help manage transitions between different game states and ensure that the game behaves correctly based on its current state.

ResourceManager
The ResourceManager is responsible for loading and managing game assets, such as textures, sounds, and scripts. This manager can help optimize resource loading and ensure that assets are reused efficiently throughout the game.

arctic hornet
#

I took another look at the stuff you posted in quick help ( #❓┃quick-help message ), and I'd recommend just separating out the code from the level script to separate scripts

#

Player script handles everything on the player, enemy script handles everything on the enemies, bullet script handles everything on the bullets, etc.

#

For bullets, you can differentiate between who shot the bullet, and with that you can change who can get hit by it

#

I tried reading about managers, but I'm not sure how to correctly implement them
What are you thinking managers would be useful for?

#

I think managers are unnecessarily complicated for this, but I might be imagining something else than what others have meant by "managers"

#

Also, I hope you're using Git! Version control is pretty useful for programming. It allows you to see changes you've made to your code & scenes, and easily save snapshots of your project