1 registered members (TipmyPip),
679
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: TUST or "The community library"
[Re: PadMalcom]
#422556
05/12/13 18:25
05/12/13 18:25
|
Joined: Nov 2007
Posts: 2,568 Germany, BW, Stuttgart
MasterQ32
OP
Expert
|
OP
Expert
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
|
I've updated the documentation and started on a camera controller (a little lie the old from A6 times ) @OT: My programming mood is back, yay!
|
|
|
Re: TUST or "The community library"
[Re: MasterQ32]
#422705
05/15/13 10:30
05/15/13 10:30
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
Serious User
|
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
hi, I have been out of my hobbies for a while, but in the meanwhile I wrote a little system that works as a global state machines collection manager. I was wondering if it could fit on tust or it is reinventing the wheel xP DOWNLOAD I wrote it translucent for the user, where he has only to start the system, add new state machines and close the system at the end. All the added machines will run automatically. It can manage any object pointer as machine holder (same concept as 'me' pointer in entity actions) and it is function pointer based. It executes functions with the state machine passed as first paremeter, where the state of any machine can be changed.
void stateHappy ( STMACHINE *stm )
{
ENTITY *ent = stm_me ( stm );
ENTITY *entFriend = stm_me ( stm_by_index ( stm_index ( friends_index ) ) );
if ( entFriend->happyness > 50 )
ent->happyness += time_step;
else
ent->happyness -= time_step * 0.5;
if ( ent->happyness < 50 )
stm_set_state ( stm, stateWretch, 0 );
if ( ent->happyness > 80 )
stm_set_state ( stm, stateSmiling, 0 );
}
In order to avoid any state change preference between machines I aded a system that ensures that every machine executes its actual function before been changed by another machine. It can be used for automate almost eveything and the resultant coding style is normally quite clean and readable. Look into main.c to see it by yourself. What do you think about this? Is it usefull?
|
|
|
Re: TUST or "The community library"
[Re: PadMalcom]
#422735
05/15/13 21:08
05/15/13 21:08
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
Serious User
|
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
It is a state machines manager. It does what a state machine does: run a different script depending on a state. These state machines are usually contained in a switch case block inside the entity action. A function pointer based state machine avoids the need of this switch case, so does not matter the states amount of the machine. Each machine runs its state function straight. In the worst case, imagine the performance lost with a state machine with a hundred of different states running its last state inside a switch case. And then multiply it by a hundred state machines. Mainly, the benefit of this code is that you can run function pointer based state machines without having any knowledge about what a pointer to a function is. Furthermore you get the benefit (not really big but necessary in some cases) of that next frame change that avoids the inherent advantage of the execution order. It has also the minor benefit of executing all the machines from a single array pass inside a single while loop. And the big benefit of been objects of any data type, not just entities. The machines do not need an object at all but there it is for its convenience. This is not originally developed for tust but a code structure I usually write converted (with tust in mind) to an user friendly extension that I will certainly customize for my future projects
|
|
|
Re: TUST or "The community library"
[Re: MasterQ32]
#423067
05/23/13 16:45
05/23/13 16:45
|
Joined: Nov 2011
Posts: 274 de
lemming
Member
|
Member
Joined: Nov 2011
Posts: 274
de
|
In case you plan any further network programming, I'm currently working on a network-library wrapper as a side-project.
It's intended to cover basic network commands in ANet, GSTNet and AckNet (or whatever the internal network lib is called) like - client/server connection (already working for ANet/GSTNet) - events and messages (already working for ANet/GSTNet) - create entities (already working for ANet)
You choose the lib you want to use by a define. It is NOT MEANT to cover everything the different libs provide. But to be enough for a simple tutorial chat or shooter. (Or more if you only use the message-event system.)
I thought this might be useful (and it has already prooven useful to me) if you want to switch the network engine for whatever reason.
At the moment it needs to be cleaned up and is very incomplete. The whole Acknet part is impossible for me anyway, because I have the Extra Edition. Right now I have no time to work on it. Maybe after the AckCon again.
If you want it, PM me, or tell me here to add it to TUST.
Last edited by lemming; 05/23/13 16:46.
|
|
|
|