Game Development

Learning More Kyra

I’ve decided that I should probably create a Learning Kyra series. You can read the first one to get some background:
Learning Kyra

When I last worked with Kyra, I managed to get my head floating on a black background. Since then, I found out why lines like #include “SDL.h” are preferred, so I updated my code to reflect that change. I’m definitely becoming more aware of the issues I’ll encounter in development, much more than I was a month ago. Good. It means I’m learning. My goals for my next iteration in development:

  • I want to make the head’s background transparent.
  • I want to make the head move.
  • I want an animated body to go with it.

Geting the head transparent was weird. I was under the impression that Kyra’s sprite editor would actually pick a color to make transparent based on which corner I told it to use, but apparently I was mistaken or there is a bug when it uses something other than certain graphic file formats. I switched to using .tga files from .png, and I also found that I could set the transparency within The Gimp. First task: completed.

It didn’t take me long to get the head moving. I didn’t even have to change my code since I already programmed it to move. The data file just didn’t have the information to know how to move it. To change it, I entered the Kyra editor and set it up so that the head would move a few pixels in some arbitrary direction each frame. It was quite easy to do, and I even experimented with creating multiple frames. With only one image, it wasn’t very good looking, but it was good progress. A Black Triangle, if you would. Second task: completed.

Once I accomplished movement, I set out to create a cartoon body. I fired up The Gimp again, and was able to create three images for the body. The total walking package is below, and as you can see, I should stick to programming:

After getting the data encoded properly, it only took a few tweaks of the code to get the walking body on the screen. Check it out:

So now I have a walking character. He only moves in one direction, but he walks. Third task: completed.

So I managed to accomplish what I set out to do, and it was much easier than I expected. I managed to get more familiar with the mechanics of Kyra’s sprite editor and the code itself. I learned how to use The Gimp for more than just capturing screenshots and cropping photos. I also am learning that content development will probably require a lot more planning than I originally thought was needed.

My goals for my next iteration:

  • I want interactivity: the character should walk in the direction indicated by input.
  • I want multiple characters at once.
  • I want them to practice collision avoidance: a character shouldn’t be able to “walk into” another

You can download the updated version of the code:
Kyra Source in .tar.gz format
Kyra Source in .zip format

NOTE: You will need Kyra v2.0.7 to use this code. Also, the comments in the code weren’t all updated to reflect the fact that I’ve changed it. It is licensed under the GPL or LGPL as specified.