Improv math

I always loved math and it was one of my favourite subjects during school. I have to thank my dad and my bro for instilling that love in my head. My young self was always baffled by how most people around me not only hated math, but they seemed to have a hard time with it. How could it be hard? It was all logical, you hardly needed to work or memorize anything because, hey, with just a few basics in your head you could deduce any formulas or theorems you needed during an exam, right? Heh.

This year I’m one of the tutors for the Master on Game Programming at the U-Tad. The subject I’m teaching this course is Game Architecture: Game Objects, Main Loop and Timing, Reading & Saving, etc. This is the Master’s debut year, so while I believe the course is going great (and students seem to agree so far), some bits and pieces are not ideal and will need improvement for the following years.

One of them is, unsurprisingly, math.

Continue reading

Metro and JavaScript

On Facebook I wrote a bunch of thoughts on the fact that Windows 8 treats JavaScript as a first-class citizen for native Metro apps. It was triggered by this and a few other related reads on WinJS.

In general, there is value in having a single language available for all your needs and platforms even if it’s not 100% portable (look at C/C++). JavaScript is the most widely available language today and, while ugly, the popularity of runtimes like NodeJS and the myriad HTML5 mobile app wrappers like PhoneGap prove that it is viable.

But what’s the value for Microsoft? Is this WinJS effort going to encourage devs to port their web apps easily into native Win versions? I think that’s just not very likely, most devs will settle with just a web app (e.g. Trello), and very successful web apps will get native versions regardless (e.g. Evernote).

I can’t help but think that the effort would have been better spent developing a hassle-free PhoneGap-for-Metro kind of wrapper rather than a close-but-not-quite web-like native environment that developers still need to treat like a port and a separate platform.

Facebook IPO and Mobile Social Games

Facebook’s IPO has been announced, and this means lots of details on Facebook financials have become public. The most interesting bits for social game developers (in VERY broad terms):

  • Almost all revenue from Facebook Credits is generated by games.
  • Zynga makes up 80% of the total Facebook Credits revenue.
  • In broad numbers, on Facebook, Zynga has MAU equal to 1.5x all other game devs combined. But Zynga’s FB Credits revenue is 4x. That’s an idea of how much better Zynga is at getting players to pay.
  • Most of Facebook’s revenues come form advertising.
  • Facebook mobile gaming is in its infancy.
  • Half of Facebook users use the site via mobile, and this percentage is growing very quickly, but Facebook does not monetize them with games nor advertising.

Continue reading

Stage3D Vertex Buffer formats

If you played with the Stage3D spinning cube sample I linked in the previous post, you will notice one thing: the vertex colors in the vertex buffer are given as 3 floats (red, green and blue). This is rather wasteful in most cases because color components often vary between 0.0 and 1.0, and it’s more efficient to specify vertex colors (including alpha) as a single 32-bit value. For example, in hexadecimal notation, 0xFF800040 would mean alpha of 1.0 (0xFF), blue 0.5 (0x80), green 0 (0x00) and red 0.25 (0x40).

If you look in the Stage3D docs, you will find the constant Context3DVertexBufferFormat.BYTES_4 to use in the call to Context3D.setVertexBufferAt(). But if you naively just change the vertex buffer array to turn each vertex color’s set of 3 components into a single hex value, make dataPerVertex = 4 instead of 6, and use BYTES_4 for va1, then you will find that the colors are coming out wrong. Why? Because the function VertexBuffer3D.uploadFromVector() always stores the values from the Vector in floating point format. Of course! This is the most common situation for the components of the vertex positions, normals, texture coordinates and such. But we need our BYTES_4 color value to be stored verbatim as a 32-bit uint.

Vector.<Number> and uploadFromVector() do not give you control over the byte format of value. How do you solve this?

Continue reading

Fun with HTML5

I have been playing around with HTML5, Canvas and WebGL. Not a lot to show for it, but at least I forced myself to write a bit again. Check it out here if you’re curious, and good luck reaching a score of 150 on Lesson 5!

By the way, for some reason Firefox has started to run Lesson 5 rather slow in both my PCs. I’m pretty sure it used to be a rock solid 60 fps back when I wrote the game, but at some point either upgrading past Firefox 5, or upgrading to Windows 7, has made it slow. Other Canvas or WebGL stuff (for example Hello Racer) show similar slowdowns. Chrome and Opera run everything silk smooth, so it’s definitely not a hardware or drivers problem.

I’ve been slowly moving away from Firefox and using Chrome more and more. Firefox was really my favourite, but it’s got so many problems, it’s so bloated and slow (even 7.0), Chrome has become my browser of choice.

Hello world again

I may be getting interested in writing stuff again with more depth and detail, appropriate (even if small) audience, and with clearer ownership than social networks provide. Twitter is cool as a sort of RSS aggregator; Facebook has become intrusive, annoying and just generally inadequate for anything but on-the-fly photo and YouTube sharing; and Google+ has flatlined. In preparation for more writing, I have added a WordPress blog to my site, because my old blog system was fun to write but boring to maintain and extend.

I imported all the old content, converted the markup with a php script (destroying a bunch of stuff along the way) and deleted most of the old spam comments I could find (over 700).

Lots of settings, style and layout still to do, but it’s a start. Update your RSS if you are a subscriber!


Time for that old laptop to receive Ubuntu 11.04!


Apparently, the graphics card is too old to run the fancy new Unity UI. Ah well, in any case, it’s a good idea to have a working Linux machine.

Then, the same problem as before. And I hate myself for not detailing precisely what I did to speed up the HDD. I need to fix this ASAP because the system has started doing massive checks to update packages and the machine is completely unusable. So here it goes this time (DISCLAIMER: I don’t really know what I’m doing and I don’t care if I destroy the hard drive and its contents):

– See this link for instructions.

– The problem is that I can’t do these things on a boot partition while happily running the full system on the Gnome desktop.

– Reboot in recovery mode (keep SHIFT pressed while booting), drop down to the recovery terminal.

– ‘mount -no remount,ro /‘ to remount the file system in read only mode with. Ooops! can’t do that while running services that have files open for writing.

– ‘fuser -v -m /‘ lists which services have files open (look for a ‘F’ or ‘f’ in the flags) and get ready to kill some of these processes. Note that not all of them will need to be killed, so use some judgement and go one by one. Start with the ‘F’ ones.

– Try to kill them nicely first with ‘stop servicename‘. In my case, I just did ‘stop rsyslog‘ and tried to remount, it worked even though there were other services (recovery-menu and root) with ‘f’ flags. We have a read only filesystem!

– ‘tune2fs -o journal_data_writeback /dev/sda1
– ‘tune2fs -O ^has_journal /dev/sda1
– ‘e2fsck -f /dev/sda1
– ‘reboot

– Upon reboot, I see that the system is now complaining about a missing disk but it then proceeds. Looking at the /etc/fstab file, the missing disk was used as swap during installation.

– In the /etc/fstab file, add the options ‘data=writeback,noatime,nodiratime‘ for your / drive. Reboot.

– Go to the Synaptyc Package Manager to continue updating the system. Mine complained about broken files, and asked me to do ‘sudo dpkg –configure -a‘. That’s all for now!

Well, I dunno what will be different for you.