ENTITY* houseOne;
ENTITY* houseTwo;
BMAP* cursor = "cursor.tga";
var frame_speed = 0;
STRING* myString_One = "You clicked on house one!";
STRING* myString_Two = "You click on house two!";
TEXT* myText_One =
{
pos_x = 300;
pos_y = 250;
string (myString_One);
}
TEXT* myText_Two =
{
pos_x = 300;
pos_y = 250;
string (myString_Two);
}
function main()
{
video_mode = 9;
video_screen = 1;
level_load ("level1.wmb");
mouse_mode += 1;
mouse_map = cursor;
while (1)
{
mouse_pos.x = mouse_cursor.x;
mouse_pos.y = mouse_cursor.y;
wait (1);
}
}
function house_event()
{
if (event_type == EVENT_TOUCH) // the house was touched?
{
my.ambient = 50; // make it look bright
my.lightrange = 50; // and generate light on a radius of 50 quants!
while (frame_speed <= 101)
{
ent_animate(my, "Move", frame_speed, ANM_CYCLE);
frame_speed += 8 * time_step;
wait(1);
}
frame_speed = 0;
}
if (event_type == EVENT_CLICK)
{
if (houseOne == me)
{
toggle(myText_One, SHOW);
}
else
{
if (houseTwo == me)
{
toggle(myText_Two, SHOW);
}
}
}
else // the house isn't touched anymore
{
if (event_type == EVENT_RELEASE) // the mouse was moved away from it?
{
my.ambient = 0; // then restore its initial ambient value (zero)
my.lightrange = 0; // and stop it from generating light around it
}
}
}
action house_one_selection() // this action is attached to both houses
{
// make the house models sensitive to mouse touching and releasing
houseOne = me;
my.emask = ENABLE_TOUCH | ENABLE_RELEASE | ENABLE_CLICK;
my.event = house_event;
}
action house_two_selection() // this action is attached to both houses
{
// make the house models sensitive to mouse touching and releasing
houseTwo = me;
my.emask = ENABLE_TOUCH | ENABLE_RELEASE | ENABLE_CLICK;
my.event = house_event;
}