Entries in Code (7)

Wednesday
Mar032010

Processing

So I just came across this language called Processing... How did I not already know about this!?

What Is It?

Processing is a free, open-source, multi-platform, programming language and IDE used for easily creating digital artwork and visualizing data.

While looking through some code samples, you'll quickly realize how quickly easy it is to achieve impressive results. The rotating cube above, with a fire-effect, was done in less than 100 lines of code (including comments and white space.)

Click to read more ...

Wednesday
Feb032010

I Really Want to Be Able to Put if Statements on the RHS of an Assignment Operator

That's pretty much my whole rant right there in the title. But I suppose I should elaborate a little.

At work, I write a lot of code in Progress (I know, nobody's ever heard of it.) In Progress, you can put if statements in the RHS of an assignment operator, like so...

Click to read more ...

Saturday
Sep192009

Are Small Coding Tricks Worth It?

The following code snippet is part of the PAUSE BUTTON implementation in a video game. The game is paused by setting Time.timeScale to 0 and it is unpaused by setting it back to 1.0.

if (GUI.Button(Rect(25,100,100,30),"PAUSE"))
{
    if (Time.timeScale == 1.0)
    {
        Time.timeScale = 0;
    }
    else
    {
        Time.timeScale = 1.0;
    }
}

The code is simple and straightforward. The solution is logically consistent with the way most people would naturally think through the problem. But is this the most efficient solution? With just a little more thought, one might come up with something similar to the following solution.

if (GUI.Button(Rect(25,100,100,30),"PAUSE"))
{
    Time.timeScale = 1.0 - Time.timeScale;
}

Click to read more ...

Monday
Apr202009

The Default Case Dilemma

I have to confess something. In my last post, I talked a lot about good coding practices. Well, it seems I have a tendency to break one of my own rules. I was looking through some of my Memories of Hyrule code and I realized that I have a tendency to leave the default cases, in my switch statements, blank.

Click to read more ...

Saturday
Jan172009

Comparing Strings in C#

Here's something that I never really gave much thought. In C#, there are multiple ways to compare two strings. But these different methods don't all yield the same result, particularly when a null value is involved. So I decided to write a few tests to see how the various methods differ.

Some of the info here should be common knowledge, but I think it's worth the time to take note of these different comparison methods.

Click to read more ...

Saturday
Jan032009

Zune Bug - Source Revealed

Zune FAIL!As you may have heard, on New Years Eve, 30GB Zunes everywhere stopped working. That's it! They just stopped working! When this happened, Microsoft's solution for the problem was to simply "do nothing". The next day, the Zunes were all working again.

Weird, huh?

So What Happened?

The Zunes all "fixed themselves" on New Year's Day, so that would lead people to believe the bug was somehow related to the new year (Y2K arriving late?). Close, but that's not quite it. Instead, the bug actually occurred because the Zune's software didn't properly handle our extra day this year.

The source code for the problem at hand has been released and you can download it here for your own personal enjoyment. I have to warn you though, the code does contain goto statements.

Click to read more ...

Saturday
Oct112008

Flex Broke (I think)

[Originally published 06/04/08]

I've been messing with Adobe Flex quite a bit for the past few months, and so far it's awesome! However, I was recently working on a small application when I ran into a weird issue. Now I'm not sure if this is an issue with Flex, ActionScript 3.0, or maybe it's just something that I did wrong, but here's what's happening.

Click to read more ...