Sunday, March 10, 2013

7DRL 2013 day 2: Heroes on the move

Well, now I've got some heroes in the game, and you can move them around on the map. Since this is a tactical game, and it would be a pain to have to adjust your formation every time you want to fight monsters coming from a different direction, the game has two movement modes: normal and strafe. In normal mode (just pressing the arrows), the formation will automatically rotate to face the direction you pressed if you are not already facing that direction; if you are facing that direction it will just move there. (Note that rotation costs a turn - don't get flanked!) In strafe mode (shift-arrows), on the other hand, your formation does not try to rotate when it moves.

Here's what the game looks like thus far:


I also wanted to add the ability to rearrange your formation today, but I'm getting a bit sick of programming for now. Maybe I'll do that later this afternoon. I ran into a lot of issues with slow rendering; it turned out that just rendering a 100x100 map with each tile being a 3x3 grid of characters is actually pretty slow! So for now I'm just rendering stuff in line of sight. Eventually I'll have to add a proper fog of war, and find some other way to clip stuff that you've seen before but that's currently offscreen. Or I could just show the fogged-but-previously-seen tiles on the minimap, and not on the tactical map...

Saturday, March 9, 2013

7DRL 2013 day 1: I'm the map, I'm the map, I'm the MAP!

Well, I got map generation working today! It wasn't all that hard, since I'm doing a natural overworld style map instead of a dungeon, so if things aren't lined up perfectly - hey, it's nature!

Here's a screenshot of what I've accomplished so far. It looks better than I'd anticipated!


Tomorrorow I'll implement heroes, so that will require subtiles, since the heroes will be traveling together. I'm not sure if I'll do the subtiles today or tomorrow - just have to see if I feel like working on this some more later on today! Should be pretty simple, since I'm not planning on doing anything like allowing different subtiles within the same tile to have different terrain. Just a 3x3 array or something!

Friday, March 8, 2013

7DRL 2031 day 0 redux: Bitbucket!

I've created a Bitbucket repository for TriQeust:

https://bitbucket.org/ekolis/triquest

Check back tomorrow and onward to follow my progress!

Thursday, March 7, 2013

7DRL 2013 day 0: Intro to TriQuest!

So I'm going to be participating in the 7DRL challenge again. If you don't know what 7DRL is, it's 7 Day Roguelike, where "roguelike" is a genre of single player adventure/roleplaying game with minimal graphics and intricate gameplay mechanics. The goal of the 7DRL challenge is to write a roguelike in 7 days. No prizes or anything (apart from some neat logos you can put on your blog or whatever), but it's fun to build a game and play the games that other folks build. I've participated four times before, and succeeded twice; you can see my completed games on my website:

http://edkolis.exofire.net/decimation.php - Decimation, my 2009 entry, a very simple game where you're the number zero and you use math to eliminate the other numbers.

http://edkolis.exofire.net/smasharena.php - Smash Arena, my 2010 entry, an arena battle game where you try to knock enemies out of the arena; the more you damage them, the further they fly when you hit them, sort of like in Super Smash Bros.

I also participated in 2008 (tried to make a game called Rogue Battalion that had driveable vehicles, but got in over my head since it was my first time) and 2011 (tried to make a game called Into the Darkness that was a metaphor for spreading the Gospel, but was too busy with work). I didn't participate in 2012 because I didn't have any good ideas for games that year.

But this year I've got an idea! A bit ambitious, but if I plan it out, I think I can accomplish it. My idea is called TriQuest, and basically it's a hybrid roguelike and turn based tactics game. Instead of controlling one character, you control three - a Warrior, a Mage, and a Priest. Now there have been other roguelikes where you control multiple characters, but these have always either had you controlling one character directly, with an AI controlling the others, or required you to move each character in turn. My idea simplifies the mechanics a bit, while adding a new level of tactics to the genre.

You know how in roguelikes, it's one character or monster per tile? Well, in TriQuest, this rule no longer holds. Each tile will be split up into nine subtiles arranged in a 3x3 grid (hmm, like the numpad? how convenient!), and you can arrange your three heroes in a formation in any way you like (using the numpad of course). Monsters, too, will appear in formation. You might run up against a squad of up to nine goblins!

I haven't got all the mechanics worked out quite yet, but I do have a few ideas on how they will work. For instance, I think that weapons will have a "length" or "range" attribute. This range will be measured in subtiles, and attacking a monster outside of your weapon's range (say, from the back of the formation) will reduce your accuracy and/or damage. Of course, hanging out at the back of the formation will protect you from monsters' attacks in the same way (assuming they don't have long-range weapons), so it's sort of like Final Fantasy with the front and back rows. Except that monsters can attack you from all four sides, so you'll have to adjust your formation on the fly to deal with threats from every direction! I'm thinking there might also be an additional penalty (or maybe even inability to attack, but also inability to be attacked except by area of effect spells) for hiding directly behind another character.

Also, I was thinking of having not the traditional "dungeon levels", but instead a sprawling Zelda-style overworld with a gradient noise mapped "threat level", with the final boss lurking at the maximal point on the noise map. You might be fleeing from some level 3 monsters, and unwittingly stumble into a level 4 zone... eek!

So, what's the plan? Well, here it is:


  1. Saturday: Map generation
  2. Sunday: Heroes and movement
  3. Monday: Monsters
  4. Tuesday: Combat
  5. Wednesday: Magic and skills
  6. Thursday: Items and weapons
  7. Friday: Polish, testing, and bugfixes
Oh, and technically I guess this post should be titled "day -1", since today's Thursday, but whatever... :)

Monday, February 11, 2013

On Error Don't Explode

Everyone in the programming world mocks VB's old On Error Resume Next feature, saying it led to "cowboy coding". But you know what? The old horse had its merits!

The next time you're frustrated by Java's checked exceptions, think what fun it would be if you could write some code and not have to catch every single eventuality that whoever designed your API could think of... seriously, do I really need to catch a MalformedUriException when I'm just passing the constant string "www.wikipedia.org" to the Uri class constructor?

.NET, while it doesn't have checked exceptions like Java, has problems of its own. It's like a crotchety old uncle who is hard of hearing, so if you don't say what you want exactly right, it spews a stream of profanity in your face. It's almost worse than Java, since (although it's easier to code), you live in constant fear of runtime exceptions crashing your production code, so you are forced to spend all your time writing unit tests (not that those are unnecessary in Java, but they're more needed, in my opinion, in .NET).

And then there are the dynamic languages. These are the most flexible of all, so naturally they need tons of unit tests. You can't even assume that a variable you reference actually exists in some of these languages! However they are quite a bit more flexible when it comes to data structures. While Java and .NET will scream at you if you try to add a key to a map/dictionary and the key is already present, or conversely if you try to change the value of one that's not actually there, Perl (for instance) will happily overwrite the existing key when you add, and is glad to insert the one that's not there for you. (This is primarily because there is no distinction between "add" and "change value" for Perl hashes, since both are simply assignments, but that's beside the point.)

So where can we find a happy medium? On Error Resume Next is too lenient, but Java's anal-retentiveness is too strict. .NET and Perl take various stances in the middle, but I don't think either is optimal. What we need, I'd have to say, is actually a rethinking of the whole exception handling mechanic.

Instead of specifying in our code every time we want to handle an exception, why not assume that exceptions are meant to be handled? It's the best practice, so why shouldn't our programming languages adapt to it? The only thing left is to specify how the exceptions are to be handled.

There are several ways to handle an exception:

  • ignore it
  • log it and continue
  • log it and terminate
There are of course more than these, but these are the main ones that are "sane" - sure you could terminate without logging it, but that's not very helpful!

So, the idea is, in each source code file you would specify a default exception handling behavior, which could then be overridden in individual block scopes. For instance (in pseudo-C#):

// This class is very important to the global economy! If it produces incorrect results the world is doomed! We must stop it at once if it errs even slightly!
@Catch(typeof(Exception), CatchMode.LogAndTerminate)
class ImportantBusinessLogic
{
    public static void Main()
    {
        DoImportantBusinessStuff();
        // OK, we can be a little more lenient here; sometimes the web service we are using returns nulls instead of actual data; in that case we just use the cache.
        @Catch(typeof(NullReferenceException), CatchMode.LogAndContinue)
        {
            ComputeSomeInterestRates();
        }
        SaveTheGlobalEconomyFromRuin();
    }
}

Good idea? Bad idea? Anyone care?

Repurposing this blog

I haven't written anything here in a while, but that doesn't mean that God hasn't been working in my life. I just haven't taken the time to write about it here. Maybe because I don't think anyone is actually reading? If you're out there, say something!

Anyway, I'd like to start writing again, but I'd like to make this more of a general purpose blog, so I can post whatever I want here that's too long for a Facebook status.

Sunday, March 27, 2011

Knowledge < Truth

Man, it's been forever since I've posted here! How appropriate given the topic I'm going to write about today... Knowledge vs. Truth!

It seems that in many churches today, we are following, if not worshipping, knowledge, as opposed to truth. What's the difference? Well, did Jesus ever say "I am the Way, the Knowledge, and the Life"? No, he said "I am the Way, the Truth, and the Life"! The difference between knowledge and truth is simple: Knowledge is something that is owned, that is personal, that is possessive. You can "have" or "own" knowledge, and you can choose to share it or not with others. On the other hand, truth is universal. You can't say that you "own" the truth; if you do you will basically be claiming to be God! Sure, you can patent some medicine or other, but you're not really "owning" the scientific truth behind it - you're just owning the means of producing the medicine - or if you're smart, the knowledge of how to make the medicine in the first place!

So, what's the problem with following knowledge instead of truth? The problem is simple, too! If you follow something that can be owned, such as knowledge, or money, or material possessions, what happens when someone else takes them away from you? Or what happens if you decide to give them away? You no longer have anything to follow! So you need to follow what is eternal, and that is truth, aka God.

And since truth is universal, and meant to be shared, why are you "hoarding" your mustard seeds of faith? They won't do any good unless you plant them! So get out there and share your faith!

Yet in the parable of the talents, the steward entrusted with one talent of silver was called a fool by the master because he took the silver and buried it in the ground. Why is that? Well, that's because that's not how you "plant" money - that's how you plant seeds! The analogy between seeds, money, and faith is imperfect, as are all analogies - I imagine Jesus must have been quite frustrated at the lack of human words to express what he was trying to say! Not that I claim to know what Jesus was "trying to say" any more than the average person, but surely some of us grasp certain aspects better than others, while grasping other aspects worse! Why not share the truth we have received, rather than hoard it away?

So, to get started, here are some truths I've come to grasp, but not fully...

Jesus said "I am the Way, the Truth, and the Life" - Yes, this is true - Jesus is the Way, the Truth, and the Life! But how can a person, even if that person is God, "be" those things? I don't quite understand....

Jesus also said that he is the gate, and the good shepherd - the shepherd analogy makes more sense, as shepherds are at least people! But again, how can a person be a gate? I always took it to mean that Jesus is the only person capable of "saving" people - but does that mean that only Christians can be saved? How late is "too late" in a person's life - can people be saved after they die? What about people who lived before Christ?

In the beginning, God said "Let there be light!" But I thought God is light! How can God create himself? Or is God a special kind of light? Or is calling God "light" just another analogy?

Oh, and here's one question that was bothering me earlier... Is Satan actually a real, personal being? Because if he's not, then what is God fighting against? "The darkness"? Surely God is more powerful than Gulstaff, Sorcerer of Light! (In case you're not familiar with that reference, he's the one from that D&D skit who cast "magic missile" at the darkness because he didn't know any other spells!) And if Satan is a real, personal being, then that means that either he was created by God (in which case, why/how did God create him if God knew that he would be the root of all evil?) or that he exists independently of God (in which case, doesn't that make him almost equal to God in standing?)

Or is darkness just more powerful than we give it credit for? Maybe Gulstaff knew not what forces he was playing with when he cast "magic missile" at the darkness! After all, darkness does have a way of obscuring truth, while light will penetrate the darkness and obliterate it, revealing the truth beneath! And there are lots of things that people (including myself, of course) have been hiding in the darkness... do we really want the light to come into our lives and reveal the truth beneath? At this point I'd say the answer for me is a tentative "yes" - yes, I do want the light, but first, can I please clean up my act? Maybe that's why I've been given so many second chances - I do want to clean up my act, but it's taking me many years to do so, and I'm not done yet! And neither is anyone else who is still alive, I suppose... let's just give each other the time we need!