Lite-C is coming pretty fast for me. But it seems I am at a stand still. I did look at all of the tutorials, manual, and the AUM for this information. What I am trying to do is to have a mouse click on a model 1. Trigger the mouse clicked event. 2. Find out which house was clicked. 3. Load the appropriate level. Here is my code thus far:
BMAP* cursor = "cursor.tga";
var frame_speed = 0;
STRING* mystring = "You clicked the mouse!";
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)
{
TEXT* myText =
{
pos_x = 300;
pos_y = 250;
string (myString);
flags = 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_selection() // this action is attached to both houses
{
// make the house models sensitive to mouse touching and releasing
my.emask = ENABLE_TOUCH | ENABLE_RELEASE;
my.emask |= ENABLE_CLICK;
my.event = house_event;
}
The lighting and animation on the mouse over event works perfectly. I am trying to test the mouse click with a message. The message is always up even if there were no mouse hover or click events. Which to me is weird. Why would it even execute before the event. This could be because of my background in C# and Java that I am just not getting why this is happening. The events are setup correctly as you can plainly see from the code. I also tried different flags and tried using toggle keyword but still the message is always up.
I also need help finding the correct keyword in Lite-C to get an object (model) from a mouse position. I can find little of this in the manual. I have the express version of 3dgs.
Thanks for your help!