205 lines
5.3 KiB
Plaintext
205 lines
5.3 KiB
Plaintext
// ActiveVRML 1.0 ASCII
|
|
|
|
/*****************************************************************************\
|
|
*
|
|
* Library code
|
|
*
|
|
\*****************************************************************************/
|
|
|
|
model = let
|
|
|
|
createBitmap(image, xSize, ySize) = (image, point2Xy(xSize, ySize));
|
|
imageOf(image, size : point2) = image;
|
|
sizeOf(image, size : point2) = size;
|
|
xsizeOf(image, size : point2) = xComponent(size);
|
|
ysizeOf(image, size : point2) = yComponent(size);
|
|
|
|
accumulate(func, value, lst) =
|
|
if empty(lst) then
|
|
value
|
|
else
|
|
accumulate(func, func(head(lst), value), tail(lst));
|
|
|
|
after(endTime) = predicate(time > endTime);
|
|
|
|
interpolate(from : number, to : number, num : number) =
|
|
from + (to - from) * num;
|
|
|
|
interpolateVector2(from : vector2, to : vector2, num) =
|
|
vector2Xy
|
|
(
|
|
interpolate(xComponent(from), xComponent(to), num),
|
|
interpolate(yComponent(from), yComponent(to), num)
|
|
);
|
|
|
|
smooth0to1 = (0.5 - cos (time * pi) / 2) until after(1) => end;
|
|
|
|
in let
|
|
|
|
/*****************************************************************************\
|
|
*
|
|
* The background
|
|
*
|
|
\*****************************************************************************/
|
|
|
|
backBitmap = import("back.gif");
|
|
backImage = imageOf(backBitmap);
|
|
backXSize = xsizeOf(backBitmap);
|
|
backYSize = ysizeOf(backBitmap);
|
|
|
|
/*****************************************************************************\
|
|
*
|
|
* Blinking stars on the background
|
|
*
|
|
\*****************************************************************************/
|
|
|
|
brightBitmap = import("bright.bmp");
|
|
dimBitmap = import("dim.bmp");
|
|
|
|
starImage =
|
|
let
|
|
s0 = imageOf(dimBitmap) until after(1) => function x. s1;
|
|
s1 = imageOf(brightBitmap) until after(0.25) => function x. s0;
|
|
in
|
|
s0;
|
|
|
|
/*****************************************************************************\
|
|
*
|
|
* The title letters
|
|
*
|
|
\*****************************************************************************/
|
|
|
|
titleImage =
|
|
let
|
|
titlePos = vector2Xy(-0.60 * backXSize, 0.9 * backYSize);
|
|
|
|
images =
|
|
[
|
|
first(import("title0.gif")),
|
|
first(import("title1.gif")),
|
|
first(import("title2.gif")),
|
|
first(import("title3.gif")),
|
|
first(import("title4.gif")),
|
|
first(import("title5.gif")),
|
|
first(import("title6.gif")),
|
|
first(import("title7.gif")),
|
|
first(import("title8.gif")),
|
|
first(import("title9.gif"))
|
|
];
|
|
|
|
zoomImage =
|
|
let
|
|
number = smooth0to1;
|
|
in
|
|
transformImage(
|
|
translate(titlePos * number)
|
|
o scale2(number),
|
|
nth(images, 0)
|
|
);
|
|
|
|
glowImage =
|
|
let
|
|
index = sin(time * 2 - pi / 2) * 4.99 + 5;
|
|
in
|
|
nth(images, index);
|
|
|
|
image =
|
|
emptyImage until after(1) => function(x) .
|
|
zoomImage until done => function(x) .
|
|
transformImage(
|
|
translate(titlePos),
|
|
glowImage
|
|
);
|
|
in
|
|
image;
|
|
/*
|
|
zoomInTransform
|
|
*/
|
|
|
|
/*****************************************************************************\
|
|
*
|
|
* Button swoosh animation
|
|
*
|
|
\*****************************************************************************/
|
|
|
|
swooshImage(motionImage, staticImage, xsize, xend, yend, delay) =
|
|
let
|
|
number = time * 4;
|
|
maxSize = (backXSize + xend + xsize) / 2;
|
|
midPoint = (-backXSize + xend + xsize) / 2;
|
|
|
|
stretchIn(number) =
|
|
transformImage(
|
|
translate(
|
|
interpolate(-backXSize, midPoint, number),
|
|
yend
|
|
)
|
|
o scale(number * maxSize / xsize, 1),
|
|
motionImage
|
|
);
|
|
|
|
shrinkIn(number) =
|
|
transformImage(
|
|
translate(
|
|
interpolate(midPoint, xend, number),
|
|
yend
|
|
)
|
|
o scale(
|
|
interpolate(maxSize / xsize, 1, number), 1
|
|
),
|
|
motionImage
|
|
);
|
|
|
|
static =
|
|
transformImage(
|
|
translate(xend, yend),
|
|
staticImage
|
|
);
|
|
|
|
image =
|
|
if (number < 1) then
|
|
stretchIn(number)
|
|
else if (number < 2) then
|
|
shrinkIn(number - 1)
|
|
else
|
|
static;
|
|
|
|
sound = first(import("schwoop.wav"));
|
|
in
|
|
(emptyImage, silence) until after(delay) => function(x) .
|
|
(image, sound);
|
|
|
|
/*****************************************************************************\
|
|
*
|
|
* The buttons
|
|
*
|
|
\*****************************************************************************/
|
|
|
|
tutorialBitmap = import("tbutton.bmp");
|
|
|
|
(tutorialImage, tutorialSound) =
|
|
swooshImage(
|
|
first(import("tutor.gif")),
|
|
first(import("tutor.gif")),
|
|
xComponent(second(import("tutor.gif"))),
|
|
0,
|
|
0,
|
|
3
|
|
);
|
|
|
|
modelSound = tutorialSound;
|
|
|
|
//
|
|
// put it all together
|
|
//
|
|
|
|
modelImage =
|
|
titleImage
|
|
over tutorialImage
|
|
over backImage;
|
|
|
|
model = (modelImage, modelSound, modelSound)
|
|
until leftButtonDown => function(x) . model;
|
|
|
|
in model;
|