Wednesday, December 31, 2008

Adding sound

One of the really important overlooked parts in games is sound.

And in obeisance to that fact I have made my latest update about sound.

I added pygame.mixer to the project
Notes:
now pygame has to be installed
If something crashes pygame will catch the crash and display it. That does not mean that pygame caused the crash.
mp3 support seems to be shoddy. oggs can be used instead.
audacity is a great sound editing tool
I added midis for the music. MIDIs are awsome.
I added espeak voices. Espeak is neat on its own.
To get the timing right its real easy to just look at the size of various voice lengths
I had to add a pause at the beginning of the event. It should probably be variable and based on whether or not everything is loaded (like have a singleton loaded variable and set appropriately)

One more thing. I believe that open al has positional audio, but I remember having issues with it.

Wednesday, December 24, 2008

Rebuilding or modifying

I've noticed that the concept of rebuilding things seems to be fairly important in games. For example when you set an effect on a unit or remove it a reset attributes function is useful because knowing the previous state is hard.

To give an example in everquest you could cast a spell on yourself that made you stuck and then cast a shorter spell that made you stuck and then you could move around after the second one was done.

so you want to apply the effect then reset all attributes (or just some) based on the effect and your base stats.

Tuesday, December 23, 2008

Unbound method error

If you get an unbound method error and don't know why make sure you add the () on the end of the class. Python can often give you something even if you don't want it.

A bit of history

I didn't really start out trying to make what this ended up as. There wasn't supposed to be a grid and I had intended on using physics more. I like the grid stuff I think so thats really gonna stay, and I intend on adding more that deals with physics as well but thats a later thing and it was probably a bad idea to keep physics maybe (then again maybe not)

One of the key things that kept me on track was focusing on implementing something similar to something that already exists. Could I have finished the game and so on if I hadn't done that? Probably, but most likely I would have gone off into AI and other hard stuff that is cool, but takes too long

I'll probably be trying to implement some cool AI later on that should be able to do some advanced tactics (like you could set goals for it and such instead of it all just being baked in. But right now the 50 lines of code is fine. Hopefully if it takes off I'll get to work on that.

I think that Wesnoth the game really inspired me with its simple game and 2d graphics but really pretty great AI and gameplay.

This isn't the first attempt at doing something similar. I tried doing a similar thing using c++ and xml but it turns out its nicer to write in static c++ than dynamic xml and I was trying to genercify things too much. Ultimately though my main problem was that I built an art intensive game and had no artists. It was based off of Gunnerkrig Court and my art skills were sadly lacking (but I did at one point have a voice actor.

Sunday, December 21, 2008

Useful python methods when working in boost (pyc++)

def printlist(x):
y = ""
for z in x:
y += str(z)
return y

Boost lists just show the memory address and are kinda useless. This just prints a list


def debugpickle(obj,tofind = Ogre.Vector3,depth = 0):
print obj
depth +=1
if depth > 10:
return
if isinstance(obj, tofind):
return obj
if hasattr(obj, "__getstate__"):

for x in obj.__getstate__().values():
debugpickle(x,tofind,depth)
elif hasattr(obj, "__dict__"):

for x in obj.__dict__.values():
debugpickle(x,tofind,depth)
elif hasattr(obj, "__iter__"):
for x in obj:
debugpickle(x, tofind,depth)

This could probably be done better, but it was all I needed, for a quick way of finding out what can't be saved in pickle