Sunday, November 20, 2011

Finished, but just barely...

Here's the proof:



http://dl.dropbox.com/u/8791050/Magecrawl%20-%20Arena%20.1.zip

This version has the correct SDL libraries bundled so you don't need the SDL dev libraries installed.

http://dl.dropbox.com/u/8791050/Magecrawl%20-%20Arena%20.11.zip

Tomorrow I'll have a legitimate posting with instructions and the like. I just wanted to get something up tonight.

You'll need the .NET 4 runtime or the equivalent mono. You probably need the SDL development libraries installed as well. I'll try to clean things up tomorrow and shove out a better release.

Go go 4DRL.

Saturday, November 19, 2011

Hello...is this thing on...

I just received a comment wondering what the status of anything I've been working on, since I haven't posted in forever. This was ironic, since I was thinking about making a post tomorrow anyway.

The wife was out of town for a business conferences, so I decided to see what I could hack out in two after-work timeslots and Saturday/Sunday.


You might notice the stubbed out "action bar" at the bottom, but I have a lot working. I've "stolen" chunks of code from previous "iterations" of the game, but the "core" is all new.

It's written in C# and using SDL C#. My goal was to get something playable by end of the day tomorrow, so I've kept many things simple (but functional).

Things working so far:
  • Turn based movement with a "party" of player characters and various enemy monsters
  • Line of Sight and Pathfinding
  • "Animations" done in a way that for once makes me not want to cry
  • AI decision making is done off the UI thread to keep the game responsive.
Things to finish by tomorrow "hopefully"
  • Melee/Ranged combat with animations and targetting
  • "Skills" of some basic type
  • Multiple different monster types
  • Different "rounds" in the arena
Wish me luck on my 4DRL.

Saturday, April 23, 2011

Magecrawl-Arena status update

I'm going to try to try to create something like Doryen Arena using python, seeing how things go. I figured I'd post a status update:

Project started 8 days ago, with about an hour of coding a day roughly. I'm through stage 5 of this, which includes:

GUI - Using public domain graphical tiles from Crawl Stone Soup, found here, I have a scrollable map with variable tiles (not every dirt tile is the same), that persist.
Physics - I have a simple physics engine that includes walls (that one can't walk through), and doors one can open.
Keybinding - Arbitrary key mapping (mouse support to come!)
Serialization - Save/Load support.

Compared to Magecrawl itself, it seems somewhat pathetic a feature list. However, I'm enjoying poking around in python between games of Portal 2 and Rift.

Source can be found here if you are curious.

Clever Python Hacks Part II - Serialization

Serialization is Magecrawl is pretty good, however it is somewhat verbose. I write out a giant XML tree with all of the attributes of everything, and parse that in on load. It is about 200 lines of core code, along with about 100 for the map and about another 100 for the player.

Here's what my serialization code looks like in python so far:

    SaveVersion = 1
    def __save(self):
        with open(self.player.name + ".sav", 'wb') as file:
            pickle.dump((self.SaveVersion, self.player, self.level), file)

    def __load(self, filename):
        with open(filename, 'rb') as file:
            fileSaveVersion, player, level = pickle.load(file)
            assert fileSaveVersion == self.SaveVersion
            self.player = player
            self.level = level

I do loose the XML format in exchange for a binary one, but you have to love that simplicity.

Wednesday, April 20, 2011

Clever Python Hacks Part I - Keymapping

Keymapping was complicated stuff in Magecrawl. See here for the XML reader(LoadKeyMappings() and HandleKeystroke). It was powerful stuff, using reflection, XML and such. However, I just got 80% of that in a four liner today:

def load_key_mapping():
    globalDict = {}
    exec(open("KeyMapping").read(), globalDict)
    return globalDict["KeyMapping"]

This function loads the given file as a python script and executes it, then sucks out the KeyMapping dictionary. The KeyMapping script looks like this:

import pygame

KeyMapping = \
{
    pygame.K_UP : 'Up',
    pygame.K_DOWN : 'Down',
    pygame.K_RIGHT : 'Right',
    pygame.K_LEFT : 'Left',
}

I get a simple dictionary of button presses to string, and I can switch off those later. The only concern I have is people sharing KeyMapping files and people doing stupid things in them. However, right now I'm now that concerned, as this is stupidly simple and works great.

Tuesday, April 19, 2011

Spinning Up The Time Machine

So, I'm still playing with python. Not sure I'm going to write an entire roguelike in it, but figured I'd hack out to the step 4 (walking around a room) on the 15 steps to a roguelike.

I noticed the number of files/lines of code seemed to be much smaller than I remembered, so I pulled up the equivalent submission in magecrawl.

The python copy looks like this:


While the magecrawl looked similar to this (this was from a few weeks later, similar idea though)



Here is the comparision (excluding test code). This isn't comparing to the map generator picture above, just the walking around an empty room.

Python - 3 source files, 127 lines of code.
C# - 13 source files, 503 lines of code.

Much of that difference comes from the verbosity of C#. Some of it comes from the use of interfaces in C# compared to duck typing in python. The rest comes from an effort to implement the minimum needed and keep things simplier.

As a side note, pygame is pretty awesome. I might pull in libtcod for line of sight and pathfinding, but since I want "tiles" graphics, pygame made that crazy easy.

Friday, April 15, 2011

Has it been 6 months already?

Wow, I can't believe 6 months slipped by that quickly. Between work and my personal life, I seem to have lost track of time (and stopped updating this). Eitherway, I'll try not to let that happen again.

I've picked up programming for fun again, but so far not on magecrawl. I still want to finish it or something like it, but I've come to realize something about myself and the projects I work on as a hobby. I find things fun that are different from what I work on while at work. While I was working in C/C++, C# was fun to work on; now that I use it 8+ hours a day, not so much now. The Silverlight front end was fun until I started wrestling with Silverlight at work.

I'm playing around with Test Driven Development and Python these days. It is kind of funny that I have more test code in my little project than actual lines of code, but I hear that is how things are supposed to be.

Once I get something a bit more presentable I'll post more about it. I just wanted to get back in the habit of blogging again.