Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Art 321 Lecture 7 Dr. J. Parker. Programming In order to ‘make things happen’ on a computer, you really have to program it. Programming is not hard and."— Presentation transcript:

1 Art 321 Lecture 7 Dr. 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 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

11

12

13

14

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 The Common Sense Explanation A variable is a place to put something; it’s the name of that place.

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

21 Draw a set of lines

22 Draw a square.

23

24 Draw a triangle

25

26 Draw a collection of triangles

27

28 Results are often surprising

29 Random positions …

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

31 Details of the ‘loop’

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

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

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

35 Draw Change colors – RGB values can be set.

36 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.


Download ppt "Art 321 Lecture 7 Dr. J. Parker. Programming In order to ‘make things happen’ on a computer, you really have to program it. Programming is not hard and."

Similar presentations


Ads by Google