If I have a class “flies” and reference it in the condition of an Event:
then the Event Manager UI displays “All in class flies”, but the condition evaluates to true if Any object in the class exhibits the behaviour described by the remaining slots.
Example: If “All in class flies”/sensing/touching object/someobject
really means : If “Any in class flies”/sensing/touching object/someobject
So my question is: is there a way in Ready to create a condition that is true iff the given behaviour is exhibited by ALL elements in a class. Or is it necessary to revert to a brute-force approach i.e.
I believe it gives you the option of both already does it not? It’s just a longer process because it’ll be separate
There is no easy way yet, but I think that the counter can come to the rescue.
For example, add a counter for objects in the class and create a condition when an object in the class touches another object and its counter should be equal to 1 (Then, using the timer, you reset it). The event may look like:
If “Any in class flies”/counter/not equal/0
Thanks guys! @kenobi @Ready
So the timer technique is a real thing? I used it before (recently in @Suzzy-Grey’s “Find flat land” challenge) but I thought it was just a clumsy hack because I couldn’t think of anything better
In my present use case, I haven’t found a successful solution using timers because objects in the class can change state back and forth several times before the final state is reached. Concretely: one of my students built a variant of the Ready Maze Game (https://www.getready.io/hourofcode-maze) which features multiple prizes. (Thanks again to @Suzzy-Grey for helping with this last summer!).
Using a counter is fine until the following happens: the player picks up some, but not all, of the prizes (keys), then hits a wall and drops them. When the player picks up this cluster of dropped keys, I’m struggling to figure out how to detect how many keys were picked up. Here’s the game using the “brute force” method to check each key individually:
I would make a variable - angle type.
So when a character collides witb a key, the key sets position to the character and add 1 to the angle.
When character collides with a wall, all keys drop away and set the angle to 0.
So drop 6 keys and the variable angle 6 sets to 0
Thanks for this idea, @Suzzy-Grey! I tried implementing it but my events got messed up and now I’m out of time. I’ll try again tomorrow and post my findings. Resetting the angle provides the benefit of a guarantee that if one key in the cluster is touched, all keys in the cluster will be re-picked-up. So if we count the keys as they are picked up, if a group of them is dropped, we know the new required number of pick-up occurrences.