Wednesday, June 29, 2016

Announcing Ares:Dogfighter

My "very early space game demo" has transmogrified into a game!  Although still very early in development, there is now something to download and play.  It's called Ares: Dogfighter, and you take control of a spaceship and can fight enemy ships using lasers and missiles.

Here's a brief gameplay video:-


The game is uses the excellent JMonkeyEngine for the 3D, and lots of complicated Java code for the rest of it.  Getting the AI to fly realistically was a challenge; the standard response for a pilot, whether AI or human, is to try and point their ship at the enemy ship in order to shoot them.  However, this has a tendency to result in both ships flying around in circles until someone dies of boredom.  I've made the AI check for this, and if things aren't happening then the AI will react with some random evasive manoeuvres.

The game is free to download and there are versions for Windows and Linux.  Please let me know what you think!  (Or at least whether it works).

Monday, April 25, 2016

Very early space game demo

It will probably turn into some kind of Elite-style game.


Wednesday, March 09, 2016

Loading a texture from a file in JMonkeyEngine

It's taken me over an hour to work out how to load a simple .png file and use it as a texture on a box.  To help prevent anyone else who might be having the same problem from tearing all their hair out, you need to ensure two things:-

* Your files must be in a directory off your main directory called "assets/Textures/[png file]".  You must conform!

* Add the line "assetManager.registerLocator("assets/", FileLocator.class);".  Despite what the documentation says, this isn't added internally by default!

Also, when adding the texture to the material, the String parameter isn't your own name as you might first assume, but must be the text "ColorMap".

Saturday, January 16, 2016

Java Voxel Engines with Source

I recently carried out a trawl of the internet to find all the open-source Java Voxel Engines I could.  My intention is to use one of them as a foundation to write my own voxel-based game (which is still a long way off).  I didn't spend too long on each one; I simply checked that they worked and that they included all relevant code.  Here are my results which others may find useful.

Firstly, the best ones I found.  (As an aside, one of my general requirement is that an open-source project should work, once all dependencies have been resolved, and these should be resolvable easily.  What's the point of releasing source code that doesn't work?)  These all worked:-

* https://github.com/MovingBlocks/Terasology - You could say this was the best of the lot.  It worked first time and looks amazing.  The only drawback is its complexity; there's loads of code and loads of dependencies and libraries.

* https://github.com/mk12/mycraft - This is a great simple engine.  It's only about 8 classes big but provides a nice simple voxel engine in Java.

* http://borderterrierart.weebly.com/programming.html (BlockWorld) - This one seemed to fit my requirements best.  It's got lots of features including .obj model loading, and worked first time.  The only drawback is that the source is a bit messy (formatting, unused vars etc..)

* https://github.com/Zaneris/Tranquil - This worked well, and since it uses LibGDX could work on mobile devices as well as PCs.


Other Mentions:-

* https://github.com/aaasen/voxel-party - This worked, although it didn't have any textures.


* https://github.com/matortheeternal/JVoxelEngine - This uses raycasting.  Seemed very slow and simple, and although it worked, it was very bare-bones.


I couldn't get these to work:-

* https://github.com/SpoutDev/Spout - Seems very worthy, but I couldn't get it to work as the Maven build fails.

* https://github.com/afaulconbridge/ArdorCraft - Couldn't get this to work due to missing source.


The following use JMonkeyEngine which I haven't tried:-

* https://github.com/Sleaker/Cubed
* https://github.com/TheWiseLion/VoxelTerrain
* https://github.com/jMonkeyEngine-Contributions/voxel
* https://github.com/melsov/JMonkeyVoxel
* https://github.com/boogie666/Blocky
* https://github.com/roboleary/GreedyMesh
* https://github.com/francois5/voxelengine


And I also found these two projects which are not voxels, but rather "traditional" 3D but still worked very well:-

https://www.youtube.com/watch?v=kBcGrLGAbQ0
https://www.youtube.com/watch?v=7IXFUflNZJs


That's pretty much all I could find. I hope you find it useful.  I'd be interested to know if anyone has found any more, and which one's they found the best?


Thursday, January 14, 2016

Team Tactics

Team Tactics is a new realtime action multiplayer tactical strategy game that I'm currently developing.  You could probably label it as a MOBA or an ARTS.  Whatever the label, the game works like this: each player controls a single unit, which is on one of two sides (although in the future I might expand this to 3 or 4).  Depending on the mission (or "game mode"), each side has an objective, and the winner is the first to complete this is the winner.


ANOTHER MOBA-STYLE GAME?

Technically yes, but you could probably say something similar about any game since the 1980's.  This is how games progress; almost all games are very similar to what came out before.  But hey, let's not argue about that here - I'm developing this game for several reasons:-

* I like multiplayer games more than single player games.  It's far more fun to play against someone else where you can see their reaction and gain pleasure from their pain (and vice versa of course).

* I like to add new features to games, and this game will have features that no other MOBA has.  Whenever I'm playing a game I always wish I could tweak this or that.  If I have my own MOBA, I can do that.  In addition, if any players request a feature, it's always a pleasure to be able to do that.

* I think true "tactical" MOBA's are a bit thin.  I'm not a gamer, but I can't actually think of another multiplayer tactical game where working as a team is paramount.

* I like developing games, and the best way for me to maintain interest in whatever game I'm currently developing is to have something to aim for, i.e. similar game(s) that I want to reproduce and hopefully improve upon.


WHAT FEATURES WILL IT HAVE?

This is just a brief summary of the main features.  I'll blog about new ideas as I have them:-

* Multiple unit types - this is a no-brainer of course.  They will be different in that some move faster than others or shoot more accurately, but some will have specific skills required for missions.

* Multiple missions - There are currently two missions, The Assassins and Moonbase Assault, more about which I'll do another post.  I might also transpose some of the more interesting missions from Stellar Forces.

* Map editor and easy customisation - I want people to be able to easily customize this game (in so far without affecting balance), e.g. adding their own graphics and sounds, maps etc...

* Different weapons and equipment as well as the usual guns - smoke grenades, nerve gas, ammo packs, gas masks, incendiary grenades.  Grenades mean destructable maps!

* All the usual features like fog of war, line of sight, unit stats, chat, voting etc...


SUMMARY

I'm really excited about this, and really looking forward to playing it.  I enjoy a game of TF2 as much as the next person, but sometimes it lacks enough depth for me.  This should address that, and also be fun to write.  I've never written a realtime multiplayer game before (more than 2 players, anyway), so looking into all the technical aspects will be very interesting.

UPDATE:

Wiki: http://team-tactics.wikia.com/
Blog: http://team-tactics.blogspot.co.uk
Download:  http://teamtactics.penultimateapps.com/teamtactics.zip

Saturday, November 14, 2015

Outpost Omega

I've used the same graphics engine I used for Stellar Forces and Assault Squad to make another new Android game: Outpost Omega.  In this realtime strategy game you must defend and maintain a moonbase for as long as possible against a range of problems, including meteors and invading armies.

You start with 6 armed units and some medibays.  These used power, and over time resources are dropped that must be collected to maintain the power levels.  There are also other factors that make life harder: meteors will randomly crash into the moon starting fires which must be extinguished.  In addition, enemy invaders will attack your base and must be repelled.


The layout of the moonbase is randomly generated each time to give each game variety, and there's loads of tension as you send out a unit to collect resources outside where they are exposed to attack.  It's a great game if you've got a spare 5 minutes, and completely free!

Friday, November 06, 2015

Free Websites for Android Developer!

I'm all about saving time, and here's a great tip for any Android developers who need their own website to promote their games, but haven't got the time to create one: let someone else do it for free.

Let me break it down into easy steps:-

1) Google your "company name" and follow the links.  By "company name", I mean whatever name you gave Google when you set up your developer account.  If you follow the links, it shouldn't be long before you get to one of those app aggregator sites, with all your apps nicely listed on one page.

Here's a few I found when I googled my own "Penultimate Apps" name:

https://play.google.com/store/apps/developer?id=Penultimate+Apps&hl=en_GB
http://www.androidappsgame.com/publisher/penultimate-apps
http://apkpure.com/developer/Penultimate%20Apps
http://www.mobogenie.com/developer/penultimate-apps.html
http://apk4ios.com/productlist_bydev.Penultimate+Apps_1
http://www.androidapps.biz/publisher/penultimate-apps
http://www.appbrain.com/browse/dev/Penultimate+Apps

Frankly, they've done a much better job than I could.

Wednesday, July 29, 2015

My Most Popular Android Game

The world is a strange place.  Out of all my free Android games, my Kids Horror Adventure, a no-graphics text adventure, has now had over 29,000 downloads, which is about twice as many as my next most popular free game (Stellar Forces).  Who would have thought in this day and age that a simple text adventure would be so popular?  I might create another one.  They are the ideal game for me: no graphics!

Friday, July 17, 2015

New Game - Assault Squad

So my new game Assault Squad is about ready for proper public consumption and has now dropped its "alpha" tag.  It seems to be bug free, I just have to probably improve its instructional aspect so players know what on earth is going on and how to play!



It's a Realtime Strategy game, and it's main selling point is the advanced AI. There's an AI for each side of each mission, and you can even set the AI to play against itself and sit back and watch the action.  It's single player only (or you can even set the AI against itself and watch the action unfold).  There are currently 4 missions, each with a range of maps, and there is also the option of randomly-generated maps so no two games are the same.


You control a squad of units and play against an advanced AI. Select a unit and then select where you want them to go. Your units will automatically shoot at the enemy if they see them, or if you're in control of aliens they will automatically attack. You also have a limited "pause" option which allows you to temporarily freeze the action so you can take stock of your impending doom. Use it wisely!



Play link: https://play.google.com/store/apps/details?id=com.scs.assaultsquad.main.full

Tuesday, April 14, 2015

British Summer Time and System.currentTimeMillis()

It's that time of the year when I remember that you can't directly use System.currentTimeMillis() to calculate the current time, since it is now an hour out.  D'oh!

Thursday, February 19, 2015

Deity - "Multiplayer Populous"

My latest Android project is ready to announce: Deity.  If you remember Populous, then you'll be right at home here.  This is a multi-player turn-based strategy game.

You play a God who begins the game with a small group of followers and not much power (or "Mana" as professional Gods call it). 


As a God you can move your followers about, and ask them to either pray (giving you more Mana), grow crops (which are needed for your followers to survive) or build a house (which will generate more followers).

Once you have some Mana, the real fun begins.  You can create god-like effects to try and destroy your enemy God's followers, like floods, earthquakes and volcanos.  See the lava in the above screenshot!

This game is still in alpha, and I'll be the first to say that the graphics are a bit ropey, but I wanted to get it out there as quickly as possible as it's ready to play now, completely free, and has no adverts or IAPs.  What have you got to lose.

Monday, February 09, 2015

Seeing into the Future

The Linux "locate" command has a "-e" option which "Print only entries that refer to files existing at the time locate is run.". 

Does this mean that if you leave this out, it will find files that don't exist yet?  I'm running "$> locate half-life3" now...

Thursday, July 03, 2014

Hey!

Hey!  Do you breath air?  And do you like messaging?  If the answer to either of those questions is true, then you need Hey!, the new way to stay in contact with friends for free.

Hey! is a free Android app for sending and receiving message from other Hey! users quickly and easily.  It costs nothing, and there's no adverts!

So join Hey! today!

Monday, June 23, 2014

Think Anagrams Are Easy?

So did I until I wrote my new education app 'Alien Anagrams'.  It's a sort-of shoot'em-up, except you shoot bullets by correctly guessing anagrams.


Take the anagram in the screenshot above: "lseo".  it took me a good few minutes to guess it, when I would have assumed a 4-letter anagram would take about 4 seconds.  How many combinations can there be?  But for some reason my brain keeps thinking of words like "leo's" or "selo"[tape].  Still, that's why I like playing this game; if you lose it's your own fault, and when the computer shows you the word, it suddenly becomes obvious what the answer was.

Give it a go (the first few levels are free, and they are challenging enough) and see how well you do.

Friday, June 13, 2014

System-Wide Mutex

It's been a long long time since I actually posted anything directly to do with Java programming, so here I am to make up for that.

In one of my projects I needed to create a system-wide mutex (a "mutex" being an object or "flag" to say that something is locked, e.g. a method or bit of code, so no other process can call it).  I needed it to be system-wide since I had multiple programs running on the same computer that needed to be in sync, so I couldn't use the synchronized keyword.

So I created a new class which I've called  FileSystemMutex.  It's very simple, and works by creating a temporary file to indicate that the lock is enabled and the file is deleted when the lock is released.  Because it uses the filesystem, it is "global" across everything that uses that filesystem.

Here is the code:-


import java.io.File;
import java.io.IOException;

public class FileSystemMutex {
   
    private File file;
    private long max_duration;
   
    public FileSystemMutex(String _filename, long _max_duration) {
        super();
       
        file = new File(_filename);
        max_duration = _max_duration;
    }
   
   
    public void waitForLock() throws IOException {
        while (isLocked()) {

            // This is my own function.
            // Surely everyone's written their own "Thread.sleep()" 
            // wrapper by now?
            Functions.delay(100); // Wait for a sec 
        }
        lock();   
    }
   
   
   
private boolean isLocked() {
        boolean exists = file.exists();
        if (exists) {

            // It might exist but is it too old?
            long age = file.lastModified();
            if (age + max_duration < System.currentTimeMillis()) {
                // Too old!
                release(); // Delete the file
                return false;
            } else {
                return true;
            }
        } else {
            return false;
        }
    }
   
   
    private void lock() throws IOException {
        file.createNewFile();
    }
   
   
    public void release() {
        file.delete();
    }

}



One thing to always remember with locks it to ensure that under no circumstances should the lock get left on, usually by a program ending prematurely.  This is why I've included the failsafe "maximum duration" parameter, so if the process that created the lock "crashes", the lock will still be released, eventually.

You would use it like this:-

    private static FileSystemMutex fsmutex = 
        new FileSystemMutex("my_lock", 1000*60); // Might as well make it static

 
    public void MyFunction() {
        fsmutex.waitForLock();
        try {
            [ do something that requires locking this bit of the code]

        } finally {
            fsmutex.release();

        }
    }


'Tis all.

Thursday, June 12, 2014

Intelligent Traffic Alerts

One of the biggest problems with traffic alert apps is actually finding the relevant traffic alerts.  Most apps give you lists of roads or maps, and you have to spend the time either going through all the roads you might be travelling on, or examining maps to see which road the alert is actually on, and whether it's even on the section of that road you will be using.

That's why I wrote Intelligent Traffic Alerts, which takes all the work out of finding relevant traffic alerts.  Simply turn it on, ensure your GPS is active, and listen.  It will constantly scan for new traffic alerts, and if there are any in your vicinity, speak them out to you.

The other major advantage to this is that you don't have to take your eyes off the road.  Even SatNavs can be dangerous as you try and translate the image on the SatNav map to the real world you are on.  With this new app, you get told about the traffic alerts while you drive, which has to be the safest way.  The onlydrawback is that there are no interesting screenshots because there's not a lot to show!

Monday, May 12, 2014

Math Monsters

I've just released my latest app, called Math Monsters!

Math Monsters is a game designed to help and encourage kids to get better at maths. By making maths fun, they will become better at it without even realising, and have fun along the way!

The game is very simple to play. The player must get to the end of each level; they will automatically walk forwards until the monsters that appear get too close. The player can shoot at the monsters by entering the answer to a sum. If they get it right, the weapon linked to the question they answered will be fired. Different weapons are available, but the better the weapon, the harder the sum! If the player gets to the end of the level, they will go onto the next level, which has harder sums and more monsters. If any monsters manage to reach the player, it is game over!

If you download it, please let me know what you think.  As usual, all my apps come with a full money-back guarantee forever at any time.

Friday, December 20, 2013

Mystery Screenshot!


My latest Android project: At the moment it's just a 3D test.  I've not really thought about what game to make yet. 

Wednesday, July 17, 2013

Compiling Firmware for an ADSL Router Modem

I've been Googling on and off for about a week, and I've come to the conclusion that no-one has ever managed to successfully compile firmware from source and install it onto a ADSL router.  There's plenty for a "normal" router, but not an ADSL router, i.e. one that allows you to connect to your ISP.

I've tried it myself, downloading the ASUS source.  Because of GPL, they're obliged to provide it, but they make it as difficult (well, impossible I suppose) to actually compile it due to all the extra libraries, specific toolchains and config files that are required.  And then there's the problem of the hardware being pinickity about allowing custom firmware.

There's OpenWRT and DD-WRT.  OpenWRT doesn't have anything for an ADSL router, and DD-WRT only seems to have it for one model, but that doesn't seem to compile and there seems to be a question of whether it is open source any more.

Part of the problem seems to stem from all the different chipset and hardware configurations, but surely someone somewhere has managed it?

Thursday, June 20, 2013

Is Oracle trying to kill Java?

I'm a big Java fan, but it seems that Oracle, and before them, Sun, are doing everything in their power to put people off using it.

I've just run one of my applets that I run every day.  Today Java came up with a new window saying my version of Java was insecure and "would I like to update it?".  I clicked on OK, and it took me to the download page.

"While it's downloading", I thought, "I'll go back to my applet.  I don't really have time to install the update today."  I didn't bargain for the fact that Oracle had other ideas.  Now, every time I go to the page with the applet, it is automatically redirected back to the Java download page.  Until I update my Java, Oracle won't let me view any web pages that have an applet.  What?  Who owns my computer, me or Oracle?  This is also Linux I'm running on, so installing isn't just a case of running "install.exe".  So goodbye to whatever I thought my job was, Oracle has decide that the only thing I can do now is update my Java.

If that doesn't put people off using Java I don't know what will.  I like Java (the language) and use it for almost all my programming, but I wouldn't use it for applets unless you held a gun to my head.

tl;dr - Don't use Java for applets unless you want to lose control of your own computer.


Friday, May 24, 2013

Android Football!

Allow me to announce my latest Android game: Android Football!


I've always wanted to create a football game, and with touchscreen controls it gets round the problem that old-style football games have in deciding which football player is under control.

But before kick off, the first thing to do is choose your teams formation.  One aspect I'm quite please with is the AI of the players.  They always seem to be in the right place at the right time.



Once the game has kicked off, you control the players by dragging a line from the player to where you want them to go.


The players will automatically kick the ball when they hit it.  The direction is determined by the angle the touch the ball at, in the same way as a game of air-hockey (though this game is thankfully not quite as frenetic!).


The free version only has friendly games, but gives you all the features of the actual match so you decide if you like the game.  In the full version you can also play in a league, and choose the number of other teams.  If it proves a success, I'll be adding a Knockout Tournament option to.

Thursday, May 09, 2013

I've had a great idea!

I know, I'll add the Google+ API to my game Stellar Forces!  That way, new players will be able to sign up quickly and easily!

[3 hours later, after jumping through lots of Google-shaped hoops...]

What a waste of time.  I think I'll keep it the way it was.

Friday, April 26, 2013

When is Normal not Normal?

Say you've got a vector that you want to normalize:-

Vector v = new Vector([a number], [another number]);
v.normalize();

What would you expect to happen if both your numbers (maybe the movement vector of your space invader) were 0?

I would hope it would return a vector of (0, 0), so that when you added this vector to your sprite's co-ords, it didn't move.  Which, with a vector of 0, 0, would be correct.

Unfortunately, in Android Java (and maybe normal Java as well), it returns (NaN, NaN), which is no use to anyone.  I'd prefer an error at least (failfast?) so that I knew something unexpected was happening.  With NaN, all your sums suddenly go awry, and until you know the above piece of information, you'll spend ages trying to work out just how your vector is turning into garbage and why your sprite has decided to move to infinity on both axis.

Wednesday, March 06, 2013

Was making money harder then or now? [Android]

I'm at that common stage of Android development where I'm wondering what my next project should be.  I'm tempted to do something in 3D, but it always turns into a maths nightmare.  Note to self: Don't do it!

I've recently finished my last app, a platformer called "Ninja!".  It's pretty good, and I might use the engine for something a little more complex - I'm thinking a Bladerunner-y / Judge Dredd.  However, I am put off by the sheer number of other platform games available on Android (not that the platform genre is any more saturated than any other genre on Android).  Who would even notice my game?  I guess that's why marketing is so important on Android now, probably more so than the programming.

But then I look back to the golden age of gaming (in Thatcher's Britain anyway): the mid-80's, when it was predominatly the Spectrum that everyone played on (and maybe the C64 if desperate).  How do conditions now compare to then?  There may be thousands of platform games available for Android, but there are also millions of users playing them.  What was it like in the 80's?  According to Wikipedia, 5 million Spectrums were sold and 24,000 programs were released.  According to some random website I found after Googling, there are 295 million Android phones and 460,000 Android apps.  Despite the fact that these numbers are untrustworthy and vague, lets work out the average:-

Spectrum:-
5,000,000 devices and 24,000 programs = 208 customers per program.

Android
295,000,000 devices and 460,000 apps = 641 customers per app.

So it seems that despite the competition, we've got it over 3 times better than they did in the 80's.  Still, it doesn't seem like it.  Maybe I should stop programming and do marketing for the time being.

Monday, February 11, 2013

New Android Game: Ninja!


It's a platformer.  Avoid the enemy ninjas (or throw shurikens at them) and negotiate the fiendish levels.

One of the great things about creating a "platformer engine" is that once it's created, it's simply a case of having fun designing levels.  Going through historically classic platformers and implementing your own version of their ideas, and being able to play it straight away, makes all the hard work worthwhile.

I've also written the code for moving platforms, but I'm still trying to work out how to include them in the map data; the map data only handles a block type in each "cell", whereas moving platforms require data on the direction to move in, and the distance.  More on that in a future post.

Anyway, find Ninja! here!


Tuesday, February 05, 2013

Eclipse Hangs or Freezes on Startup

Try this:-

  1. cd .metadata/.plugins
  2. mv org.eclipse.core.resources org.eclipse.core.resources.bak
  3. Start eclipse. (It should show an error message or an empty workspace because no project is found.)
  4. Close all open editors tabs.
  5. Exit eclipse.
  6. rm -rf org.eclipse.core.resources (Delete the newly created directory.)
  7. mv org.eclipse.core.resources.bak/ org.eclipse.core.resources (Restore the original directory.)
  8. Start eclipse and start working
 (Thanks to Olaf)

Monday, November 12, 2012

Installing Java for Applets

I've blogged before about the fact that Sun (and now Oracle) like to make it as difficult as possible to get Java working, especially for applets.  You can spend hours trawling the new for soutions, but often they don't work due to differing versions of your OS, of Java and your browser.

However, for future reference I've found this page which seems to wort and is incredibly simple:-

http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html


Wednesday, November 07, 2012

Julian Gollop Announces New Chaos

If you're a fan of Chaos then you probably already know this, but Julian Gollop, famed developer of strategy games, has announced he's working on a new version of Chaos.

Chaos is indeed a brilliant game; that's just one reason why I copied it so faithfully for my own Sorcerers for Android.  I hope Julian won't mind if I treat this as a bit of competition between us as to who can create the best game.  I'm bound to lose, but it's the kind of impetus I need to keep working on a game.  And there can be no losers!

Friday, November 02, 2012

Speed Warning

Here's a new app which will hopefully save me money from those annoying speed cameras.

Without wanting to get too political on this blog, what really gets me about being caught for speeding is that it's too easy to creep over the speed limit.  Staying on the right side of the law shouldn't be a test of skill, and the more time you spend looking at your speed dial, the less time you spend looking out the window to check you're not going to crash, which can't be right.

Anyhoo, either way, my new Speed Warning app for Android should help and save people from the usual speeding fines.  It sits on your dashboard and will show you your current speed, in either Miles per Hour or Kilometres per Hour, depending on what your country uses. 

The main feature however, is to give you a visual and audible warning should your speed creep over the limit you have set, which can be easily adjusted with the '+' or "-" icons.  So now you can keep your eyes on the road at all times without worrying if you're breaking the law.

Wednesday, October 24, 2012

Podcast Manager


I listen to a lot of podcasts.  They make driving much more fun; now, when I hit a traffic jam, I think "Great, I can listen to more comedy before I get to work!".  (This probably sounds sarcastic, but it's true).

I was yet to find a decent podcast manager on Android, so I decide to create one.  All the other ones seemed too complicated; all I wanted was one that would let me easily find the podcasts on my phone and play them, but have lots of convenience features like let me return to the same point in a previously played podcast as it was when I last stopped playing it.

With this in mind, let me present Podcast Manager, and android Podcast player with all these features and more:-

* Scans your SD Card for all mp3s.
* Voice search
* Reads and displays the details of your podcasts (artist, album, etc...)
* Remembers previously played podcasts and the last position, so you can pick up exactly where you left off.
* Delete listened-to podcasts.
* Easily browse your phone's memory for podcasts.
* Easy to use interface for skipping through podcasts.

If you have to get it, let me know what you think and I'm always open to feature suggestions.  But at the moment it does everything I want from a Podcast player.

Tuesday, October 23, 2012

Minecraft + 3D Printer?

You read it here first - I predict that in the future you will be able to connect Minecraft to a 3D printer and print out a model of the worlds that have been created.  And I predict the first person to do this will get very rich.  And there will be a shortage of 3D paper since everyone insists on printing out the Mines of Moria.

(I also predict that someone will tell me this has already happened).

Friday, July 27, 2012

New App: Sorcerers

Like every other human being on the planet, I am a big fan of most Julian Gollop games, and the pinnacle of these are obviously Laser Squad and Chaos.  I've "tributed" Laser Squad with Stellar Forces, and now it's time for some Chaos.

My new app is called Sorcerers.  Like Chaos, it's a multi-player game where each player takes control of a wizard.  Each wizard has some spells which they must use to destroy the other wizard, and the winner is the last wizard left standing.  The spells range from fantasy creatures like a Wraith or Golden Dragon, to Magic Fire and of course Turmoil and the dreaded Gooey Blob.




There are a few changes to the original: there are more variety of spells, and turmoil doesn't crash the game.  It's currently 2-player, but will be increased soon to up to 4 player.

Thursday, July 26, 2012

Jellybean Graphics Bug - Help!

There's a really annoying bug in Jellybean, and I can't work out how to get round it, so I'm posting it here in case someone else has come across it and knows a solution:-

I've got two .png images in my app, both identical except for the name and I've changed one of them to be "bluer" (using Gimp). However, Jellybean refused to draw the bluer one. (I'm having trouble with other random images as well). There are no errors, and it loads the file okay, but nothing appears. I've tried swapping their names. They're both only 57x57 pixels, so it's not a memory issue.

Someone else has posted the same problem on Stack Overflow, but as of now there are no replies.

It's driving me mad!  How can something broken like this end up being released onto millions of mobile phones?


UPDATE: I've found a workaround!  Copying my images into /drawable-nodpi, seems to have solved it.

Wednesday, July 25, 2012

Free Service?

One thing that is starting to annoy me is the number of services that start out free, but then as soon as they become popular they introduce paid-for features while slowly reducing the free features until they are virtually useless.

The stock response to this is "well, it's free, what do you expect?".  However, this oversimplifies the issue and ignores all the other aspects of the problem.  Most important of these is that I've recommended these services to others, thus giving the free service its userbase.  My comments on these services are still on the internet, but I wouldn't recommend them now.  I've also spent my own time incorporating their service into my apps and my time isn't free.  Their services are now so entwined in my apps that it's going to take me lots more time to remove them and find alternatives.

I've got no problem with these services charging for extra features, but reducing the features that were there originally is almost tantamount to blackmail.

Friday, June 01, 2012

Your First Java Library Function

The first thing to do when you start creating your own library of Java functions is to write a wrapper for Integer.ParseInt() (and any of the other similar built-in functions).

Integer.ParseInt is, maybe deliberately, the most pedantic piece of code ever written.  Pass it a string like "2" and it works fine.  Pass it a string like " 2" and it goes "waoh!  A space?  What the f*ck is that?? Error!  Crash the system, we're going down!!".  Is it too much to ask to be able to handle a space?

In fact, almost any non-numeric character (the main exception being a "minus") in the string will cause it to throw a wobbly.  Even a decimal point: "2.0" is beyond its capabilities. 

My suggestion is as follows, although it's not the hardest piece of code to write:-

    public static int ParseInt(String s) {
        try {
            if (s == null) {
                s = "0";
            } else if (s.length() == 0) {
                s = "0";
            }
            return Integer.parseInt(s.trim());
        } catch (java.lang.NumberFormatException ex) {
            return 0;
        }
    }

Monday, May 28, 2012

MySQL Replication Challenges

If you've got a server running MySQL that's creaking under the weight of database reads, the obvious solution is to set up replication.  MySQL replication seems to work fine, but one thing I didn't appreciate at first is the changes that probably need to be made to your code (and not just changing which server it reads data from).

I imagine that most web pages, if they're anything like mine (oh dear) implicitly rely on the database being updated immediately.  My web pages usually have a similar structure:-

1: Read any get/post values and update the database
2: Display the new updated data as part of the web page

This seems fine, and it is if your database is updated immediately (since stage 2 is reading the data that has just been changed by stage 1).  If you're using replication, then you'll be updating the master database in stage 1, but then reading the data from a slave for stage 2.  However, if the slave hasn't updated itself from the master by the time stage 2 is running (and we're probably only talking millionths of a second) then stage 2 will display old data, and your users will cock their head to side wondering what's going on and why the system has ignored their commands.

Another similar problem I experienced is with an automatic routine that transfered data from one table to another.  For various good reasons, this routine would read the first 100 records (from the slave, obv), append them to another table, and then delete the originals (on the master).  And this worked fine until there was a small glitch in the communication between the master and slave.  Glitches in communication aren't normally a problem since you can specify how long the master retains logs for, so you can turn a slave off for a few days, turn it on, and it will (eventually) update itself.

However, due to the glitch, the slave wasn't updating itself.  It read the first 100 records from one table (on the slave), wrote them to another table (on the master), and then deleted the records from the original table (on the master).  Since it was reading the records from the (non-updating) slave, the next 100 records it read were the same 100 records as last time, because they were still there.

Being an automatic routine that runs overnight, this process was duplicating identical records at a hysterical rate, eventually eating up all the disk space and so the whole system went down within just a few minutes.  Oh dear.

So, in summary, replication technically works very well, but you can't just plug it in and turn it on and expect all your problems to be solved.  You probably need to think carefully about when to read from the slave or master, and what will happen if the slave is too far behind the master.

Thursday, May 17, 2012

Recording Videos of my Android Apps

If there's one thing I've learnt (or learned - which is it?) over the last month, it's that people like to be able to see what an Android app looks like before they hand over any hard cash.  I recently created a video of a few of my apps: Chromakey Photo Edit, Worldcrafter and Stellar Forces.  And blow me down with a feather if sales and/or downloads didn't increase!

So how did I create the videos?  I do have access to two phones, both of which are capable of recording videos, so the obvious answer was to use one phone to record another.  However, keeping both phones steady while recording and playing was harder than I thought; the phone that is recording doesn't need to be held by a person, but it does need to be positioned between the player ("hello") and the phone I'm playing on.  Asking a fellow human to hold the recording-phone tends to feel a bit ridiculous as they have to reach around you and keep the phone super-steady, which isn't that easy.

The solution hit me like a birthday present when, for my birthday, I got a present that turned out to be a phone holder for my car.  Perfect!  Its suction cup held it securely to a table while I played the games around it.  The only challenge now is to make a vaguely entertaining video that's short but also shows off the best features of the games.  And also where my thumb isn't always in the way.

Here's the Worldcrafter one:-



Since the game involves tilting the phone, that provided an extra challenge for keeping the phone in-view.

Friday, March 30, 2012

More Eclipse Update Frustrations

I use Eclipse all the time for coding, but every time I want to add a new add-on to it, it turns into a nightmare making me want to strangle whoever came up with the Eclipse update system.  Todays living hell is all about trying to add MAT (Memory Analysis Tool), just so I can read a "hprof" file.


Okay, where to start?  It was easy enough to find the MAT homepage (http://www.eclipse.org/mat/).  How do I actually get it?  There's a link called "Download the latest version as RCP application" (whatever RCP means), but I know I want to add it using the Eclipse Update Manager.  There is a "Getting Started" link, so I'll try that.

This is looking good.  There is a link called "Read the Eclipse Memory Analyzer Tutorial to see how to start the program. "

We must be there soon.  The tutorial says "Install Eclipse MAT via the Eclipse Update manager . Select "General Purpose Tools " and install "Memory Analyser (Incubation)" and "Memory Analyser (Charts)"."


Okay.  I assume by Eclipse Update Manager they mean the Install New Software option.


That asks me for a site to update from.  Erm, any clues Mr. Tutorial?  No?  Gee, thanks.

Okay, lets go back to the downloads page.  It's better than nothing.


Watch out!  It has an update site!  Okay, let's go back into Eclipse and put that in.

Hmm, it lets me put in the text, but OK is greyed out.  It seems that this is a "Duplicate Location", even though it's not in the dropdown list of locations.  Great.  Another dead end.

What next?  After fumbling about for half an hour I try the Eclipse Marketplace (which takes about 2 minutes for the window to appear as it insists on loading data from the internet every time).  I'll just do a search for MAT.


It's here!  This must be the solution then.  Okay, what do I click on?  The only links are "Share" and "Learn more", neither of which sound like "End all this messing about and just get it now", so I guess I'll try "Learn More".


This link just takes me to the website of MAT on the marketplace.  The only link I can see on the page that might be of use is the one that gives the update site.  What?  I thought this was the update site!  And the link to the Home Page returns a 404.


Fucking Hell this is ridiculous.  It seems that the Marketplace only has v1.0 of MAT, which has been replaced with a seemingly non-existent v1.1.  Maybe.  I don't know and am rapidly losing interest in this piece-of-shit life-wasting process (Apologies for the swearing but I've lost count how many days of my life I've wasted trying to find my way through the maze of Eclipse updates only to give up).



UPDATE

I finally got MAT by discovering a "Available Software Sites Preferences", adding MAT and then doing the update (this sentence makes it sound far easier than it was).  With MAT installed, I opened the HPROF file:


[Sound of programmer stabbing himself]


Friday, March 23, 2012

Java URL class is Buggered to Buggery

Take this bit of code:

URL url = new URL("http://www.somesite.com/forums/test.php");

What should "url.getFile()" return?  I would have guessed the string "test.php".  But it returns "/forums/test.php", which seems to be including the path as far as I can see.

The javadoc actually says "Gets the file name of this URL", but then goes on to contradict itself in the very next sentence with "The returned file portion will be the same as getPath().".  Is it me or Oracle[/Sun] that needs to go back to programming school and learn about the difference between a path and a filename?  Or maybe there is a subtle but massive difference between a "file name" and a "filename".

Also, AFAICT there's no way to get the (what I would call) filename, i.e. "test.php" in the example above.

Thursday, March 15, 2012

XML is a Step Backwards

XML has its place, like when transferring data between disparate systems.  But I can't help wondering if using it for things like the Android Manifest is a step backwards.  Why not use a programming language?  With XML, you lose a lot of the useful features of a programming language, like code-completion and interaction with the main code.

Taking the Android Manifest as an example, I have to refer to a list of the specific permissions that I require, since without code-completion it won't tell me the possible options.  These also have to be spelled exactly right.  Also, I'd like to change the icon based on some flags in the code.  Can I do this?  No, the XML is static.  Great!

Friday, March 09, 2012

New Android App: Speech Browser

I can now unveil my latest app: Speech Browser!  It's a voice-controlled web browser with all the usual functions that a web browser has, such as going to a website, doing a search, going forwards/back through history, following links, searching for text etc..  

However, being voice-controlled, there are a lot of extra functions: repeating a page, going forward/back through the page, controlling the speed of the voice.  There are also 3 voices available: British, American and Canadian (although being British myself I can't tell the difference between the last two :) ).

It should hopefully be quite useful for blind Android users (and if any find it useful or otherwise I'd be please to know), but I also wrote it for people to be able to listen to a website like Wikipedia without having to stare at a screen.

Wednesday, February 29, 2012

Thunderbird Deleted all my Deleted Items!

It's not the double-negative that it sounds like.  I "delete" all my emails (that have been actioned) so they go into my Deleted Items folder in Outlook, for reference at a future date.

However, I then started using Ubuntu at work meaning Outlook was no longer an option.  There is the Outlook web view, but as far as I can tell there's no search feature.  Being the modern techno-geek radical that I am, I thought Thunderbird would be a good idea, at least for the search facility.

Initially it went well, but then I noticed that the contents of my deleted items had disappeared: 5 years worth of emails (about 9,000 emails in all)!

The problem seemed to stem from the fact that I had "Empty Trash on Exit".  I naively thought that this meant it would empty the Trash folder on exit, but Thunderbird, presumably trying to be clever and helpful, decided that my "Deleted Items" folder was my trash, not the actual Trash folder.  Er, thanks.  Back to Outlook it is then.  I just hope I can recover them all.

Thursday, February 23, 2012

Good Review!

While it's nice to make a bit of cash from my apps, getting a good review is always great; I don't think many users appreciate how much effect they can have on a developer; a crap review (especially nonconstructive ones) can be a real downer.  Even the most basic app takes days of work, and when they are given away free but a user still leaves a crude review like "this is rubbish", it makes you think "What is the point?".

Conversely, getting a good review is great and really makes it all worthwhile.  Here's a humdinger that I received a few days ago for UK Traffic Alerts.  I've taken a screenshot since it could well get superseded by (hopefully) just as gushing reviews.


Whoever Peter is, I thank you!.

Thursday, January 19, 2012

Android Bitmap Idiosyncrasies

Whilst improving my Android app Chromakey Photo Edit, I've come across a few idiosyncrasies with Android Bitmaps which I thought I'd share for reference:-

  • Bitmap.createScaledBitmap() always returns a bitmap of type RGB_565, regardless of the source bitmap.  See http://code.google.com/p/android/issues/detail?id=13038
  • ARGB_4444 is now depreciated, so you'll always need to use ARGB_8888 if you want to store transparency information.
  • When using BitmapFactory.decodeFile(), always try to pass a BitmapFactory.Options().inPreferredConfig to ensure you get a bitmap in the format you need.  By default, bitmaps loaded this way are always immutable (uneditable), so you'll need to do a Bitmap.copy() if you need to make it mutable.
  • Bitmap.recycle() is ALWAYS required; if you create a bitmap but don't recycle when you're finished with it, expect to run out of memory eventually.  Setting bitmaps to null isn't necessary.

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.