Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
4 registered members (AndrewAMD, fogman, Grant, juanex), 972 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
mouse problems... #240469
12/11/08 05:00
12/11/08 05:00
Joined: Dec 2008
Posts: 528
Wagga, Australia
the_mehmaster Offline OP
User
the_mehmaster  Offline 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 Offline
Expert
Xarthor  Offline
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:
Code:
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 Offline OP
User
the_mehmaster  Offline 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
Code:
hullo
world

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


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1