|
|
mouse problems...
#240469
12/11/08 05:00
12/11/08 05:00
|
Joined: Dec 2008
Posts: 528 Wagga, Australia
the_mehmaster
OP
User
|
OP
User
Joined: Dec 2008
Posts: 528
Wagga, Australia
|
hi everyone, i wrote the following(long) peice of code, and it worked fine. so i saved it and turned off the computer. When i turned the computer back on and compiled and ran the program after making some minor adjustments(of which i cant remember) the mouse had disappeared and i couldnt click on anything!
what the program is ment to do: -when i put the mouse in the corners of the screen, the camera moves.(this works fine) -when i click on a 'node' its meant to light up, if i click on the other node, the previous one will turn off, and the new one will light up. if i click on the ground, both turn off(this USED to work) -i should be able to see the mouse!(i used to be able to) any help is greatly appreciated. code:
function mouse_event() { while(1) { if(player == me) my.ambient = 1000; else my.ambient = 0; if (event_type == EVENT_CLICK) { player = me; } wait(1); } } function mouse_eventg() { while(1) { if (event_type == EVENT_CLICK) { player = NULL; } wait(1); } } action ground() { my.emask |= ENABLE_CLICK; my.event = mouse_eventg; } action node() { my.emask |= ENABLE_CLICK; my.event = mouse_event;
while(1) { wait(1); } } function main() { video_mode = 6; video_screen = 1; mouse_mode = 2; level_load (""); ent_create("object.mdl",vector(0,0,0),ground); ent_create("node.mdl",vector(10,0,0),node); ent_create("node.mdl",vector(0,0,0),node); camera.pan = 270; camera.tilt = -59; camera.roll = 0; camera.x = 0; camera.y = 0; camera.z = 23; while(1) { //vec_set(mouse_pos,mouse_cursor); if(mouse_cursor.x > (screen_size.x-10))camera.x -= 3*time_step; if(mouse_cursor.x < 10)camera.x += 3*time_step; if(mouse_cursor.y > (screen_size.y-10))camera.y += 3*time_step; if(mouse_cursor.y < 10)camera.y -= 3*time_step; wait(1); } } end code bye, many thanks.
|
|
|
Re: mouse problems...
[Re: the_mehmaster]
#240482
12/11/08 07:43
12/11/08 07:43
|
Joined: Jul 2002
Posts: 4,436 Germany, Luebeck
Xarthor
Expert
|
Expert
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
|
I'm asking myself why it worked in the first place, but anyway, I simplified your program based up on your description what it should do and removed thoses while loops out of the event functions. Remember: An event function is called when an event is triggered, thus if an event once was triggered there is a infinite while loop running. That means that each event will create such a while loop. Here is my version (excluding your main which looks fine), not tested, no guarantee that it will work:
function mouse_event()
{
if(event_type == EVENT_CLICK)
{
if(player) { player.ambient = 0; }
player = my;
my.ambient = 1000;
}
}
function mouse_eventg()
{
if(event_type == EVENT_CLICK)
{
player.ambient = 0;
player = NULL;
}
}
action ground()
{
my.emask |= ENABLE_CLICK;
my.event = mouse_eventg;
}
action node()
{
my.emask |= ENABLE_CLICK;
my.event = mouse_event;
while(1)
{
wait(1);
}
}
ps: please use the [ code ] ... [ /code ] tags (without the spacing) in the future to embed your code
|
|
|
Re: mouse problems...
[Re: Xarthor]
#240717
12/12/08 02:21
12/12/08 02:21
|
Joined: Dec 2008
Posts: 528 Wagga, Australia
the_mehmaster
OP
User
|
OP
User
Joined: Dec 2008
Posts: 528
Wagga, Australia
|
hey, thanks for your time (very much so) but i got the problem fixed. turns out i had to load a custom mouse bitmap to make it work in full screen. Those while loops inside the events are supposed to be there(i finished them this morning, they have terminating structures in them now, thanks anyway) ill just test that code thingie cool i have like the messiest code ever (after all, i am 13) i am working on a sort of strategy game at the moment. thanks for your help, the_mehmaster
|
|
|
|