BlockLeftTop, PRELOAD BlockLeftBottom, PRELOAD BlockLeftStretch, PRELOAD BlockTop, PRELOAD BlockBottom, PRELOAD BlockStretch, PRELOAD BlockRightTop, PRELOAD BlockRightBottom, PRELOAD BlockRightStretch, PRELOAD

Writing games on different platforms

by Marcel Friedrichs 2. November 2009 21:14

In the last few weeks i was reading many articles about writing games on different platforms.
Each platform has their own frameworks, restrictions and so on. As C# is my main programming language i want to talk a bit about writing C# games on multiple platforms.
- Windows – one of the most established platforms is and will be windows with DirectX. Since XNA is out creating games for windows is easy as pie and everything is based on C#.

- XBox 360 – Same as windows this platform can be programmed with XNA and C#. So very simple. Problem for hobby developers is that you need a Creators Club Premium Membership to test your games on the Xbox.

- Linux – now a very unusual gaming platform but very easy to program! Using the mono framework C# code can be run on unix based systems e.g. Linux or Mac. For OpenGL graphics we can use the OpenTK framework which runs very well with mono.

- Zune/Zune HD – a very new platform is the microsoft zune. But it’s also easy cause XNA supports this platform as well.

- iPod Touch/iPhone – these are not that easy but important cause the apps you can buy on the internet are selling very well. The problem is that apps for these two platforms are normally written in objective-c and it’s more ugly than c++ in comparison to C#. Cause of this a new framework came up called MonoTouch. Okay this makes it possible to run C# code on the iPhone and you also get a special version of OpenTK with it but it only compiles on Mac. That makes it very hard to create and build your games on windows. You can write a little tool which sends the code to another tool on the mac which compiles it and sends it back but this is very time consuming and ugly. Hope there will be an other way soon! In addition you must be aware of that OpenTK for iPhone and MonoTouch is very new so many stuff is still missing.

Not tested:
I never tested this but i was reading about it that you can run C# games on Wii and Android with mono as well. Hope i can test this sometimes in the future.

Interesting links:
- C# on Android, iPhone and Wii with mono
- OpenTK Documentation
- Mono Documentation
- MonoTouch Trial version

Hope these short introductions helped you a bit exploring new and interesting platforms :)

Cute little trick to share memory of C# structs (e.g. with Vector3)

by Benjamin Nitschke 2. November 2009 02:41

C# Union

We recently had the problem that we want to share some structs we wrote with other structs in other assemblies. For example we cannot change XNA Vector3 (well, its not open source) and even an open source Vector3 like the one from OpenTK should not be changed, we just want to use the libraries. However, if you start using an XNA Vector in some class and then decide you want to switch to OpenTK, you kinda have a problem. The data is EXACTLY the same: X, Y and Z, thats it! Just 3 floats, but many different structs that describe them and have different methods for manipulating them. If you are only using XNA or only OpenTK, then there is no problem, except maybe when you want to extend the given Vector3 struct from the framework/library you are using. Then you might introduce a Vector3Helper class like I did in almost all my XNA projects, which is kinda ugly too.

Our engine however is going to support many frameworks and libraries, and not only that, it is easily extensible and totally customizable. We do not enforce to use XNA or OpenTK or whatever else, it is all a choice of the programmer, whatever he needs. To accomplish this I today present a very little cute trick on how to merge all those structs together and make them easily extensible: Yes, you can add methods to exsting structs without any helper classes!

The magic word is: Union. Now you might say: Wait a second, C++ has unions, but C# does not have them and using pointers is also no fun in C#. Well, you still can use the StructLayout(LayoutKind.Explicit) attribute and then the FieldOffset(0) attribute to mark overlapping memory regions. Just add all the structs (since they are value types and have the sequential x, y, z data there are all the same) and then define x, y and z yourself and use whatever vector you want. Our implementation works a little different because the use of XNA or OpenTK is optional (Tip: Did you know that you can have partial structs? They are fun ^^), but the overall idea is very much the same. I present you the Vector3 struct with XNA and OpenTK support all in one:


	/// Class with own Vector3 functionality, but still using the same shared
	/// memory as Vector3 does. This not only means we get all the XNA Vector3
	/// (and any other Vector3 we plug in here) functionality for free, but
	/// we can also mix the data types as much as we want (e.g. just set
	/// the xnaVector and all the other vectors are set automatically for us).
	public struct Vector3
		#region Shared vectors (XNA, OpenTK, and our own data)
		// First setup the shared vector structs. Start with an XNA Vector.
		// Note: This could also be private if you want to hide this from the
		// Vector3 users!
		public Microsoft.Xna.Framework.Vector3 xnaVector;
		// Same with OpenTK.Vector3
		public OpenTK.Vector3 openTkVector;

		// And then the same data again just as we want to use it! Start with x.
		public float x;
		// Da Y coordinate
		public float y;
		// And finally the z coordinate!
		public float z;

		//Note: This won't work, it would make x, y AND z all start at offset 0!
		//public float x, y, z;

		// Go ahead with our constructors, methods, etc.
		// Note: We can easily use the XNA or OpenTK functionality here.
	} // struct Vector3


And finally some testing code to prove this actually works (this is just some copied code from our early unit tests, I just added some Console.WriteLine code lines):


			// Create a simple vector that happend to have the length 5 (3*3+4*4=25)
			Vector3 vector = new Vector3 { x = 0, y = 3, z = 4 };
			Console.WriteLine("vector=" + vector);
			Console.WriteLine("vector.x=" + vector.x);
			Console.WriteLine("vector.y=" + vector.y);
			Console.WriteLine("vector.z=" + vector.z);

			// Sadly xnaVector and vector are not the same by default :(
			// We could easily add operators to support comparing these too,
			// but for now we should try to use Vector3 exclusively.
			//does not compile: Assert.Equal(vector, vector.xnaVector);
			Console.WriteLine("XNA vector=" + vector.xnaVector);
			Console.WriteLine("OpenTK vector=" + vector.xnaVector);

			// Lets play around with xnaVector and openTkVector
			// First use an XNA method
			//Assert.Equal(5, vector.xnaVector.Length());
			Console.WriteLine("XNA vector length=" + vector.xnaVector.Length());
			// Next try an OpenTK method
			//Assert.Equal(5, vector.openTkVector.Length);
			Console.WriteLine("OpenTK vector length=" + vector.openTkVector.Length);

			// Do a more complicated test, add another XNA vector and then
			// check if the OpenTK vector is also updated.
			Vector3 anotherVector = new Vector3 { x = 0, y = 3, z = -4 };
			// Note: We don't have our own + operator yet, just use the one from XNA
			vector.xnaVector += anotherVector.xnaVector;
			// Finally check if our new vector is 0, 6, 0 now!
			Console.WriteLine("XNA vector+anotherVector=" + vector.xnaVector);
			Console.WriteLine("OpenTK vector+another length=" +

Trying out Mercurial with VisualHG

by Benjamin Nitschke 1. November 2009 19:53

I talked a month ago about how much I disliked Subversion at the end of our last project (Fireburst), but guess what happend? We are right back at Subversion and curse it everyday for the pain we have with it.


GitWhy? Well, we tried Git and it totally sucked (even worse than I last described). It is not like we were to stupid to use it, I even forced the whole team to use it for 3 days until we finally gave up. As game developers we just lose too much time with it, the disadvantages clearly overshadowed the benefits git gave us. Merging and branching all the time was fun (we made 70 commits in those 3 days with lots of branches and conflicts that were solved pretty easily), but the Visual Studio integration was just useless. In the end we used the Git tools (GitExtensions), but the constant committing to yourself, then trying to sync with the server, ohh that does not work, try to update. Well, that did not work either, some random error message. Trying over and over again. It seemed like every time we wanted to share our work (which was VERY often, sometimes in less than 5 minutes) it seemed like Git was in the way and we had to wait a extra few minutes until all developers could update again without errors.

We also used SourceGears Vault for a few weeks, which I pretty much liked in September (after I complained about the complexity and problems with TFS). But Enrico really did not like it and was able to convince everyone (including me, I also had some strange issues with Vault) that it might not be the ultimate versioning tool after all. For me three main issues prevented me from continue using and purchasing Vault: 1. It always took a very long time (10-20s) whenever I started up Visual Studio and tried to connect to the Vault server over VPN. This is INCREDIBLY annoying, especially when the Get Latest Files at start-up dialog was enabled. 2. Get Latest Files at start-up is useful to get you updated right away when starting to work, but you always have to confirm it, which does not save you any time or clicks. I reported this 2 months ago in the Vault Forums, but nothing has changed in this regard. And third, but probably most importantly: Vault sometimes was completely unable to upload or download files, but when working over VPN (slow internet), but sometimes even at the office. Some random error message is reported, but after this happened to me 2-3 times in one day and I certainly lost an hour of work already, I gave up on Vault. It still is integrated the best way into Visual Studio and has really nice features, but I really need some convincing arguments to force everyone in the team to use it and then even to convince the other CEOs that we will buy all those licenses.

We also tried some other versioning tools like Perforce, TFS, SourceSafe and other crap for a short while, but they all were way worse than Vault or Subversion. Perforce is like working in an environment from 1995 and why the hell would I want to pay 900$ per user for that? TFS is also way too expensive and while integrated nicely into Visual Studio, no one really liked it in our team. And finally SourceSafe is completely useless crap. It was not hard to convince everyone that SourceSafe would not help us much. I don't want to reiterate arguments brought up many years ago, read it yourself: here, here and here.


TortoiseSVNAnd thats why we went back to Subversion since we know what the problems are, how we can circumvent them and live with it. But even then we still curse it every day. I just read this really fun to read page about someone that really hates Subversion too. I think I mentioned some other bad articles about subversion before. I think Subversion is ok if you just want to make a simple checkout from CodePlex, SourceForge, GoogleCode or similar sites. As long as you only have source code in there and you don't mind merging files all over the place, it can work for a while. There are also great plugins like TortoiseSVN for the Windows Explorer and VisualSVN and AnkhSVN for Visual Studio, which all are great, but it is still subversion and each of those tools has its own set of problems:


  • TortoiseSVN isn't integrated in Visual Studio, it is akwared to do your commits and updates in the Windows Explorer, there is always an extra work step and people don't checkin very often.
  • VisualSVN is not implemented as a MSSCI provider, so using it is similary akwarded. It also does not detect added/removed files properly. VisualSVN Server is however the best tool ever for Subversion!
  • AnkhSVN is a great tool and supports everything I want, it is integrated nicely into Visual Studio, it detects which project files have been added, moved or removed. But guess what, it is horribly slow. Once you got a few hundert files in your solution, you can forget about AnkhSVN, it is completely useless. This website with just 30MB of files checked in, it takes 10+ minutes to do a simple update or commit, which is very retarded (takes like 3-5 seconds in TortoiseSVN, which is already too long). You can do nothing while the modal dialog of AnkhSVN is open in Visual Studio. This is one of the things that you only figure out after really working with a tool, it might sound good on paper, but the problems later might kill any usefulness.

I started to use Subversion to for the development of this website in the last week, but a few days ago I had to stop, after importing about 800MB from my old blog and the old website Subversion totally got on my nerves. I did not even checkin most files (only 30MB was content I wanted to change and backup). I was the only person checking files it, but I worked from 2 locations and even that was too much for subversion. Once I moved a file and did not check it in right away I was in real trouble. Now I just use my good old SyncBackSE to do backups and work directly on the webserver (which is even fast enough with my slow VPN). It worked out after all, but I probably would have saved time by not using Subversion at all, which is not a good argument for a versioning tool.

MecurialDon't get more wrong. I love working with a version control system, getting back old code, merging stuff from all developers together. I just think neither Subversion, nor TFS, SourceSafe, Vault, Perforce, Git, etc. is really were I want to be. For that reason we will be trying Mercurial this week and see how long we make it. Since Mecurial allows importing from Subversion we can continue working with the same repository as before. Since Visual Studio integration is the most important aspect, we gonna use the VisualHg addin, but also the TortoiseHg addin for Windows Explorer because it is so similar with TortoiseSVN, which we know very well. We gonna report back how it goes, hopefully we won't run into the exact same problems as with Git. My first early tests this weekend were pretty good, it seems to run well. Setup is a little hard first (configuring .hgignore for example, there is not much help, you gotta search a little), but since then it works like a charm (locally at least ^^).





Disclaimer: The opinions expressed in this blog are own personal opinions and do not represent the companies view.
© 2000-2011 exDream GmbH & MobileBits GmbH. All rights reserved. Legal/Impressum


Which platform should Soulcraft be released on next?

Show Results Poll Archive

Recent Games



Jobs @ exDream


<<  August 2014  >>