This little tutorial shows you how to create your own slide show in ten easy steps. Try to understand every step that is taken here and you will soon be able to create your own scripts.
The following things are required for this tutorial:
BG.png
with two arrows. Rectangle embracing arrow 1 is
X: 4, Y: 430, W: 35, H: 19. Rectangle embracing arrow 2 is X: 591, Y: 430, W: 35, H: 19.
The area where the pictures are displayed is at coordinates X: 29, Y: 41.
0.jpg
, 1.jpg
, 2.jpg
... 10.jpg
of size 571x377 pixels
MyMusic.mod
Of course I have prepared all these things for this tutorial. They are in your Hollywood directory under Help/Tutorial. Please copy those files to the directory where you will create your script. Then follow these steps:
BG.png
as the first background picture. This is done by specifying
the preprocessor command @BGPIC together with BG.png
. So you
have to write the following code now in your script file:
@BGPIC 1, "BG.png" |
This command tells Hollywood to use BG.png
as the initial background
picture. The initial background picture must always have the
identifier 1. If there is no background picture with the identifier 1,
Hollywood will create a blank display.
MyMusic.mod
. So we add the following
line to our script:
@MUSIC 1, "MyMusic.mod" |
MakeButton(1, #SIMPLEBUTTON, 4, 430, 35, 19, {OnMouseUp = p_Back}) |
We can do the same now with the right arrow which is in a rectangle starting at 591:430 with the same dimensions as arrow 1. So we write the following keyword in our script:
MakeButton(2, #SIMPLEBUTTON, 591, 430, 35, 19, {OnMouseUp = p_Forward}) |
Now we have defined two buttons that can be clicked. If button 1
gets clicked Hollywood will call the function p_Back()
, and if button
2 gets clicked Hollywood will call the function p_Forward()
.
MyMusic.mod
as the music object with number 1,
we now call PlayMusic() with argument 1. Add the following line to
your script and Hollywood will play your Protracker module:
PlayMusic(1) |
We also need to define which picture shall be the last one. In our
example we will have 11 pictures ranging from 0.jpg
to 10.jpg
,
so the last picture is number 10. Therefore we add the following line
to our script:
lastpic = 10 |
We also add the following line because our first pic is 0.jpg
:
pic = 0 |
p_NextPic()
. You will see in
point 10 how to write this routine. Let us pretend that it was already
there and therefore we will now say that Hollywood shall execute
this routine:
p_NextPic() |
Repeat WaitEvent Forever |
The command WaitEvent() holds the script execution until an event
occurs, e.g. a button is pressed. If an event occurs WaitEvent()
will jump to the function that handles this event, e.g. if button 1
is clicked, WaitEvent() will jump to the function p_Back()
. When the
function has finished its action, it jumps back in our main loop and
WaitEvent() gets called again. This is repeated until the user closes
the window.
p_Back()
which is called by WaitEvent()
when button 1 (backward button) was pressed and p_Forward()
which is
called by WaitEvent() when button 2 (forward button) was pressed. It
is important that you define the functions before you reference them.
Thus, you need to add the following code before the calls to MakeButton()
which you added in step 5. So let's add the functions for the buttons now:
Function p_Back() If pic =0 pic = lastpic Else pic = pic - 1 EndIf p_NextPic() EndFunction Function p_Forward() If pic = lastpic pic = 0 Else pic = pic + 1 EndIf p_NextPic() EndFunction |
As you can see in the above code, the variable pic
contains the actual
picture number. If the user clicks the forward button, pic
is increased
by one, if the backward button is clicked it is decreased by one. The
variable is also checked against 0 and lastpic
so that it always stays
in the range of our pictures.
p_NextPic()
which shall
load and display the picture with the number that is stored in the
variable pic
. Here is the code. Remember to insert this code before the
calls to MakeButton().
Function p_NextPic() LoadBrush(1, pic .. ".jpg") DisplayBrush(1, 29, 41) EndFunction |
So what does the routine p_NextPic()
do? It simply adds the ".jpg" extension
to the variable pic
and after that it loads the file and displays the brush
at coordinates 29:41. So the pictures must be named like this 0.jpg
(first pic), 1.jpg
(second pic), 2.jpg
(third pic) and so on.
Altogether our script looks now like this:
@BGPIC 1, "BG.png" @MUSIC 1, "MyMusic.mod" Function p_NextPic() LoadBrush(1, pic .. ".jpg") DisplayBrush(1, 29, 41) EndFunction Function p_Back() If pic =0 pic = lastpic Else pic = pic - 1 EndIf p_NextPic() EndFunction Function p_Forward() If pic = lastpic pic = 0 Else pic = pic + 1 EndIf p_NextPic() EndFunction MakeButton(1, #SIMPLEBUTTON, 4, 430, 35, 19, {OnMouseUp = p_Back}) MakeButton(2, #SIMPLEBUTTON, 591, 430, 35, 19, {OnMouseUp = p_Forward}) PlayMusic(1) lastpic = 10 pic = 0 p_NextPic() Repeat WaitEvent Forever |
Now you can save your script and start it through the Hollywood GUI or from the console. Congratulations, you have just created your first Hollywood script! Wasn't that easy? Only 35 lines of code!
Now you can go and extend it if you want. For example, if you want that the picture gets displayed with a transition effect just replace the line
DisplayBrush(1, 29, 41) |
with the line
DisplayBrushFX(1, 29, 41, #RANDOMEFFECT) |
and your picture will appear with a nice transition effect from Hollywood's wide palette of transition effects.