Midnight Mansion Forums
http://www.actionsoft.com/forums/cgi-bin/yabb2/YaBB.pl
Free Chat >> Speaker's Corner >> Under the Hood
http://www.actionsoft.com/forums/cgi-bin/yabb2/YaBB.pl?num=1171660917

Message started by VernJensen on 17.02.2007 at 04:30:56

Title: Under the Hood
Post by VernJensen on 17.02.2007 at 04:30:56
Okay, so this *is* related to Midnight Mansion, but I didn't know where else to put it.

Someone mentioned a while ago in some other forum post (I forget where) that I was probably right when I said that things are more complicated "under the hood" than they appear when you play the game. Today I was working on the new troll monster, that can both walk left/right AND climb ladders. And ladder climbing is pretty tricky.

So for those of you who are a little curious what the source code looks like, and to gain a deeper appreciation for the complexity of the game "under the hood", here is some of the code (not even all of it!) that handles Jack climbing ladders.

Hmm, seems it's too long to post as a message, so I'm attaching the file. This is purely for your amusement.

I seem to remember ladders took me like 2+ weeks to get working initially, not to mention fixing bugs later. It was definitely one of the harder parts of Jack's movement.

This is also one of those things you might call "ugly code."
http://www.actionsoft.com/forums/cgi-bin/yabb2/YaBB.pl?action=downloadfile;file=ladders_txt.zip (5 KB | )

Title: Re: Under the Hood
Post by joeb on 17.02.2007 at 06:24:19
Vern,

Living in a programmers world daily I think I have an appreciation of what's under the hood. Just curious about when the rest of the car will be available (expansion pack).

::) ::) ::)

Thanks,

Joe B

Title: Re: Under the Hood
Post by joeb on 17.02.2007 at 06:32:18
Why ugly?
It's commented which is my definition of pretty vs ugly.

Joe B

Title: Re: Under the Hood
Post by Wingy on 17.02.2007 at 10:04:43
Looks like hard work, Vern! Here's an example of what I did with my simple Meta language. (Type of code) These I believe is the buttons code... or the controls... It's been along time since I programmed, took me awhile to figure out. Its the code for my game, Laser Blaster. Download it free at my site! (www.antsarts.surf.to)
Picture_1_002.png (8 KB | )

Title: Re: Under the Hood
Post by aquaMat on 17.02.2007 at 20:59:36
Vern....that's really amazing (and crazy...) - so many linmes of code needed just for moaking someone / something climbing a ladder....  Jesus Christ.   :o
I wonder how many pages would be filled by the code for the whole game ???  

Title: Re: Under the Hood
Post by samskelton on 17.02.2007 at 21:27:21
I'm not sure if there's a number for that!!! ;D

Title: Re: Under the Hood
Post by Wingy on 17.02.2007 at 21:54:26
There's 311 lines exacly for my Laser Blaster! My older brother is coming over soon to help me to get Health Packs working and to appear every now and then when you're playing! Then Laser Blaster 1.2 will be out! After that, I'll get more weapons for 1.3! It'll be wicked.

@Vern: Do you know any Meta-Laugage? I use a app. known as Metal with my code. You can download it at: http://www.iit.edu/~sarimar/GDS/DL/metal-173.sit

Title: Re: Under the Hood
Post by VernJensen on 18.02.2007 at 02:50:47

joeb wrote on 17.02.2007 at 06:32:18:
Why ugly?
It's commented which is my definition of pretty vs ugly.


Well, ideally it would be modularized a bit more. Right now, it's the "stuff everything into one function" (or in this case 4 functions) type approach, which makes it hard to read, and difficult to modify and debug.

But sometimes you never really can get away with the "ideal" elegant approach, and have to go with real-world.

The nice thing it, I was successfully able to copy and modify this code for use with the new Troll monster fairly easily. Now I have a troll who runs along bricks *and* climbs ladders when he comes to them -- something I was previously afraid might be very hard.

Title: Re: Under the Hood
Post by VernJensen on 18.02.2007 at 02:58:37

aquaMat wrote on 17.02.2007 at 20:59:36:
I wonder how many pages would be filled by the code for the whole game ???  


Quite a few. ;-)

I have 15 main source code files for the game, not including the animation engine, SpriteWorld, which I also wrote much of, and not including many utility files, used for things like handling File Input/Output.

In the previous source code listing, there were 4 "functions":

ClimbingSpriteMoveProc
FinishClimbingLadderMoveProc
GetLadderRect
GetLadderRectFromTile

Below is a screenshot showing the entire function list from just one of those 15 source code files, to give you an idea of how long one of the files can be. This particular file has 4910 lines of source code.

This is one reason why they say programming has a "steep" learning curve on modern computers. ;-)

And now you can also recognize why commercial games typically have *teams* of 30+ people working for 1-3 years to create a single product. (Although many are typically do artwork or other non-programming roles.)
functionlist.jpg (102 KB | )

Title: Re: Under the Hood
Post by Wingy on 18.02.2007 at 03:18:17
Looks... long. ;)

Midnight Mansion Forums » Powered by YaBB 2.4!
YaBB © 2000-2009. All Rights Reserved.