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!