25 December 2009

Merry Christmas

'Tis the season for complainers, blah-blah blah-blah blah, blah-blah blah blah!
And anti-Christmastime campaigners, blah-blah blah-blah blah, blah-blah blah blah!
'Tis the season to dig trenches, blah-blah-blah, blah-blah-blah, blah blah blah!
So let's all be pedants and grinches, blah-blah blah-blah blah, blah-blah blah blah!

Enough with the War on Christmas, people!

I'm fond of saying that people who look at the world as though it's black and white see it as twice as complicated as it really is, because it is in fact grey. There's good and bad (and the smooth gradient in between) in all things, but people tend to make snap decisions and sweeping declarations, tossing things into either the "good" box or the "bad" box.

This kind of an outlook may seem at first blush to be a handy way to simplify your life, but as it turns out it really serves to overcomplicate it. Like the proverbial donkey with two equally tasty bales of hay, any time you come across something sufficiently "grey" and difficult to categorise, the decision of which box to chuck it in becomes needlessly stessful.

Christmas is one of those things that's pretty darn grey. For atheists like me, it's annoying because it's full of religious symbols. For many Christians, it's annoying because of its pagan roots. And for just about anybody the blatant consumerism is nauseating, but on the other hand who's gonna knock family and good food?

For me, though, Christmastime has, on balance, more good than bad. It's mostly because I love the time of year - if I'd grown up in the southern hemisphere, I might feel completely differently about it - but it's also partially because I dig the whole style of Christmas. Sure, it's superficial and cloying, but just like fast food and amusement parks, there's something about its particular brand of decadence that makes my brain scream "yes" louder than it screams "no", though scream "no" it does.

I like the general buzz of excitement and purpose. I like the excuse to watch "Ernest Saves Christmas", or listen to Weird Al's "Christmas at Ground Zero". I like the grounding effect it has on the year, the timekeeping effect it has on your life. The sights, sounds, and smells that come with each cycle trigger memories and emotions from passed days that might have never bubbled to surface if each year were totally different, stripped of the rhythm of Christmastime.

Granted, anything could fill the same role. There are plenty of other cultural holidays, some artificial, others not, and weakly irritating parodical celebrations like Squidmas. But similarly, any other combination of sounds and letters could subsume the role of the word "coatrack" - but doesn't "coatrack" already do the trick?. The point is that Christmas - for me, and millions of others - already does fill this role, and fighting against it seems like pointless windmilling, with just a touch of unbecoming self-importance.

But during this time of year, when everyone could otherwise be enjoying their acknowledgedly crass and superficial holidays, the "grinches" come out of the woodwork, whining about how offensive Christmas is and how everybody is terrible for wishing them a Merry Christmas.

Offensive? Offensive? There is no cosmic law that says you should be specially exempt from being offended. In fact, to be regularly offended might do a body good. Regardless of that, though, how much of an arrogant prude must someone be to be offended by how someone else chooses to enjoy themselves?

At the risk of complaining as much as the complainers I'm complaining about, I thought I'd briefly bring up this article by Sarah Miller. It's a real doozy, containing not just fluff-headed thinking, but trite observations and contradictions. These are the kind of dead reindeer points the pedants like to drag out and flog every year, and one does get tired of them. (Do bear in mind, though, that the article is written in the voice of the Grinch himself, and likely intended to be humourous. Don't take it or my retorts too seriously.)

How many times do I have to hear “Merry Christmas!” in my lifetime? How many times will I have to respond with “happy holidays” before people realize that not everyone is celebrating their holiday with them? Isn’t it a bit egotistical to assume that everyone else is ALSO celebrating Christmas? I find it super rude. Especially for those who are celebrating Hanukkah and Kwanzaa at this time of year. And funny no one wishes me a happy Raam Navami...

To put it into perspective, American Muslims don’t go around wishing EVERYONE “happy Ramadan” every year. Why? Because they know that not everyone in America is celebrating Ramadan with them. So why do Christians, or those celebrating Christmas, assume that everyone else is playing along with them? Weird.

What a kind spirit! Taking offence to someone wishing you well. Is that Jacob Marley's chains I hear rattling in the distance? What a world we have to live in, where a person has to fear uttering pleasantries! If someone did wish me a happy Ramadan, well, what of it? Happy Life Day to them!

There’s also the reality that the “Christmas tree” is associated historically with paganism and several other traditions but gained popularity in the U.S. and UK during Queen Victoria’s reign mid 18th century. As it turns out, it is a fairly new holiday association.

...

We all know there was a St. Nick who lived once. ... I like the guy. But...my point is, he doesn’t actually belong with Christmas at all. Call me a Puritan, but he’s not Christmas. And besides, you’re lyin’ to the kids and that ain’t cool.

People do love to point to all the Christmas traditions that are recent adaptations, as if that somehow makes them less "pure". Your head wasn't always a part of your body, either. Surely that is warrant enough to part you from it? Traditions are just that - traditions. Who the hell cares if Santa Claus or Baby Jesus are recent additions? It's like the infuriating grammar pedants who seem to think that language is our master, not our servant, that dictionaries antecede usage, and that the "misuse" of the word "hopefully" should be punishable with a flogging. We do not follow Christmas tradition - Christmas tradition follows us.

As a non-Christian and non- religious (but extremely spiritual) Being, I take offense to much of these customs that are seemingly forced upon us during this time of year.

...

Let’s first point out that Christ wasn’t a Christian- he was Jew. Secondly, I’m all for celebrating Christs’ day of birth except for one small thing: he wasn’t actually born in December. In fact, he was born sometime closer to spring. The Christians actually disguised their celebrations under the auspices of Solstice (a considerably “Pagan” holiday by some standards) in order to avoid persecution.

I find an alarming number (even one would be an alarming number) of non-religious people knocking Christmas for its pagan origins. Why should that not be a good thing in their eyes? Have they lived in a predominately Christian society for so long that "pagan" remains a stinging invective? I would have taken it as a compliment.

It’s disgusting. Kill nature. Then decorate it. Then throw it away. Oh so American! I am obviously not pro-killing trees for decoration. Tree farms? Still a bad idea.

Tree farms are "still a bad idea"? (am I the only one who hates, "yeah, but still..." arguments?) Next they're gonna start complaining about all those poor tomatoes we kill to make soup and ketchup. Oh, the humanity!

There are important things to be said about the excesses and imbalances of Christmas. Shopping centre stampedes and flagrant expenditure of fossil fuels are terrible things that should be taken seriously. But no one is going to listen to these important issues when they are surrounded by silly boring complaints about inflatable Santas and the premature commencement of caroling.

Have a good Boxing Day - and like it! (Gee, I hope I haven't offended any Americans...)

24 December 2009

!SCIENCE

I love sloppy, mouse-drawn web comics. So I made one of my own: !Science (say "Bang Science").

Don't expect them often.

22 December 2009

Meme Cloud Special: Misfits of Science

I was born in the tail end of the 80's, so I missed experiencing most of them firsthand. However, through the magic of reruns and VHS, my childhood could still benefit from large doses of 80's TV, movies, cartoons, and music videos. I've come out the other side with an undying love for all things that capture that glittering 80's style.

Indiana Jones, Die Hard, Duck Tales, NES games, Phantasy Star, Men Without Hats, MacGyver, Infosoc - the whole decade was made out of awesome (which, in case you've ever wondered what unprocessed awesome looks like as it occurs in nature, it looks a lot like this).

But there is one 80's TV series in particular that I wish to discuss here - "Misfits of Science". I've just spent the last couple of months working with fellow 80's nut, ThirdBass, constructing a fansite dedicated to the show, Science of Misfits. I must hasten to add that I merely tidied up the HTML and offered a few suggestions - the brilliant retro design, content, and hours of research were Bass's hard work.

I love so many things about the show: the rocking music selections; the humour, which is often content to slip by in the background or in expertly written cross-wise conversations; the comraderie of the characters, and the coolness of their superpowers; the fact that the show remains about the characters, and not about their superpowers; and of course, Johnny B, whose red guitar, super speed, signature colour blue, and wariness of water bear a passing resemblance to another one of my favourite characters. ;P

I could go on about the show itself, but you don't need to hear my trap flapping. Bolt on down to Science of Misfits and check it out for yourself - and if it doesn't put a smile on your face, you have a cold, cold, blackened heart.

13 December 2009

Sonic Extractor 3&K Mix Update Alert!

Just a minor update to Sonic Extractor 3&K Mix, to version 1.2. It now has the ability to view the original Sonic 3 alone object layouts.

Sonic 3 and Sonic & Knuckles were originally intended to be one epic 32 megabit cartridge (according to Yuji Naka), but the game was split in half, and the first few levels were released early as Sonic 3.

By the time Sonic & Knuckles was released, Sonic Team felt like making a few changes to the zone layouts. When Sonic & Knuckles is locked on to Sonic 3, the 6 zones from Sonic 3 are tweaked a bit - sometimes for general ease of play, other times specifically for Knuckles and his new abilities.

Unfortunately, the object layout data for these two games, locked together or not, is read directly from the ROM, not the RAM. Therefore, Sonic Extractor, which uses savestates to map the zones, has to already know the object layout data. It's built in to the programme, and can't be changed.

This was a problem, though, when trying to map Sonic 3 alone levels with the unrevised object layouts. No matter what state you used, Sonic Extractor would blithely fill the level using the modified Sonic & Knuckles object data!

Version 1.2 corrects this problem. The user is now given a choice which version of the zone to view. Now anyone with a taste for minutiae can export both versions of each zone, and get a comprehensive comparison of the changes for the first time!

08 December 2009

Code of the Ninja: Sinusoidal Motion

If you haven't already, read the Code of the Ninja: Introduction

Welcome, Code Ninjas!

This time we'll be looking at a simple script that makes certain motions look more natural.

Imagine you have a platform that you'd like to move back and forth, a common element in platformer games. You might use code something like this:

Create Event:

r = 64;//maximum distance in pixels the platform may travel from its origin before reversing direction

s = 1/32;//speed of the platforms. The divisor is how many steps you wish the platform to take to reach its maximum distance from its origin.

Step Event:

if a //moving forward...
  {
  p += s;
  if p >= 1 { p = 1; a = 0; }
  }
else //...and moving back
  {
  p -= s;
  if p <= 0 { p = 0; a = 1; }
  }

x = xstart + r*p;//update platform's position
xspeed = x-xprevious;//get platform's speed in pixels

(Note: If this code seems a little overcomplicated, it is because it had been purposefully written to be able to make platforms of any speed and range.)

This effect that this code achieves is a platform that moves away from its starting point at the specified speed, reaches its maximum distance, and then immediately reverses direction and trots back to repeat the process indefinitely. This is the sort of platform you'll often see in early 8- and 16-bit games.

The trouble with this kind of motion is the immediate reversal of motion. In one step, the platform can be moving with a speed of +5 pixels, and the in the next, with a speed of -5 pixels. This doesn't look very realistic, because in reality, most often when something reverses direction, it has to slow down to a halt, and then begin to accelerate again.

This jerky motion isn't so bad if the platform's "patrol area" is bounded by walls at its extremes - then it just looks like the platform is bouncing off of the walls, and the motion doesn't look too bad. But if the platform is floating in mid-air, as they often are, there is nothing that appears to plausibly reverse it, and the motion looks unnatural.

And it's worse than just looking unpleasant. It actually makes the game less fair, and less fun. If the player can't tell by some visual cue when the platform is going to decide to turn around, they have a much harder time getting the proper timing on their jump. They will have to use more trial and error, watching the platform make its rounds more than once before they can confidently make their move.

This is almost game-breaking if you want to keep good flow, as in a Sonic game. In the Sonic the Hedgehog games for the Mega Drive (Genesis), almost all platforms not bounded by walls move with a natural motion - decelerating as they reach their extremes, and accelerating toward their point of origin as they turn back around. This allows players to intuit exactly where the platform will be any time when they first come across it, without patient study of its entire cycle. This is one of the subtler points about the Sonic the Hedgehog game, seldom recognised, but it contributes not insignificantly to the sense of speed that made them popular.

Well then, how can we achieve the same effect so that our platforms move with a natural motion, rather than an outdated, unrealistic, and unfair jerky one? Why, with the trusty cosine function, of course!

Imagine, now, a platform that - instead of moving simply up and down, or left and right - moves in a complete circle, as many do in Sonic and Mario games. The platform's speed should be uniform, but if we were to look at just one component of its velocity - say, just the xspeed, or just the yspeed - we would notice acceleration and retardation of its speed. Simply imagine looking at the platform's circular path edge on, instead of face on. It would appear to be moving in a straight line, but slowing down at the edges and speeding up in the middle, just like those Sonic platforms we want to emulate.

So, in effect, what we want to do is make the platform move in a circle - just a really flat circle that might as well be a line. We'd use code something like this:

Create Event:

r = 64;//maximum distance in pixels the platform may travel from its origin before reversing direction (radius of the circle)

s = 180/32;//speed of the platforms. The divisor is how many steps you wish the platform to take to reach its maximum distance from its origin. (This time we use 180, not 1, because we'll be using degrees.)

Step Event:

a += s;
if a >= 360 a -= 360;
//alternatively the preceding two lines could be 'a = (a+s) mod 360;'.

//also, here we don't need to use two states, forward and back, because the circular motion takes care of that for us automatically.

x = xstart + r*cos(degtorad(a));//update platform's position
xspeed = x-xprevious;//get platform's speed in pixels

To make the platform move vertically, we can just replace all the references to x and make them y. Or, to make it actually move in a perceptible circle, we can have both sets of lines. By using a different range value for both x and y, you can squash the circle into any sort of ellipse you want - for example, a circle that is twice as wide as it is tall:

Create Event:

xr = 64;
yr = 32;

Step Event:

//...

x = xstart + xr*cos(degtorad(a)); xspeed = x-xprevious;
y = ystart - yr*sin(degtorad(a)); yspeed = y-yprevious;

Remember to subtract the sine for y, and add the cosine for x, otherwise instead of moving circularly, it'll just move in a smooth diagonal - which is actually another useful effect you might want to achieve.

Well, that about does it for platforms, but the power of sinusoidal motion goes far beyond. There are other applications, and for just such an example, I'll use the purpose for which I first I needed it myself.

In games like Phantasy Star, when you talk to townsfolk or shopkeepers, their dialogue appears on the screen inside of bordered window, or a 'text box'. In most games, the text boxes appear on the screen gradually, either opening up, dropping down, or fading in.

I wanted this animation to appear smoother, so I thought perhaps I could apply sinusoidal motion as the solution. But there was a slight hitch.

Imagine you want to fade in a window, from an alpha of 0 (invisible) to an alpha of 1 (fully opaque). You could simply add 0.1 for ten steps, but that wouldn't look very smooth. How about, instead, we use a sine function.

Code:

step = 18;

for {a=0;a<=180;a+=step}
  {
  alpha = sin(degtorad(a));
  }

Well, clearly this won't work. The value of alpha will go from 0 (the sine of angle 0), accelerate toward 1 (the sine of angle 90) and decelerate back to 0 again (the sine of angle 180). The text box wouldn't fade in, it would fade in and back out again just as quickly! This obviously isn't what we want.

But why not just use 90, instead of 180, so that alpha will stop at 1, thereby fading the text box in how we want it? Well, in that case, the fade would start smoothly, but stop abruptly. I wanted it to both start and stop smoothly.

I needed some way to have the alpha value "move" like a half-circle (slow start and stop), but only "traverse" a quarter-circle (start at 0 and end at 1).

So I made a script, called it 'sinusoidal()', and this is the function I used:

sinusoidal()

//argument0: any value between 0 and 1

return (cos(degtorad(180-(180*argument0)))+1)/2;

Now, sinusoidal motion can be employed anywhere by calling the script. The text box fade code ends up looking something like this:

Code:

step = 0.1;

for {a=0;a<=1;a+=step}
  {
  alpha = sinusoidal(a);
  }

This little script can be very versatile. You can use it to slide logos or menus onto the screen. You could use for flashing lights for smoother look. You could use it to animate a pendulum. You could even use it to make your character push a block (as Link does in the Zelda games) with a less abrupt and better looking motion. And with clever modification, who knows to what ends a Code Ninja might put it to.

For an example GMK illustrating the difference between normal and sinusoidal motion in several types of movement and animation (flashing, shrinking, swinging, sliding), click here.

Next time we'll be looking deeper into text boxes - how to make the text type out, change the text speed, and more. Until then, happy coding, Code Ninjas, and happy holidays, too!

If you use my code or scripts in your game or engine, no credit is necessary. But I'd love to hear about your project if you do! Just drop me a comment below, or e-mail me at us.mercurysilver@gmail.com