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.

Sunday, November 7, 2010

Learning OpenGL, slowly...

So I've burned a few hours trying to learn OpenGL. I'm using C#, accessing OpenGL via OpenTK. The tutorials here are great, but a bit out of date. After much frustrations, I found that ramblingcoder picked them up and converted them to C#.

Wednesday, November 3, 2010

Frustrations on programming languages

So, I'm honestly a bit demotivated to work on Magecrawl. Part of it is that I'm in the middle of porting it to Silverlight as a way to get a tiles version with little work that will work on Windows/Mac/Linux. Then this week, I come across these articles.

While it isn't like they are canceling Silveight, their "change in focus" and the fact that Mono is currently two major versions behind has me a bit worried. I don't want to sink another 20+ hours fixing things up, and then in a year or two have to move to another UI layer. I also don't want to loose being able to work on it on my Mac, and right now I'm in that boat.

More fundamentally, I'm frustrated that there doesn't seem to be a "good" way to do cross platform UIs for my game. I'm going to rattle though the programming languages I know or are good options. None of them right now seem to be a good fit.

C# - Silverlight: Only Mac/Windows right now. Linux is an unknown period of time away. A bit worried about its future, but probably best option right now.

C# - libtcod: Works everywhere, but no tiles UI.

C# - winforms - Yeah, it might technically work on Mac/Linux, but there are licensing concerns that make ppl not want to install it.

C# - GTK# - Doesn't look native on ANY platform except Gnome.

C/C++ - Any number of frameworks here, QT being the most obvious framework or OpenGL. Ignoring the rewrite aspect, I'd rather not chase memory errors in an unmanaged language when I'm not being paid for it.

python - pygame would be the most logical choice. I don't think I want to write in a dynamically typed language.

objective C - See C/C++ for the unmanaged language type. It also wouldn't work well on Windows/Linux, and I have no clue what GUI framework to use. 

Java - Seriously? Swing looks terrible anywhere, and with Sun Oracle trying its best to kill developer uptake, that isn't an option.

In writing this article, I've come across opentk, which appears to be a open gl binding for C#. While I'd have to learn yet another UI framework, at least I know it'd work everywhere...

Sunday, October 31, 2010

Status Update - Not dead yet...

As one might have noticed, my postings the last few weeks have been few and far between. There are a few contributing factors to this decline:
  • Large amounts of software testing reduce my motivation to come home and work on Magecrawl
  • Work on a website for my wife's business. {shamelessPlug} Music therapy in Austin, Round Rock, Georgetown {/shamelessPlug}. This involved learning pretty quickly CSS/HTML and Joomla as a CMS.
  • Starcraft II - I gave in and got it. It is video games goodness distilled into a drug like potency. I am currently playing against Gold level players on 1v1, and I have a pretty mean 4gate rush. 
 I still haven't given up on Magecrawl. With the testing at work ending and the website up and running, things should be calmer over here. The only hurdle to working on Magecrawl will be not playing SC II...

Tuesday, October 19, 2010

[Offtopic] Pain in PDF printing on my mac, workaround...

So, since I spent three hours of my life on this, I figured a post on the internets for other to find was worth writing.

My goal was simple. My wife had created a document in pages and wanted it professionally printed. First attempt was a simple "save as pdf". That failed, as there were tiny inconsistencies when viewed on a PC. I installed adobe reader on my mac and low and behold, they showed up there. I thought PDFs were supposed to look the same everywhere...

Some google research pointed to PDF X-3, which iWorks claims to be able to export. It is apparently a subset of PDF that everyone agrees on. Yes, let that last sentence sink in. PDF, the format that is supposed to look the same everywhere, now has a sub-format to do that job. Eitherway, attempts to export the document fail with a generic "can not create PDF-X3" error. Apparently this is a long standing bug with iWorks where some complicated documents throw that error. No fix, no work around. This is starting to sound like bloody Linux...

Alright, next approach is using the "ColorSync Utility" to create a filter. People online seem to saying this sometimes works. After launching the beast, I find out that it apparently fails to save resolution settings at all. This means when I filter wife's document through it, it comes out looking like 1990 smacked it upside the head, low resolution and all...

The solution I have come up with is the 500 lb  (226 kg for my metric friends) sledgehammer of a solution.

  1. Open iWorks. Save document as PDF that won't work in adobe.
  2. Open PDF in preview, File->Save As.
  3. Selection JPG, change quality to full and DPI to 500.
  4. Send that 15 meg JPG to the printer...

Thursday, October 7, 2010

crawl-tiles announcned, a "public domain" source of graphical tiles

My work on getting the crawl tiles public domain is complete. Here is the "press release" that I posted to R.G.R.D:

I am happy to announce the first release of the crawl-tiles project
(http://code.google.com/p/crawl-tiles/).


Crawl Stone Soup (http://crawl.develz.org/wordpress/) has a beautiful
set of graphical tiles based on rltiles (http://rltiles.sourceforge.net/) with many extensions and modifications.

Until now, they were under the "Crawl license", derived from the
Nethack license and thus unusable by most projects.


A majority of the developers/artists have signed off their work into
the public domain (CC Zero license technically), and thus their work
is now redistributable and usable by other projects.


I have packaged that work up into a form easily consumable by other
projects, and placed it on the crawl-tiles download page.


Feel free to take a look, use them in your new project. If you do so,
please consider noting in your game where they came from.

Thursday, September 30, 2010

Chugging along on Magecrawl for SL...

Quick update:

I'm still chugging along on Magecrawl for Silverlight. I just finished ranged targetting with overlays, which makes melee/ranged attacks, inventory/spell use, and operate doors work.

I have a bunch of "easy" dialog work to do, a splash screen to make, animations for ranged attacks, etc. I also have the harder work of a skill tree, preferences, and such.

Tuesday, September 28, 2010

Back to work - FF XIV currently a bust...

As some of my previous posts mentioned, I was blasted excited about Final Fantasy XIV and planned a month or two of ignoring Magecrawl around it. The short answer is that isn't happening anymore. The game has major balance and lag issues that currently make it not fun to play. If you were interested in it, I'd give it a few months to see if they can shake out the bugs and make it fun to play.

And so, I'm back to normal development again. My plan is as follows:

  • Finish up my crawl tiles license project, which just involves a boring night or two in front of changelists.
  • Get Magecrawl for SL up and running. My previous post had my TODO list.
  • Start work on the backlog of bugs/features. Right now, for each one that involves UI changes, I'm planning on doing it twice if reasonable.

Monday, September 20, 2010

Magecrawl Status Update

I'm making good progress. I finished up the inventory dialogs tonight, and got started on targetting. Here is is my todo list as of tonight:

Other:
Health/Mana Bars
Status Effect/Monster list on character info
Handle player death
Icons in inventory
Hitting z to cast spell, z should target

Dialogs:
Splash Screen
Help

Hard:
Equipment
Skill Tree
Way to edit preferences
Reasignable keystrokes

Message Box:
Up/Down Stairs
Save
Quit
Welcome Message

Requires Targetting:
Operate
Draw ranged attack
Attack Melee/Ranged
Inventory w\ targetting


Obviously rewriting the skill tree viewer will take the most work, but most of the rest of them will fall into place quickly. Four them require targetting, which I'm currently working on, while 6 require dialog to be written (easy). 4-6 of them don't have to be done for the game to be playable, just nice to haves.

Sunday, September 19, 2010

[Silverlight] ChildWindow focus bugs, oh my!

Another day of programming, another bug in silverlight to work around. When I'm not working around bugs, I'm crazy productive however.

The issue today is key focus, in particular with ChildWindow. This class allows you to place modal dialogs up with a minimal of fuss. The problem is that for some reason they weren't getting keyboard focus correctly. This is a big problem when you want your entire game to be able to be run from the keyboard alone.

Here is my solution (with help from a friend):
public ChildWindowNoFade ParentWindow;

        public ChildWindowNoFade()
        {
            this.DefaultStyleKey = typeof(ChildWindowNoFade);
            this.Loaded += new RoutedEventHandler(ChildWindowNoFade_Loaded);
            this.Closing += new EventHandler<System.ComponentModel.CancelEventArgs>(ChildWindowNoFade_Closing);
        }

        void ChildWindowNoFade_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            Dispatcher.BeginInvoke(() =>
            {
                if (ParentWindow != null)
                {
                    ParentWindow.Focus();
                    if (ParentWindow.InitialFocusItem != null)
                        ParentWindow.InitialFocusItem.Focus();
                }
            });
        }

        void ChildWindowNoFade_Loaded(object sender, RoutedEventArgs e)
        {
            Dispatcher.BeginInvoke(() => 
            {
                Focus();
                if (InitialFocusItem != null)
                    InitialFocusItem.Focus();
            });
        }

        protected abstract Control InitialFocusItem
        {
            get;
        }

Roughly, I'm creating a base class that hooks into loading and closing of windows. It fixes up the focus problems in cases of stacked modal dialog (where ParentWindow is non-null).

A few other notes:
  • Some child windows act funny with keyboard focus if they don't have controls in them and/or they don't have IsTabStop="True" TabIndex="1" set on the window
  • System.Windows.Browser.HtmlPage.Plugin.Focus();    If you call this guy on the creation of your root object will give your application focus.

Saturday, September 18, 2010

[Silverlight] Binding to list box elements throwing MethodAccessException

I spent an hour or two figuring this out, so I figured I'd post about it. Hopefully, the next poor soul who runs into it will find it here:

I was running into a problem binding my list to a Silverlight list box. On listbox creation, the output window had lots of lines that looked like this:


System.Windows.Data Error: Cannot get 'DisplayName' value (type 'System.String') from 'Magecrawl.Items.Consumable' (type 'Magecrawl.Items.Consumable'). BindingExpression: Path='DisplayName' DataItem='Magecrawl.Items.Consumable' (HashCode=45492604); target element is 'System.Windows.Controls.TextBlock' (Name=''); target property is 'Text' (type 'System.String').. System.MethodAccessException: Attempt by method 'System.Windows.CLRPropertyListener.get_Value()' to access method 'Magecrawl.Items.Consumable.get_DisplayName()' failed.
   at System.RuntimeMethodHandle.PerformSecurityCheck(Object obj, RuntimeMethodHandleInternal method, RuntimeType parent, UInt32 invocationFlags)
   at System.RuntimeMethodHandle.PerformSecurityCheck(Object obj, IRuntimeMethodInfo method, RuntimeType parent, UInt32 invocationFlags)

The answer is that under Silverlight, you can not bind to non-public objects. The Consumable objects noted above was a internal object with a public interface. Once I made it public, the problem went away.

A side note, this apparently also occurs if you bind to an anonymous type as well.

Tuesday, September 14, 2010

Why getting your licensing straight is important

So, you might have noticing my posting frequency has decreased the last few weeks. A few things factors have contributed:
  • Deadlines at work give me less time/energy to code for fun
  • Final Fantasy XIV is in open beta
  • Side projects
One of those side projects is what I want to talk about. As you might have noticed, the Silverlight prototypes uses the wonderful graphics from Crawl. Those graphics were based on rltiles and expanded upon by many great artists.

However, no explicit license grant was required of those submissions, and such they are by default under Crawl's license. It is derived from Nethack's license, and is incompatible with pretty much everything. I got around this in the short term by duel licensing magecrawl under BSD/Crawl, but this is not something I'd like to continue forever.

In talking to the development team, I offered to attempt to contact the 20-30 people who have made changes and ask for them to relicense their work. They were interested in getting away from the crawl license, and so they agreed. The license that I suggested and we settled on was this one, which is pretty much a cute way to say "public domain".

The e-mails are still going out to try to get a hold of everyone. This work is going to suck up at least a week or two of my programming nights when it all finished. In addition to that, if I can't get a hold of some people, those tiles will either have to be redone or separated from the "public domain" tiles.

If the number of people that touched the tiles was higher, in the hundreds or thousands, it would be impossible to get everyone to sign off. The impossibility to relicense the Linux kernel is a great example of a project that is in that boat. It is somewhat different, because they are happy with the gpl v2.

This is why getting your license straightened out early is important. Here is a 30 second, I am not a lawyer so don't pretend I am one (not even on TV), summery of licensing.
  • "Public Domain" - Technically not a license, the idea is to give up all rights to the code. This CC license or the WTFPL licenses are in this class.
  • "BSD" - This is the next step in being restrictive, but just barely. The license only requires that you keep the copyright notations on the source code. The MIT license is also very similar.
  • "GPL" - A very common license, with the idea that the source code should stay "open/free". Roughly, any code linked to GPL code must be GPL, and you must offer to distribute any changes that you make to anyone you give copies of your program. It places more restrictions on you as a programmer (other licensing may not be GPL compatible and hence a GPL program can not link against them), and also places restrictions on anyone who distributes your program. However, it prevents anyone from using your source code without opening their changes.
  • "CC" - Many of these licensing don't apply very well to things like text and artwork. The creative commons licensees many times are good fits, with many different flavors.
  • Proprietary - The source code is not open for view/edit. Uncommon but not unheard of in roguelikes. Can not link against GPL code, but can use BSD/Public Domain code.

Tuesday, September 7, 2010

Silverlight fun and arcane "batteries"


While the open beta of Final Fantasy 14 has taken more programming time away that I'd like to admit, I haven't dropped off the face of the planet yet. I've made good progress so far on the new "tiles" GUI, using silverlight. See this video for a quick video of gameplay. There is a huge number of things needed to make it fully functional, ranging from picking up items to the skill tree.

Assuming I was able to make the tiles interface work on Windows/Mac/Linux, both in the web browser and in a stand alone application, I've been toying around with the idea of ditching the ascii interface. I personally enjoy playing the tiles version of crawl more than the ascii version, and I feel I could make either two decent front ends or one awesome one. There is a lot of "if"s still in the air, but would doing that enrage anybody out there? While in the end I'm programming this game for personal pleasure, I do care about the opinions of the players of my game.

Another idea floating around my head is redesigning the magic system in Magecrawl. Right now, it is a fantasy standard MP system, with the MP being generally recharged after every fight. This makes fights "front heavy" with the characters dumping most of their MP early on, and resorting to melee afterwards. Also, it generally devolves into spamming the most powerful attack spell over and over. When I think about arcane duels, this isn't how I imagine things. I imagine almost every round until exhaustion some spell being cast, whether it is a earth-shaking powerful effect or a simple cantrip.

It is hard to make such a wide spread of spell types and tempos effective in the current system. My idea is a take on recharge magic, with a twist. Each spell has a total amount of "energy" that is needed to cast it. The player has a "battery" of mana, which at the end of each turn (that isn't spent moving?) some is syphoned off to fill each skill not ready to cast.

With a property selection of spells, one could alternate between two relatively fast recharging spells, or cast a range of spells (damage, push back, damage, blink away). Long term effects could reduce either the total "battery" before spells start running dry or the rate that spells recharge. Playing arcane characters should be about casting spells and making things blow up :)

Tuesday, August 31, 2010

I can has magecrawl on the internets?


So it might not look like much, but that's magecrawl running in a web browser! Levels generated, items created, monsters waiting for time to start ticking. The only thing missing is drawing and control.

My good friend Ben inspired the idea and helped implement some the magic.

Roughly the magic entails removing all references to libtcod from the game engine. That way, we can load all that code inside a web browser via silverlight, (which can't load native code). I "ported" this code from libtcod:
  • Shadowcasting Line of Sight
  • A* Pathfinding
  • Bresenham Line Generation
"Porting" could be described as the twisted application of force needed to move C code to compile and run in C#. Since none of them used pointer math too heavily, it was reasonable to attempt. The code looks ugly for C# code, but it works.

In theory, it should even save and load! I can use my same serialization code, just point it to "isolated storage" and away we go.

Obviously, a lot of work is needed to make it a real game frontend. But the fact that I could even get this far (and not have to rewrite everything in flash) is pretty awesome.