introduction to programming - class 10
TRANSCRIPT
Introduction to ProgrammingClass 10 and Quiz 1
Paul Brebner
What next?
• Revision quiz (at end)
• Chapter 7 Text Book
• Canon game extensions
• Next week Chapter 8 (Functions)
Chapter 7, Motion
• frameRate– Maximum, may be slower
• Ex 7.3 moving a shape– Uses float variables (decimal) for slow speed
– Whoops – where does it go?
• Ex 7.4 Wrap around– What happens when you reach the edge of the
screen?
– One option is wrapping around (pretend the left and right edges are connected).
Bounce
• Another option is to change the direction of the object
– Ex 7.5
– Uses a new variable, direction, to keep track of which way the object is facing
• Other options?
– Could scale (zoom) the screen size?
– Could move the screen so it follows the object?
Tweening, Random
• Tweening– Moving an object smoothly from one location to another– Inbetweening generates intermediate images to trick the
brain– Have a look at: Fantasmagorie (1908 film) on wikipedia– Ex 7.6
• Random– Motion in the real world is “idiosyncratic” (chaotic)– The random() function gives random values
• Ex 7.7, 7.8, 7.9• Results will be different each time program is run• If you want them the same, set the start seed value with
randomSeed() function
Circular
• Sine and Cosine functions (used in Canon game)
• http://en.wikipedia.org/wiki/Sine– Look at animation “Relation to the unit circle”
– Ex 7.12-7.15
• Summary– You can load examples from
• File -> Examples -> Books -> Getting Started -> Chapter07
– Try exercises 7.1-7.15• Excluding Timer (7.10)
Quiz 1
1 My name is:
2 Colossus, the 1st programmable computer, was 70 years old recently. Did it work with:
A Valves
B Transistors
C Relays
3 A typical Bank computer from the 1970’s was programmed using:
A Mind control
B Levers
C Punch cards
4 A typical home built computer from 1979 had how much RAM memory?
A 256 Bytes
B 1M Bytes
C 1G Bytes
5 Which of the following is NOT part of basic computer architecture?
A CPU
B Registers
C Taxi
D Bus
6 “Processing” is a high level graphics language: True or False
7 “Processing” runs on top of Java. In this case what does “Java” stand for?
A Indonesian Island
B Coffee
C A portable high level programming language.
8 In Processing, shapes drawn later are drawn over the top of earlier shapes – True
of False?
9 In the Processing RGB colour model, what colour does color(255, 0, 255) make?
A Orange
B Yellow
C Purple
10 Do all the following expressions produce the same answer? True of False
x = x + 1; x += 1; x++;
11 What does the following print out?
int number = 1;
while (number <= 10)
{
println(number);
if (number == 5)
println(“Once I caught a fish alive”);
else if (number == 10)
println(“Then I let it go again (etc)”);
number++;
}
12 Circle all the bugs you can find:
char numberr;
if (number < 10)
// {
println(“number”);
if (number == 5);
printl(Once I caught a fish alive)
elseif (number == 10)
println(Then I let it go again (etc));
number = 1;
}