Tuesday, July 26, 2016

Zero-Time Programming

Welcome to a description of my new programming paradigm: zero-time programming.  Being a busy family dad, I've got no time for programming.  I've got no time for even reading blogs, never mind actually writing one.  Or that's what I thought until I developed zero-time-programming, for people who have zero spare time but still want to create and release something.

The principle behind zero-time programming is to write code, run it yourself (if you've got time) and then release it.  The main requirement is that you have the facility in your released software to inform you immediately if there's a problem; my usual choice is by email, so I get an email every time there is an error.

"But this is crazy" I hear you say.  Sorry, I've got no time to discuss it.  I will concede that this is not the best method for writing mission-critical code for NASA, but if you're a hobby programmer like me who just wants to get games out there while also having family life and full-time job, there's no better choice.

Here's the main bullet points to help you out though:-
 
* Wrap all your new code in a try/catch, and in the catch, send yourself the error.  That way, the whole program won't grind to a halt.
* Throw exceptions wherever something happens that shouldn't, i.e. at the end of switch statements.
* Make a note of any thoughts you have about what to code, immediately.  Whether in the shower, on the toilet etc.., your subconscious will do a lot of the thinking for you, so don't ignore it or forget what it's telling you.  I've "found" plenty of bugs whilst sitting on the toilet.
* Use your own code, and make other code your own.  Avoid moving ground.  Who's got time to refactor code when your favourite library decides to change their method signatures?
* Send yourself a message from your software when something you need to check for happens, so you know it is happening (or not).
* Sanity checks - for example check variables aren't null.
* Ensure your error messages state which version has the error, so you can ignore old errors that have already been fixed.
* As you code, if you think of an extra bit of code that needs to be written in addition to the bit you're currently writing, e.g. a null-check that needs to be made, quickly write a todo, e.g. "// todo - nullcheck socket".  Otherwise it will fall out of your head and bite you later.  Once you've written the bit you're writing, do a search for all the "todo's" in your code and addess them.
* Never start a new project from scratch.  If you can, copy an existing project and refactor it towards your new ideas.

All this will save you loads of time.  How long does it take to go through a testing plan?  Too long.  Of course, this method of programming may mean you get a stream of messages informing you of bugs, but that just means you can fix them as soon as you have a spare couple of minutes, and then upload the next version.

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.