View previous topic :: View next topic |
Author |
Message |
bane
Joined: 01 May 2007 Posts: 41 Location: Pancevo, Serbia
|
Posted: Sat May 05, 2007 10:21 am Post subject: A game networking lib for Yage |
|
|
Regarding http://dsource.org/forums//viewtopic.php?t=2699&sid=6dbc5d419c27ee3bb82b72648120f341
i think this deserves a separate topic.
I started working on low level UDP lib for games.
Its low layer's job is to fix 2 probles with sending byte streams over udp:
1. packet loss
2. unordered receiving of packets
Low level layer can be used alone in any project. It uses (for starters) Phobos so it will be portable. It will have no-charge-for-any-type-of-project open source licence.
Until dsource provides me a space for this (project name is classified for now ), i'll discuss stuff here about api. _________________ "I apologize only for my spelling" - a quote shamelessly stolen from some guy at unknown forum. |
|
Back to top |
|
|
bane
Joined: 01 May 2007 Posts: 41 Location: Pancevo, Serbia
|
Posted: Sat May 05, 2007 2:43 pm Post subject: |
|
|
Does this api for high level replication looks understandable?
Gimme your sugestions and ideas.
Code: |
Server s;
if (!s.create("", 3333)){
writefln("Server not up!");
return 1;
}
// first we must register some object classes with their properties
// we do not specify what are types of properties, only names as strings
// registration can happen before or during process, on both server and client side
// same goes with all other operations here
s.registerClass("car", ["model", "position", "speed"]);
// adds object of some class. each object has unique id (int) for its class
// after adding object, we set values on its properties
Object a;
a = s.addObject("car");
a.setString("model", "Ford");
a.setVector("position", vector(0,33,12));
a.setFloat("speed", 33.4);
// add next object
a = s.addObject("car");
a.setString("model", "Mazda");
a.setVector("position", vector(3,44,11));
a.setFloat("speed", 12);
// loop trough all objects of class "car"
foreach(Object x; s.getObjects("car")){
writefln("Car id is %d", x.getId());
writefln("Model is %s", x.getString("model"));
writefln("Position of car is %s", x.getVector("position").toString());
writefln("Speed %f", x.getFloat("speed"));
// note that it is programmers job to watch out for property type
// do not call something like x.getFloat("model")
// becouse "model" property is string, not float
// replicator stores all properties like void*, it doesnt knows type
}
// get car with id 22, if it exists
a = s.getObject("car", 22);
// or you can delete it, too...
s.deleteObject("car", 22);
// other way of deleting it
s.deleteObject(a);
// main loop
while(1){
// now we change some property value during process
// lets increase a speed on each loop. it will get really fast soon!
a = s.getObject("car", 11);
float old_speed = a.getFloat("speed");
a.setFloat("speed", old_speed + 10);
// it is with this call that changes are transmited / received
// after this call, all other clients and server will have same data
s.update();
}
|
Client side would be allmost same except initialization part that is
Code: |
Client c;
if (!c.connect("", 3333)){
writefln("Could not connect to server!");
return 1;
}
|
_________________ "I apologize only for my spelling" - a quote shamelessly stolen from some guy at unknown forum. |
|
Back to top |
|
|
JoeCoder
Joined: 29 Oct 2005 Posts: 294
|
Posted: Sat May 05, 2007 8:56 pm Post subject: |
|
|
I'm not one to speak since I have no experience with game networking libraries, but that setup makes sense, and I think it's something that Yage could use and build on top of. Contact me on AIM, Yahoo IM, etc. if you'd like to talk about it some more.
It may be a few weeks or more before I have time to work on Yage again though. I've been working on a side-project to try to get that whole passive-income thing working, which would hopefully mean more time for yage in the long run. It's always a gamble of course. |
|
Back to top |
|
|
bane
Joined: 01 May 2007 Posts: 41 Location: Pancevo, Serbia
|
Posted: Mon May 07, 2007 2:51 am Post subject: |
|
|
You are more than qualified to talk about api being a developer yourself. Knowing network stuff is mostly needed for guys making implementation based on api.
dsource kindly provided me with space, so
network lib is can be found here http://dsource.org/projects/dnet and forum is, off course, here http://dsource.org/forums/viewforum.php?f=138
And it is called DNet. Who could have guessed? _________________ "I apologize only for my spelling" - a quote shamelessly stolen from some guy at unknown forum. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|