Metro App with 2D Graphics in C# - 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.

Related

How to use libcinder with c#?

I recently came across libcinder which seems to be promising for creative coding.
It's for c++ but I'm more familiar with c#. Is there a way to use libcinder with c#?
Or maybe in c# world, there is some other collection of libraries / framework for the same purpose?
The first thing I'd like to try is to open an image then draw lines/rectangles on it, the second thing in my list is to open a live video and then draw some thing on the video. Is it the best choice to use cinder or should I just use OpenCV with c++/c#?
What libcinder feature are you looking for in "C# World". Many of the features listed on that link are already available in C# (.NET) since 2005-2008.
Example things that C#/.NET can do (same as libcinder):
Standalone Apps
Internet I/O
Platform Specific API's (PInvoke)
Xml & JSON Parsers
Full I/O Stuff
UI Events
Multi Touch
Communication API's
3D & 2D Graphics
Multimedia

Do games like Starcraft 2 use Windows Forms to build their UI?

This may be a dumb question...
When I log into Starcraft 2 and see that beautiful UI, I can't help but wonder if it's designed using Windows Forms (.Net or C#). Is the login box just some kind of Windows dialog or do they do their own thing - whatever that may be?
Is it possible to get that much customization within Windows Forms?
No. Games and other apps that use DirectX to take control of the video device don't use WinForms or even the Win32 API for screen output.
StarCraft 2 most likely implements its own windowing and UI system, completely independent of the Windows API or WinForms library.
Yes, you can write an app in C# to perform similar DirectX graphics output, but using DirectX is not as simple as working with WinForms. I wouldn't recommend attempting to write a DirectX app as a way to teach yourself C# unless you are already very experienced with DirectX through other languages or tools (C++, mostly).
WinForms is fine for learning C# and whatever IDE tool chain you choose to use. After you're comfortable with C# patterns and terminology, then tackle learning how to write DirectX code with C#.
No. They use DirectX. DirectX bypasses normal windows and operates at alower level.
You can customize a form to a great degree. You have full control over painting it to look however you want.

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.

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.

Control Camera Device From C#

I am now facing one problem which to get the live image from Camera (eg. Sony, Canon) into winform and also control the camera capture button from a button in the form.
have Anyone build something like this, or are there any similar project like this which is done in C#?
This hardly depends on the capabilities of the camera and its driver. Your biggest chance might be the Windows Image Acquisition (WIA) framework.
Take a look at this article or the MSDN reference.
Emgu cv is a project that provides all the bindings for OpenCV. I've used it on both Windows and Linux platforms (Mono) with great success.
http://emgu.com/
http://emgu.com/wiki/index.php/Camera_Capture_in_7_lines_of_code
You can also take a look on Intel OpenCV.
It's C++, but you can use use PInvoke to use it from c#
This project supports even high-end PTZ camera. Code Project - Versatile WebCam C# library.
It uses Touchless.Vision and WebCamLib

Categories

Resources