Wednesday, September 21, 2011

Fixing GRUB

Grub seems to be a constant source of problems.  After updating my Ubuntu I got an error along the lines of "grub may need sorting out for various reasons".  I hate it when it does that, because if it does go wrong, you're usually stuck without a computer and are thus unable to browse the internet to find out how to solve the problem, a'la Catch-22.  Needless to say, when I rebooted, I just got a completely blank screen, not even a cursor flashing in the corner.


Anyway, for my own reference, here's what I did (after booting from a LiveCD - what did we do before LiveCD's?)

Mount the disk:
sudo mount /dev/sdX /mnt


Re-install Grub:
sudo grub-install --root-directory=/mnt /dev/sdX
Obviously, change the sdX bit to point to your HD.
If you're a real masochist, you could try reading this.

Tuesday, September 06, 2011

How to be a productive programmer

Here's my humble checklist of what I think are the most important requirements for being the kind of programmer that can create something ultra-quickly.

* A stock of library code, built up over years so that simple and common tasks are already covered by a pre-written function or two.
* Be either the only programmer on the project or have your area clearly defined, and not be dependant on someone elses code that is still being produced.
* Have it clear in your head exactly what you are creating and how it is generally going to work.
* You have already "solved" any major technical hurdles that you know you are going to encounter.
* A quiet-ish place to work.
* A desire to actually create this program.
* Access to the internet to solve those niggly problems or to copy-and-paste code from websites.
* As a bonus, have a similar project that you previously created that can be easily subverted to the new task.

If you've got the above covered then you should be able to churn stuff out quickly, and then you can spend the rest of your time writing your own more interesting projects.

Tuesday, August 16, 2011

Megaproject #2: Worldcrafter

I call it a "megaproject" since I'm pretty convinced I can see this one through to the end without getting bored or sidetracked onto something else.

It's called Worldcrafter. In a nutshell, it's a 2D Minecraft-style game for Android. Yes! Another one! This is what it looks like so far, after about 5 days since I started (most of those days being spent trying to decide what to call it):-



Does the world need another Minecraft game? I'll let the world decide. What I like about writing this kind of game (and what I like about Stellar Forces) is that it's almost "modular". You (i.e. me) can play a bit, then think "ooh, wouldn't it be good if it did this". And then add it. However, the basic game is quite easy to get up and running, and that's the important bit when starting a new project: have something playable ASA-goddam-P.

Friday, August 12, 2011

Domain Squatters Can Die!

If you've ever tried finding a domain name for your new project, no doubt you'll have come across the problem of cybersquatters, the vermin that polute the internet with ad-farms by buying up any and all domains that might be remotely useful for anyone. The rest of us have to try and think up obscure domain names that still try and relate to whatever subject our website is about, and hope people will still be able to find our site on the net.

Of course, you can usually buy a domain back from them if you want, using one of the their very helpful "make us an offer" forms. Gee, thanks. You're doing mankind a service.

Friday, July 29, 2011

Software Patents Metaphor

I'm a chef, and I've just patented a new recipe: chips with *2* sprinkles of salt over them. So if I see anyone sprinkling between 1 and 3 sprinkles of salt over their chips, expect a letter from my lawyer.

-- Update --

I've just had an amazing idea: chips with 3! Yes 3! sprinkles of salt over them! I don't know how I do it. I might start to sell this new recipe over the internet, but of course it will take you more than 1-click to buy it.

Thursday, July 21, 2011

Tower Invaders: Hints'n'Tips


It was my deliberate intention to make Tower Invaders quite difficult from the start. I didn't want players to have to wade through loads of screens of baddies before they got to the challenging bit.

Anyway, here are some quick hints'n' tips for those who might be having some problems defeating the invaders. I like to think of the game as more of a puzzle or even strategy game. There is a lot of strategy involved in what at first seems to most simple of choices:-


* Position of towers is important!
Even though the invaders move from left to right (and back, and so on) covering the whole width, the position of the towers is still very important. Statistically, the invaders will be mostly above the middle of the screen, so that is the best area to place your pulse lasers. However, this also means that this is where the most bullets are going to fall; if you have the full version, shields are a good idea, especially on towers you've spent a lot of creds on upgrading.


* Sell towers that are about to be destroyed!
You will get the same amount of money back for a brand new tower as for one that's about to crumble. You do get more for upgraded towers, though obviously not as much as you paid for them. Wait until a tower is about to go belly-up before selling it.


* Keep Zappers to the side!
Since Zappers will always hit an invader, keep them out of the way of bullets. As mentioned earlier, the most bullets will fall in the middle of the screen, so you might as well build Zappers to the far sides, where they will have much less chance of being hit.


* Upgrade towers to limit your exposure!
It costs the same to buy two towers as it does to buy one and upgrade it. Even though an upgraded tower will shoot about 10% less than two basic towers, those two basic towers cover twice as much area, so they have twice as much chance of being hit by a bullet. Also, you'll need 2 shields to protect them. Of course, they will be able to incur twice as much damage, so things aren't always so clear cut.

Thursday, July 14, 2011

Android Apps: Minimum Price

After putting my first paid-for app on the market place, I noticed that the minimum price you can sell an app for in the US is 99c. This is strange, since it's possible to sell it for 50p, which is less than 99c. Isn't it usually the UK that gets the raw deal where price conversion is concerned?

Tuesday, July 12, 2011

My First Android Game!


I've just released my first Android game with the help of Dipper (who provided the graphics) called "Tower Invaders". It's a bit like Tower Defence mixed with Space Invaders, and (even though I say it myself) I actually quite like playing it, which is always a good sign.

It's free and available at https://market.android.com/details?id=com.scs.towerinvaders.main.lite. Let me know what you think!

Friday, June 10, 2011

Float.MIN_VALUE Craziness

Did I miss a memo? How can this be right:-

float f = Math.max(Float.MIN_VALUE, 0f); // Returns "1.4E-45" (i.e. Float.MIN_VALUE I think)

What? Maybe I missed something in the documentation that said "Please note that this function is crazy." Unless the logic of "closest to positive infinity" means that Float.MIN_VALUE is actually closer since it loops round backwards. I hope not.

Friday, May 27, 2011

Android Rect Confusion

Jesus christ! That's all I have to say on this subject. Apart from the following:-

In their wisdom, Google decided to give the Android function Rect.intersect() a side effect. Without reading the docs, you would naturally assume that something like:-

boolean b = rect1.intersect(rect2);

would be reasonably straightforward, returning true or false depending on whether the two rectangles intersected. However, if it returns true, it also sets rect1 to be the shape of the intersection. WTF?? Wouldn't calling the function something like getIntersect() be a good idea?

There is a function called Rect.intersects(), which does do what you'd expect (and avoids doing what you wouldn't expect); so just remember to add that little 's' at the end of the function name because it makes all the difference.

Tuesday, May 10, 2011

I got the call!

Last month I got an email from someone at Intel asking if he could call me about porting Stellar Forces to work on AppUp. We did, and had a quick chat about it and AppUp in general, which seems like Intel's take on the AppStore/Marketplace. I checked out the documentation that was emailed to me, and looked at the website. It wasn't going to be a small job, they obviously weren't going to pay me to do it, and it's a free game so I make no money from it anyway.

However, eventually I came to a page that listed the Java SDKs, and noticed the lack of a Linux version. I sent an email back to confirm if this was the case, which would be a showstopper for me. That was about 4 weeks ago and I've still not had a reply.

It's a bit crap that they expect me to spend the time converting a game to their system (without any financial benefit) but they can't even be bothered to send an email as soon as there's nothing in it for them.

Friday, February 25, 2011

Dependency Hell

I seem to be stuck in Dependency Hell when trying to write some Java code that will compile Java source; I'm trying to use Apache JCI but it's turning into a nightmare. Here is the list of all its dependencies, which need to be downloaded one by one (at least, I can see nowhere where they are all included in one nice download).

But unfortunately, at least one of the dependencies (as I could see no point looking for any more) doesn't exist, and I can't find it after lots of Googling. So, as far as I can see, there is no way to use Apache Commons JCI.

Thursday, February 17, 2011

My Adage

Everyone else seems to have one, so here's my "programming adage":-

"The worst thing you can do as a programmer is write new code."

Discuss.

Tuesday, February 15, 2011

A Bite at Java Bytes

After using Java for so long, I'm still surprised that you can't write something like:-


public byte addNums(byte a, byte b) {
return a+b;
}

// Call the function:-
addNums(1, 2); // Get a compiler error??


The compiler error is because the 1 and 2 are ints by default, and the function is expecting bytes. Surely it must be able to work out that 1 and 2 are bytes in this case, not ints? To get it to compile you need to write:-

addNums((byte)1, (byte)2); // Get a compiler error??

I don't normally mind verbose code as long as it adds information for the programmer, but this is pointless.