Saturday 25 September 2010

Silverlight still on hold... Terrastrom v1.0.3

I had another go at Silverlight this weekend. I managed to make some headway with it, following a tutorial which taught me to draw some bmps to the screen. I'm basically in a situation where I have the tools to translate now.

However... I'm having major trouble working out how to distribute my Silverlight application. I've had some advice on the forums, but no luck so far. I just can't get the app to display on this blog. I will continue in XNA for now, and keep chipping away at Silverlight when I have time.

This weekend I started creating the basics of an inventory system. Each object is now assigned a boolean variable "CanBePickedUp", and those that have it set to true can be grabbed.

Now when the game is paused, a little arrow appears next to the list of objects, which can be scrolled using up and down, and objects can be picked up using Enter. At the moment the only items that can be picked up are mushrooms. Originally everything could be picked up, including deer, which was kind of fun (though they were hard to catch), and looked rather silly in the inventory. There's no way to drop or use anything in the bag yet, but it will fill up, and not accept new items when full. Each item takes up one square. I can set the bag to any size I choose, which for the moment is 10x5.

It's all very functionality-focused at the moment, and consequently looks dreadful, but here's a screenshot of the game when paused with a bag half-full of mushrooms (if you look closely there's also a tree in there, but I've switched them off now).


I also performed a major overhall of some of the code structure, completely changing how the sprites get stored and drawn. I realised it was focussed on drawing things on the map, and of course once the mushrooms get picked up they are no longer on the map. The sprites were basically storing information that should have been with the objects such as the map the object is placed on and the (x,y) position.

The Sprite class is basically trimmed down a lot, and I now have an intermediate Object class, which MapObject inherits from. The Map class stores all the objects on it in a big array of lists, and the Player class stores a bag as an Inventory class, which is essentially an array of objects with some functions (IsFull, GetNextEmptySquare, DrawAt). Each object has an associated sprite. When an item gets picked up it simply deletes itself from the relevant list on the map, and adds itself into the player's bag array in the first available slot. When drawing the map, there's a rectangle defining which area is currently being drawn, and a for loop goes through each object with "Drawn" set as true in each list in that rectangle, and draws the corresponding sprites. The bag's draw function is very simple, and just draws a slot at each point, and if there is an object in that slot, the object on top.

Next up ought to be dropping items from the bag, which should be fairly easy based on what I've done already. However I really want to think about the controls a bit more, as it's fairly Dwarf Fortress style so far, and while I don't want to require the mouse, I want the controls to be more intuitive. Not that DF isn't awesome, with or without impossible control scheme.

No comments:

Post a Comment