Not tagged photo
This is a filtered list of entries. To see all of them, go back to the home page.
Sunday, July 26th 2009 — Random Stuff, Gaming, Google App Engine — 7 comments
Check out a new project I'm working on! You could say it's in early alpha now. It just barely works, but it's worth keeping an eye on.
It's called multifarce (which means something like "many situations abounding with ludicrous incidents".) You can find it at beta.multifarce.com.
What is it? It's a collaborative text adventure. The idea is that at any point in the game – called a "frame" – you, as a user, may add commands to the frame, which in turn can change the state of the game (e.g., "pick up torchlight") or lead to another frame (e.g., "go east".) Of course, you're also able to add new frames.
Eventually, the game will have a ratings system where you are able to point out commands or frames that you like/dislike, thus separating poor and excellent content. These votes will also affect a score that each user has (let's call it reputation), encouraging users to provide good content. Further down the road, a high reputation would also lead to more delicate features of the game being unlocked for the user, since a good reputation should indicate that the user can be trusted with them.
The interface is still being developed, but it's possible to register, log in and create new frames and/or create new commands.
If you just want to try out the game, there's a small "storyline" that starts with go east. It's very hard to figure out what commands to use, but I'll make sure to add an easy to play storyline soon.
Oh, and it's open source, in case you want more insight on how it is built.
Thursday, July 9th 2009 — Programming, JavaScript — 3 comments
Do you like JavaScript? So do I! I've found that over the years I've developed quite a few useful stand-alone libraries, and now I've finally refactored them and put them online for everyone to benefit!
The libraries are available on a separate site, that quite suitably requires you to have JavaScript enabled:
My JavaScript realm
Friday, June 5th 2009 — Programming, C# — 3 comments
I've worked on a couple of applications that support plugins, and wanted a way to automagically get all the classes that implement by base plugin class/interface. Using LINQ in C# 3.5 this is really easy to do!
Check out the following piece of code:
/// <summary>
/// Gets all the types implementing the Type.
/// </summary>
public static IEnumerable<Type> GetImplementors(this Type implementee)
{
var types = from a in AppDomain.CurrentDomain.GetAssemblies()
from t in a.GetTypes()
where t != implementee && implementee.IsAssignableFrom(t)
select t;
return types;
}
As you can see, it's implemented as an extension method. Stick it in a static class and you'll be able to do the following:
var plugins = typeof(PluginBase).GetImplementors();
This piece of code has been of use to me on several occasions. Just consider that it'll also return interfaces and abstract classes (which, of course, cannot be instantiated) that implement the type.
Another piece of code useful when working with types is the following shortcut to get an instance of a type:
/// <summary>
/// Gets an instance of the Type using the constructor that matches the given type
/// signature and with the given parameters.
/// </summary>
/// <typeparam name="T">The Type to instantiate.</typeparam>
/// <param name="types">The type signature of the constructor to use.</param>
/// <param name="args">The parameters to use when invoking the constructor.</param>
public static T GetInstance<T>(Type[] types, params object[] args)
{
return (T)typeof(T).GetConstructor(types).Invoke(args);
}
/// <summary>
/// Gets an instance of the Type using the given parameters.
/// </summary>
/// <typeparam name="T">The Type to instantiate.</typeparam>
/// <param name="args">
/// The parameters to use when invoking the constructor. The types of the parameters
/// will be used to determine the type signature.
/// </param>
public static T GetInstance<T>(params object[] args)
{
return (T)typeof(T).GetInstance(args);
}
/// <summary>
/// Gets an instance of the Type using the constructor that matches the given type
/// signature and with the given parameters.
/// </summary>
/// <param name="type">The Type to instantiate.</param>
/// <param name="types">The type signature of the constructor to use.</param>
/// <param name="args">The parameters to use when invoking the constructor.</param>
public static object GetInstance(this Type type, Type[] types, params object[] args)
{
return type.GetConstructor(types).Invoke(args);
}
/// <summary>
/// Gets an instance of the Type using the given parameters.
/// </summary>
/// <param name="type">The Type to instantiate.</param>
/// <param name="args">
/// The parameters to use when invoking the constructor. The types of the parameters
/// will be used to determine the type signature.
/// </param>
public static object GetInstance(this Type type, params object[] args)
{
Type[] types = new Type[args.Length];
for (int i = 0; i < args.Length; i++)
types[i] = args[i] == null ? typeof(object) : args[i].GetType();
return type.GetInstance(types, args);
}
Just call it like so:
var instance = Types.GetInstance<MyPlugin>();
If you only have the Type instance, you can use the extension method:
var instance = (PluginBase)typeInstance.GetInstance();
Wednesday, May 6th 2009 — Random Stuff — 10 comments
I've found myself reading a lot lately. The last few weeks I've read through four books of the Temeraire series by Naomi Novik and right now I'm reading Jonathan Strange & Mr Norrell by Susanna Clarke.
The Temeraire series is definitely worth reading if you're into fantasy. It's cleverly woven into the history of early 19th century England, with the main characters (a man and his dragon) time and time again getting entangled in big events of the war.
Jonathan Strange & Mr Norrell is definitely an interesting book about the reinstatement of magic by two magicians in early 19th century England, having been in decline for two decades. It has a good and in-depth story, but it's almost too in-depth for my liking. That said, I don't regret reading it, it's an interesting take on magicians. You'd expect magicians to be learned know-it-alls, but the greatest magicians in this book have barely read a book and are borderline insane (or at least not very morally aligned!)
My next undertaking will be The Hitchhiker's Guide to the Galaxy by Douglas Adams. I've been meaning to read it for so long, so it's about time!
Tuesday, May 5th 2009 — Web Design — 3 comments
I've finally taken the time to rewrite my article about tabbed navigation! Be sure to read it! It's on my articles page.
The old article will still be available at its current address: http://tutorials.mezane.org/tabbed-navigation-using-css/