|
Today I did Functions. They are used to make blocks of code usable multiple times. To create a function, we make a variable for it ex var makesquare =function(){ }; then we put code in the {} ex var makesquare = function() {rect(200,200,10,10);}; now all we have to do is type makesquare(); and it make the square and we make it so we can change the postion by in function making the x and y into variables that we determined. ex var makesquare = function(Posx,PosY){rect(200,200,10,10);}; now typing makesquare(250,204); will change the postion and u can the other ones too. Next Ill be learning logic and if statements. |