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
1 registered members (AbrahamR), 717 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
ANET multiplayer #270925
06/10/09 15:23
06/10/09 15:23
Joined: Dec 2004
Posts: 87
Nederland Tilburg
GarniSoft Offline OP
Junior Member
GarniSoft  Offline OP
Junior Member

Joined: Dec 2004
Posts: 87
Nederland Tilburg
Hello,

Does anyone have an example how i can use ANET for moving entity's from point A (his current location) to point B (target location) with only sending point B (target (mouseclick position)) to all other clients and the server?

I don't want to use the keyboard (arrowkeys) to do this.

I can't get it right!

Please help.

Thanks!


I am a dreamer ... i dream they all come true ...

www is in bewerking
Re: ANET multiplayer [Re: GarniSoft] #270947
06/10/09 17:48
06/10/09 17:48
Joined: Nov 2007
Posts: 1,032
Croatia
croman Offline
Serious User
croman  Offline
Serious User

Joined: Nov 2007
Posts: 1,032
Croatia
can we see your "so far" code?



Ubi bene, ibi Patria.
Re: ANET multiplayer [Re: croman] #271099
06/11/09 09:41
06/11/09 09:41
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
this is not tested, but it might get you started:

Code:



void setNewPos()
{	
if(theEntityPointer != NULL)
{
	theEntityPointer.newPosSet = ON;
	theEntityPointer.newPosX = mouse_pos.x;
	theEntityPointer.newPosY = mouse_pos.y;
}
}


#define newPosSet skill1
#define newPosX skill2
#define newPosY skill3

void theEnt()
{
	var myMoveSpeed = 3;
	
	
	while(enet_ent_globpointer(my) == -1)wait(1);
	
	
	if(enet_ent_clientid() == enet_ent_creator(enet_ent_globpointer(my)))		//this is executed on the client who enet_ent_created the entits
	{
		while(my != NULL)
		{
			if(my.newPosSet == ON)
			{
				newPosSet = OFF;
			enet_send_skills(enet_ent_globpointer(my),1,2,-1);		//sending skills skill2 and skill3 (skills in anet start with 0, not with 1)
			}
			
						vec_diff(temp,vector(my.newPosX,my.newPosY,0),my.x);
			vec_normalize(temp,minv(vec_dist(vector(my.newPosX,my.newPosY,0),my.x),myMoveSpeed*time_step));
			c_move(my,nullvector,temp,IGNORE_PASSABLE);
			
			wait(1);
		}
	}
	else			//and this on all other clients
	{
		while(my != NULL)
		{
			vec_diff(temp,vector(my.newPosX,my.newPosY,0),my.x);
			vec_normalize(temp,minv(vec_dist(vector(my.newPosX,my.newPosY,0),my.x),myMoveSpeed*time_step));
			c_move(my,nullvector,temp,IGNORE_PASSABLE);
			
			wait(1);	
		}
	}	
}


in main:
mouse_mode = 4;
on_mouse_left = setNewPos;


...set up connection
theEntityPointer = enet_ent_create("entity.mdl",nullvector,_str("theEnt"));


the idea is that skills of the entity are set to the position where it should move, and then these skills are sent over to the other clients.
good luck, hope this helps!

Last edited by Germanunkol; 06/11/09 09:42.

~"I never let school interfere with my education"~
-Mark Twain
Re: ANET multiplayer [Re: Germanunkol] #271149
06/11/09 14:39
06/11/09 14:39
Joined: Dec 2004
Posts: 87
Nederland Tilburg
GarniSoft Offline OP
Junior Member
GarniSoft  Offline OP
Junior Member

Joined: Dec 2004
Posts: 87
Nederland Tilburg
Thanks!

I try it your way.


I am a dreamer ... i dream they all come true ...

www is in bewerking
Re: ANET multiplayer [Re: GarniSoft] #271444
06/13/09 08:12
06/13/09 08:12
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
sorry, just noticed that this:
enet_ent_create("entity.mdl",nullvector,_str("theEnt"));
should probably be:
enet_ent_create(_str("entity.mdl"),nullvector,_str("theEnt"));


~"I never let school interfere with my education"~
-Mark Twain
Re: ANET multiplayer [Re: Germanunkol] #272140
06/16/09 18:12
06/16/09 18:12
Joined: Dec 2004
Posts: 87
Nederland Tilburg
GarniSoft Offline OP
Junior Member
GarniSoft  Offline OP
Junior Member

Joined: Dec 2004
Posts: 87
Nederland Tilburg
Hello,

Thanks to you all.

I have it running now, but it stiil needs some tweeking.

When i complete my test project then i place it here.


I am a dreamer ... i dream they all come true ...

www is in bewerking

Moderated by  HeelX, Spirit 

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