December 13, 2011

Devin's Sequence

I have found my own unique integer sequence, I'll just call it Devin's Sequence, and as far as I know this is an original. I'm having a hard time finding an exact formula for it, but I do know how to generate it empirically, because I'm using it in one of my programs. I just wish I could figure out a formula to find any value in this pattern, but alas my math has failed me! Here is the first 20 values:


1, 9, 21, 37, 57, 89, 121, 161, 213, 261, 325, 385, 457, 545, 621, 717, 805, 917, 1033, 1137, ...

December 5, 2011

It certainly has been a while since I've posted here!

I've just made my submission to the java4k contest and had a blast making the game! It is a derivative of my ballmove, but it has been enhanced to be a full game. I'm just hoping that I didn't screw up with the submission (crosses fingers). Yes, the 4k version of the game has more features than the regular... it's interesting how much more I can pack in when working under pressure of size limits.

My android game went on hold for about two weeks because of Skyrim. Which is a fun game, but after a while  I just lost interest when I was running around one-hitting everything. The game has undergone some real device testing, you'd be surprised how annoying it is not having a device for the target I'm developing for. First thing that I'll be buying with any money I earn from the game is an android device so I can actually test more frequently on a device.

I'm starting on my second android game, as I wrap up the first one. Mostly just cleaning up code, and fixing the odd defect that appears. The next game will end up being far more robust, mostly because this first one was mainly about learning and understanding game development on android. Yes, there is a lack of details here as I'm not ready to talk about anything yet.

Anyways, I should be writing a review right now. However, my frequency on this blog should increase again in the near future.

October 29, 2011

My Game

I'm in the final stages of getting my game ready for deployment onto the Android marketplace. A week or two and I should be ready. Considering the simplicity of the game I actually find it to be somewhat satisfying to play randomly. It isn't your all-star game, but it is pretty fun to just play randomly. I expect to reuse a bunch of my code and quickly whip up a free game; well, before I get into a more serious game.

I'm not sure what it is, but I have a thing for 'shapes' I like the whole geometry based art and the style that goes with it. I'd be tempted to take my tower defense and port it over to android, and finish it. Considering development is actually very fast and easy on android thanks to a number of tools out there I probably could without breaking too much of a sweat. I will probably make an announcement on this blog once the game is posted. I won't say anything about it, or even the name of it because nothing is finalized yet.

October 5, 2011

Android Development

It has been over a month since I've posted anything. In that period of time I've basically done minimal work when it has come to actual game development. However, I've been busy learning a framework inside out so that I can easily develop games for Android. OpenGL ES isn't actually that bad once you've learnt most of it and how everything works (it still is a bit ugly and I hate procedural programming). I've found a 'cure' to the crappy emulator by using a cross-platform framework. This means I can develop a Desktop, Webapp and an Android app all in parallel without having to change my code. I've actually spent a reasonable amount of time figuring out artwork and building GUI elements. It would appear that I've done nothing, but at the same time I've done so much its hard to explain everything without boring someone to death.

I've also spent the last month catching up with friends and relaxing a bit more. It isn't out of the question for me to take a bit of a break. I'm starting to get settled in again and this time I'm ready to take on some more serious development. I'll be able to focus more on development of the game and less on the framework since I'm going to be using a third-party framework. It is actually designed very well that it pretty much matches most of what my old framework did (but the fact its an open-source project with 20+ contributors means it is better overall and more robust).

I even peaked at the older XNA + C# game that I had worked on. I might even consider polishing it up and getting some artwork/sounds then post it as a Win7 Phone app (assuming 7.5 hasn't broken everything lol). I'll have to revamp and rewrite a good chunk of the code to make it acceptable/performance orientated. However, that is down the road. For now, I will focus on my Android project and probably post a developer's preview on my website within the next few weeks.

September 3, 2011

OpenGL ES on Android

I'm exceptionally disappointed right now with how bad the emulator is for android. It is painful to just get the basic emulator to render a few simple shapes since it wants to run at 1-2 fps. Then to top that all off, the emulator doesn't even support OpenGL ES 2.0. I have to say its really just like a big middle finger to developers as without a device you will have to test on a system that is painfully slow.

The Win7 Phone emulator was vastly superior in so many aspects. Unfortunately, that isn't my target device and now I'm starting to think I'll need an android device to even consider developing the game on Android. I guess I might have to pump out $200 and get myself an IdeaPad A1 when it comes out... The only issue I have here is that I just wanted to test out the waters and see if I really want to do Android. After spending a number of hours and digging around... I'm not even sure about it.

August 31, 2011

Android Development

I had a decision come across my mind a little while back. Basically, I want to develop for android. I've played around with applets and that is good and all. However, after literally 'scouting' out android development I've come to realize my time is much better spent working on Android as my plan was to port the game to it. The structure is a bit different than I had anticipated, but it simplifies a significant amount of work for me. With two reviews behind my back I can focus on development for the next month or so. Unfortunately, that means I'll be scraping the current project and putting my resources towards Android. The game I'm developing will be identical to Project X.

I'll will keep updating my blog as I progress through the development. I will probably start off with an extremely simple game. I think I'll call it RMC!

August 24, 2011

Reviews Reviews and more Reviews

Well development might hit a halt for the next little bit as I had another review pop up from under my sleeves. I have a feeling a few more are to come after that, which makes for a pretty busy time. I'll have to see how much time I have for things as I'll be taking a course over the next couple months as well. I think I might be getting a bit too busy these days. I might have to make a few adjustments if I want to seriously keep up development at a reasonable rate.

August 21, 2011

Release 0.2.5

Today I decided to release a cumulative sum of a number of changes/features I had completed. The best news about this is I've made a number of changes so that development can be significantly faster than before for certain things. The bad news is that I still have lots to do haha! Currently, in the tower defense, units don't have any stats, towers cost nothing, and well it makes for a very easy game. On the other hand it is significantly more 'playable' now, but don't worry, the stats for the units is nothing more than me simply adding in a few numbers. I just still am deciding on what kinds of numbers and where :P

I have myself another hardware review to write so I'll be MIA for the next couple of days getting that all finished up. I hung out with a friend of mine last night, he just had laser eye surgery, I wanted to see him and check out how he was doing. I found it hilarious when he told me he has a lifetime warranty on his eyes. I guess they give out warranties for your body parts nowadays. (Scary thought). I know it isn't a whole lot yet, since it the game is still in an early alpha build, but in a few weeks from now it should be heading into a beta stage.

August 18, 2011

Updates

I've added a couple of new features to the Tower Defense. I mostly work on this in my spare time between jobs so sometimes I get a bunch done, and other times it seems like development stalls. That is the unfortunate situation of working two jobs, one which happens to be full-time. I certainly enjoy my other jobs, no doubt about that, but I do wish I had more time to spend working on developing the game.

I've planned out roughly 30 tasks to do and by my estimates I might be able to get them done by early September. After that, well, I'm thinking I'll have to play the game a reasonable amount and fine tune it a bit. I'm thinking about that time I'll consider working on an Android version. I avoid thinking too far into the future as things come up and I find I have to move my plans around. However, right now, I think its time for bed!

August 13, 2011

Bugs

Don't you just hate bugs? Now, I'm not talking about insects here. I'm talking about the little computer bugs, and I have to say I've grown to appreciate Test Driven Development (TDD). I'm not referring to extreme programming, which is a type of TDD, but the whole concept of testing your code before you even deploy it. I know so many people think some things are trivial and it wouldn't be useful. For the most part, you probably are right, but the beauty of it is for large-scale systems. Let's also not forget how handy it can be when trying to modify old code.

I was overhauling how input is handled in my framework, essentially gutting and redoing roughly 1500 lines of code. Which, isn't really a whole lot, but certainly has room for error. I decided to quickly draw out my basic plan, followed by rough implementation and then continued to develop and refine it with test code. I caught 4 little bugs before I had even executed the code once because my tests caught some really silly mistakes. Later, during my deployment of the new code into the framework I ran the program and it didn't work and the program was doing something weird. I looked at the code and couldn't find what could have possibly caused it, especially when my tests I ran earlier proved that the case should work. So, for good measure, I ran the tests again, and guess what? I got failures. It took me a bit to figure out the root cause, which ended up being one line of code that I had added during the transition for "convenience". I don't have tests for a good majority of my code, but this little experience has made me value how all the time and effort up front has paid off later. It would have taken me hours to find that one line, which I had completely forgotten about, instead it took me minutes.

Honestly, you don't write tests to make sure your code works. That is just a benefit of writing tests upfront. The real reason is so that when you go and change your code, you can check to see if you broke something without even having to run the program. It is more just for a convenience to save yourself time when you want to change something. If you are writing code that you know you're never going to touch again, then don't bother with the tests. However, if you think there might be a chance you'll change it later, probably best just to go and write some tests that covers the basic cases of how the code will run and a few odd cases. Obviously, if you were really serious about the tests you would analyze the code and figure out your input domains and boundary conditions, heck, you might even see how your code coverage is. Code coverage is another topic, and is really a double edged blade when used incorrectly.

The short version: If you write code that you are going to change down the road, write some unit tests and save yourself tons of time later.

August 7, 2011

User Input

One of the challenges with games is figuring out how to translate user input into meaningful actions in the game. Unlike GUI design you don't always have nice interfaces and buttons that do a lot of the input tasks. I've found my basic input system I've been using just won't cut it for the next tasks I have planned with the tower defense. After 250 unit tests and ~4000 lines of code later I've come up with an extremely robust user input system. Unfortunately, I still have to integrate it into the framework, but that task 'should' only be a few hours of work. On the plus side, I'll be able to do a ton of really cool things behind the scenes with how input is handled by the framework.

I'll probably focus on getting it in and running by the end of the week, I have a few other things on the go right now. Then it will be time to get back into development. I've been doing some planning and figuring out what sorts of things I want to add into the game. Like tower and unit types, how upgrades work, levels/waves work, and so on. The first thing on the to do list is give the ability to sell towers. Which should be a fairly quick change and then I'll probably work on the 'upgrade system' for towers.

August 2, 2011

Server Upgrade

Progress towards the games has been very limited as I've been working on a number of other tasks. I always get sad when I feel like there has been no progress. However, I have fixed a minor bug where the background music doesn't loop. I cleaned up a little bit of code, really minor stuff. Basically, I think it would be pointless to do an update for something so trivial.

Now, what have I been doing? Well, as we speak I'm actually setting up a new server to host a number things from so I'm not bogging down my main computer. I'm running 10GB/12GB ram is a little bit unnerving... but surprisingly, I don't take a performance hit from it! Good news, the new server will have 16GB dedicated to actual server tasks and I can return this machine back to more of a development role.

I've been working on a little tool for myself to help with development for the games. It is a bunch of stuff nobody will ever see, but it makes my life easier hence why I'm doing it. Once I've finished it off and used it to update the games I'll probably put out a new version on the website.

July 27, 2011

GUI

I have to say that over the years I've slowly started to hate programming GUI. It seems every tool and even language has its own way of doing things and very few of them actually line up nicely. Is it really that hard to ask for a common design between them? I've played around with GUI in .NET, Java and C++ (using Qt) and so far Qt has proven to be one of the simplest solutions I've come across to date.

Qt lets you organize and setup your UI to look good and be re-sizable without doing unexpected things. There is a good separation between models and views. The best thing I like about it is how you develop is very sequential, you create your object and then define how it is setup and what it does in response to certain actions. The best part is most of the setting up is done behind the scenes, but gives you the ability to easily code it up yourself without that much effort. Oh did I mention the whole cross-platform compatibility? I'm sure most people who don't know about Qt would laugh at you if they heard you were saying C++ easily supports cross-platform development.

For Java, most of what I've done has been using Visual Editor in Eclipse and also using Netbeans. Netbeans provides a significantly more robust environment for GUI development, but my lack of comfort and familiarity with it has given me a few minor headaches. Overall, it is pretty nice and has that 'advanced' feelings in comparison to Eclipse. I'm pretty sure there are a few people out there that would agree when I say Eclipse has a childish and baby feel to it. (No I'm not a pedophile, its a figure of speech!)

I use a slightly different approach to GUI design inside of my applets. If you want to refer to the MVC model, essentially I have just Model and View, the Controller is basically added to both objects. Basically the View  is responsible for keeping track of its own state and interpreting what the inputs mean locally. Then the Model hooks up to the View and checks to see what 'state' it is in and based on that determines what it should do in response (if anything). I don't use an observer pattern for this because it is a real-time system. The Model has to quickly check the View every loop, personally having your code check the value of a variable every iteration isn't overly costly.

I'm currently in the process of creating a tool to generate serialized objects for use in my projects. The only issue is that I'm learning how Netbeans does GUI so it is a fairly slow process because of the learning. Thankfully, Netbeans really helps the programmer by providing a simple interface for setting up GUI elements and hooking up there actions. So really, don't expect many changes when it comes to my applets, but for the time being I'm planning out what I want to do next with the games anyways.

July 24, 2011

SQLite, Java and Applets

I've basically wanted to die over how painful the combination of SQLite, Java and Applets have been. Honestly, I spent well over 12 hours trying to get the combination to work and it seems to be something very few people do... oddly. I tired about 3 different solutions and the end result was still unsuccessful.

The solutions that I tried were very well designed and I'm actually very impressed at the quality of Java SQLite wrappers and JDBCs that exist. Unfortunately, they are not designed to open SQLite files located inside of a JAR file. That was basically my only real requirement for using SQLite, and it looks to me like I'm going to have to implement my own 'database system'. I could use XML, but at this point in time I'm thinking serialization could be more useful and faster. My database needs don't even require any links between tables so SQLite was almost overkill. Yes, something light-weight is overkill...

I've updated the applets with some background music, and I hacked together a workaround for my 'lack of database issue'. Probably be my next task, as I want something more 'solid' than a few text files. I'm actually curious if you can even use JDBC on a file inside of the JAR that your code is running in... So far, it appears to be down right impossible and very few people seem to have written anything about it. Oh well, it is getting late and Monday is upon us again!

July 20, 2011

Java Audio

I have to say, Java really doesn't make playing audio simple and intuitive. It isn't overly complicated, but I expected it to be as easy as loading images, apparently not. I will have to check to make sure the Applet is loading the audio file from the jar and not trying to download the song from my website every time someone runs the applet (I have a feeling that could get costly).

If all goes well not only will I have background music but also sound effects. For anyone that is interested this is the code required to play wav files: (mp3 requires a third-party library)


import java.applet.Applet;
import java.applet.AudioClip;
import java.net.URL;


public class SimpleAudio {
  public static void main(String[] args) {
    try {
      Applet.newAudioClip(new URL("YOUR_FILE_PATH_HERE.wav")).play();
    } catch (MalformedURLException e) {}
  }
}

As you call tell... why not abuse the high-level API of Applet to do the dirty work? Java will automatically mix multiple AudioClips, and unlike Clip, AudioClip doesn't appear to have a length limit. Turns out to be a very easy way to do something apparently complicated in Java.

The above is obviously not code I would use for anything practical, but it is simply a way to hopefully show someone how easy audio can be added to a Java application. Now, before people ask me what 3rd-party library they need for mp3... go here: http://www.javazoom.net/mp3spi/mp3spi.html

I was going to tell the guy he should thread his Player play() method so that it is non-blocking, but it is simple enough to workaround I really doubt it is a useful suggestion. I guess a short example to prove my point:


import java.io.InputStream;
import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.Player;

public class ThreadedPlayer extends Player implements Runnable {
    public ThreadedPlayer(InputStream arg0) throws JavaLayerException {
        super(arg0);
    }
 
    public void play() {
        new Thread(this).start();
    }

    @Override public void run() {
        try {
            super.play();
        } catch (JavaLayerException e) {
            e.printStackTrace();
        }
    }  
}


Okay, good enough for me. Yes, calling close() will unblock play and exit the thread. :P

July 16, 2011

New Update

I have done most of the stuff I needed to for an update to Project X, but it really has just been too long. Only missing the actual part of the game that makes it "playable", units killing each other haha. I'm still kind of fighting a cold but it is basically gone so I have no idea how to describe it. I was given an extension on another thing I was working on so that allowed me to put in a bit of time into the game, but we will see how much more spare time I have in the near future.

Here is the listing of user stories I completed:

  • As a User, I can press a wave button when playing to spawn an enemy unit.
  • As a User, when playing I can see the number of lives I have remaining.
  • As a User, when playing I can see the amount of money that I have.
  • As a User, when I press a tower button I get a floating indicator so that I know where it is going to be placed.
  • As a User, when playing I can see the price to place a specific type of tower.
  • As a User, when I click on the board with a tower indicator I can see a tower be created.
  • As a User, I can see the unit change its path to go around a tower if it is placed in the way.
  • As a Developer, I can create a button with an image in the background.
It isn't that much right now, but I'm getting there.

July 12, 2011

Delays

It feels like a while since I've made an update, but rest assured this isn't because I'm not trying/wanting to. I am planning on doing a larger than normal update mostly because I don't want to give a bad impression. I'm also getting that sick feeling so instead of staying up and working on development. Then getting sick and regretting it, so I think I'm going to call an early night and get some more sleep.

I had an interesting idea come into my head when I was driving home the other day. Using polymorphism to also classify objects into categories, and no this isn't a new concept to me, I simply found a very useful way to apply it to games. This pretty much makes sense to anyone, but what it allows me to do is treat many different types of objects in a unified way. An example would be, I have a spawn unit which I can have inherent something called 'attackable'. This means it has methods for taking damage or getting an armor value, etc. Then I can very easily make the towers attack-able by simply inheriting that and implementing the related methods. It will make it easy to check conditions because something that is an instanceof attackable is obviously something you can attack.

For non-programmers that probably won't make any sense, so don't worry about it. Tomorrow I plan to put in quite a bit of time to development, but tonight I think sleep would do me some good so I don't get sick.

July 2, 2011

Self Documenting Code

To be fair, some documentation is always a good idea; however, one thing that I've noticed over the years is people who feel it is a requirement. Personally, comments have only been somewhat useful for me after looking back at my code from years ago. Why? Comments take up space. I fully understand how useful comments would be back in the days with heavy assembly programming, but in high-level languages such as Java or C# (no, I don't consider C++ high-level anymore, its more of a mid-high) if the code is written "properly" and written to be easy to understand (typically done by extracting common code) then comments simply waste space.


Usually, when I look up code I see it being documented, which is good, but then I also find extensive commenting where it would have been better to just write self-documenting code. Documentation is great for libraries because you don't usually have direct access to the code. When you do have direct access to code it seems to be a waste. Example, I was looking up an algorithm and the guy had written in a significant amount of comments/documentation. Did it help? No. I spent more time reading comments than code, so simply removing the comments and looking and the code alone (with a few refactorings for names) it took me minutes to figure out the code. I literally cut the content down by more than half because of the comments.


I'm I saying commenting is bad? No, it should just be done in moderation, because it takes almost more time to write it than the code itself, then take into account maintainability. Those two alone are very costly, whenever you need to produce or modify code. If you instead write easy to understand and simple code you won't even need to document. If you choose variable names that are descriptive then you won't have to sit there and refer to documentation on what epsilon means.


Think of this code inside of a class called box:

int static getType(int w, int h) {
    if (w == h)
        return 0;
    if (w > h)
        return 1;
    if (w < h)
        return 2;
}

So what do you think it is supposed to do? Well, lets look at it again with comments:

 /** 
  *  Finds the type of box based on its dimensions
  *  a - first side of the box
  *  b - second side of the box
  *  returns 0 if it is a square, non-zero if it is a rectangle
  *  and 1 if width side is larger than the height side or 2 if
  *  height side is larger than the width side
  */
int static getType(int w, int h) {
    if (w == h)
        return 0;
    if (w > h)
        return 1;
    if (w < h)
        return 2;
}

Now, you probably get what it is trying to do, but how long do you think it took me to do the second code section compared to the first one? How long did it take you to read the second one compared to the first one? And how many things do you think I would have to change if I decided to change the return type to an Enum?  So what would I write?

Well take a look:

BoxType static getBoxType(int width, int height) {
    BoxType type = null;
    if (width == height)
        type = BoxType.Square;
    if (width > height)
        type = BoxType.HorizontalRectangle;
    if (width height)
        type = BoxType.VerticalRectangle;
    return type;
}

So what is horizontal and vertical rectangle? Well, you don't need comments to figure out what the difference is. Look at the conditional statement prior to the assignment. What is BoxType? Well its a type of box, looks to me like it can be either a Square or a Rectangle. As you can see, this code essentially doesn't need to have comments, or documentation unless you cannot look at the source code.

Could I have changed the above code to return an Enum, sure... but wouldn't I then also have to update the documentation? :P

June 30, 2011

Python

I just spent most of today learning python at work. I knew almost nothing and in about a day I can say I mostly understand python and how to use it. My first impressions were, this is interesting, but by the end of the day it really just bothers me. The idea of having everything in classes as public scares me, and having nothing constant is even more scary. Personally, I hate the idea of variables not being connected to a specific type, but that is pretty common in scripting languages *shudder*.

I do have to say I do enjoy the len() built-in function as well as you can use isinstance() w/ exceptions to store of stimulate some sort of type-checking. The python library is pretty much like most other languages and the fact that string is pretty much a built-in type makes things very convenient. The other nice feature of python is how simple they make reading files. It honestly feels just effortless to do some of the things in python, I mean you can even potentially use python as your back-end instead of say... php or a few others. I personally like php more than python for a number of reasons, okay maybe not for the $. Now, don't get me wrong, python is wonderful, except it just feels very different than what I am used to which means debugging results in a number of small little errors here and there.

White space being important is a nice thing, but I do prefer my braces just to keep it clear where things end and begin. With python you have to look for the last statement and then the first one that is indented less. It feels like too much work looking around for things, instead of just having a reassuring brace there to be like "hey I'm done now". I do admit the whole concept of "definition must occur first before usage" is a little bit annoying, but I pretty much think of it along the lines of... programming without function prototypes. Then I just feel like I want to cuddle up with Java or C# and keep things simple.

In other news, I'm working on a new game... I'm sure by tomorrow there will be some sort of game on display.

June 28, 2011

Ballmove Reborn!

Ballmove was the very first applet game I had ever created. It is nothing fancy and really I doubt it would be that much fun to play for very long. It is still being hosted on my original tripod website and probably will be for a very long time. I have renamed and called it Ballmove Classic, as the name seems fitting for it now, and posted it up on my website.

I finally got around to doing a revision on the game and this time I did it by putting it into my own custom framework. It turns out to be super easy to develop in my own framework and I'm quite impressed by that fact alone. I added more to the game in terms of complexity but it really wasn't that difficult to do any of the work I had done.

My next project will be a brand new game. I'm thinking for simplicity I might just do a tower defense game. I think Ballrun (a product of a single late university night) isn't really something I plan to make into a game, at least at this point in time. I could probably port it over in less than an hour, but why bother with something that is just a little experiment of mine?

For the time being I guess some people might find joy out of playing Ballmove Reborn. It isn't much, but on a side note it only took me about 8 hours to get it all up and running smoothly.

June 24, 2011

Reflection

Now, to most people reflection would mean looking back at yourself and thinking about where you have been and where you want to go. For me... It means a way of programming. Reflection is an exceptionally powerful tool for when you want to do things that OOP (Object-orientated programming) doesn't normally allow.

First of all, reflection gives the programmer unlimited power. (This is when you would hear an evil laugh in the background). To be fair, it basically completely breaks OOP at some of its basic levels. So what am I saying? It allows for you to directly access any part of any class at will. Private and protect contructors, methods, fields, etc. are all at your finger tips. As you can imagine that's pretty insane, you can even define classes dynamically on the fly. Say you want method y on class x, well you can do that. AOP (aspect-orientated programming) uses this concept and defines an entire programming paradigm around using reflection.

Reflection is very useful in the following scenarios:

  • You are testing a class and want to validate private/protected parts of it
  • You are creating a framework that needs to load plugins on the fly
  • You want to try some AOP
I'm sure there are many more reasons, but those are plenty to learn about Reflection. Reflection also allows you to define new test cases that you never thought were possible. Like testing the class structure itself. You can test which constructor signatures exist, which ones are accessible or not. You can test for methods or fields existing as well. Or test those which do not have public access too and even set the private fields prior to running the test. This means you can not only test the external but also the internal behavior of your classes. This opens up a huge new door to testing, one that is neglected in academics. 

So all this great stuff? Whats the catch?

Simple, performance. When you use reflection you take huge performance hits. So why would you use it? Well, if you need to access something in a non-standard OOP way you can do it. As long as you don't do it often that's perfectly fine. Loading an external set of plugins is basically effortless with reflection. You don't exactly do that very often but now you can. Another aspect that most people wouldn't want is the fact you can load and unload classes during run-time so you can use multiple versions of the same class in your program. Not, that you should do that, but the possibility that you can is a very interesting one.

Why am I talking about Reflection? Well, I plan to use it a little bit to make my developments significantly easier. Since I'm creating a framework, being able to load up various games into the framework would provide me with a very effective way to isolate the framework from the games. I also plan to use to help assist with testing. This way I can modulate testing of the framework from any actual games as well which is pretty sweet.

June 20, 2011

MVC Again

I've been slowly starting to see how useful the ideas from MVC really are. Strict MVC isn't a very good implementation but the idea of proxy models is very useful. For example, read a set of data from a database would be the controller. Load the data and store the data into a list of information, that would be the model. Take the model and sort it with mappings to the original data, that would be the proxy model. Display the sorted data to the user inside of a table, that would be the view. As you can see by isolating the model from the view you never need to directly modify the model, instead you can use a proxy model to change the mapping of the data into a sorted version for the view. Separating this means that you can sort the data on the fly without having to actually modify the underlying data. If you want to remove a row after you have sorted it, you can map back to the original without having to find out where it was stored. It is kind of neat, but something nice to have with MVC. This idea can be applied in a few places in games which is why I mention it. I'm not saying use MVC for games, but you can easily take concepts from it and use it to effectively solve problems with it.

June 18, 2011

Graphics rendering

It appears my original source of information on 2D graphics rendering was crap. It wasn't using any GPU and was fully dependent on CPU. This became apparent when I started to draw 800x600 images at 60fps. It basically couldn't go any faster than 37 frames per second. I'll give my CPU some credit for that, since its pretty damn impressive for completely non-accelerated rendering.

The difference is unquestionable. Using my graphics card I was able to pump out 10000 FPS. I'm not even kidding about that, mind you I do have one of the best single GPU cards on the market. I found it just absolutely stunning to go from 37 FPS to 10000FPS doing almost the exact same thing. I was expecting to jump up to maybe a few hundred, but to go to a few thousand is absurd.

Bad news is, I have to go re-implement this new rendering mechanism, but thanks to highly modular code this won't be hard... just take quite a bit of time. The good news is, I've increased the performance of my framework by 10000/37 = 270 times!

June 17, 2011

Progress

Using concepts from Agile I feel pretty confident about my current goals. I've mapped out my first iteration and have started work on it. Unfortunately, I happen to have more spare time than I anticipated so only a few days in I'm 2/3 done a 2 week iteration. Now, those that have no idea about what I just said: I'm doing more than I thought I would. Right now I'm in the process of starting on the settings menu for the framework.

The question is what kind of settings should I have without even having a game to manipulate? Obviously, one of the them will be FPS, possibly even graphics quality... which... i'm not sure that is something I want to support at this point. I could put in an Audio flag, but I have no audio so that seems almost silly. Maybe the ability to adjust the FPS is all I really need at this point in time. If the game requires more settings I should make it easy to add them in.

I want to change the game so that on start up the screen displays a splash screen. Most of the back-end is coded and really I just have to add a few things and pop the splash screen up. I totally threw test driven development out the window and massively over-engineered the buttons. I created a number of things that I am not currently using, but I will definitely be using and re-using them in the future. So really I won't have to rewrite a better implementation next iteration.

This is why I dislike test driven development, you program for the now and not for the future. That is great when requirements change for your program, but when you know what you are going to be doing. It would be silly to just simply ignore them now and have to re-write the code again later when you are adding new functionality. I'm not saying I spend hours figuring out the best way to do something, but I do take a few moments to figure out a good architectural approach to a problem. If I at least start with something reasonable I can then go back later and enhance it if needed. TDD simply says, write only the code needed to make the test pass. Which really means that your implementation might work, but it could be a nightmare to change later or even perform very poorly. Having to write additional tests to simply prove that your implementation is a poor one is great, but why bother writing bad code in the first place?

June 12, 2011

Agile

I've been looking for a very simple agile tool to use for my own personal projects here and so far nothing has really come up. I've decided I might just use a table inside of word (not excel because of formatting). Since it doesn't need to be online since for now at least it is just me. It has made me tempted to just create my own simple tool, just a basic web interface and hook up to a sqlite database. I could even just run a basic mysql server as well, but that just feels like overkill for one user. The downside to that is I'd spend time working on that instead of developing the applications. Which, if you haven't seen the website, definitely could use some attention.

June 11, 2011

Hobby

This is really mostly just a hobby for me and gives me something productive to put my time towards. Over the years I've settled with playing video games either by myself or online with a bunch of friends. I have to say I haven't played very many games in the last few months. This is mostly because I have a new interest in learning new things and further developing my skill sets. I know very few people are reading this, and probably fewer are even interested in this. To be fair, both learning about web development and working on refining my programming skills is just overall beneficial to me. At my job I do both so really this is just adding to it, but most people would say your hobby should be something different than your work. I do have a few other hobbies, I like working on my car and learning about how things work. I am in engineering after all, sure I've gone into software, but that doesn't mean I am not curious about things in the physical world. I always want to disassemble various things and rebuild them. Physics has always been a very interesting topic to me, as well as mathematics (I'm referring to real math here, not arithmetic). Naturally, calculus has been a very interesting area as well, but because of my lack of devotion to areas other than computers I've never really bothered to extend my knowledge in those areas.

The applets on the website are old ones and I've yet to really update them. I've been working on one of them to provide a basic framework that will allow me to rapidly develop games from so most of the things I've been doing aren't something a user would even see. In Agile, that is a straight no-no but to me it is experimenting and exploring ideas. So far I've found a super efficient way to get user input down to any part of the application in real-time with minimal overhead. It is pretty sweet, and basically will make things very efficient. When it comes to a game, you never want to be wasting resources. Anyways, enough babble from me!

June 4, 2011

Website

Well I added a link to my website (look to the right), now its in super early stages and I've only put maybe an hour and a bit of actual work into it. Three hours if you count the time I've spent reviewing php, html and learning css. I kept reading about "JavaScript" and how awesome it is for stuff. Honestly, for a simple site that is mostly just meant to show off some of my work, I really could care less at this point for anything fancy. It is just a simple way for me to distribute Java applications and having the user not need to do anything.

If I ever want to get fancy the option is there for me. However, in the mean time, I say it would be more useful to actually spend my time working on the applet itself. Rather than make some nice website without any real content. So far, the site just has a few little things, nothing much with any effort put into it. I'll worry about it as time goes on.

June 2, 2011

Web Development

I'm currently working on developing a webpage to put up some of my work in progress and some old stuff of mine. Unfortunately, I'm really rusty with HTML, barely know CSS and my PHP has seen better days. It only took me a few hours to get pretty decent with them again, but its going to take time to organize and build the website. Since my last post I've done very little towards the game itself, other than strip out the MVC implementation and start from scratch almost. I feel a lot better about it now, but I'm definitely going to have to sit down and think about how I want to implement this. Just get a rough idea, and I can revise it later as I see fit. Over planning is really a curse, but not planning at all just means I want to rewrite it many times over, which isn't the best practice either.

I'm tempted to do some test driven development, but its always kind of on the iffy side for me. I'd rather write my code to be easy to test, and then write my tests to make sure what I wrote is actually what I wanted. To define what I want first makes sense, but it just feels clunky to do the tests and implement along side each other. I guess I should give it an actual shot and see how it goes.

In other news, tomorrow is Friday and we all know what that means... *music starts in the background*. I'm just going to block out that song and go to bed!

May 27, 2011

MVC and Games

It has certainly been a busy time for myself over the last few weeks. Changing jobs, moving in and out of the house, helping out some others with some work, starting a new job, working on a few hardware reviews, getting rid of people from my life, getting new friends, catching up with old friends, doing some work for my internship, taking care of a friends dog while they are away,... I could keep going. The point is, I've had time to take a step back and think about my whole approach. I've come to the conclusion that the great and wondrous MVC pattern is really bad for game development. I had a guy convinced it was the best way, but really, the V in MVC is only a small portion of the game which isn't very good. It just makes for a very bloated M and a reasonably large C.

MVC is great when the components are proportional, but is absolutely horrible when they are not. MVC is very good for action-response orientated systems. An interactive program or web interface is perfect for this as it is user driven. A game on the other hand is only partly driven by the user but for the most part a lot goes on the back-end and is based off of a clock. This difference means that you could use MVC, but it is becomes very messy because of the large number of uncertain situations of having multiple objects needing to know about others to figure out if they should be doing something or they shouldn't be. Games, for the most part, also have a global state. Are you playing? Is it paused? Title screen? In some menus? Etc. This really comes to me as you should have an overarching Singleton for the state of the entire game. Very rarely you will be in multiple states (I'm not talking about sub-menus).

Singleton abuse. It really is a bad thing, but for keeping track of the global state of a game, it is actually better to have than to neglect. Does it make testing harder? Only slightly because you can very easily use interfaces as a way to mask parts of a Singleton that your code should not have access too. Interfaces being the mechanism for accessing a Singleton are very power and drastically reduces the coupling. In tests you only need a set of mock classes which can easily be reused, since the Singleton is really only meant for keeping states and handling the construction/take down of states it makes it very effective for tasks that normally would require multiple loosely connected classes. Having the Singleton perform actions by calling Abstract Factories through a Facade for construction is very effective for 'loading'. 

With more time on my hands opening up... I think I might start investigation this idea. I'm setting up a few servers to use for source control and maybe I can get some people to work on something with me once I've figured out the basic ground work.

May 2, 2011

Concurrency

After brushing up on some multi-threading I feel pretty good about it now. It's always interesting to find out more about it from looking at Java concurrency package. I also had to brush up on my C++ the other day too, I haven't had to seriously use it for a few months and its surprising how quickly it can slip on you if you don't use it all the time. With everything changing over for me I haven't had much time to work on the project, but after this week I should be able to work out some more. Currently, in the process of setting up a local git server, but haven't a few hick ups with the old laptop I'm putting to use. I have to say though, a server with 80GB of disk space just doesn't seem right. It is like saying I bought a new sports car, but without an engine. Either way once I sort out those issues all should be good to actually focusing back onto the project.

April 26, 2011

The Decision

I'm still not sure what my final expectations are, but for starters I'm going to use Java and work on an applet. Probably start off with the basic graphics API for 2D as I don't expect myself to go into 3D right away. I've been in the works on building the game engine and its been a great learning experience so far. I never knew all of the possibilities that open up with enumerations in Java. I think it is a bit amusing that they can implement Runnable but it only makes sense as they essentially are static classes.

The built-in Observer/Observable class/interface makes implementing observer patterns as easy as eating cake. With an MVC system this pretty much does all the 'hard work'. The factory method is fairly nice but I got a feeling I might consider using an abstract factory pattern just to make the factory less bloated when I go into it (Once I figured out the inner workings on the system). I keep seeing "Design Patterns: Elements of Reusable Object-Oriented Software" Which is looking to me like a book that is probably something I might want to consider looking through. Except for the fact that Wikipedia seems to have a good chunk of the information readily available which is always convenient.


April 19, 2011

The Choices

I've been thinking about which language to develop on and possibly which graphics API to use. The following combinations have come to mind:

  • C/C++ with DirectX
  • C/C++ with OpenGL
  • Java with OpenGL
  • C# with OpenGL
  • C# with XNA

Now its certainly a tough choice to be making at the moment. I do have an MVC system for C# w/ XNA and a Java one that uses MVC but currently only with Graphics2D. If I wanted to do one in C/C++ I would have to start from scratch which at this point doesn't look very promising. I guess the better question is what are my target platforms?

  • C/C++ with DirectX <-- this one is just asking for Windows
  • C/C++ with OpenGL <-- mostly Windows, but there is the option for X-platform here
  • Java with OpenGL <-- this one just spells out X-platform (tempting)
  • C# with OpenGL <-- this one I'm 'iffy' with, basically the same as XNA but more work
  • C# with XNA <-- Xbox, Windows, Win7 Phone
I think for a 2D game DirectX in C/C++ would be overkill and a bit of a headache, but I have a tiny bit of experience here. OpenGL would be a good starting place but I think this can be saved for when I want to go 3D (I can just here the sound 'Ooooo' in the background). XNA is very straight forward, for 2D is very sufficient even baby's the developer with what it can do and I have the backbone of an MVC system already in place. I will admit I'll need to clean up the system a bit before I can do any serious work with it (Yay, for code revisions!).

April 15, 2011

Programming Language

One of the toughest choices for me nowadays is figuring out which programming language to start a project in. The main options that come to mind are C#, Java or C++. I guess it is only fair to see which one would be the most productive. Java is wonderful in that it supports cross-platform development, easy-to-use and many great free tools. C# on the other hand also supports cross-platform, but for the purposes of the projects projects I have in mind this would be limited to Windows, Xbox or Win7 Phone. Just something to think about.