Typewriter Effect Text
-
@Juggalo_Jesus OK understood. There is nothing built-in but it shouldn't be too hard to write a function to do this.
-
@pianofire I am going to try my hand at it soon I was just wondering if anyone had figured it out before I spend my time on trying to figure it out.
-
It's really just a case of setting a "cached" variable and ticking it upwards every x frame. I've not done this specifically but I guess it's similar enough to other things I've written. Something like;
frame_count = 0 string = "Really looking forward to playing Steve's Missile Command game" tick = 0 loop clear() printat(0, 0, string[:tick]) if frame_count % 20 == 0 then // Or however you want to do it? // This would (hopefully) just cycle it round to zero again // but you'd obviously continue on rather than pause here. tick = (tick + 1) % len(str) endif update() frame_count += 1 repeat
Obviously that's completely untested!
-
what is the colon before "tick" for?
printAt(0, 0, string[:tick])
Also, what and how is % used?
Thankyou!
-
Okay, I just tested it and meh ~ use this instead;
frame_count = 0 string = "Really looking forward to playing Steve's Missile Command game" tick = 0 proceed = false while !proceed loop clear() printat(0, 0, string[:tick]) if frame_count % 20 == 0 then tick += 1 if tick == len(string) then proceed = true endif endif update() frame_count += 1 repeat
It was close enough :)
edit: See https://fuzearena.com/forum/topic/70/hints-and-tips/9
-
@lawyerlounge Have a look at this post to see how you can slice up strings using : https://fuzearena.com/forum/topic/70/hints-and-tips/9
% is the modulus operator which basically returns the remainder when you divide by the number see https://fuzearena.com/help/view/modulus
-
Oop! Thanks, I missed the question about the
%
! The good thing about doing it by frame skipping, is that you can then also add controls in there too, and justor
a button press which would speed up the "typing". -
Ok neat I think I understand now. The modulo operation is used to only run this loop when frame_count is a number divisible by 20 with no remainder. so it will print a new letter every 20 frames? so you could even have a button press to have frame_count += 10 to speed up the text.
Also when you have
Loop
clear()
update()
repeat
how many times does that run per second, is it 60fps? -
@pobtastic Thank you for this!
-
The above (% on the number of frames) is how I've always done this kind of thing, but I think this might be the first instance where I might be tempted to try and use a timer instead?
-
How about this?
string message = "Really looking forward to playing Steve's Missile Command game" tick = 0 speed = 0.25 // Call function 'doTick' every 'speed' seconds, indefinitely tickTimer = setTimer(speed, -1, doTick()) loop clear() printat(0, 0, message[:tick]) update() repeat function doTick() tick += 1 if (tick >= len(message)) then tick = 0 endif return void
Nearly always lots of ways to approach the same thing. Usually all just as valid.
-
Thanks for that, I just ..borrowed it..