The Official Raspberry Pi Projects Book - Projects_Book_v4

(singke) #1
>STEP-03
Add the push buttons
Right-click and select a push button. Resize it to 45 by
45, place it at 60, 148, and make it yellow. Click on the
copy and paste icons and set the x position to be 210.
Repeat this for x equals 360. Repeat this, move it to
60, 380 and make it red. Again, copy this and make
three more buttons at x equals 210, 360, and 510. Paste
again, change it to orange and place at 726, 109. Make
four more copies at the same x position, but with y
positions of 189, 269, 349, and 429. Check the controls
have the addresses shown in the picture. You will need
to click on each control in turn to see this information.

>STEP-04
Transfer the layout to the tablet
Finally, create labels for each element. The Wolf and
Red Riding Hood should have a size 25 font. Save the
layout, then open OSC on your tablet. Go to the layouts
page and click on Add. Then click on the Pi, and click
on the green Sync icon. You will see the Raspberry Pi
appear on your tablet. Click on this name to download
the layout, then click Stop Sync on the Pi. Go back to
the configure page on the tablet and click Done to see
your layout and try it out. If the devices don't see each
other on the network, try power-cycling your router.

Tutorial


raspberrypi.org/magpi The Official Raspberry Pi Projects Book 145


Figure 2 Removing the wife with the clone tool


DIY CUT-OUT THEATRE


/1/push1 /1/push2 /1/push3

/1/push4 /1/push5 /1/push6 /1/push7

/1/push8

/1/push9

/1/push10

/1/push11

/1/push12

/1/fader2

/1/fader3

/1/fader1

Range -240 to 900

Range -240 to 900

Range 0 to -580

of unnecessary drawings when nothing has changed.
The Setup function defines the ports used for the OSC
messages and loads in all the individual images. By
far the longest function is oscEvent, which handles
the incoming messages. This looks in turn at the two
active control elements, push buttons and faders. The
push buttons work as toggle buttons for the props
and background by sending back a confirmation of
the push, and fixing the colour of the button. This
shows you that a message has got through, because
occasionally OSC messages, like all slip-formatted
messages, can go astray. The actors’ costume buttons
are implemented as radio buttons, so you can’t have
more then one selected at a time. The controls for the
faders simply pass on their value to the appropriate
variable. This is all that is needed because the range of
the fader has been defined in the TouchOSC setup.
When the program first starts, the curtain is closed.
A message is sent to the tablet to move the faders to
reflect this. The initial elements for the first scene are
also set up. There are a few other small functions that
help with the parsing.


Taking it further
You can set up another play with your own characters,
and once you see how it works, change the controller
to cope with more variables. However, be careful not
to make the control too cluttered. You could use some
controls to trigger sound effects or animations, like
the curtain automatically rising, or a prop falling over.
You can replace the slider controls for the actors with a
small XY pad for flying objects, or to put a bit of bounce
into a walk. You could replace the single graphic of
an actor with a sequence to show things like walking.
Finally, you can add special effects, like lightning
or a character dissolving in a teleporter.


A B

Free download pdf