Batch script current directory

I was just trying to write a batch script that calls another batch script. This one was called by another batch script however, and I was having trouble with “batchfile.bat is not an operable command”. I figured my working directory must be different to what I thought, and indeed it was. The following command at the beginning of your batch file will show you the working directory and help you get the correct location:

echo %CD%

This let me add the necessary “folder/” before “batchfile.bat” and now the script works as intended.

Passing variables in C++

Just a bit of condensed info that people will hopefully find helpful…

Variables that go ‘in’ but not ‘out’:

void foo(int x)

-x will not be modified outside the scope of foo
-x is copied (consider overhead for big things)


void foo(int const &x)
x=6; //will no compile

-x cannot be modified inside foo
-x is not copied, preventing some overhead


Variables that go in and out

void foo(int &x)

-x will be modified within foo and outside of foo
-x is not copied, preventing overhead, but modification of x outside of foo may be undesirable. see the use of const above.
-simpler than using pointer technique and avoids having to change calling code to pass a pointer


void foo(int *x)
*x = 6;

-the value at *x will be modified inside and outside foo
-x is not copied
-involves more effort to program


Don’t email me my password!

You’d think, with all the recent hype about security scandals, missing briefcases and phishing attacks, people would be just a little bit more sensible about how they deal with usernames and passwords.

The correct way to do things…

You sign up for a site, your password is transmitted securely and encrypted in a store. There is no way to ‘retrieve’ a forgotten password, that is it, it will enver come out of the database in a readable format. To reset your password in this scenario, you receive a new, randomly generated password, after providing some details – something of that sort.

The wrong way to do things…

You sign up for a site, check your inbox, and find an email: ‘Dear user, thank you for signing up with us. Your username is JoeBloggs and your password is paSSword25. We hope you have a secure inbox, because we don’t have a secure system!’ (I added the last bit)

Your email, sent unencrypted in most cases, could easily be intercepted. Intercepted, and assuming you’re human like the rest of us, the hacker has access to a great many, if not all of, the sites you’ve ever signed up to, along with whatever details you have submitted to them.

What’s more, the database itself has a reversible encryption method (or just stored in a plain-text file, maybe? Why make it difficult after all…) – so a dedicated hacker canĀ  take all of those lovely passwords.

The message to developers – if you’re setting up a username and password system, there is no excuse not to research security. If you email me my password, then I will put you in my blacklist, which is available here.

Bubbel – Starting to look like a game

My first (woo) game, Bubbel, has started to look like a game. It’s a very simple 2D bubble clone. The aim is to make a really addictive playable game to begin with. Then maybe I’ll add some funky ideas – or maybe not.

The motivation for this game is threefold. Firstly, most importantly, is for myself. I want to make it, I want to do it. The second is to get a demo, which I can show off to prospective employers – a demo I couldn’t develop very well within the scope of my degree. The third is for Illusia, a bubble fan of supreme proportions.

So here it is – the beginning!

An early version of bubbel - not playable yet, but geting there.
An early version of bubbel - not playable yet, but geting there.

A menu for an(y) XNA game

So, my current project is to make a game, as you might have guessed. Ideally I want it to be so darn good I can sell it through some distribution service for a very reasonable price.

My first sub project (I’m easily bugged by not having certain ‘features’ of programs during development) was to build a menu that extended GameComponent, and was a pluggable, easy to implement menu. It has no flashy features (currently) and is not quite ready to release (it’s clean running, but I want to make the code a bit more flexible for possible future features). When it’s ready I’ll make it available on

Using only a few lines of code, the menu looks like this:transparentsilvermenu

And by picking that irresistible button…

transparentbunnymenuA semi transparent bunny fill the image. Obviously (or not?) a bunny would not be the image of choice in a real game, but it allow you a few important choices:

  • The menu background is an image showing some beautiful prerend of a scene in your game
  • The menu is a transparent grey, using the real game (paused, potentially) in the background as an image
  • A plain colour
  • A slightly transparent image of something (maybe stars, clouds?) over the background. Although I haven’t tested it, pngs with transparency data should work too.

In case you’re wondering, the blue tint in these images is the ‘game’ showing through – a default otherwise unedited XNA project.

The features, then:

Choice of menu title position and menu items position (auto aligning to look best). Choices are top and bottom lefts and rights, and centred. Menu items can be automatically stacked under the menu title.

Menu item active and inactive colours can be set (the title is inactive colour, but I’m planning to make that so you can set it differently)

Menu items are added in the form of text-delegate pairs – so you have complete control over what they do. The menu listens for Escape key presses, and can hide and show itself. When hidden by escape it calls a user set ‘pause’ and ‘resume’ delegate to give you control over your game when the menu shows itself. You don’t actually have to set these… the menu will then just show and hide itself.

All in all, to get a menu with 2 options (resume/quit, maybe?), you need only 6 lines of code, and a simple but functional menu will work alongside your existing game. (not counting the methods that respond to resume/exit – I’m assuming you already have them. It makes the required lines of code look better! If you must be picky, the methods take another 6-7 lines depending on what you put in them)

Next time – I’ll either have added some game to the menu (woo), flashed up the menu some, or quite possibly done something totally different… You will have to wait and see!

First Impressions of XNA

One of my real ‘things’ is playing and developing video games – ideally I want to work in video game development, and that was my plan until a certain bank turned down my application for postgraduate funding (and there’s no way I can afford the costs from my own savings). So, instead of my MSc course, I’m having to teach myself… No doubt I’m going to miss out on a lot of stuff this way, but it should still give me enough of an edge to get into the industry. (especially if things go as well as I want them to)

My current ‘project’ is a sort of bubble shooter, and it’s just in the design stages at the moment, but as experimentation I had a go using Microsoft’s XNA game studio – and I’m really impressed. Working through Riemer’s 2D tutorial showed just how simple it is to get a playable game up and running, and laid the groundwork on lots of basic useful stuff for getting the bubble game off to a healthy start.

Having used MOGRE before to do my 3D solar simulation (you can download it here), I know how tricky it can be to get things going – I would say that in XNA (in 2D at least) it is much easier. Though this may in part be due to my experience from MOGRE, I’m pretty sure XNA is the better. It also performs better on the cpu, by only calling update 60 times a second – stopping the massive load on the CPU I encountered with MOGRE (renders and updates as fast as it can). The 60 times per sencond also makes animation and control much easier!

So I will continue to work with XNA, and this week I’ll be trying to get a set of reasonable 2d graphics ready for use in the prototype stage. I’ll post screenshots and so on when I have some.