Sign in to follow this  
lordimmortal2

A Specific Question About Windows Form

Recommended Posts

This probably is too specific of a question but how would you create a game level designer? Specifically like Hammer for the Source engine or Doombuilder for Doom. I'm not looking to create anything as complex as Hammer (just something that's usable for a classic tile-based RPG) but I'm still quite confused as to how you convert a C++ graphical engine into C# for the Windows form.

That's really where the heart of my confusion lies. I understand how to place objects from the toolbox and how to add events and such but I'm kinda confused about how to jump from that into a full-blown level designer. Maybe it's too big of a jump.

Any and all replies are appreciated as always. Links to other tutorials are great as well.

Share this post


Link to post
Share on other sites
[quote]
[color=#1C2837][size=2]how you convert a C++ graphical engine into C# for the Windows form.[/size][/color]

[/quote]
Hmmm, what do you mean by this...

Maybe I'm missing something but I think the way to go in this case is to have the forms application generate a file that the game engine can use to create a level.
In other words, the file must contain information about everything for the level.

Not sure I understand the problem though...

Share this post


Link to post
Share on other sites
What i like to do when using a high level language is to use low level c++ dll(s) so i code the interface in Delphi (or c#) and encapsulate the more complex tasks in the dll. It might take a bit longer to code, but this way you have the better of both worlds. All you need to do is pass the handle of the window you want to draw onto in your Initialize function and, with a bit of tweaking, it should work.

Share this post


Link to post
Share on other sites
The thing you want to look into is for c# DllImport attribute.

[url="http://msdn.microsoft.com/en-us/library/aa984739%28v=vs.71%29.aspx"]http://msdn.microsof...v=vs.71%29.aspx[/url]

I have only done this a few times myself and the declarations are not easy at all

[code][DllImport("Advapi32.dll", EntryPoint="GetUserName", ExactSpelling=false,
SetLastError=true)]
static extern bool GetUserName(
[MarshalAs(UnmanagedType.LPArray)] byte[] lpBuffer,
[MarshalAs(UnmanagedType.LPArray)] Int32[] nSize );[/code]

Hope that puts you on the right track.

I'd rather suggest you take a look at XNA It's pretty cool to work with as all those tasks have already been done.

Share this post


Link to post
Share on other sites
Thanks for all the replies!

[quote]
Hmmm, what do you mean by this...

Maybe I'm missing something but I think the way to go in this case is to have the forms application generate a file that the game engine can use to create a level.
In other words, the file must contain information about everything for the level.

Not sure I understand the problem though... [/quote]

Level editors generally use the entirety, or a simplified version of, the graphical engine they're trying to represent. So you can test your game in the level editor without having to switch around to a different app and use commands and such. My graphical engine is coded in C++ so how would I implement that into the C# environment of a Windows Form?

[quote]What i like to do when using a high level language is to use low level c++ dll(s) so i code the interface in Delphi (or c#) and encapsulate the more complex tasks in the dll. It might take a bit longer to code, but this way you have the better of both worlds. All you need to do is pass the handle of the window you want to draw onto in your Initialize function and, with a bit of tweaking, it should work.[/quote]

Could you elaborate on this? Sorry, I understand C++ fairly well but am still a beginner and I haven't really messed around with anything else beyond just coding in C++ when it comes to building applications =P.
[quote]
The thing you want to look into is for c# DllImport attribute.

[url="http://msdn.microsoft.com/en-us/library/aa984739%28v=vs.71%29.aspx"]http://msdn.microsof...v=vs.71%29.aspx[/url]

I have only done this a few times myself and the declarations are not easy at all

[DllImport("Advapi32.dll", EntryPoint="GetUserName", ExactSpelling=false,
SetLastError=true)]
static extern bool GetUserName(
[MarshalAs(UnmanagedType.LPArray)] byte[] lpBuffer,
[MarshalAs(UnmanagedType.LPArray)] Int32[] nSize );

Hope that puts you on the right track.

I'd rather suggest you take a look at XNA It's pretty cool to work with as all those tasks have already been done.[/quote]
Could you elaborate as well? The link you showed me seemed to be from only calling unmanaged code in managed code. As above, I don't really know about this either as I haven't had much experience with the different between the two and such but it doesn't really seem to help unless I'm missing something. So if I am, please prove me wrong =P.

Share this post


Link to post
Share on other sites
[quote]
[color=#1C2837][size=2]Level editors generally use the entirety, or a simplified version of, the graphical engine they're trying to represent. So you can test your game in the level editor without having to switch around to a different app and use commands and such. My graphical engine is coded in C++ so how would I implement that into the C# environment of a Windows Form?[/size][/color]

[/quote]

Right. Since you said this
[quote]
[color=#1C2837][size=2]I'm not looking to create anything as complex as Hammer (just something that's usable for a classic tile-based RPG)[/size][/color]
[/quote]
I wasn't sure if you were actually looking at binding your C++ engine to C#, something I find to be a relatively advanced thing to do.
I'll leave it to the other guys to help you with that then [img]http://public.gamedev.net/public/style_emoticons/default/dry.gif[/img]

Share this post


Link to post
Share on other sites
Do some reseach on dlls, with them, you can use unmanaged c++ code for example, in your c# project, making them ideal for your kind of project since you don't have to rewrite all the directx or opengl code in c#. Basically, a dll export functions(they don't have to, but most of them do), those function can then be called in other languages, once linked to your application. The thing is you can't export class or other fancy stuff in other languages directly(well you can export class in delphi using a trick, but it's fairly advanced), you have to create a bunch of function for your c# application to call, but you can do whatever you want from there.

For exmaple you could create a dll that export those functions:

InitDirectX(HWND hRendererWindow);
CleanupDirectX();

RenderScene();

LoadModel(char *filename);
FreeModel();

ect...

Then in your program, you call them exactly like you declared them in the dll, and the program will execute the c++ code in the dll inside your c# application.

That's just an example, you can do pretty much whatever you want this way.

I've made an example of a dll that export 1 function that add 2 integers and return the value, using some template code i had, here it is
[url="http://www.freewebs.com/vortex666/Dll.zip"]http://www.freewebs....rtex666/Dll.zip[/url]

The .def file is needed so the exported function name dosen't get "decorated" (like you see in a linker error for example).

That's how i've made this little unfinished project [url="http://www.freewebs.com/vortex666/Cube%20Not%20Indexed.jpg"]http://www.freewebs....t%20Indexed.jpg[/url] , only the interface is coded in delphi, all the 3d stuff are stored in a single dll that manage all the important code.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this