1 / 36

Art 321 Lecture 7 Dr. J. Parker

Art 321 Lecture 7 Dr. J. Parker. Programming. In order to ‘make things happen’ on a computer, you really have to program it.

Download Presentation

Art 321 Lecture 7 Dr. J. Parker

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Art 321 Lecture 7Dr. J. Parker

  2. Programming • In order to ‘make things happen’ on a computer, you really have to program it. • Programming is not hard and does not require advanced math skills. It does require that you understand how limited a computer really is, and know how to use a particular language to speak to it.

  3. Programming • There are many ways to program a computer. Ones uses a ‘drag and drop’ interface where you click and drag icons into a sequence. Another is to use a scripting language, which is a highly structured way of giving a computer instructions on how to do something.

  4. Programming Computers do not think. (want to discuss this?) They do precisely what you tell them to do. If a computer does something incorrectly, it is caused by either a flaw in the electronics or my a mistake in the program it was given. Mostly the latter.

  5. Programming HTML is a simple programming language, in a sense. It describes how a computer should display a document. We will look at one of the simplest ways to program a computer – using ‘turtle graphics’ and Logo.

  6. Blockly We are going to use a drop and drop coding system created by Google, called blockly. http://code.google.com/p/blockly/

  7. Programming

  8. Programming The ‘turtle graphics’ concept has a pen (carried by a turtle, one supposes) move along a paper. One can go forward, back, turn left and right, Lift and drop the pen, change colour, and so on. We select an action using the mouse and place it in the window, then click on ‘run program’.

  9. Programming

  10. Programming

  11. Programming

  12. Programming

  13. Programming

  14. Programming

  15. The Abstract Explanation A variable is a name (IE a symbol) that represents some value, usually a numeric value. The name is often indicative of the nature of the value – so the variable score represents a value that is also called a “score” in English. This is a coincidence; the game score could just as easily be kept in a variable called “fred”.

  16. The Engineering Explanation The variable is another name for the address in memory where the value is kept. The programming language takes the name that it sees and replaces it with a memory address. So score = 12 becomes memory[10020] = 12 Where 10020 is the address of score.

  17. A variable is a place to put something; it’s the name of that place. The Common Sense Explanation

  18. What can we do with variables? We can save things for later. We can add to them, accumulate values. EG • How many enemies have we shot? • How much fuel do we have left? • Where is my ‘ball’ object? We can test it against sentinal/target values. • Am I out of fuel (is fuel = 0)? • Am I near to a water hole (distance < 20)?

  19. Programming

  20. Draw a set of lines

  21. Draw a square.

  22. Draw a square.

  23. Draw a triangle

  24. Draw a triangle

  25. Draw a collection of triangles

  26. Draw a collection of triangles

  27. Results are often surprising

  28. Random positions …

  29. Repeat many times – select a random place each time from which to begin.

  30. Details of the ‘loop’

  31. Concept of ‘procedure’ ‘a bunch of things you want to do that has a name’. Here, ‘triangle’ is a procedure.

  32. Now ‘reposition’ is a procedure too. It places the turtle at a new random point.

  33. The new program draws a triangle and then repositions, 100 times.

  34. Draw Change colors – RGB values can be set.

  35. Assignment 1. Draw a "+" figure 150 units high by 150 units wide. 2. Draw the letter 'W'. (Bonus marks: draw the word "WHY" 3. draw 5 parallel horizontal lines 400 units long separated by 25 units. 4. Use turtle graphics to draw a sequence of squares (100 units per side) that have a common lower left corner, but are each drawn at a different angle. There should be at least 10 squares in the sequence. 5. Draw a set of 9 squares in a 3x3 arrangement. Draw one in each of the colours: black, yellow, green, red, blue, purple, grey, orange, and a colour of your choosing. 6. Draw a circle.

More Related