C# For Game Development

Started by
9 comments, last by Raghar 18 years, 6 months ago
Dear All, I want to use C# instead of MFC to develop Game Editor because C# is a new technology and C# is more like Object-Oriented. But I still use the Visual C++ to develop my game. Here is my questions: 1. When I develop a Map Editor, it involves DirectX function. Does the C# has a great support for DirectX? 2. Does it common to develop game editor by C#? 3. What do you think for my approach? Thx Michael
Advertisement
C# works great for making the tools used to make games. At my studio we're starting to move all of our tool development in this direction. As to your questions:

1. Yes, C# has good DirectX support. You can use what's called "Managed DirectX" in C#. It's almost identical to the C++ version in most respects, but has a bit nicer syntax in some cases. However, if you want to use the same rendering code as your engine in your editor than you can wrap your engine in Managed C++ and use that in your tools instead.

2. Yes, it's becoming a lot more common.

3. I think it's good =)

-John
- John
Dear John,

Thx your great support!

From Michael
1 - as said before, you can use the managed wrappers directx provides. Note that depending on how fast you need your game to be, you may need to pay more attention at allocating memory - tricks like instantiating stuff in the stack or reusing allocated memory might be necessary to prevent the garbage collector from taking too much time and cause decelerations in the game. Search around, I'm sure you'll find plenty of tricks about it.

2 - Yup
3 - It's probably a good choice, but I'd say more for the reduction in bugs and increased speed of development than for the reasons you gave :) but whatever rocks your boat.

Now, a suggestion - the icon you used makes whoever read your post assume you're angry about something, which will confuse people - I'm sure you'll admit your english isn't perfect, which might make some people wonder exactly what is it that you're trying to say - up to the end of your post I was wondering when you were going to start complaining about something :). So what I'm trying to say is, you probably should pick a symbol that reflects the general attitude of your post, or just use the default post symbol - no use in confusing other people :)
I don't understand why you say C# is more object oriented than MFC. Typically, you use C# with the Windows Forms class library / toolkit, which has a different structure, but I don't understans why you think one is more "OO" than the other. I would understand it if you said you liked the design of WinForms better than MFC, though :-)

You can write tools in C# that call DirectX; most of DirectX is exposed through the managed DirectX layer. You can also import unmanaged assemblies (a k a "dlls") and call them straight from C#, if you want to use game-specific data formats written in C++.
enum Bool { True, False, FileNotFound };
Dear alexmoura,

Thanks your suggestion. Actually, I always make me confuse when starting to develop a game. Therefore, I show the angry icon. But I am not really angry anybody or something. :-)

Anyway, Thanks your suggestion and idea

Michael
I've tried to use .NET to develop a game recently. I second the comment on the garbage collector... My headaches were almost all about the garbage collector. In C++, I have very tight control on my memory. Maybe it's because I'm new to C# (aren't we all right now?), but I feel like memory is totally out of my control in C#. The garbage collector became such a serious hazard that I went back to C++ for game programming. C# would be great for anything except the strictest real-time applications (like games) where a 15ms lag once every several seconds is a very serious problem.

Thumbs up for tools, thumbs down for the actual game, IMHO.



~BenDilts( void );
Dear All,

I have another question but I don't want to create a new thread, I hope you can answer me.

If I want to Load 3D Object from Maya or Max to my map editor, so, what is the steps I need?
Best bet is to write or find an exporter online that can output the model in a format easy for you to load into your program. I'm sure there are exporters for those programs that can output X files. Then use Direct X and MSDN to figure out how to load them. There are probably 100's of tutorials if you check google for how to load X files.
I just went through this exporter issue with c#. I wrote some stuff to import it natively, but then removed that code and decided on another format for natively imnporting the 3d data. http://www.collada.org

If you want to load these other models in C# I would suggest creating a wrapper around the available c++ library to call things with pinvoke in C#. This will be easier and faster, and since you are talking about a tool, those are probably worthy goals. I hope you can learn from my mistake.

This topic is closed to new replies.

Advertisement