Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Quad, 1 invisible), 721 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 3 of 3 1 2 3
Re: Real Programmers... [Re: mpdeveloper_B] #318673
04/09/10 06:27
04/09/10 06:27
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
I go even a step further.

Taking the code example above (not intended as criticism, only to have some work basis):

Why is it one time health, and then is it HP?
For me there is only one base name, and if I choose health for it, then my other variable would be var vOldHealth.
I would drop newHP completely, as it only reads the entity value one time and is used directly afterwards.
Also I would use a less generic function name, like checkSkinChangeOnHit().

Re: Real Programmers... [Re: FBL] #318674
04/09/10 06:33
04/09/10 06:33
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
Okay, code striptease laugh

Code:
void STATEMGR_execute(STATEMGR* psState)
{
	/* check whether atate machine is ready */
	if (	(LIST_items(psState->psActions) > 0) && (LIST_items(psState->psTransitions) > 0) )
	{
		/* first check, if transition has to be done */
		STATEMGR__checkTransitions(psState);

		/* now execute cyclic action callback */
		if (psState->pfAction != NULL)
		{
			STATEMGR__pfCallback = psState->pfAction;
			STATEMGR__pfCallback();
		}
	}
}


An interface function of my state handler module.

The corresponding header file part looks like this:
Code:
/*! Execute cyclical actions and transition checks for State Machine.
 *  Must be called cyclically.
 *  \param	psState Pointer to affected STATEMGR
 */
void STATEMGR_execute(STATEMGR* psState);



The generated manual page:
http://firoball.de/stuff/toolbox_manual/state_8h.html#b420c531bd0c72348b153df19f7fd5b3

Re: Real Programmers... [Re: FBL] #318741
04/09/10 14:00
04/09/10 14:00
Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
T
TWO Offline

Serious User
TWO  Offline

Serious User
T

Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
This is nice and ok in C. You provide doxy info how to use the function and in addition you comment scopes and important calls. In C++ function names would be much easier to read and as such the function wouldn't need this much inner commenting.

Edit:
Here a not-so-clean example of my code; Criticism welcome.
http://awake.svn.sourceforge.net/viewvc/awake/trunk/AwakeEngine/AwakeMain/include/AwEngine.h
http://awake.svn.sourceforge.net/viewvc/awake/trunk/AwakeEngine/AwakeMain/src/AwEngine.cpp

Last edited by TWO; 04/09/10 14:09.
Re: Real Programmers... [Re: TWO] #318892
04/10/10 17:06
04/10/10 17:06
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline
Expert
mpdeveloper_B  Offline
Expert

Joined: Feb 2006
Posts: 2,185
I also use prefabs, I used to not do them, but when I learned how much of a time saver they were I started doing them. Generally If I would give that out to the public, I would do what you did, give a readme.

Of course, this still proves I don't comment alot lol grin
I'm a butt-end of the joke.

Last edited by mpdeveloper_B; 04/10/10 17:06.

- aka Manslayer101
Page 3 of 3 1 2 3

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