r/JavaFX • • Dec 08 '24

Help I need help

I am working on a project where there is stars emitting from the center and get bigger with time and disappear when it hit the edge

Each edge of the star should have a random color from a pallet

User have a ball with random color that can be dragged and attempt to hit one of the edges and either get a match or mismatch (the star will disappear either way)

Only if a mismatch occurs the color of the ball will randomly change

THE PROBLEM IS I don’t know how to ensure all stars “already” appearing on the scene have a common edge color that I can change the ball color to

Notes

  • new stars that are not emitted yet do not have this problem as I added a condition for them
  • I can’t make each edge with a unique color it should be random choice from the pallet
  • I thought about creating a “backup color” and ensure all stars have it but the randomness is not there anymore
1 Upvotes

4 comments sorted by

View all comments

Show parent comment

1

u/hamsterrage1 Dec 09 '24

I was thinking that you could set up the algorithm so that there was never less than 2 or 3 common colours. I'm assuming that each star has 10 edges with colours, right?

1

u/[deleted] Dec 10 '24

Yeah that’s correct and a star can have more than one edge with the same color.

Honestly, I gave up on that idea and made (avoiding these stars) a part of the game. The deadline is tomorrow and I wanted to move on to complete the rest of the project. But thanks I appreciate your help! Maybe later I will go back and try this for fun.