Technical communication

Games for Touch Walls

20 Jul 2011
Posted by xeophin

One future I see for our little company? Definitely something like this:

A StarWars game called FleetCommander, played on a 8160 by 2304 pixel wide touch screen.

Well, let me correct that. A touch wall.

More information on that project can be found on Arthur Nishimoto's site. Interesting fact, mostly for Dragica: apparently, it was programmed in Processing. Not too shabby, I have to admit.

[found via GamelLife]

More Design Patterns

24 Nov 2010
Posted by xeophin

Writing Serialised Data to a String Instead of a File in C#

Instead of writing the serialised data to a file, which can be done using using (Stream s = File.Create("foo.xml")), you might want to have just the string – maybe because you want to send it to a server? You can use the StringWriter class to do so:

string data;
using (StringWriter stream = new StringWriter()) {
    xs.Serialize (stream, foo);
    data = stream.ToString();
}

Uploading Data to a Server in Unity 3D

Unfortunately, you can't directly upload data to server in Unity 3D. Instead, you have to write some sort of wrapper script that resides on the server.

Since you can create POST variables in Unity, you can mainly work with those in your script.

A very simple, preliminary implementation could look like this:

concierge.php

<?php 
//concierge.php resides on the server – and might not be written so nicely,
// my PHP skills are rusty.
 
if ($_POST['action'] == 'save') {
    // Needs to be rewritten to add folders when they don't exist 
    // – otherwise, fileputcontents will silently fail.
    file_put_contents('./'. $_POST['type'] . '/save.xml', stripslashes($_POST['data']));
 
} else if ($_POST['action'] == 'load') {
    $data = file_get_contents($_POST['type'].
Posted by xeophin

Iterating over a Dictionary in C#

Iterating over a dictionary in order to change its values will not work; the program will throw an exception because the dictionary has been modified while iterating over it (which was, frankly, the purpose, but I digress). I can see that this could be problematic. Workaround: copy the dictionary into another temporary one, iterate over that to change the original dictionary. Or create a new dictionary using the iteration.

Allowing Various Elements in no Particular Order in Relax NG

In order to allow several element within another element, but without enforcing a strict order of those elements, use a combination of <zeroOrMore> and <choice>, like this:

<element name="foo">
    <zeroOrMore>
        <choice>
            <element name="bar" />
            <element name="foobar" />
            <element name="blubb">
                <attribute name="blabb">
                    <text />
                </attribute>
                <text />
            </element>
        </choice>
    </zeroOrMore>
</element>

Serialising Objects that Derive from MonoBehaviour

Sadly enough, serialising objects that derive from MonoBehaviour, the standard class in Unity 3D, is not possible.

Instead, you will have to use the Memento pattern: create a second class (the memento) that will hold all the necessary information, and when you want to serialise it, you create a new memento instance, copy all the information over and serialise the memento instance.

Upon deserialising, you do it the opposite way.

Hometown GP

19 Nov 2010
Posted by xeophin

While getting some answers on UnityAnwser, that were kindly answered by someone going by the handle of Duck, I stumbled over his website.

And look what I have found:

It's a F1 racing game, where you can design your own racetracks, based on Google Maps. How awesome is that?

Hometown GP 002

Hometown GP 001

It is an advergame for Vodafone – and you can play it over here.

Posted by xeophin

Update

The code for this project has seen extensive changes and has since been migrated to GitHub. Read more about it over here – and then go forth and fork it. It is released under a Creative Commons License, so you are free to build upon it.

Since I already played around with XML in C#, this part of the project was easier to do than before.

What is it supposed to do?

Basically, I could simply hard-code most of my strings used in the game directly into the code – no one would notice the difference anyway. But obviously, this is not a very good idea, both because editing strings and later translating them becomes a pain.

Creating some data that would allow me to get strings out of an XML file would solve this problem – and, if the code is good enough, be reusable in later games.

It would allow me to edit text independently of the game code and add translations on a later date.

Posted by xeophin

Update

The code for this project has seen extensive changes and has since been migrated to GitHub. Read more about it over here – and then go forth and fork it. It is released under a Creative Commons License, so you are free to build upon it.

Since I want to make some basic statistics for my game at Fantoche, I needed some basic logging function of the player's position.

Of course, this could also be done using a simple CSV file, but the perfectionist in me insisted on an XML format. A preliminary test showed me, that I would be able to transform the XML to a CSV later on, so that my S.O. would be able to use it in his own programs.1

Having set up my development environment in MonoDevelop, I started to work on the problem on how to get my data into a well-formed XML representation and onto the hard disk.

The first approach was to use serialisation. I created a Location class, with all the necessary attributes – until I realised that this would only allow me to get one dataset into a file. I wouldn't be able to add more data to the file.

Conclusion: Serialisation is only good when you have one clearly defined object you want to dump onto the drive as a well-formed XML file.

So I tried to work with the XMLWriter.


  1. So why again am I doing it with XML? Good question. Because I can? Does that make me a nerd? 



Navigation



Languages


Syndicate

Syndicate content