I like a short challenge
Here is my entry, I'd love to see somebody make an improved algorithm for setting the fizz/buzz/fizzbuzz/number.
No cheating, create your own before checking mine. I have documented for the benefit of beginners.
SetScreenResolution(1200,800)
SetVirtualResolution(1200,800)
SetSyncRate(0,1)
//Allow 3 text entities, with an attached tween chain
global txt as integer[2,1]
//store current text entity
global curText as integer
// Array for tweens
global tween as integer[1]
//initialise text entities
for i = 0 to 2
txt[i,0] = CreateText("")
txt[i,1] = CreateTweenChain()
next i
//initialise tweens
tween[0] = CreateTweenText(0.5)
tween[1] = CreateTweenText(2)
SetTweenTextAlpha(tween[0],0,255,TweenEaseIn2())
tween[1] = CreateTweenText(1)
SetTweenTextAlpha(tween[1],255,0,TweenEaseIn2())
time# = timer() + 1
i = 1
//Loop 100 times
while i < 101
//only advance once every second
if timer() > time#
//mod() gives a result of 0 if divisible
f = mod(i,3) : b = mod(i,5)
//number
if f >0 and b > 0
SetTextString(txt[curText,0], str(i))
else
//divisible by 3 (Fizz)
if f = 0 and b > 0
SetTextString(txt[curText,0], "FIZZ")
else
//divisible by 5 (buzz)
if f > 0 and b = 0
SetTextString(txt[curText,0], "BUZZ")
else
//divisible by 3 and 5
SetTextString(txt[curText,0], "FIZZBUZZ")
endif
endif
endif
//create a randomly sized, randomnly coloured, randomly positioned text string with fade in/out
SetTextSize(txt[curText,0], random(80,120))
SetTextColor(txt[curText,0], random(128,255), random(128,255), random(128,255), random(128,212))
SetTextPosition(txt[curText,0], random(getVirtualWidth() * 0.25, getVirtualWidth() * 0.75), random(getVirtualHeight() * 0.25, getVirtualHeight() * 0.75))
ClearTweenChain(txt[curText,1])
AddTweenChainText(txt[curText,1],tween[0],txt[curText,0],0)
AddTweenChainText(txt[curText,1],tween[1],txt[curText,0],0)
PlayTweenChain(txt[curText,1])
inc time#, 1
inc i, 1
inc curText,1
if curText = 3 then curText = 0
endif
UpdateAllTweens(GetFrameTime())
sync()
endwhile
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt