I know how to make text move across screen, however the student is wanting to make the text scroll back and forth. I thought we could do it, however we tried multiple things without any luck. Right now the text is moving to the left across the screen. We tried setting up the if statement to say when the text is < -50 then we want it to move to the right, however it just stops. We tried using and if/else block and then it just bounces back and forth once it gets to the -50 spot. We tried going ahead and setting up two if statements for <-50 and >425 but then the text did not move at all. Any guidance would be greatly appreciated. I included her code.
I would suggest creating a variable called “direction” at the top of your code.
It could start with a value of “left”. Then, when the text reaches the designated leftmost turnaround point , change the variable to equal “right”. Then, use a conditional to control whether the x value is being augmented (when direction == “right”) or decreased (when direction == “left”).
Then, when the text reaches it’s rightmost turnaround point (x > ?), change the direction to “left” again.
This should work and give your student a challenge to implement!
Let us know if they hit any roadblocks!
Mike