Monday, 26 December 2011

Complicated? Why yes, yes it is...

Well after tinkering with Java for a little while I have come to somewhat of a conclusion. (This might seem a little premature, but hey, I'm not getting any younger..)

Unless you have been tutored professionally, or have bucketloads of time to throw at it, Java is one hell of a mind-boggling beast! I've done a fair bit of reading and my usual amount of tinkering and messing about (I've never known such an unforgiving language!) but it seems that you have to jump through hoops just to get even the most basic of tasks accomplished.

This gives me even more respect for people who code fluently in this language.

I have managed to open a window, and render some rudimentary graphics but they really are basic. And I do mean basic. I started with this...


...and after some messing around, managed to persuade it to evolve to this...


...but it was far, far from straightforward. I also found that unless you dig really deeply, a lot of the language syntax can be confusing. For example a loop will execute the first line if you don't encase it in braces (and the compiler won't notify you that you have omitted said braces). So when you add a second line to the loop, the whole thing throws a wobbly and returns some totally unrelated error message - both in NetBeans and Eclipse. 

Believe it or not, here is a snippet of code I wrote to create that second image above. (Yes, I realise it's called "zombies", there is a story behind that which isn't worth going into here)...


...confused? So was I. And a single upper case letter where a lower case one should have been and, well, let's just say it didn't like it much.

When I first decided to have a look at this language, I had the idea of making a (really) simple game, maybe in an Applet that could run in a web browser. As soon as I started reading about graphics animation, I pretty  much changed my mind there and then. I might give this another look after I've had some sleep, but I think I'll be jumping back aboard HMS DBPro, where I feel more at home and it doesn't take 20 lines of code to draw a pattern in a window.

I think I'll leave Java to the professionals. And the young people :)

Sunday, 18 December 2011

First steps...

I know it's only been a day or so, but I have taken some tentative first steps and I want to log them here :)

The first thing I had to decide on was which GUI (Graphical User Interface) Environment to use with my Java experiment. As I don't know the first thing about this language, I'm not really qualified to make an informed choice about this, so after a little sniffing around I found the two most popular front-end tools seem to be Eclipse and Netbeans.

This is Eclipse...


... and this is NetBeans...


I know they look very similar, and as far as I can tell they pretty much do the same thing, so for the moment I'm leaving them both installed, hoping that if I've made the "wrong" decision as to which platform to use, I can change my mind later. If it even works like that, who knows?

Anyway, having browsed around java.com for a while, it seems that NetBeans is the GUI of choice, so that's what I'll stick with for now. If you're interested, Eclipse can be grabbed from HERE and NetBeans from HERE .

I don't know if you noticed on those pictures (which you can click on to enlarge, by the way), but my first Java code is in there. A fully working program! I have got a handle on how the structure of the language works (sort of, it's early days) and it looks a bit daunting, but manageable. Anyway, here's the code...


... and here's the resulting output...


Awesome or what ?! Now it's time to do some research...

Friday, 16 December 2011

Long time, no post :(

With the arrival of Battlefield 3 and a number of social events, it turns out that I have been neglecting my blog somewhat. However, with the excitement of BF3 dying down a little, and the upcoming potential free time due to Christmas holidays, I'm starting to get the creative itch again.

The EasyMatrix project is a fully working and usable application, and I do intend to use it at some point when I try and learn more about AI (Artificial Intelligence) programming, but at the moment I feel the urge to learn something new. I'm one of those people who can't stick with something for any length of time before being attracted to something new and shiny, but then I usually end up returning to the "old faithful" environments I'm comfy with.

I pretty much know my way around the DarkBasic language now, and finding solutions to programming problems is more a matter of "what to code" rather than "how to code it". If you're a programmer then that will make some kind of sense to you, I hope :)

So during the holidays I'm going to try and learn yet another programming language, namely Java. I have a few friends who already know Java reasonably well, and another couple of friends who have been meaning to take a look at it, but never got round to it. So I think I'm going to dip my toes in the water, and see what it's like. The only thing I do know for sure is that everything I need to learn the language is available for free online, so that's a huge plus in my book!

I'm going to try and keep this blog updated with my progress again, if only for historical reference so I can look back one day (while smoking my pipe and admiring my slippers) and think to myself - "remember when I tried to learn Java...."

It might turn out that after a bit of sniffing around, I decide that the language isn't for me, but right now my intentions are clear. I'll let you know how I get on.

Friday, 1 July 2011

Video Demo

Just a really quick blog update this time. (Yes, I've said that before, but this time I mean it...)

I have made a short video demo of EasyMatrix at it's final Alpha stage. It's pretty much finished apart from a front-end which I am working on now.

Before you watch the video, I need to explain a couple of things. Firstly, I used some free software to grab this video, and the colour rendering isn't brilliant, so towards the end - at the bit where I flood-fill the matrix with "grass" - the colour looks really weird. The program renders it perfectly, it's the video grabber that is distorting it. Also, the mouse pointer is visible throughout the video. It isn't there when you are actually using the software.

So that's it. Enjoy the video and I'll see you soon. Next stop planet Beta!

Thursday, 23 June 2011

Quickly approaching the beta stage...

EasyMatrix is getting to the point now where it's almost at beta. I have tons of ideas that I'd like to implement, but I am hesitant because (a) The whole point is to keep it simple to use and (b) originally I only wrote this as a tool to help myself create levels for my AI experiments, and it can already do that!


Since my last blog update, lots of cool stuff has happened...

  • I have now written the texturing routine, which includes a "Texture Paint" function
  • After a suggestion via the DarkBasic Forums, I have changed the node indicators from spheres to cubes
  • I can now Export a matrix design, and Import it again, complete with textures
  • I have implemented "AutoSave" which intelligently saves the design if any changes are made
  • I have moved away from an imported 3D object for the selector rod, replacing it with an internally rendered model.
  • The user can now toggle the "help panel" on or off
  • A few internal routines have been completely rewritten for extra efficiency
  • The code is now fully "Remmed Up", more concisely than I ever have in the past


There are a couple of things that I'm still looking at...
  • A "Flood Fill" function which covers all the tiles with the selected texture
  • A "Node/Tile Drag" function when you drag the selection up/down rather than click to raise/lower
  • "Auto Texture by Height" which automatically textures a tile depending on its height (experimental)
  • "Lamp Posts" which allows the user to place a number of light sources
So it's getting there. I can throw together a perfectly usable level in about 5 minutes which, if coded without using EasyMatrix would take me the best part of a day (including texturing). That's pretty efficient in my book.

Of course I still need to code for the user-selectable bits such as Matrix dimensions, number of tiles, minimum and maximum node heights etc.., but I have pseudo-routines already in place that just need a graphical front end writing.

One thing I will have to look at is the texture pack. The one I'm using is just cobbled up from stock PaintShop Pro textures and colours, and I really am hopeless at graphics. But the idea is that the end user can replace the standard texture pack with one of their own design anyway. Maybe in a later release there will be a couple to choose from. Now if I could only talk someone into throwing some packs together for me..


I just made this level to show the editor in action (it took about 3 minutes), imagine that with a higher resolution (more matrix tiles), better textures, some light sources dotted about etc.. and you get the idea of what I'm trying to ultimately achieve here.

The alpha version used while writing this post can be downloaded FROM HERE.

My biggest "problem" at the moment is that I've fallen in love with Call of Duty 4 all over again...

Saturday, 11 June 2011

A near-usable tool!

I got some really productive coding sessions in over the last few nights. Yes, there were the usual bouts of frustration mixed with raw expletives and sprinkled with a topping of "wtf?", but on the whole, I got loads done.

First up, the viewpoint movement routine. I tried various methods of achieving this, but it turned out that the most effective was one of the simplest. Move the selector rod to a tile, hit "C", and the camera then centres on that tile. Simples. I had to code an assist routine, because when the camera makes the jump, if the tiles aren't yet textured (and they're not because I haven't wrote a texturing routine yet) it's easy to become disorientated and lose track of which tile you centred on. To aid here, I have made a translucent cube appear on the centred tile, and slowly sink down through the matrix. This instantly shows which tile the camera was focused on...


Next up, the Save and Load routines. Admittedly, these do need more work, but the basics are there and I can actually export matrix data, then re-import it. Sort of. What you have to remember is that there is no "Save Matrix" command available. (Or "Load Matrix" for that matter). Both of these routines have had to be built from scratch, and I've probably gone right around the houses to get them where they are, but it's a learning curve.

So on to the issues. Firstly, the Save isn't 100% reliable. That's not a great start. I'm still trying to nail the problem down, but when it does save - which is 9 times out of 10 - it actually saves data. It's just that now and then it completely refuses to export anything at all, and I'm not sure why yet. By the way, these Load/Save tools aren't like your standard Windows dialogue boxes or anything fancy like that, they are pretty much "Press S to save then type in a filename" or "Press L to load then type in a filename" affairs, but I'm a beginner at this so I have to start at the beginning. Or something.

Anyway, on to the Load routine. Yes, it loads the data I saved earlier. Unfortunately, it doesn't pick up on any texture data, and I can't work out why - yet. So I get the Matrix shape loaded, but it's completely wireframe. I know I haven't wrote a texturing routine yet, but all the tiles are textured by default, and it's not picking those values up for some reason. But I'll get there.

So the following pictures show what is currently happening when you export a matrix, then shut down the program, then open it again and import that saved matrix. As you can see, the correct shape is there but that's all. Having said that, getting this far was no walk in the park.


 

Finally, I've started work on the texturing routine. This is a standalone program at the moment because I want to figure it all out before I embed it into EasyMatrix. Basically, the program takes a bitmap which contains all the textures needed for the level, cuts it up into 48 small pictures, makes 48 sprites from these pictures and lets you manually select which one you want to work with. The "active sprite" as I call it, is shown at the top of the swatch as a full-size (128 x 128) texture tile, ready for application to the Matrix. But I haven't got that far yet.


As you can see, the mini-swatch rotates slightly, to give you a quick indication of where abouts in the texture pallet you are.

So that's about it so far, it's a near-usable tool but not quite there. I would say another couple of weeks if gaming doesn't get in the way. Which reminds me, I re-installed Call of Duty 4 and completed it again this last week. I forgot how much better than Modern Warfare 2 it is. Now I'm getting hooked on the Multiplayer again. So I managed to do that, and get a fair bit done on EasyMatrix. It's been a good week, coding-wise. 


Sunday, 5 June 2011

Off on a tangent...again!

Anyone who has been following this blog will know that I tend to shoot off at random directions when it comes to coding stuff. I'm weak like that, too easily distracted.

Once again, while researching and writing test routines for my AI experiments, I got a bit fed up of working with a flat floor. My newly acquired model objects demanded some more interesting scenery to interact with. So I decided to bang together a quick program which created a randomly generated "matrix" of tiles. But the problem was that they literally were too random. Yes I could apply various restraints etc, but I wanted something that would reflect a realistic game level.

So again I "went off on one" and started a new project. This one is a level editor of sorts, based on a matrix system. This will actually be a useful tool I think, because not only can I use it to make test levels for the forthcoming AI routines, it can (or rather will) be used to make actual game levels once I learn how to code AI.

I was also partly inspired by the "MouseCam" routine mentioned in my previous post. This proved to be very handy in my "EasyMatrix" program, essential in fact. Also, you might remember at the end of my last post, I talked about working out a routine that would convert the mouse input for use in a 3D environment. Well, I nailed that one too! (An achievement I am pretty happy with, if I'm honest.)

So now I can control the camera in 3D space and I can use the mouse to point to any object or area within that space. I just know these routines are going to be useful to me one day, and they are already deeply embedded in my EasyMatrix project.


That picture shows the concept of EasyMatrix - a tile based editor, with 4 editable node points per tile, and a 3D viewing angle. This image was kindly rendered by my friend (and 3D/game design artist) Tom Joyce.

The development of EasyMatrix has flown along so quickly over the last week that I haven't really taken many screenshots. I must throw a shout out to another friend (and mathematical genius) Ragnar Karlsson, who helped me out with a particularly tricky algorithm. I never was any good at trigonometry.

Anyway, this is what EasyMatrix looks like right now...

 



That bottom picture shows the same viewing angle, but the left one is in "edit" mode while the right one is in "real world" mode. It will look a lot better when I implement the textures. It is still possible to edit the matrix in "real world" mode, but you have to be pretty accurate with the pointer, because the helper objects (red dots) are turned off.

So next I need to implement a way to move the point of view (at the moment you can pan around but the camera always points to the dead centre of the matrix), and I need to look into texturing the tiles, and I also better figure out a way to actually save or export the matrix otherwise this whole thing will be pretty pointless.

If you want to have a play with an early version of this, you can download the file by CLICKING HERE. It's a .rar file so you will need to unrar (unpack it) prior to use.

There are only a couple of requirements...
  • You must have at least DirectX 9.0c installed. But you already will if you're a gamer, right? (Get DX9 here)
  • Your mouse must have a clickable wheel. The camera pan only works when you hold the wheel button down.
That's pretty much it really. It will still work if you don't have a clickable mousewheel, but your view will be very VERY restricted. 

Now, I should make a start on that viewpoint movement routine. I think there is some Magners in the fridge...