Jump to content
  • Advertisement
Sign in to follow this  
Morley

[C#] Converting a smidge of Code

This topic is 2537 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to convert the following bit of code to try and visualize what this kind of 2D bone system might look like in C#, and, frankly, I'm new to C++ and I really dont understand what a bit of it is doing.


struct _Bone *child[MAX_CHCOUNT], /*Pointers to children */
*parent; /*Parent bone*/




[font="monospace,"]the bit i'm having trouble with here is this part of the code that can be found here under the 2D section:
[/font][font="Arial"]how do i create children of an object in the way it is doing, like it does here. Again,[/font] [font="Arial"]the link to this tut can be found here[/font]

[font="Arial"]Thanks in advance![/font]

Share this post


Link to post
Share on other sites
Advertisement
That code would be the same, were it written like so...
struct _Bone *child[MAX_CHCOUNT]; /*Pointers to children */
struct _Bone *parent; /*Parent bone*/

If that helps any.

Share this post


Link to post
Share on other sites
You have an array of size MAX_CHCOUNT which holds pointers to _Bone structs, plus a single pointer to a _Bone which is the "parent."

In C#, you would likely implement this very similarly, except using a class instead of a struct, because in C# structs are moved around by value whereas classes are handled by reference. (In a nutshell, the way to get pointer-like semantics in C# is to use a reference type.) So:

Bone children[16]; // or whatever constant suits you, don't know what MAX_CHCOUNT would be
Bone parent;


:-)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!