Skip to content
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

Merged
merged 11 commits into from
Nov 25, 2020
Merged

Custom particles #1544

merged 11 commits into from
Nov 25, 2020

Conversation

Semphriss
Copy link
Member

@Semphriss Semphriss commented Oct 13, 2020

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!

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!

image

Control where your particles spawn and live with 5 control zones for your particles!
editor
test


Info for the users

To create custom particles :

  1. In the level editor, go in Objects -> Sector
  2. Notice two very similar icons : A yellow sparkle, and another yellow sparkle with a small file icon.
    • The one without the file icon is if you want to create your custom particles the traditional way. Be careful, it can get messy!
    • The one with a file is if you want to use the particle editor. Read below for instructions about the particle editor :)
  3. Add one of the object you chose to the sector
  4. Right-click the icon that just appeared, and give your particle system a name. Keep it in note, you'll need it later :)
  5. If you want, change some settings. If you want to see them immediately, make sure the "Cover screen" option is checked, then test your level. Beware, that means your particles will spawn everywhere on your screen - if that's not what you want, keep reading!
  6. Go in Objects -> Environment
  7. Towards the bottom, you should see a light green box, with a barely visible yellow sparkle that looks like the one for the particle system; that's the particle zone object.
  8. Add a particle zone object, place it and resize it at your taste, then right-click on it:
    • Set the "Particle Name" (not "Name", really "Particle Name") property to the name you gave your particles a bit earlier. A particle zone will only affect particles that correspond to its particle type. All other particles (either non-custom particles, or custom particles with a different name) will be unaffected.
    • Set the zone type to whatever you want it to be. The possibilities are :
      • Spawn zone (default) : Particles of the type you specified will spawn in this zone. You can have multiple spawn zones for the same particle object. Make sure the "Cover screen" option is not checked, else your spawn zones will be ignored :)
      • Living zones : Particles are allowed to spawn in or enter this area, but if they leave it, they'll enter their dying phase. (That is, if you set the death effect to be a fade out, the particle will start fading out immediately as it leaves the zone)
      • Living zones with clear on exit : Same as above, but if particles leave it, they are instantly destroyed. This can be useful if particles leaving the zone cannot be seen on the screen - this will avoid having to calculate the movement for a particle that doesn't matter anyways :)
      • Kill zone : If a particle enters this zone, it'll start its dying phase.
      • Clear zone : If a particle enters this zone, it'll be immediately cleared.
  9. Repeat step 8 as many times as you want.
  10. Save and test your level. You should see your particles :)

Info on the development

What has been done

Oct 13, 2020

  • The custom particles object is fully customizable both using the classic interface and through the particle editor
  • The particle editor is accessible from the options menu of custom particles
  • The zones are all ready and fully-functional; they also display their corresponding particle's name, and their color change based on their type

What remains to do

  • Get user feedback!
  • Add options for multiple textures for a single particle object (the game will pick one of the textures at random - let the user select the likeliness for each texture)
  • Expose the particles to scripting
  • Improve the code quality, and fix all the TODO's and FIXME's
  • Create some decent showcases - perhaps some people can help me with that?

Semphris and others added 7 commits September 12, 2020 16:04
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.)
if (controller.pressed(Control::ESCAPE)) {
m_enabled = false;
MenuManager::instance().set_menu(MenuStorage::PARTICLE_EDITOR_MENU);
return;
Copy link
Member

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.

Copy link
Member Author

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?

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; }
Copy link
Member

Choose a reason for hiding this comment

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

const correctness

bool has_focus() { return m_has_focus; }

void set_rect(Rectf rect) { m_rect = rect; }
Rectf get_rect() { return m_rect; }
Copy link
Member

Choose a reason for hiding this comment

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

const correctness

bool
ControlButton::on_key_up(const SDL_KeyboardEvent& key)
{
if (key.keysym.sym == SDLK_SPACE && m_has_focus) {
Copy link
Member

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 ?

Copy link
Member Author

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)
{
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

Copy link
Member Author

Choose a reason for hiding this comment

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

Same question as above :^)

bool
ControlEnum<T>::on_key_down(const SDL_KeyboardEvent& key)
{
if (key.keysym.sym == SDLK_DOWN && m_has_focus) {
Copy link
Member

Choose a reason for hiding this comment

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

Invert if statements.

Copy link
Member Author

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.

src/interface/label.hpp Outdated Show resolved Hide resolved
src/interface/label.hpp Outdated Show resolved Hide resolved
src/interface/label.hpp Outdated Show resolved Hide resolved
src/video/surface_batch.hpp Outdated Show resolved Hide resolved
Semphris added 4 commits November 17, 2020 20:47
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 :)
@tobbi tobbi marked this pull request as ready for review November 25, 2020 21:32
@tobbi tobbi merged commit 14ac958 into master Nov 25, 2020
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.

2 participants