Thursday, June 19, 2008

Ever onward, Ever upward

After a week of playing with jME, generally not actually moving forward but more ona tangent, I've added a nice skydome found on the jme wiki, as well as background music.
I've also added a kind of cheap zoom, whereby a user can change the perspective of the camera by scrolling the mousewheel. I also added this snap-camera-to-terrain feature, which I have disabled at the moment because I find it rather limiting, but intend to add a keypress event to enable it, probably M or somesuch.

The one thing I wanted to do after getting one animation playing is to change antimations and play several at once, especially focusing on the animation blending afforded by the md5importer.

So then first up, multiple animations, playing at once, and changing between several.

After that, we just have to have it move about randomly, probably according to a locomotion definition somewhere, probably in xml and via http://javaboutique.internet.com/tutorials/config/ .

Regarding things not code related, we have storyline and other such frivolities to contend with. So here goes my initial idea(s):
The player plays the part of a hamadryad, a nymph forever bonded to their tree.
This particular dryad is actually a new creation, brought to life by a moderately powered druid. After a brief introduction by the druid that created the dryad, during which a seething racial tension seems to be in play; the druid disliking the dryad because he feels that another druid should be doing the job the dryad is about to be charged with.
The dryad's sapling is then planted in the centre of a vast desolate, deforested plain and ordered to rebuild this area of the forest.
The player first has to care for his tree, and coax the first fruit from it. This should take no more than 10 minutes at most. The tree has an uncanny ability to purify soil immediately under its branches, and as such, opens up a nice little circular
Once it's able to produce fruit (which provide essentially one-shot magical spells), the dryad goes on to wrangle his first animal. I'm thinking some sort of vole or mouse.
The first trick is to convince the animal to stay by providing a suitable habitat and food source for it. In the case of mice, this would be suitable cover (lots of grass), and suitable food (lots of grass). Lack of predators helps.
After getting his first animal and plant, the druid will come back and tell him to keep it up (in not so encouraging words) and give a quick overview on reproducing plants and animals. This should be complete with a discussion about the Voles and the Trees (birds and the bees). You know, "You need at least two of something to reproduce them. Mix em together, and a little while later, you get another one. Careful not to breed em too close. You wont like the result."
After reproducing a plant and an animal, he returns and tells the dryad to keep attracting and breeding plants and animals. As they do so, they'll gain experience points and be able to purchase new spells, plants, animals, tools, hardscape, and terrain elements (waterfalls for example).
After getting several species of each, the tree will quietly start to expand the area with which the dryad is free to experiment with.

After a while, the player might be invaded by another dryad or a human or an orc whose land they encroach on. For example, an orc raiding party might send in their worgs who'll run through, killing animals and destroying plants. If the player doesnt/cant fend them off, they'll tire and run off. I expect to have some sort of plant-based defensive measures, not to mention foot soldiers like bears and wolves. I expect the wargame aspect to be a VERY small part of the game. I do however, expect multiplayer and visiting dryads to be a larger part of the game.

More musing on the far future and idea of Sylva next week.

(Grab the code by using `bzr branch lp:sylva`)

Thursday, June 12, 2008

Java is *almost* as good as Python.

So I didnt finish the client for xmlrpc-cardgame. When I do finish it, it might be in Java. (If you want to help out, as always, feel free to email me.)

As promised, I was going to pick up Sylva again when summer struck. I'd taken a break from programming to sorta clear my mind for a month or so and have now decided that summer's already here. Hence, Sylva's back on my plate. After much consideration, I decided to put the C++ engine Matt assisted me with on the back burner. The time it would have taken me to develop Sylva in C++ outweighed the point, which firstly was to let me learn a new language and evolve my programming ability a bit, and secondly to develop something semi-playable, over the course of the summer. If it took me 3 years to finish, it'd be pointless.

As such, I decided to try again but in a different language. I checked the TIOBE index and weighed the pros and cons of each of the top-10.
From the bottom up, my opinions:
Ruby (2.640%): "This will do me no good. It's a slightly different Python."
JavaScript (2.927%): "This thing will not be web-based. It'd need a java applet to be playable."
C# (4.058%): "No Java+Mono kthx."
Python (4.899% ): "I already know Python."
Perl (5.548%): "Yes, it's more than capable, but it's source is unreadable to me."
(Visual) Basic (9.787% ): "No BASIC+Mono kthx."
PHP (10.206%): "Not web based. Dont want to make a PHP desktop app."
C++ (10.806%): "Too much work for too little. Plus I wanted a different language."
C (15.513%): "WAY too much work for too little. Plus I wanted a different language. I'd also like a little object orientation please."
Java (20.890%): "It's kinda slow, but then again so is Python. And I get thousands of frames per second in a very basic C++ scene, so if Java is 10 times slower, I'd still get hundreds of frames per second."

In the end, I decided to go with Java. Just cant argue with that percentage (though admittedly, it's not particularly accurate). After I discovered Java Monkey Engine, I was sold.

After a little while fighting with version 2 (which I could tell was a real upgrade over version 1 from the little time I spent with it) and the examples provided on their wiki, I finally switched over to "latest stable" version 1 jars. Got it all set up in netbeans, and it's been a breeze since. My only hangup was adding physics. Turns out I had to add it to my classpath as well as adding it to the "Libraries" section in the netbeans project. (I did mention I was a Java/Netbeans newbie, right?) It's been a little over a day, and I already have:
Lighting
Camera
(Acceptable) Controls
Skybox
Terrain
Static Model Loading (animation to follow shortly)
(Bounding-Box based) physics (I want trimesh-based physics in the future)

Most of those are just 10 lines or so "flipping the switch" to enable them in my application.

It's rather neat, instead of giving you one "Game" class to derive yours from, there's several different derivatives, for example, I started out using a class called SimpleGame. It basically sets up a very simple game for you, the only thing it does is set up the camera and controls, the rest are up to you. Though most methods are on the order of 10 to 20 lines for each "feature". (The secret is that it handles all the threads such as rendering and updating the scene for you. You have to override these if you derive from BaseGame.) For example, when I decided I wanted physics for no real reason, I had to change from SimpleGame to SimplePhysicsGame. Since it derived from SimpleGame, pain was zero if I recall correctly.

The project's page is up at https://launchpad.net/sylva and you can grab the source by using `bzr branch lp:sylva`.