-
-
Notifications
You must be signed in to change notification settings - Fork 493
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
Custom particles #1544
Custom particles #1544
Conversation
…in a working state)
What has been done : - The custom particle object exists and in instanciable (creatable) from the editor toolbox - The particles show up and are manageable with plenty of settings already (I intend to add even more if needed) - The particles spawn and death locations can be handled via a new particle area object (light green, has the same sparkle icon as the custom particle object itself) TODO: Scripting (Every single setting should have getters, setters, faders and easers (when relevant) in Squirrel) TODO: Make a particle editor alongside the level editor, because jeez, that's waaaaay too many settings TODO: Store custom particle data in standalone file for easy editing reusability (and allow users to load custom particle data from files) ... and probably much more to do and fix :)
There is waaaay too much I've done in this. I apologize to anyone having to do maintenance in this. That being said, there is still a lot to be done, much more than I can list here. (scripting, some custom particles features, etc.)
…custom particle object
if (controller.pressed(Control::ESCAPE)) { | ||
m_enabled = false; | ||
MenuManager::instance().set_menu(MenuStorage::PARTICLE_EDITOR_MENU); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this return since we're at the end of the function anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left the return
there in case someone might want to add more keyboard binds, so that they won't have to think about adding a return
before adding their stuff.
Should I remove it anyways?
src/interface/control.hpp
Outdated
virtual bool on_mouse_motion(const SDL_MouseMotionEvent& motion) override { if (m_label) m_label->on_mouse_motion(motion); return false; } | ||
|
||
void set_focus(bool focus) { m_has_focus = focus; } | ||
bool has_focus() { return m_has_focus; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const correctness
src/interface/control.hpp
Outdated
bool has_focus() { return m_has_focus; } | ||
|
||
void set_rect(Rectf rect) { m_rect = rect; } | ||
Rectf get_rect() { return m_rect; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const correctness
src/interface/control_button.cpp
Outdated
bool | ||
ControlButton::on_key_up(const SDL_KeyboardEvent& key) | ||
{ | ||
if (key.keysym.sym == SDLK_SPACE && m_has_focus) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you invert the if statement, then return false
early, and then get rid of the else
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this okay?
bool
ControlButton::on_key_up(const SDL_KeyboardEvent& key)
{
if (!m_has_focus)
return false;
if (key.keysym.sym == SDLK_SPACE) {
if (m_on_change)
(*m_on_change)();
m_mouse_down = false;
return true;
}
return false;
}
I'd like to preserve some future-proofness, so that future keybinds will be easy to add. With this, future maintainers/contributors just have to reproduce the if (...) { ... return true; }
template.
|
||
bool | ||
ControlButton::on_key_down(const SDL_KeyboardEvent& key) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question as above :^)
src/interface/control_enum.hpp
Outdated
bool | ||
ControlEnum<T>::on_key_down(const SDL_KeyboardEvent& key) | ||
{ | ||
if (key.keysym.sym == SDLK_DOWN && m_has_focus) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invert if statements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an else if
in the middle; I put the m_has_focus
check on top, though.
Added: Opening the particle editor through a custom-particle-from-file object now opens its corresponding file Added: It is now possible to add multiple textures to a single custom particle object through the particle editor Added: Saving particles now support multiple textures per object Added: It is now possible to make particles bounce on solid surfaces Done: Code cleanup and const correctness :)
…ot managing textures)
Please, please, provide me some user feedback on that one! I want to take note of the changes as early as possible, so that I don't work for nothing!
Custom particles!
Now you can create your own particles for the game! With a fully-featured particle editor, you can make your particles look and behave the way you want!
Control where your particles spawn and live with 5 control zones for your particles!
Info for the users
To create custom particles :
Info on the development
What has been done
Oct 13, 2020
What remains to do