Apr-12-2018, 03:38 AM
I am working on processing version 3.3.6 and I am having trouble simplifying some code. My goal is to have text that types out across the screen like in some video games. I have tried using lists but haven't found a way to get that to work. I would like to retain the exact same effect with more efficient code. My code is as follows:
story = 0 def setup(): size(400, 400) def draw(): #slower framerate to exaggerate what I am trying to do, and make it easier for you guys frameRate(10) #I know resetting the background isn't necessary for this example but it is for a larger project this is a part of background(0) textSize(32) global story #beggining of the ineffecient code that I need help with story = story + 1 if story > 1 : text("t", 10, 30) if story > 2 : text("th", 10, 30) if story > 3 : text("thi", 10, 30) if story > 4 : text("this", 10, 30) if story > 5 : text("this ", 10, 30) if story > 6 : text("this i", 10, 30) if story > 7 : text("this is", 10, 30) if story > 8 : text("this is ", 10, 30) if story > 9 : text("this is a", 10, 30) if story > 10 : text("this is a ", 10, 30) if story > 11 : text("this is a t", 10, 30) if story > 12 : text("this is a te", 10, 30) if story > 13 : text("this is a tes", 10, 30) if story > 14 : text("this is a test", 10, 30) if story > 15 : text("this is a test.", 10, 30) #end of the ineffecient code that I need help withthanks to all who help out!