Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Ayumi, 1 invisible), 584 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
select an entity with the mouse #306287
01/20/10 23:23
01/20/10 23:23
Joined: Jan 2010
Posts: 44
Galati, Romania
CItrok Offline OP
Newbie
CItrok  Offline OP
Newbie

Joined: Jan 2010
Posts: 44
Galati, Romania
I need to select entities with the mouse. (for this exercise I need to display a message when selecting a entity, When I select an entity it is displayed "you clicked entity Nr.1! "

Anybody can suggest me? Thanks a lot.

Re: select an entity with the mouse [Re: CItrok] #306291
01/21/10 00:00
01/21/10 00:00
Joined: Jul 2009
Posts: 16
E
episch Offline
Newbie
episch  Offline
Newbie
E

Joined: Jul 2009
Posts: 16
try to usw de EVENT_CLICK ,EVENT_TOUCH events.
here is an example:


function click_event()
{
if(event_type == EVENT_CLICK)
{
show massage
}

action model()
{
my.emask |= ENABLE_CLICK;
my.event = click_event;
}

i hope i can help you

Re: select an entity with the mouse [Re: episch] #306351
01/21/10 11:37
01/21/10 11:37
Joined: Jan 2010
Posts: 44
Galati, Romania
CItrok Offline OP
Newbie
CItrok  Offline OP
Newbie

Joined: Jan 2010
Posts: 44
Galati, Romania
episch, thank you very much for your help. Unfortunately, I haven't succeeded.

Is not working by no means. WHAT is wrong in my code?

I uploaded the entire project files. I also let the code concerning with the joystick navigation, in order to assure this is not the problem.

I tried to modify "mouse_range" with differents values. The some thing, is not working.

http://uploading.com/files/bf432aa3/mouse_press.zip (you will have to wait about 50 seconds to download the zip archive )

Bellow is the code

#include <acknex.h>
#include <default.c>


STRING* aloha_str = "You clicked on earth!";

TEXT* greetings_txt =
{
pos_x = 300;
pos_y = 250;

string (aloha_str);
flags = SHOW;
}

function click_event()
{
if(event_type == EVENT_CLICK)
{
set(greetings_txt, SHOW);
}
}

action planet_act()
{

my.emask |= ENABLE_CLICK;
// my.enable_click = on;
my.event = click_event;
}


function main()
{
level_load("small.hmp");
ent_create("earth.mdl", vector(80, 80, 20), planet_act);
video_mode = 9;
mouse_range=400;
reset(greetings_txt, SHOW);
while(1)
{
camera.y -= joy_force.x;
camera.x += joy_force.y;
if (joy_4)camera.pan+=0.3;
if (joy_5)camera.pan-=0.3;
if (joy_1) camera.z += 1;
if (joy_2) camera.z -= 1;

if (joy_1 && joy_2)
{
camera.x = 0;
camera.y = 0;
camera.z = 0;
}
wait(1);
}


}



Thank you guys.

Re: select an entity with the mouse [Re: CItrok] #306362
01/21/10 13:14
01/21/10 13:14
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
You have to activate the gamestudio mouse by setting mouse_mode = 1 or 2, set mouse_pos and mouse_map (there is an example in the manual).
mouse_range=400; is a short range, btw.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: select an entity with the mouse [Re: Superku] #306395
01/21/10 20:37
01/21/10 20:37
Joined: Jan 2010
Posts: 44
Galati, Romania
CItrok Offline OP
Newbie
CItrok  Offline OP
Newbie

Joined: Jan 2010
Posts: 44
Galati, Romania
thanks for the tip, Superku. I also added mouse_
pos.x = mouse_cursor.x; // allow the mouse pointer to move
mouse_pos.y = mouse_cursor.y; as you may see in the corrected code bellow:

So the code bellow is working...



#include <acknex.h>
#include <default.c>


STRING* aloha_str = "You clicked on earth!";

TEXT* greetings_txt =
{
pos_x = 300;
pos_y = 250;

string (aloha_str);
flags = SHOW;
}

function click_event()
{
if(event_type == EVENT_CLICK)
{
set(greetings_txt, SHOW);
}
}

action planet_act()
{

my.emask |= ENABLE_CLICK;
// my.enable_click = on;
my.event = click_event;
}


function main()
{
level_load("small.hmp");
ent_create("earth.mdl", vector(80, 80, 20), planet_act);
video_mode = 9;

mouse_mode = 2;

reset(greetings_txt, SHOW);
while(1)
{
camera.y -= joy_force.x;
camera.x += joy_force.y;
if (joy_4)camera.pan+=0.3;
if (joy_5)camera.pan-=0.3;
if (joy_1) camera.z += 1;
if (joy_2) camera.z -= 1;

if (joy_1 && joy_2)
{
camera.x = 0;
camera.y = 0;
camera.z = 0;
}

mouse_pos.x = mouse_cursor.x; // allow the mouse pointer to move
mouse_pos.y = mouse_cursor.y;


wait(1);
}


}


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