I was tinkering around with this code, from @Ignatz (I don’t know who he is… but I love this guy) the only tutorial, thus far that has awakened me and as slow as I am, I leave his guide with understanding
Anyways… this is his tutorial I am following:
@Ignatz is teaching us noobs how to get Codea to re-draw a line every 60 frames a second (animated line). This is beyond cool, he breaks it down block by block. Again, I have to say it, this teaching style is amazing. I truly want to send monetary contribution to this guy via paypal. He’s making me smarter!
I wanted to tinker with the line starting point, in regards to the negative Y Axis (-Y Axis), with the sole purpose of attaining some insight with the code., no rhyme or reason, other than to glean and understand how to manipulate code in Codea.
Here is Where I Think I Understand What’s Going On, But Not Quite Sure If I Do Get It
In Function Draw() There is a code block in this tutorial, that states if the WIDTH is greater than the variable x=0 (x>WIDTH) then the animated line calls the value declared in the Function Draw(), which for the tutorial is zero.
I thinks I understand that part… But this one, concerning the variable - throws me off a little.
At the Function Setup() x is declared as a variable with the value zero.
For tinkering, I changed it to 300 to see what would happen. When I hit the play button, the negative y axis portion of the line (the swinging pendulum) started off in the center. (Yay! I did some manipulation)
But after, the line reached the far right of the screen, it would follow the IF and THEN statement made in the Draw() block. Here’s the confusion, I think. The line would start off at the far left of the negative Y Axis. Because the x value set to zero at the Draw() code block section.
*Soo, my question here is…
Are the variable values that do matter or get called, are the ones in the Draw() NOT the ones in the Setup()?
In other words, declaring a variable in Setup(), really means… “Hey simple Human, X is a variable of value zero” but that doesn’t really matter, because Setup() is only used to declare a variable.
where it really matters, is over at the Draw() setup, it is here, where changing the values matter and will be re-drawn every time, not at the Setup().
Am I explaining this correctly?
Am I comprehending the abstract idea correctly here?
-- Use this function to perform your initial setup function setup() displayMode(FULLSCREEN) -- Are establishing you want to see the play screen in full screen mode with the console view tucked off to the side. print("Hello World!") -- You know what this is -> don't be stupid! print(WIDTH,HEIGHT) -- You are establishing, you'd like to know the width & height of the display, and would like it presented in the console via the print command. x=300 -- You are establishing, x variable equals zero end -- This function gets called once every frame function draw() -- This sets a dark background color background(40, 40, 50) -- This sets the line thickness strokeWidth(15) -- Do your drawing here line(x,80,400,500) --[[ You are establishing you want a line drawn via the line command. You are establishing you want the line transformed to the exact specific values placed in the x,y grid. ]] x=x+3 -- Learned-> +<Increment> and <Numerical> equals the speed at which the line is being re-rendered <animated>. if x>WIDTH then x=300 end end