-
-
Notifications
You must be signed in to change notification settings - Fork 192
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
Add random timer range as a feature of timers #396
Comments
Hi! I'd like to work on this if it's still up for grabs 🙏 |
All yours! 👍
…On Sat, Apr 27, 2019, 16:42 May Kim ***@***.***> wrote:
Hi! I'd like to work on this if it's still up for grabs 🙏
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#396 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEVNZ3EC4GL4LKYNJZAGWTPSTCC7ANCNFSM4A2ZT3IQ>
.
|
Is this still up for grabs ? |
@DProBoy All yours, I've added the in-progress label |
@eonarheim Can i (or Should I?) add new sandbox tests for the Random Timer ? I've committed the changes to my fork of Excalibur and i'm about to submit a pull request for #875 and #396 . (hehe ... still haven't gotten used to Git, as I was a Perforce user before ...) |
It may be good to add some visual tests to the sandbox/tests/timers
directory (which doesn't exist yet but feel free to follow an existing
example).
…On Wed, Aug 7, 2019, 11:57 AM DProBoy ***@***.***> wrote:
@eonarheim <https://github.com/eonarheim> Can i (or Should I?) add new
sandbox tests for the Random Timer ? I've committed the changes to my fork
of Excalibur and i'm about to submit a pull request for #875
<#875> and #396
<#396> . (hehe ... still
haven't gotten used to Git, as I was a Perforce user before ...)
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#396?email_source=notifications&email_token=AAEJU267ALV5H3I6GGKUHYDQDL5HVA5CNFSM4A2ZT3I2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3ZBRYA#issuecomment-519182560>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEJU26VKNYTIGJOIJLWJQDQDL5HVANCNFSM4A2ZT3IQ>
.
|
Add RandomTimer with the ability to specify a range (min,max) of time and allow the RandomTimer to choose a duration within it. Resolves: excaliburjs#396
Hi, is this issue still open? |
@c3ho I haven't seen any work on it, all yours! Excalibur has a built in seeded It may be worth while to rethink the constructor and the Timer interface as well. Perhaps something along these lines? If possible we should allow the previous constructor to be used as well avoid a breaking change export interface TimerOptions {
// milliseconds before the timer fires
interval: number;
// if number of repeats null, undefined means it fires once
// if number of repeats <= 0 or Infinity means repeat forever
repeats?: number;
// maximum number of milliseconds to randomly add
randomRange?: number;
// timer callback
fcn?: () => void;
}
type Callback = () => void;
export class Timer {
// Constructor overload
constructor(options: TimerOptions);
constructor(fcn: Callback, interval: number, repeats?: boolean, numberOfRepeats?: number);
constructor(optionsOrFcn: TimerOptions | Callback, interval?: number, repeats?: boolean, numberOfRepeats?: number) {
//... todo implement
}
} // Example new usage // repeat once in 200 ms
const timerOnce = new ex.Timer({
fcn: () => { console.log('Called Once'); },
interval: 200
});
// repeat 3 times every 200 ms
const timerThreeTimes = new ex.Timer({
fcn: () => { console.log('Called Three Times'); },
interval: 200,
repeat: 3
});
// repeat forever every 200 ms
const timerForever = new ex.Timer({
fcn: () => { console.log('Called Forever'); },
interval: 200,
repeat: Infinity
});
// repeat with a random range 200 ms + (0ms to 200 ms)
const timerRandomRange = new ex.Timer({
fcn: () => { console.log('Called every 200ms + random range'); },
interval: 200,
repeat: Infinity,
randomRange: 200
}); |
@eonarheim is this issue still up ? |
@eonarheim Hello, is this issue still up? |
@malitherl I haven't seen any traction on the issue yet, it's yours now! |
Used /Util/Math to calculate randomness. This would set a random interval after receiving a range of numbers Resolves: excaliburjs#396
Context
There is a use case for creating a timer that has a variable duration. For example, if you wanted to randomly space events during a game.
Proposal
Add the ability to specify a range (min and max) of time and allow the timer to randomly choose a duration within that range.
The text was updated successfully, but these errors were encountered: