STILBRUCH

thoughts on games, technology and programming

Ludum Dare #17 – Islands

Very recently I watched a video where Sid Meier and a few students attempted to code a complete game in 48 hours. Conveniently enough I discovered that the next Ludum Dare, a competition to do exactly the same thing was happening this weekend. So….. here I am – 45 minutes into the 48 hours.

Sid Meier and student friends used XNA and C# to build there games, but I’m afraid that seems a bit too easy…. so C++ and a passing knowledge of OpenGL is what I’m working with. The winning theme (as voted for by the Ludum Dare community) is “Islands”.

After spending 45 minutes trying to get a game idea I like that matches the theme, I decided to go with a game idea I can’t get out of my brain, but only loosely relates to the theme. The game will be called “No Game Is An Island” and will focus on the principle that originality in games is more often than not the influence of many different games distilled.

My base code is a small skeleton framework (an insult to frameworks everywhere) that I made a while ago when learning OpenGL. Its simply a basic parent class for interactable objects in the environment, a Component Map for high level inter-module communication, an Event Manager, that deals with keyboard input and interupts etc and a (very) broken collision detection module. This base code will no doubt be hacked and ripped apart in the next 48 hours. I think first thing will be to get the collision detection working and spazzing out all over the place.

The tools I am using will be :

Editor – Code::Blocks (Windows) / Vim (Linux)
Technologies – C++/OpenGL
Inspiration – SomaFM and lots of tea
Motivation and Entertainment – X-Chat on #ludumdare and #mode7games

(I’ll update this post later with a link to the base code)

Wish me luck!

Permalink | 2 Comments »

From the cold depths of space…

As I have mentioned before, and will talk at length about to anyone who evens looks moderately interested, I play Eve Online.

For those of you who don’t know, Eve Online is a “sandbox” mmorpg set in the far reaches of space in the distant future. It consists of exciting Player Vs Player combat, immersive back stories, robust and diverse skilling system and a tangible and player-created virtual economy. Check out this video for a much cooler introduction.

So, with Eve as my main electronic love in life, I started a new website. http://capsuleering.com

Here my digital alter-ego, Kiithilurin, can rant and shout and be slightly weird about his deep space adventures. Along with Jim, our new player correspondent (who may actually be out of action due to graphics card issues), and of course PJ, when he’s not out being a student.

Anyways, check it out!

- Grieve

Permalink | 2 Comments »

[C++] Efficient compound logical expressions

I tend to waffle quite a bit so those just looking for the facts skip to the summary at the bottom.


I normally try to write my code as readable as possible, this is not for the benefit of others as some might think, its an entirely selfish act reasoned from Eagleson’s Law.

Any code of your own that you haven’t looked at for six or more months might as well have been written by someone else.

To this end whenever I come to a point in code where a collection of varying and complicated conditions must be satisfied before continuing, I would write something like this:-

bool conditionOne = object.satisfiesConditonOne ();
bool conditionTwo = object2.mPointer1->satisfiesConditonTwo ();
bool conditionThree = object3.mPointer1->mBooleanMember;
bool conditionFour = objectPointer->satisfiesConditonFour ();

if (conditionOne && conditionTwo && conditionThree && conditionFour)
{
doWhatHasToBeDone();
}

This will work fine and allows the reader to see where each condition is derived without having to stare at an unreasonably long `if ( … && … && ……`. However, what if say `object.satisfiesConditionOne()` is a very expensive set of operations that may take several milliseconds to complete, and what if this snippet of code was being executed repeatedly…?

This is where the long unreadable `if` statement wins.

Logical expressions in C++ (and most other languages) are evaluated, in order of precedence ( (), !, &&, || ) left to right, and stops evaluating once the result is known. For example, in the above code, if `conditionOne` is false, the other three boolean values will not be accessed or read, as the result of the expression can not be true if the first is false.

However the three other statements from which we derive the three boolean values are still being explicity evaluated before we get to the if statement.

So, if we know the function from which we derive conditionOne is very expensive, we should rewrite the snippet like this:-

if (object2.mPointer1->satisfiesConditonTwo ()
&& object3.mPointer1->mBooleanMember
&& objectPointer->satisfiesConditonFour
&& object.satisfiesConditonOne ())
{
doWhatHasToBeDone();
}

This way if any of the the other conditions are false, the final expenseive condition will not be evaluated and time will be saved.

Summary

- Logical expression are evaluated, in order of precedence, left to right ( (), !, &&, || )

- No more elements are evaluated once the result is known and unchangeable.

- Example:

if ( one || two || three || four )

- If `one` is true, two, three and four will not be evaluated

- To avoid conditions based on expensive operations, but them at the END of your expression

- Example:

if ( function || function || function || expensiveFunction)

- To further increase efficiency put the element most likely to decide the outcome at the START, so for compound or (||) statements, the element most likely to be true should be first, for compound and (&&) statements put the element most likely to be false first.

This all seems blindingly obvious to me now that I’ve bothered to think about it, but hopefully this will save someone else the time.

Permalink | 2 Comments »

Little hand says it’s time to rock and roll

How awesome is Point Break? I mean seriously?

(Please note that although the head, shoulders and torso of this post are dancing around in whimsical stupidity, the feet are firmly planted in the cold, barren soil of Irony)

With the 80′s barely over and little to live for in the 90′s, along came a hairy-legged spider-like monstrosity of a film to really put meaning back into our barely sentient existence. I mean, if surf-boarding, thrill-seeking, mask-wearing, bank-robbing, Californian free spirits aren’t a reason to get up in the morning then colour me comatose.

This masterpiece centres around the interactions of John “Johnny” Utah and the mythical Bohdi, respectively (and respectfully) played by Keanu “Stiff as a board, light as a feather” Reeves and Paddy “Massive Hands” Swayze. Two larger-than-life characters, cut from the same cloth, a shame that society rolled different dice for each of them.

Utah is a young whipper-snapper of an FBI agent, out to make name for himself, he hooks up with the older, yet suitably unaccomplished, Pappas (Gary Busey at his pudgey finest), who has his crackpot theories about the identity of the ever-elusive bank-robbers, “The Ex-Presidents”.

They’re SURFERS! Following the waves! Living an endless summer….! Whoop whoop!

Cue a torrent of cliches, a stick-thin non-conformist love interest, soon-to-be-rockstar cameo’s and the inevitable battle for Johnny boys soul. Will he get lost in his voyage of self-discovery or slap the Fisher-Price cuffs on that scruffy haired lovable rogue, Bodhi?

Who cares? Indulge yourself! Fire off a few rounds into the sky, and scream your torment. Your best-friend and spiritual guide is really an adrenaline-junkie super-thief.

Oh and he used to dang your girlfriend.

Permalink | 2 Comments »

Advanced Search/Replace in Vi

For as much my sake as anyone else’s here are a few tips for searching and replacing with vi. Note this is especially useful when working with XML.

Take for example this brief piece of XML…..


<Parameter>
    <Name>ConfigParam1</Name>
    <Value>ConfigValue1</Value>
</Parameter>

<Parameter>
    <Name>ConfigParam2</Name>
    <Value>ConfigValue2</Value>
</Parameter>

…and you are looking to match only one complete stanza. Try this as your search pattern :-

/<Parameter>_p{-}</Parameter>

To those of you who aren’t that well versed in vi there may be two new character representation in there… they are as follows :-

_p – This will match any printable character, including tabs and newlines.

{-} – This is non-greedy matching

Together these basically mean as few printable characters as possible. Its also worth noting you can use non-greedy matching like this…

{-X}

…to find as few as possible but at least X.

Now, say you had a huge XML file similar to the example above and you wanted to use search and replace to put it in the following format :-

Name = Value

Then we could use this Vi command :-

:s/ _p{-}(.{-})_p{-}(.{-})_p{-}/1 = 2/

Sure there are quicker, easier and presumably better ways to do this but where’s the fun in that…. I mean…. we’ve already got Vi open… :)

Permalink | 0 Comments »

Pages: Prev 1 2 3 4 5 6 7 8 9 10 Next