make background flicker

NecroDeath
28 Aug 2017, 18:18Is there a way to make the background change colour rapidly , e .g. white-black-white-black for a couple of seconds? I just want this effect when the player performs a particular action/solves a particular puzzle.
(using online editor)
Thanks!
hegemonkhan
28 Aug 2017, 18:45(filler for getting this edited post, updated/posted)
(again, filler for getting this edited post, updated/posted, argh)
you could use a Timer, with an Attribute, for the toggling of the backgrounds, for example (using a Boolean Attribute as for this example I'm only toggling between 2 different backgrounds. If you want to toggle between more than 2 backgrounds, you can't use a Boolean Attribute, as it only has two states. You can use a String Attribute or an Integer Attribute, for more than two states/backgrounds-being-toggled):
(K.V. can help with the code for the backgrounds' color --- this is outside of my knowledge base)
<game name="example_game">
<attr name="example_boolean" type="boolean">false</attr>
<attr name="duration_integer" type="int">0</attr>
<attr name="start" type="script">
EnableTimer (example_timer)
</attr>
</game>
<timer name="example_timer">
<interval>1</interval>
<script>
if (game.duration_integer = 11) { // timer duration has ended
game.duration_integer = 0
// optionally: code to change background back to its original/default color
DisableTimer (example_timer)
} else { // timer duration has NOT ended
game.duration_integer = game.duration_integer + 1
if (game.example_boolean) { // if (game.example_boolean = true)
game.example_boolean = false
// code to make a 'green' background
} else { // if (game.example_boolean = false)
game.example_boolean = true
// code to make a 'orange' background
}
}
</script>
</timer>

K.V.
28 Aug 2017, 19:15BOOM!
SetForegroundColour ("Black")
SetBackgroundColour ("White")

K.V.
28 Aug 2017, 19:21
hegemonkhan
28 Aug 2017, 19:35(pseudo: incomplete code: not full game code) BOOM SHA-KA-LA-KA (dating myself: comes from 'NBA JAM' game): flickering background colors, hehe
<game name="example_game">
<attr name="example_boolean" type="boolean">false</attr>
<attr name="duration_integer" type="int">0</attr>
<attr name="start" type="script">
SetForegroundColour ("White")
SetBackgroundColour ("White")
EnableTimer (example_timer)
</attr>
</game>
<timer name="example_timer">
<interval>1</interval>
<script>
if (game.duration_integer = 11) { // timer duration has ended
game.duration_integer = 0
SetForegroundColour ("White")
SetBackgroundColour ("White")
DisableTimer (example_timer)
} else { // timer duration has NOT ended
game.duration_integer = game.duration_integer + 1
if (game.example_boolean) { // if (game.example_boolean = true)
game.example_boolean = false
SetForegroundColour ("White")
SetBackgroundColour ("White")
} else { // if (game.example_boolean = false)
game.example_boolean = true
SetForegroundColour ("Black")
SetBackgroundColour ("White")
}
}
</script>
</timer>

K.V.
28 Aug 2017, 19:51JS.setCss ("#gameBorder", "box-shadow:0px 0px 15px 5px red;")
JS.setCss ("*", "background:black;color:white")
JS.setCss (".ui-widget-header", "background:red")
Still working on it...
I put the red border because a border will look cool when it's flashing...
About to plug it in HK's code...
MORE ON THIS AS IT COMES IN.

K.V.
28 Aug 2017, 19:55@HK
He's on FIRE!!!

K.V.
28 Aug 2017, 20:15JS.setCss ("#gameBorder", "box-shadow:0px 0px 15px 5px red;")
JS.setCss ("*", "background:black;color:white")
JS.setCss (".ui-widget-header", "border:0px solid red;background:red")
SetTimeout (1) {
JS.setCss ("#gameBorder", "box-shadow:0px 0px 15px 5px blue;")
JS.setCss ("*", "background:white;color:black")
JS.setCss (".ui-widget-header", "border:0px solid blue;background:blue")
SetTimeout (1) {
JS.setCss ("#gameBorder", "box-shadow:0px 0px 15px 5px red;")
JS.setCss ("*", "background:black;color:white")
JS.setCss (".ui-widget-header", "border:0px solid red;background:red")
SetTimeout (1) {
JS.setCss ("#gameBorder", "box-shadow:none;")
JS.setCss ("*", "background:white;color:black")
JS.setCss ("#location", "background:black;color:white;")
JS.setCss (".ui-widget-header", "border:0px solid lightgray;background:black")
}
}
}
I'm thinking it may be a good idea to hide the command prompt during this.
NOTE: I wish there was a way to set a timer for 1/3 of a second...

Dcoder
29 Aug 2017, 00:35Actually, OurJud and The Pix already dealt with this:
http://textadventures.co.uk/forum/samples/topic/4rajpgh0ikicac9we2rsiq/thunder-and-lightning-effect
Final code is about half-way down.

K.V.
29 Aug 2017, 02:31Awesome!
You rock, Dcoder!
...and your avatar is pretty bad-ass, as well!
hegemonkhan
29 Aug 2017, 03:18HK forgot about that library/link.... oh well... HK likes to re-invent the wheel (but it usually is an inferior re-invented wheel), laughs

K.V.
29 Aug 2017, 04:02Your code works, HK!
It's just the 1 second delay... I was hoping for a .33 second delay, and I think JS can pull it off.

Dcoder
29 Aug 2017, 07:02...and your avatar is pretty bad-ass, as well!
What, this old thing? Pshaw!