How to make games with WPF or Silverlight? - c#

How do I make games in WPF and in C#? Is there a document in PDF format that explains this?

You could read the articles posted on Silverlight Games 101, as a starting point.
That being said, it's more just learning how to write games. Using WPF/Silverlight is just one way to render your game - but writing the game is pretty much going to require all of the same skills as using other platforms.

Google this name. The title of the book is "3D Game Development with Microsoft Silverlight 3: Beginner's Guide".

There is a 2D (sprite based) port of the XNA framework to Silverlight called SilverSprite The same tutorials that work for XNA work for this library.

Using WPF to create games is not recommended. You should consider using cocos2d, unity or another similar framework.
If you really have to use WPF, you can see an example here => mini wpf game

Related

2D WPF Game, what are my options?

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.

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.

C# ASCII based game

I'm trying to dip my toe into game programming, C# is the language I'm most comfortable with and what I want to use.
I've purchased a book and it's very good with the basic concepts but it's using GDI, bitmaps and sprites. I'm no artist and I'd like to concentrate on game play rather than eye candy, I'm more than happy with 'Dwarf Fortress' style of presentation.
DF doesn't seem to be a Console app (to my untrained eye). My question is can I access this 'graphic mode' from C# and if so how? Any tips links tutorials would be very helpful and appreciated.
Writing a 2D game in C# is actually very simple. Try with XNA. A simple tutorial that got me started with 2D was this...
http://create.msdn.com/en-US/education/tutorial/2dgame/getting_started
It basically covers a simple 2D side scroller but what you get from the tutorial will be useful in your DF like game. It requires you to create some graphics but like you said, those graphics need not be fancy. Drawing simple sprites will be easy enough.
Console games are a great way to enter the game making business or hobby, once you are very comfortable with c#, try to go to xna or unity. Xna is not being developed anymore and I don't find it very pleasant and prefer unity over it, but many people differ from me so please try it out for yourself. Unity is a 2D and 3D game engine wit a free and paid version. It can be complicated at first but very well made. You can develop in c# and many more languages with unity and it is a lot more flexible than xna.

Metro App with 2D Graphics in C#

I have done some looking and I can't figure out a good way to write a 2D tile/sprite based game in C# for Win8. According to the MSDN documentation:
You can use managed code languages like C# and Visual Basic to develop 2D (and lightweight 3D) games.
The problem is that I can't figure out how to do this. The reason I would like to use C# is because I already have a lot of code written for Windows Phone that I would like to reuse.
Can anyone point me to how I would write a fairly efficient 2D tile/sprite MetroUI game for Win8? The only thing I can find uses C++ and DirectX.
[EDIT]
To clarify I do not care too much what I use (WinRT, DirectX...) so long as I can submit to the app store, and write my code in C#.
If you are familiar with the DirectX API, you can use SharpDX available via http://sharpdx.org. It is basically exposing DirectX APIs into C#. From my understanding, if you are going to upload apps to the store, the SharpDX should be fine and pass compliance, but I would look into it further before going too deep.
Also, as of this time, not all of the features are available (like Direct2d not fully certified for Win8 Metro).
If your game uses simple graphics, you can use Drawing Library for Modern UI, it exposes a GDI+ like interface to be used in XAML/C#/VB.NET Windows 8 Modern UI applications, it works by drawing to a XAML Canvas.
If you're looking for something quick and easy check out the "Physics Helper XAML" project;
http://physicshelperxaml.codeplex.com/
It's based on the farseer engine, and comes with sample apps. There are a few games already released using it.
http://www.andybeaulieu.com/Home/tabid/67/EntryID/223/Default.aspx
Have a look at:
[XAML images sample] (http://code.msdn.microsoft.com/windowsapps/0f5d56ae-5e57-48e1-9cd9-993115b027b9/sourcecode?fileId=102748&pathId=677969581)
The page and samples give some code for NineGrid and WriteableBitmap Image manipulation.
You can now use Win2D (open source, released by Microsoft for metro/WinRT apps) which provides hardware-accelerated 2D graphics rendering.

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.

Categories

Resources