2D WPF Game, what are my options? - c#

what would be my options if i would like to create a 2D action game in WPF(for the ease of building UI Layout) without having noticeable performance loss? The game should'nt have heavy physics calculations.
I did create XNA game in the past, and i know about the MonoGame project, but i am still unsure how to use WPF as a host for MonoGame and i didnt find a downloadable example of MonoGame in WPF.
Beside MonoGame, what will be the other options, if any?
Thanks in advance!

Have a look at SlimDX, both 3D and 2D are supported.
The tutorials have examples on integrating with WPF.

You could take a look at Nick Gravelyn's article which renders XNA inside of a WPF application. I believe MonoGame's API is very similar, if not identical, to XNA, so it shouldn't be a huge problem fixing any porting issues.
http://blogs.msdn.com/b/nicgrave/archive/2010/07/25/rendering-with-xna-framework-4-0-inside-of-a-wpf-application.aspx
or
http://www.jfmajor.com/post/38447851593/monogame-in-wpf
I do remember reading somewhere that a team attempting to render WPF controls over XNA/MonoGame (I forget which) did encounter some perf issues.
I think the approach taken by many (from what I've seen) is not to use WPF for rendering a UI and instead build the UI as part of the game/engine. WPF/WinForms can be used to build an editor, but again I believe the rendering of the game/world is embedded within a WPF/WinForms application using a UserControl similar to the articles mentioned above.

Related

Is it possible to port a WPF 3D app to UWP / UAP

I wrote an WPF app using all the 3D stuff of WPF which contains several Views displaying 3D data. IMHO WPF is not the platform for further development of the app so I am searching for some ways to port it to a Universal App/Windows Store App/UWP.
The way, Microsoft is promoting, is to use Unity meaning a complete redevelopment and complicated workflows because it should be a 2D-App with some 3D views.
The other way I was looking at way using Helix-Toolkit, because it does not just offer the WPF-way of displaying 3D but also the DirectX way using SharpDX. Unfortunately the progress concerning UWP is pretty low and not currently usable in the extend I need (like displaying custom geometries etc.).
Is anybody out there who got the same problem and found a workaround?
TY!
You may also like to consider Monogame. Like Helix-Toolkit it's based on SharpDX (when it's on Windows anyway). It's not quite as "componentised" as Helix-Toolkit but it's possible to make your app UWP-first and Monogame-second.

Graphics and Animation in C#

I created a Game in C# (Multi-player Tanks Game) using Windows Forms Tools (Panels, shapes, buttons, etc...) but the Animation and Graphics are just so poor, so is there any Type of simple Graphics or Animation to use in C# to make this game a little better, can I use flash in C#, anything?!!!
XNA is great, its a completely different technology to Windows Forms as its based on DirectX.
Another idea is to check out silverlight or WPF depending on how complex your game is. For simple 2D games with not too busy screens it might be a lot easier than XNA.
I found a great example of building a multiplayer game in WPF.
I would recommend having a look at Microsoft XNA.
I'm pretty sure if you want to improve the graphics of your game you're going to have to use design software or hire someone to do it for you. A simple look up on Google will direct you to model development software.
A good place to start is the microsoft XNA framework.
I also recommend using Blender: http://www.blender.org/
It's a completely free open source 3D model creation program.
There are many librarys and ways for game development in C#.
I prefer to use XNA, which is based on DirectX and developed by Microsoft itself.
But there are also many other wrapper like OpenGL wrapper SharpGL, a custom DirectX wrapper SlimDX or using the plain DirectX SDK.
Some time ago I was looking for libraries or frameworks to improve winforms experience with nice animations. My best options were XNA or OpenTK (OpenGL) and SDL.Net.

Buidling an XNA tile editor

I'm writing a tile editor for a game and would like to be able to select which level file to open. Once open I would load the level into an XNA window and click to add/remove tiles to the level. When the editing is finished I would save the file layout back to the original file.
Currently I don't see a way to integrate windows forms and XNA. Is this even possible?
When I was working on a small, "2.5D" isometric game in XNA, I found it worth while to also have a separate WinForms version that would just render a 2D top-down view using GDI. This was due to my inexperience with XNA and my (relative) comfort using WinForms.
This approach also had the useful side-effect of enforcing separation between logic and rendering code. It made it easier (for me, at least) to test changes without having to worry about how to deal with the XNA rendering aspects.
It may not be exactly what you had in mind, but it might be something to consider.
WinForms and Xna can cooperate, but it's not recommended to use Xna's built in Game class with WinFroms. There are two samples demonstrating it:
http://xbox.create.msdn.com/en-US/education/catalog/sample/winforms_series_1
http://xbox.create.msdn.com/en-US/education/catalog/sample/winforms_series_2

How to use XNA in WPF?

So... I want to make a game, and I want to write it in C#. In the past, I've made a mario clone using C++ and OpenGL. I quite like OpenGL, but I don't know how well it's supported inside C#/WPF. Also, it might be beneficial to use an actual game library? I guess XNA is the game library for C#, so maybe I'll invest a bit of time learning that.
However, I want to use WPF form controls for my level editor... is there any way that I can embed an XNA (DirectX?) window inside a WPF app?
Specifically, I don't need any buttons or things inside the XNA/DirectX widget, just around it, so no mixing required...just need to get a graphics widget in my WPF form.
Nick Gravelyn explains how to do it on his blog.
Although, if it's just for an editor, you may find using WinForms is easier and better supported.
First of all, you should ask this on gamedev.stackexchange.com. But I've seen a tutorial embedding XNA.
You should check this question and this page. They are on Windows Forms, but they'll help.
Also check this and this articles.
Keep in mind one thing. XNA is meant to be used for the whole game, integration would be useful on making level editors like you say, but not for a full game.
WPF uses DirectX, and you can do direct "interop" here is a codeProject article on the subject. Here is an article i dug up where the author is using win-forms and WPF controls in an XNA project. Might be worth a look for you.

What to use for C# SlimDX Game UI

I am currently developing a 3d game using C#/SlimDX (The target is Direct3D 9). I've been looking for a suitable Game UI toolkit for a while, but I was unable to make up my mind.
The Game UI will be for a roleplaying game, so it'll be fairly complex and will involve quite a few controls (text boxes, inventory grids, list boxes, select boxes, scrollable areas, etc.).
I previously (When i was still using C++/OpenGL) looked at GameSWF and very much liked the idea, but for my current game it's out of the question.
Does anyone know a good GUI toolkit for use with SlimDX?
I would be especially interested in using WPF/Silverlight for this, since there are good IDEs available for both. But a quick google search didn't reveal any information on embedding these.
You can use WPF (but not Silverlight) for this.
The way to go about this is to use SlimDX in conjunction with D3DImage. You then let WPF handle all of your final composition, including overlaying the WPF UI over the top of your SlimDX scene.
SlimDX basically just renders to a brush in this situation, which can be used on any WPF element. (This doesn't work for Silverlight, as Sliverlight doesn't support D3DImage.)

Categories

Resources