Skip to content

Add World and related tech. #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Mar 19, 2024
Merged

Add World and related tech. #25

merged 13 commits into from
Mar 19, 2024

Conversation

karnkaul
Copy link
Member

Close #16

@karnkaul
Copy link
Member Author

@swagween This is a big and somewhat complex one, so not belabouring you with a review on it, but tagged you here anyway in case you want to take a look / have questions / etc.

@karnkaul karnkaul marked this pull request as ready for review March 17, 2024 09:16
using Spawn = std::function<std::unique_ptr<Enemy>()>;

explicit EnemySpawner(Spawn spawn, bave::ParticleEmitter explode);
explicit EnemySpawner(std::unique_ptr<IEnemyFactory> factory);
Copy link
Contributor

Choose a reason for hiding this comment

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

why the need for EnemySpawner, IEnemyFactory, and EnemyFactoryBuilder? what's the difference between all of these? I get that the spawner just handles the gameplay aspects and doesn't worry about how the memory is managed and stuff, but I'm more confused about the latter two.

Copy link
Member Author

Choose a reason for hiding this comment

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

The spawner - which is not customizable - uses a customizable factory to drive itself. The factory builder converts JSON data into a concrete factory.

using bave::Seconds;
using bave::Shader;

namespace {
Copy link
Contributor

Choose a reason for hiding this comment

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

why the unnamed namespace here? are these just World helper functions?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah they are helper functions that are only used in this cpp file, so putting them in an unnamed namespace gives them internal linkage (visible only to this cpp file) and the compiler a better opportunity to optimize them.


namespace spaced {
struct WorldSpec {
struct Player {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be something like PlayerSpec to avoid confusion? Although I suppose it is a bit redundant

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it could be argued that way for sure. I didn't use the suffix because like you said it's already in the enclosing class (WorldSpec::Player).

Copy link
Contributor

@swagween swagween left a comment

Choose a reason for hiding this comment

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

Just some small questions

@karnkaul karnkaul merged commit ecc47da into main Mar 19, 2024
@karnkaul karnkaul deleted the karnage/world branch March 19, 2024 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Game worlds / levels
2 participants