in

This site is all about the amazingly cool stuff you can do with VB.NET.

Heroic Adventure!

  • Mapping Heroic Adventure!

    This project has gone through several different forms of source control and bug/issue/feature tracking (currently CodePlex for both) and has gotten a bit unwieldy. 

    Lots of features have been started but not finished. Some of the stuff that's been implemented doesn't work quite the way I want it to, and other things could be rewritten to take advantage of newe, faster technologies.

    To this end, I've decided to map out all the features I want to exist in HA! from the random dungeons to the hero properties and everything in between.  I'm using a technique called Mind Mapping to lay it all out. I'm using the FreeMind software to do it. (You can grab a copy at Freemind.Sourceforge.Net)

    I'm only about 20% done with the map, but as I get further I'll post a copy of the file for anyone who wants to look at it. 

     

  • The [L]ook command

    I actually managed to work on HA! some more this weekend while not doing "other" things (like driving almost 40 minutes each way to the airport to retrieve lost luggage... and tech-editing an upcoming VB 2008 book. (Paying gigs unfortunately must take priority over fun stuff.)

    So anyway. I worked on the [L]ook command today. (Technically it's the [l]ook command since the lowercase "l" is the action key.)

    Basically, the look command functions like this:

    1. Make cursor visible under Hero.
    2. Display instructions at top of screen (use movement keys to look, z or [spacebar] to exit.
    3. As player moves cursor around screen, display relevant information about location, following this order of precedence:
      • Has tile been seen before?
        • creature type (eventually add link to full description, with observed stats)
        • pile of items (There is a pile of items here.)
        • single item (show item name, eventually add link to more info.)
        • trap type (if previously discovered)
        • tile description (if nothing else is on the tile, show what type of tile it is)
      • If the tile has never been seen
        • "You don't know anything about this place."
    4. Loop until player presses z or [spacebar]
    5. Hide cursor
    6. Return control to main game loop

    The tricky part about working on this is setting the order of priority and taking things like Line of Sight, Fog of War, etc into consideration.


    This part is still in planning:
     

    A couple of the items (creatures and items) that currently only display a type will link to a description page. The cool part behind this (as planned) is that the description page will be dynamically built based on what the Hero has observed: 

    If you've never fought a Kobold, [l]ooking at a Kobold won't tell you much other than what it looks like. After you've fought a few, [l]ooking at one will tell you a lot more, such as approximate speed, how often they hit, how hard and what weapon type they use. Additional info such as how much experience they are worth, what sort of things they drop, etc might also be added.

    Items would work the same way. If it's unidentified, you get nothing but the very brief item title. Once it's identified, you get a little more, and once you've used a few of that exact item type, you start getting more detailed info, averaged from usage results.

     

  • New HA! Release (0.1.6f)

    Sorry about the long wait, but I finally pushed a working build onto the Codeplex site. (You can get there via http://www.heroicadventure.com)

    Heroic Adventure 0.1.6f is purely a bugfix release but I'm happy to say that I have renewed interest in working on HA! after a very long and frustrating break.  I've already started on some very in demand features, including better LOS code, ranged combat, spellcasting and the ability to examine the world around you.

    Stay tuned.

  • A more random Random.

    This is the random number generator we use in HA!  It's a much truer Random than System.Random.  It's slower, but not as slow as the Crypto Random.

    Converted from C by Paul Vick, initially for use in Heroic Adventure.  Thanks Paul! 

    For more information about the Mersenne Twister and the concepts behind it, I encourage you to read this Wikipedia article.

    To save some cut & paste heartache, I've attached the source file to this post. Be sure to grab it:  MersenneTwister.vb

    '
    ' An implementation of the Mersenne Twister algorithm (MT19937), developed
    ' with reference to the C code written by Takuji Nishimura and Makoto Matsumoto
    ' (http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html).
    '
    ' This code is free to use for any pupose.
    '

    Option Strict On

    '''
    ''' A random number generator with a uniform distribution using the Mersenne
    ''' Twister algorithm.
    '''
    Public Class MersenneTwister

    Private Const N As Integer = 624
    Private Const M As Integer = 397
    Private Const MATRIX_A As UInteger = &H9908B0DFUI
    Private Const UPPER_MASK As UInteger = &H80000000UI
    Private Const LOWER_MASK As UInteger = &H7FFFFFFFUI

    Private mt(N - 1) As UInteger
    Private mti As Integer = N + 1

    ''' <summary>
    ''' Create a new Mersenne Twister random number generator.
    ''' </summary>
    Public Sub New()
         Me.New(CUInt(Date.Now.Millisecond))
    End Sub

    ''' <summary>
    ''' Create a new Mersenne Twister random number generator with a
    ''' particular seed.
    ''' </summary>
    ''' <param name="seed">The seed for the generator.</param>
    <CLSCompliant(False)> _
    Public Sub New(ByVal seed As UInteger)
         mt(0) = seed
         For mti = 1 To N - 1
              mt(mti) =
    CUInt((1812433253UL * (mt(mti - 1) Xor (mt(mti - 1) >> 30)) + CUInt(mti)) And &HFFFFFFFFUL)
         Next
    End Sub

    ''' <summary>
    ''' Create a new Mersenne Twister random number generator with a
    ''' particular initial key.
    ''' </summary>
    ''' <param name="initialKey">The initial key.</param>
    <CLSCompliant(False)> _
    Public Sub New(ByVal initialKey() As UInteger)
         Me.New(19650218UI)
         Dim i, j, k As Integer
         i = 1 : j = 0
         k =
    CInt(IIf(N > initialKey.Length, N, initialKey.Length))
         For k = k To 1 Step -1
              mt(i) =
    CUInt(((mt(i) Xor ((mt(i - 1) Xor (mt(i - 1) >> 30)) * 1664525UL)) + initialKey(j) + CUInt(j)) And &HFFFFFFFFUI)
              i += 1 : j += 1
              If i >= N Then mt(0) = mt(N - 1) : i = 1
              If j >= initialKey.Length Then j = 0
         Next
         For k = N - 1 To 1 Step -1
              mt(i) =
    CUInt(((mt(i) Xor ((mt(i - 1) Xor (mt(i - 1) >> 30)) * 1566083941UL)) - CUInt(i)) And &HFFFFFFFFUI)
              i += 1
              If i >= N Then mt(0) = mt(N - 1) : i = 1
         Next
         mt(0) = &H80000000UI
    End Sub

    ''' <summary>
    ''' Generates a random number between 0 and System.UInt32.MaxValue.
    ''' </summary>
    <CLSCompliant(False)> _
    Public Function NextUInt32() As UInteger

    Dim y As UInteger
    Static mag01() As UInteger = {&H0UI, MATRIX_A}
    If mti >= N Then
         Dim kk As Integer
         Debug.Assert(mti <> N + 1, "Failed initialization")
         For kk = 0 To N - M - 1
              y = (mt(kk)
    And UPPER_MASK) Or (mt(kk + 1) And LOWER_MASK)
              mt(kk) = mt(kk + M)
    Xor (y >> 1) Xor mag01(CInt(y And &H1))
         Next
         For kk = kk To N - 2
              y = (mt(kk)
    And UPPER_MASK) Or (mt(kk + 1) And LOWER_MASK)
              mt(kk) = mt(kk + (M - N))
    Xor (y >> 1) Xor mag01(CInt(y And &H1))
         Next
         y = (mt(N - 1) And UPPER_MASK) Or (mt(0) And LOWER_MASK)
         mt(N - 1) = mt(M - 1)
    Xor (y >> 1) Xor mag01(CInt(y And &H1))
         mti = 0
    End If
    y = mt(mti)
    mti += 1
    ' Tempering
    y = y Xor (y >> 11)
    y = y
    Xor ((y << 7) And &H9D2C5680UI)
    y = y
    Xor ((y << 15) And &HEFC60000UI)
    y = y
    Xor (y >> 18)
    Return y

    End Function

    ''' <summary>
    ''' Generates a random integer between 0 and System.Int32.MaxValue.
    ''' </summary>
    Public Function [Next]() As Integer
         Return CInt(NextUInt32() >> 1)
    End Function

    ''' <summary>
    ''' Generates a random integer between 0 and maxValue.
    ''' </summary>
    ''' <param name="maxValue">The maximum value. Must be greater than zero.</param>
    Public Function [Next](ByVal maxValue As Integer) As Integer
         Return [Next](0, maxValue)
    End Function

    ''' <summary>
    ''' Generates a random integer between minValue and maxValue.
    ''' </summary>
    ''' <param name="maxValue">The lower bound.</param>
    ''' <param name="minValue">The upper bound.</param>
    Public Function [Next](ByVal minValue As Integer, ByVal maxValue As Integer) As Integer
         Return CInt(Math.Floor((maxValue - minValue + 1) * NextDouble() + minValue))
    End Function

    ''' <summary>
    ''' Generates a random floating point number between 0 and 1.
    ''' </summary>
    Public Function NextDouble() As Double
         Return NextUInt32() * (1.0 / 4294967295.0)
    End Function

    End Class

  • oops

    Apparently last time I worked on HA!, I left it in a broken state. No big deal except that I happened to check it in that way.  Sorry guys.  The offending lines have been commented out, and it builds now.  And of course, yes, this means I'm working on it recently.  With the Thanksgiving Holiday fast approaching, I plan to spend some quality time with HA!

    Posted Nov 21 2007, 03:53 AM by admin with no comments
    Filed under: , , ,
  • The road to XNA Roguelikes is paved with speedbumps.

    XNA doesn't support any type of "console" class, but it does support something cool called a SpriteFont. This takes a TrueType font and (basically) renders a spritesheet of the font, in the form of an XNB file.

    So if you're looking to do a Roguelike in XNA, you're gold, right? Just use the DrawString method and render the text on screen as sprites?

    Nope.

    Apparently (as of the XNA 1.0 Refresh) SpriteFonts do not support monospaced fonts. That isn't to say that you can't use a monospaced font in your SpriteFont class, just that it won't actually be rendered as monospace.

    You have some alternatives: 1. create your own sprite based font that IS monospaced. 2. use graphics tiles in your Roguelike.

    I haven't figured out which one I'll be using (if I actually take HA! that route.)

  • Moving In

    I'm hoping this may spur a rebirth of sorts for my Heroic Adventure! game. I haven't really been spending much time on it since XNA came out.

    There's a lot that remains to be done, and for now CodePlex seems to be the best place to continue hosting it, but I will be blogging about it here.

    Some things I want to work on in the future include:

    • getting spells in place so the magic using classes arent so horribly disadvantaged.
    • I also need ranged combat. Should probably do that first since some spells will need the targeting code in place.
    • skills are partially implemented
    • levelling up is in place, but needs more UI.

    more to come later.

Copyright 2008 - ILoveVB.NET
Powered by Community Server (Commercial Edition), by Telligent Systems