Rogue is a dungeon crawling video game first developed by Michael Toy and Glenn Wichman around 1980. It is generally credited with being the first "graphical" adventure game, and was a favorite on college Unix systems in the early to mid-1980s, in part due to the procedural generation of game content.

-- http://en.wikipedia.org/wiki/Rogue_(computer_game)

Monday, September 20, 2010

It is the little things

After beating my head against the wall, I called in a friend to help look at and debug the code.  If I were in a collaborative environment to begin with, I would have asked for another set of eyes sooner.  But after lunch at a nearby sub shop, I had him poke at my code.

Although the exact error was not found at that time, he did show me some more tricks working with Visual Studio and at least gave me a fresh perspective on where to focus my search.  After narrowing down the location, I was able to go back to the example code and figure out what I was missing.

In short, it was the typical "off by one" error.  In this case I was using a <= when it should have been <.  So after that was done, a few more errors in math were found in the rendering portion and finally I had completed the exercise.  Now I have half of a nice random terrain generator.

This is designed for an RTS so it has peaks and valleys.  I am not sure if I will have non-flat terrain in YAR itself, but it other aspects, such as path finding and object placement will be useful.  Orginally I was thinking of doing a simple 2D iso tile system, but it seems fairly straight forward to do this as a terrain/texture mesh over a 3D surface, even if the surface is going to be flat.  Since most of the heavy lifting has been done in DirectX (and OpenGL) like matrix transformations and what not, I might as well stay here as well.  I will be easier to make it simpler later.

Friday, September 10, 2010

Hitting a New Wall

I am slowing working my way though Programming an RTS Game using Direct 3D.  Only on Chapter 4 but I am taking my time to go over the code in the book and the full code on the CD to understand what I am doing.  Not to mention going back to some DirectX resources to see why I am doing what I am doing.

However, I have hit my first real stumper.  Some how I am getting corrupt memory in my initializations.  Annoyingly it happens at slightly different points in the code when I run it.  But the error is some type of heap corruption or other misaligned memory.  Unfortunately I have yet to see where the real problem is.  Also the example code itself runs fine, yet mine does not.  Now being the good learner, I am adding my own coding paradigm to the example code, so there are differences.  But I am not sure what difference is causing the error in question.

The upside is that I am getting more familiar with the Visual Studio Debugger.  It is kind of fun and for the most part I have been able to figure it out.  Right-Click is your friend.  Now I am still a little green trying to read some of the raw assembly code, but I got though reading UNIX trace/truss commands so this will just take some time to start seeing the patterns that have useful information.

Friday, September 3, 2010

FORTRAN is the Latin of Engineering

If you went to Engineering school in the 80's you most likely had to take a programing in FORTRAN class.  As I started in 1989, I too took FORTRAN.  Two years later, entering freshmen learned C instead of FORTRAN.  Granted I also took the C programing class as an elective, but FORTRAN was the required language.  Also I think my year was one of the last years to have a mechanical drawing class with actual boards, pencils and T-Squares.  And although I had my father's slide-ruler, we were allowed to use electronic calculators. 

So learning "old" technology is very comfortable for me even if it is academic.  Such is how I feel right now working with DirectX9.  It is on the way out since XP is finally no longer allowed to be put on new systems and soon that will be moot since it wont have the support of new hardware anyway.  I should be learning DX10 or DX11.  However there is a lot more written and available for DX9.  Currently most of the books of the variety "Programming $GAME with DirectX" are written for DX9.  So I have a lot more examples to pull from.

Now in my case $GAME = RTS. Though I do have access to the online copy of RPG as well.  So between the two of them I am getting a good idea of all the moving pieces that go in to a fairly typical, though small, game that I want to create for YAR.

I have found learning "old" methods very useful, though it has pigeon-holed me a few times.  On the other hand, I am one of the people that can bring grognards up a few centuries and use at least more modern equipment then what they were using.  Also since I am spending as much time learning the concepts of 3D graphics programing (like texturing and  transforms) I can use all the examples I can get.  My quick look in to DX10 shows that the concepts are still there but the implementation has changed (like Vertex and Index Buffers.)   You still have to know how to use those items from a conceptual standpoint regardless of the API.  When I poke a OpenGL sometime in the future, I will not have to learn basic 3D programing.

Thursday, August 12, 2010

In Scottland they speak English

There is English and there is English.  I am from the US and have what is as close to what is the "Neutral US Accent."  This is the accent of the majority of news casters and for the most part the non-metropolitan east coast accent.  Being a geek I grew up with Monty Python and other British TV as well as spent some time in Australia.  And for the most part I never had an issue understanding most other non-US English speakers.  The vocabulary may change, but I could still understand what the words were said if I did not fully understand the context of the words.  Then there is Scotland.  In theory they speak English, but it is fairly difficult to tell at times. 

What does this have to do with programing?  Quite a bit.  There is C and C++ and for the most part it is all the same.  However everyone puts their own accent on it.  Since I am now learning DirectX, I am learning to understand the vocabulary used by Microsoft API base programs and able to translate in to my own understanding of the languages.

However, I am doing it in the most curious of ways.  I started with the DirectX 9 Tutorials from MSDN as I mentioned before.  But there was quite a bit of details missing.  Now I am going though Programming Role Playing Games with DirectX by Jim Adams.  The particular edition I have uses DirectX 8. Of course in reality I should be working with DirectX 10 or 11. So here I am flipping between that book, the MSDN site as well as the occasional Googling to see what other people have done.


I feel like I am having to translate English to English and back in to English again.  If Russian were in the middle, I could have gotten: "The Vodka is strong, but the meat is rotten."

Tuesday, August 10, 2010

Looks like a Duck

It has been a few days playing with DirectX and the tutorials from MSDN.  As tutorials go, the MSDN collection is fairly weak.  Lots of steps missing that you need to go research or already know.  Very little in the way of explanation.  On the upside it was nice to know that I could fill in the holes myself, and that I have learned quite a bit so far.

Like the Win32 API, DirectX (at least version 9) is much closer to C than C++.  Even glancing up at version 10 and 11, it is still very much the same. One of the scary parts I found was:

if(FAILED(g_pVB->Lock(0, 0, (void**)&pVertices, 0)))
        return E_FAIL;

Egads.  Casting void pointer to pointer of a reference.  Perfectly legitimate C code, and quite common to see.  But always a construction that makes me curious about the "power" of C when you need to go though some interesting hoops to pass the data you need around.  Ideally this would be a rare thing.  You take care of this level of detail once in your lower level engine code and not worry about it when you are designing your game at the upper level. 

So now to find some more in depth information.  Looks like I am finally signing up for Safari Books again.  Primarily because the one book that is recommended to me is out of print, but is available there for reading online.  This way I can take a look at other books as well and determine which ones I will want to purchase for my own library.

Thursday, August 5, 2010

Character Is What You Are In the Dark

The past few days have been adventures in to the Win32 API.  After all the elegance of playing with the STL and creating classes, I have gone back to fairly basic C style coding.  Not only that, C-style coding with Microsoft style tags and means.  I can see the various Visual Basic influences as well as some other old school language methods. 

Now to be fair, this API has been around for over 15 years.  So it does pre-date the formalization of C++ and it is based on the early DOS methods of doing things.  The API is easier to deal with than pure C.  I do get more useful functions like WriteFile() and CreateFile() instead of write() and creat().  So when I was looking around for good resource books on the topic, the one that everyone mentions is Programing Windows by Charles Petzold.  The book was last updated in 1998.  Normally I am very leery of technical books over 5 years old, but it seems that the API has not changed too much since then.  What little has been added is documented well enough on the MSDN website.

It is the Microsoft Foundation Classes (MFCs) that are the "object-oriented" programing tools for windows, and that is what brings you back up to C++.  (Or Visual Basic and C#)

At this point, I got what I needed from the tutorial, that is enough information to read the road maps and signs for playing with DirectX.  Now I am no longer befuddled by LPTSTR or HWND.  I can see what they are obfuscating.

Tuesday, August 3, 2010

A New Begining

After putting a stop on Maze Mover, I have decided to take a few steps back and learn some basic Windows Programming.  Well at least the Win32 API.  Mostly this is because I am going to work with DirectX so I should get familiar with the Windows based calls. 

The SDL API did some interesting changes on top of the standard Win32 API while using Visual C++.  Then again SDL is meant to be more platform independent, so it might have to step on some established toes.  Right now this is my suspected reason for the conflicts I had with Python. 

Now I did some of the basic "Hello World" apps from MSDN, but it was a little lacking on describing all the Window-isms.  Mainly what are all these typedefs they have running around like "LPSTR."  After a bit of googling I am now running though theForger's Win32 API Tutorial.  And it is doing what I want.  Telling me what all the little bits mean.  I was at the point where there were too many foreign items I had to figure out and no Rosetta Stone to start determining my translations.

This site looks to be as good of a start as any.