Sunteți pe pagina 1din 2

Task Sheet 1: First Steps

Please note:
The following tasks will require Processing installed on your computer. Please do that
prior to working on the tasks. Dont worry if you dont understand the programs on this
sheet. It isnt required.
Task 1: Processing Examples
Open and run at least ! Processing examples from the Basics folder. Look at the code of
each of them. Dont worry if you dont understand it, just go through it with an open
mind.
Write down which similarities you can detect in the code structure of the examples youve
opened. Any conclusions you can draw from your observations?
Task 2: Counting with Fingers
How far can you count with the five fingers of one of your hands if
you have " fingers
each number is represented by a unique finger combination
you start counting at zero
in each step you increment your count by #
Hint: think of your finger configurations as states representing numbers.
Justify your answer.
Task 3: Numbers
Create a new Processing Script (File->New) and write down the following code:

println(1);
println(2);

Try the following:
a) Run the program and see what happens
b) Now extend the program to print the numbers #-#$
c) Can you do the same for #-#$$ or even #-#$$$?
Game Development I

d) To print only the odd numbers in the range #-#$$, how would you approach that?
(You dont have to program it)
e) How would you approach the problem, if the requirement is to only print prime
numbers between #-#$$? (You dont have to program it)

Task 4: Shapes
Create a new Processing Script and write the following lines:

size(200,200);
ellipse(56, 46, 55, 55);

a) Run the script and see what happens.
b) Can you find out what the numbers in brackets mean? Experiment and describe
your findings.
c) Use the Processing help page (Help->Reference) to look it up. Was your finding
correct?
d) Now extend the program to draw an additional square, right next to the circle. Use
the help page again. (Hint: a square is a rectangle with equal sides).
e) When changing the numbers in brackets playing around with the shape sizes and
positions it is quite cumbersome to type in values, start the sketch, stop the sketch,
and then again change the values. Can you think of a way to simplify this process
by changing all the parameters in one area of the code? Provide an example code.
f) Assume you want the circle and square to always have a fixed size (no changes) and
be at the same position relative to each other. Only the absolute position of the
circle shall be changeable. How could you make it more comfortable for yourself to
run tests with different positions of the shapes? Provide an example program.

Task 5: Shape-o-mania
Create a new Processing Script and use the shape commands from the former task to draw
a rectangle of a fixed size on a window with width %$$ and height %$$.

a) Now use the help page to draw the same rectangle with different border and fill
colors.
b) Assume you want to re-use the code for drawing the colored rectangle with any
color combination for border and fill color. Are there any mechanisms to make the
shape drawing code general for arbitrary colors and re-usable at any place in your
code? Provide an example code.
c) Also make the position of your rectangle redefinable, but not its size.
d) With you new superpowers to draw arbitrary colored rectangles at any given
position, draw a "x! matrix of these rectangles with a fixed spacing between rows
and columns.
e) Extend the code to draw an arbitrary NxM matrix of these rectangles, with N and M
being integer numbers. Can you again make the code generic and re-usable for any
values N and M? Provide an example code.

S-ar putea să vă placă și