Friday, March 22, 2013

Player Actions

I have been working my way though the Player Actions that I had previously coded in one long if statement and am breaking each one out into its own class or function.  So far I have the Move and Look functions done, and have started on the Use function.

One of the things that I have been playing with is Inheritance and trying to determine when two classes share enough of the same code that they should inherit stuff from a shared parent.  One of the changes that I made was to make Rooms and your Inventory as children of a parent class called Containers.  Basically, a Container is a place where you can take or drop things.  The difference between a Room and your Inventory is that things can move about in between Rooms.

Monday, March 18, 2013

Refactoring!

I'm not sure what inspired me to code for entertainment after a year and a half of nothing.  I suppose it doesn't really matter, though.  What is important is that I coded for many hours this weekend.  It felt good to get back into the swing of it.

I went back to my silly SneakOut text adventure game. The game is not particularly brilliant, but I think its a good exercise for me to finish it. Anyway, looking back on that code, man, was it horrible.

I've been doing some programming for work over the last couple of months, and by that I mean code that people actually look at and give feedback on, and that has improved my understanding dramatically.  So, when looking at what I had written on my own 18 months ago, it was surprising at how mismanaged everything was.

Therefore, I spent all my time refactoring the old code into something more sleek and understandable.  Instead of several huge classes, things are becoming broken out into bite sized chunks and I think I am eliminating some unnecessary repetitive code as well.

Anywho, I have no idea if I will continue this coding routine, but if i do, i'll make sure to keep blogging for my future self to look at fondly.

Saturday, October 1, 2011

Pathfinding

I am surprised that I haven't written here in a while.

Here's a quick summary:
  • I got things stable enough to hand the game over to a couple people to try out. It seemed to do okay - there are still some major bugs, but I knew that going in. I mainly just wanted to see if they thought it was interesting.
  • They did find some fun bugs though. For example, currently you are able to pick up the car and carry it around with you throughout the house. Talk about impressive!
  • Once I handed it off to my players, I immediately went to work on trap #2 - the dog! During the game, the dog will wake up at some point and need to use the restroom. If you don't take care of it in time, the dog will wake up your parents. The issue that I ran into was getting the dog to walk to a specific room; aka Pathfinding. I spent a lot of time working on this problem, but I couldn't seem to get it to work the way i wanted. So, i cheated and hard coded a path for the dog to take.
  • While this solution worked, it wasn't the "right" way to do it. This solution meant that I would have to hard code every path I wanted an NPC to walk to get to a specific destination. And, if i were to add or change a room, I would have to go and fix all the hard coded paths. This did not sound like fun.
  • Therefore, I decided to re-tackle this problem. To make things easier, I cloned my code, ripped out all the stuff that didn't apply to NPCs and moving and started work from there. After several hours of work this evening, I am happy to say that I got it all figured out. It seems to run beautifully.
In summary, sorry for not updating more, but work is being done. :D


Saturday, September 10, 2011

Long day

I worked a lot today.

Rewrote a lot of code AND got light to travel through doorways. I know, pretty awesome right?

More re-writes

So, the current "game" that I am working on takes place in a suburban home. When I last posted, I had figured out how I was going to create the doors and allow the player to interact with them. This morning, I implemented it all.

Now that a part of a room can be interacted with, I need to be able to relay the current state of the door back to the user. This means that I need to constantly update the room's description to include which doors are open or closed. However, before doing so, I think it's best if i finish the lighting functions first, since this too will effect a rooms description. What the player will see when its pitch black is vastly different than when the player is in a brightly lit room.

So I have also added in the ability to toggle light switches on and off. However, doing so doesn't actually accomplish anything yet.

Before moving on, I think I have to rewrite more code. It seems that this is a common practice lately. I believe that I want to change the way a room object is constructed, somewhat drastically. This will impact movement as well, so that will also need to be rewritten.

Also, I should comment my code. Sometimes it takes me a couple reads to figure out what a section is doing and I wrote the damn thing.

Also also, I am thinking of adding debug/dev tools into the code that can be toggled on and off.

In summary, there's a lot of work to be done before anything new gets finished. Arg.


Monday, September 5, 2011

Updates

Over the past few weeks, I have managed to get my C# code on par with where my C++ code was before the switch. With most of the bugs worked out, I came up with a neat game idea.

Before I began working on this game, I thought that I had most of the code that I would need already done. The player could move around, open doors, interact with objects etc. However, I was mistaken. While, yes, all of these things are true, those functions/methods weren't doing exactly what I needed them to do. Therefore, I am building upon existing code to make it more powerful.

For example, most of this weekend was spent on doors. The old maze/fighting application only had one door and only required a bit of extra code to handle it. This new game has at least nine doors. In order to make my code streamline, I had to throw out the little extra code I used for one door and write a block of code that could be used for an infinite amount.

For a while, if you opened Door A in Room 1 and walked through it to Room 2, that same Door A would be closed in Room 2 despite it still being open in Room 1. But that has since been fixed.

I have no idea of a timeline for this little project. But hopefully I'll continue to plug away at it.

-Dash27

Sunday, August 21, 2011

Moving Right Along

Progress has been made.

It turns out a lot of my code is reusable - except for small things here and there. I've gotten the point where I can navigate a grid of rooms and have walls that block passage. Unfortunately, you are blind at this point and can't see any exits. You find exits only by trial and error.

PAX is this weekend and I get a new computer on TUESDAY, so I probably won't code much after MONDAY. But, maybe i'll find some time somewhere.

-Dash