We are going to skip the boring theory and head over to where the action happens immediately - functions. BOOM!
Head over to this url, and enter rectangle(20, 20, 40, 40);
below the line that says so. Now click on run...
Great! You've written your first program! And you can show it to someone, you can even pretend it's abstract art by adding another rectangle()
with numbers other than 20, 20, 40, 40. Go ahead and try that!
What you have done in fancy computer language is you 'called a function'. Functions have many definitions, but typically they do something (usefull). In this instance the function drew a black square on the screen. The four numbers that follows the function are called parameters. The first two are the x and the y position and the next two are the width and the height. See if you can figure out how they change the shape of the square and move it around.
Not all functions take the same parameters, for instance, try this circle(20, 20, 40);
. You should now see a circle on your screen. Now the artist in you can go crazy!
That's it for today, who said learning to code takes long? Click on 'Update', wrap the URL up in some nice text and let the world (your friends (actually only those who still reads your updates)) know that you can code!!
Oh, and come back next week, cities don't get built out of black rectangles and circles!
Mmm, you're still reading. So you want a challenge do you? Well, wield your keyboard and make a city with more buildings! Don't let them touch each other (or do) and line them up at the bottom (or don't). Grap a screenshot and share it somewhere (like twitter) tagged #learn2code.