Categories
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:
KyraTest-r8.tar.gz
KyraTest-r8.zip
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.

Categories
Game Development

Learning Kyra

Today was my first Monday without worrying about homework in a long time. Sunday will be the Chicago Indie Game Developer meeting, and I want to make sure I can say I’ve accomplished something.

One of my goals was to program 5 hours per week at the minimum. While I wasn’t able to do it consistently, I did program on my own projects much more often than I did last month. I even managed to fix up my Tic-Tac-Toe game so that it is a completed project under my belt. I’ve been learning, but now that school is no longer a worry I can accomplish much more in the coming month.

Another goal was to learn how to use Kyra. I haven’t touched it since I got the demo running on my machine. The demo was quite impressive and showed the power of the Sprite Engine. So I set to work, but I had some issues.

I created a directory in my Projects directory called KyraTest. I setup a Subversion repository and setup my documentation, source, and resource directories. Kyra comes with a tutorial, so I started there. The tutorial involves using a few images together. I wanted to start simply, so I cropped a photo of my head and shrunk it. I figured I could later add a cartoon body to it and have a bunch of characters running around on a screen. For the moment though, I just had this head.

I was able to create the .dat and .xml files from the sprite editory provided. I then copied one of the tutorial code files into my source directory and edited it to make the references to my own data. For some reason the file was written as if you wouldn’t have Kyra or SDL actually installed. It would have lines like:

#include "SDL.h"

All well and good, but why not use the system include instead of a local one? If you know, please let me know why the first way would be preferable.

Anyway, once I got that part squared away, and fixed the bugs I introduced when I edited the file, I got it to compile. Unfortunately it wouldn’t run because it couldn’t find libkyra.so.0. I found that it was installed on my Debian system, but there wasn’t a link created in the standard location for libraries. Once I created the link, it worked fine.

The end result: A black background with an image of my head in the middle. B-)

It was what I set out to do for today before going to bed, but it was kind of frustrating getting to that point. I sent an email to the author explaining the issues I had and how I fixed them, and I also asked for explanations on some of the code decisions.

My goal for this week: I want to make an application where a bunch of clones (with goatees, of course) are chasing after the real me (sans-goatee) before the meeting on Sunday.

And for the code collectors:
KyraTest.tar.gz
KyraTest.zip
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.

Categories
Game Development Games

Postmortem: GBTTT-CLI

Awhile back, I gave myself a goal of trying to create a simple Tic-Tac-Toe game within a week. I didn’t want to just copy the ubiquitous code out of a book, though. I wanted to take a project from intial design to implementation on my own. This project was not meant to be something commercial quality, nor is it meant for public consumption. It was just a way for me to test my rusty programming skills as well as practice using some of the tools I was experimenting with before, such as Subversion.

I did it. I called it GBTTT_CLI, which stands for GBGames Tic-Tac-Toe Command Line Interface. No graphics. No sounds. Just a simple Tic-Tac-Toe game. You decide who goes first, and each player will select one of the spots to place his/her piece, either an X or an O. At the end, the game will tell you who has won. Simple. B-)

What Went Right:

  1. It was not made with just one code file.

    Tic-Tac-Toe is a very simple game. It doesn’t need to be object-oriented, nor does it need much in the way of content. Still, I wanted to separate elements, such as Players and the Board. For the most part I succeeded. I could replace the Player with an AIPlayer at a later time easily. I could probably change the implementation of the TicTacToe game class so it can be done over a network without changing much of the other code, if any.

  2. Development went along fairly quickly.

    GBTTT_CLI was the first project I have worked on while using a safety net. Revision control tools are amazing and I wish I would have known about them years ago. I used Subversion, and while I rarely needed to backtrack, especially in a small project like this one, it was useful to go through my log to see what changes I made before. There was also a time when I made a LOT of changes only to get nowhere with them. It was easy to revert all the code back to the way it was before the changes were made. It saved a LOT of time for me when I could have otherwise just been trying to make changes to get back to a stable state. With a single command, I was there.

    Another thing that helped was the ease I had with actually coding. I underestimated my coding abilities because I thought I was starting from scratch with C++. The truth was, I could program, and I just needed to learn C++’s syntax correctly. There were a few things that I got tripped up on, such as NULL instead of null as in Java, but a quick look at my reference material showed me where I was going wrong.

  3. The game got completed.

    It was a project that I was able to finish. It may not be much, but it is more than what I had before, and I am proud of that fact. It’s also shows that I have the ability to work on my own designs.

What Went Wrong:

  1. It took me too long to get here.

    My goal was to get this program done in a week, and in total programming time, I did way better than that. Unfortunately if you count the days from when I first posed this goal to myself until I finished it, it was way longer. When I started coding, I got a lot done within a few hours. Then nothing for days until I tried to work with it again. Then I got some strange error. Nothing for weeks. Then finally I finished it. So I had a few hour spurts of productivity followed by long periods of nothing. To be fair, it was not like I was just avoiding the project. I had other responsibilities in my life, such as homework. But to be brutally honest, I wasn’t making the time for this project either.

  2. I overdesigned the classes.

    It is Tic-Tac-Toe. How do you overdesign it? I did. I thought that if I created the classes first, they would be useful as tools to build the actual game. I still think that it would be good to design the project this way, but my problem was in designing in specific features. The Player class has a Record member. The Record class holds the Win/Lose/Tie records of that Player. I wrote the classes in this way because I originally envisioned a single game session letting you play multiple rounds. In the end, I decided not to implement that since it did not need to be done to accomplish my goals. So now a Round is useless in the project. I didn’t spend too much time making it, but there are other elements that were made but not used. For instance, I also thought this would be a great way to learn network programming, so I tried to anticipate it by making Boards unique. I could have saved time and effort by deciding to add such things later or in a new project.

  3. The code is ugly.

    When I originally programmed in QBasic, I had no concept of code structure and variable naming. When I learned C++, I thought it made sense to follow what C++ did: variable and function names would look_like_this. Then I learned Java. Java programming practices are clean looking. A class name looks like: ClassName. A variable looks like: variableName. When I went back to C++, I got it in my head that I probably should keep it looking like C++, where standard library naming conventions have the underscores as mentioned above. That is when I started the project.

    Then I found a C++ coding convention guideline. Apparently Java-like style has its place in C++, too. Well, I did not want to go back and rename everything, so when I continued to work on the game, I kept using the same style rather than confuse everything, me included. The end result is commented, cleanly separated, but somewhat hard to read. A sample:

    // switch to next player
    game.next_player();
    // keep asking for input until value is legal
    int move = player_current->get_move(board);
    bool is_legal_move;
    is_legal_move = board.isLegal(move);

    Huh. Well as you can see, I did not succeed in keeping the style uniform. Board::isLegal() should be changed to Board::is_legal() to accomplish that. Still, it’s hard to read because of the style.

I know there is normally 5 of each in a postmortem, but come on, it’s Tic-Tac-Toe!

What I Learned

  1. Practicing programming is important. I should treat it as such and make the time for it rather than hoping I have an opening in my schedule. There won’t be one if I leave it up to everything else.
  2. Iterative programming is useful because I can avoid overdesigning something that won’t get used
  3. Programming is still fun, just like I remember it.

Even though I am disappointed in how some things turned out, I am satisfied. It’s a completed project! I was originally going to leave it in a state of incompleteness and start working on a more attractive project idea, but I decided to be “great” rather than “good enough”. If I keep that attitude with these smaller projects, it will be a good habit to have when I tackle larger ones.

I think I will post the code at a later time. I originally did not think it would be something I would publish, but I figure it has to help someone besides me. I’ll need to add a proper README and installation/compilation instructions first.

EDIT: Hey, I delivered. B-) And in two forms:
gbttt.tar.gz
gbttt.zip

Categories
Game Development Games Geek / Technical

I’m Live not-at-the-GDC!!

The big news in game development these days has been surrounding the Game Developers Conference. A number of indie developers have covered the event, including David “RM” Michael, Saralah, Xemu, and Thomas Warfield. I’ve had to read about it and see pictures of people I’ve met in person or online, missing out on the fun.

I’ve read a few of the writeups that David Michael wrote for GameDev.net, and I intend to read the rest. I’ve also been reading Game Tunnel’s IGF coverage, including interviews and day-by-day news. It’s just like being there…only not.

Congratulations go out to those who made it to IGF finals! Some amazing games have been made by indie game developers, and they serve as an inspiration to the rest of us. This time next year, I hope to attend.

Categories
Game Development

Starting Small

I found this link today in my blog reading: Just Barely Enough Design. It goes through the idea of starting small instead of trying to undertake something huge.

To this day, I am sorely tempted to undertake the whole grand dramatic turn-the-world-upside-down vision…or nothing at all. The trouble is more often than not you end up with exactly…nothing at all.

This is one of the (recurring) lessons from the dotcom days I’ve beat into my head the hard way (yup, way over-planned, over-designed, over-architected and flopped – and that’s how I finally got to be a big devotee of agile software development).

It also quotes Linus Torvalds:

Nobody should start to undertake a large project. You start with a small trivial project, and you should never expect it to get large. If you do, you’ll just overdesign and generally think it is more important than it likely is at that stage. Or worse, you might be scared away by the sheer size of the work you envision. So start small, and think about the details. Don’t think about some big picture and fancy design. If it doesn’t solve some fairly immediate need, it’s almost certainly over-designed.

The idea of starting small is one of the reasons why Game in a Day is so attractive. I know I won’t be making anything huge or general so I can concentrate on just doing it.

Categories
Game Development

Programming Goals: 5 Hours/Week

At the Chicago Indie Game Developer meeting on Sunday, we had the biggest turnout since I started attending. Among the new faces were some developers of the MMO game Endless Ages (the website of which seems to be down). It was interesting listening to them talk about working in the mainstream game industry and being between jobs. It seems more than a few of us are talking about getting new jobs. B-)

Anyway, my goals for the past month were to learn about game APIs and setting aside time to practice programming. As I described before, I did look into Kyra a bit, but only enough to run the demo and go through the tutorial a little bit. So that goal is somewhat met. On the other hand, I didn’t do much in the way of programming. Currently I’ve been working on homework because I have to do so. I think to myself that I will work on my own projects when the homework is completed, but the problem I have is that the homework either never gets finished or I have to immediately start on the homework for the other class I am taking. The result is that a month went by without me dedicating much time if at all to programming.

This month, besides getting more intimate with Kyra, I picked what should be an achievable goal: 5 hours per week. Each week I will dedicate 5 hours to programming in C++. It will be my homework that will get pushed off this time. It should be fine since most of my productivity comes when I get in the zone about the homework anyway, and that won’t happen until I’ve read through and understood the Java code involved. I’ve found that my homework can get completed within hours that way.

Last month I failed to program partly because I never got around to picking a hard number of hours or lines of code or anything. It was just stated as, “Need to program more” which is too vague and doesn’t inspire me to do much. If I have to program for 5 hours a week, however, I can track it. Is it Friday? I’ve only worked for an hour all week? Well today and tomorrow have to make up the other four! Also, if I program for longer than 5 hours in a week, I am not counting it towards the next week. The goal is to get practice and learn while doing it.

Before the meeting broke up, I asked the programmers there for advice. I explained that I know that I need to practice more, but I also wanted to know if they had any other suggestions on what I should be doing. Everyone basically said that I should “just do it”. There. What could be simpler?

Categories
Game Development Linux Game Development

C++ Unit Testing and Game APIs

This past week I decided to look into CxxTest. I was attracted to it since what I’ve read was that it was easy to use and highly portable. Unfortunately I found that there was no documentation on how to set it up on your system. It took me way too long to find out that this “Production/Stable” project doesn’t have installation instructions or packages to do so. Also, the Source Forge project page is very quiet. The developer apparently isn’t very active. This is disconcerting, but I think I have figured out how to setup CxxTest on my Debian system. I haven’t actually been able to use it yet, but I hope to rectify that within the next week. Hopefully it is going to be useful.

I also decided to take a closer look at two C++ Game APIs: GameBlade and Kyra. GameBlade seems to be suffering an even worse fate that CxxTest: it’s project page hasn’t been updated since January of last year, and it’s considered in Beta state! I might look at it later, but I didn’t see much in the way of documentation.

The Sprite Engine Kyra, on the other hand, looks great. It works on Win32 and GNU/Linux platforms, and the demo showed off some cool capabilities. It’s possible to have multiple views of the same scenes, with some views at different zoom levels! Scaling, color transformations, and alpha blending at per-image or per-pixel levels are just some of the other features. I’m really excited about using this engine, although I am thrown off by the sprite editor requiring hot spots and alignment since I would think these are things that I need to control within the program.

I may look into more cross-platform Game APIs, but Kyra looks to be a lot of fun and is very mature. It looks like I’ll need to put in some time to learn how to use it effectively, time that is tough to find these days, but it should be worth it if it will allow me to create games that much easier.

Categories
Game Development

Chicago Indie Game Developer Meeting

Yesterday I went to the monthly Chicago Indie Game Developer meeting. Basically we discuss what we’re doing regarding game development and make goals for the next meeting.

Part of me was disappointed since I didn’t really accomplish my goals. I wanted to have a command line Tic-Tac-Toe game ready, primarily since it would simultaneously improve my coding skill and provide me with a completed game, no matter how simple. The game compiles cleanly, which is good, but it is causing strange errors. I firmly believe it is “strange” only because I must not understand the code thoroughly, but what I find weird is that I have a string, say “First: throwing exception”. Why would the program output “rst: throwing exception” and “rowing exception”, and even weirder, why would it do so when I don’t catch an exception?! I’ll figure it out. In any case, there is some logic error that prevents me from saying that I completed the game. On the other hand, it still counts as experience, and I believe that I learned at least a little bit from the project so far. Just not as much as I wanted to.

Also, I was supposed to look up tools I could use for game development. Primarily I was being urged to look into BlitzMax since it is supposed to ease development and also be portable to multiple operating systems. It’s currently available for the only platform I don’t own. gcc on the other hand isn’t limited, and I’m already getting quite familiar with it.

Still, I pressed on. I have to be able to use some tools, and I realized that this was my fundamental problem with how I was going about learning. Java programmers don’t program in Java. They use the Java API. And yet, here I was trying to learn how to use C++ by building up the basic components. So I finally googled and found found a few C++ game APIs, all in various stages of development. GameBlade looks promising, as does Kyra. The latter apparently works on Gnu/Linux, Win32, Mac OSX, and BSD.

My goals for next month include giving myself more time to practice coding and learning how to use one of the game APIs I found. I need to make those goals less abstract by specifying numbers such as how many hours per week I’ll practice or how many small demos or techniques I want to try to master. Still, at least I know what direction I need to go in if I want to accomplish something. B-)

Categories
Game Development Games Linux Game Development

How I Want to Make Games

I want to make games. I don’t want to make them just as a hobby, but I also want to have fun while I do this. What’s the point of going into business for yourself if you aren’t having fun?

I want to use Free and Open Source Software. People tend to get confused about the concept of Free Software. To make sure you, the reader, understands, I suggest you read some articles about it:

Regarding that last article: people think “Software Should Be Free” means giving away your hard work for no compensation. It doesn’t. If up until now you thought this was the case, I again urge you to read those articles. Free Software is about Freedom, not about getting a free lunch. You may be surprised to find that Free Software isn’t the evil you heard it was. If you don’t care to actually learn about the Free Software concept, that’s fine, but please don’t start arguing against it because you can’t be taken seriously. How can you argue against something you don’t know or understand? Question it, be skeptical about it, but don’t presume you are an authority on it when you aren’t.

I also want to focus on making games for the Gnu/Linux system. I understand that it is likely my main revenue streams will not come from it, so I also want ports to the Win32 and Mac platforms. But I’m tired of seeing games ported to Gnu/Linux months after the fact. So when I say I am focusing on Gnu/Linux, I mean that it won’t be an afterthought. Ideally, using open standards and a solid code base, I can release for the three platforms at the same time, with minor tweaking at the most.

Some people think that there is no money here. I don’t believe that is the case. For example, I read that A Tale in the Desert 2 does very well among Gnu/Linux users. The conversion rate is incredibly higher than for Windows or Mac users. Granted, it is a MMO game, but still. Loki apparently didn’t go out of business for lack of sales so much as bad management. There are no stats that say that Gnu/Linux games will sell well, but no stats that suggest they won’t either. I’m willing to find out how well sales could be for the platform.

Categories
Game Development

My Ability to Create

Within the past year, I realized that I could not only start my own game development business but also be quite successful at it. I was partly inspired by Steve Pavlina and partly by other people who have already gone into similar businesses for themselves. It’s a lot easier to see where you can be when you receive a souvenir from someone who has been there. In this case, Steve has written a number of articles on subjects ranging from running a successful indie business to marketing to product development. My favorites are the personal productivity articles, the ones that let me know that I can do so much more than I was letting myself believe.

He wrote about his college experience. He wanted to get through school as quick as he could so he could start on his business, something he knew he wanted to do. So rather than take the average course load, or even just an extra class, he took multiple extra courses. The average college student has problems completing assignments on time for a normal workload, citing a “lack of time” as the main culprit. And here’s Steve Pavlina not only taking multiple course loads at once, but doing extremely well at that! He got amazing grades, a healthy amount of sleep, and a social life to boot.

And so began my study for time management. Eventually I learned that it was also life management. This was an amazing concept for someone who had never thought about how his life has been managed. Looking back, I pretty much coasted from day to day. Sure, some days I had inspiration, but it wasn’t consistent. These days, I am doing much better. I at least have a clearer picture of my future and how I want it to be. I’m still working on it.

Anyway, another of his articles is titled If No Independent Developers Are 100 Times Smarter Than You, Then Why Do Some Get 100 Times the Results?. It outlines the seven critical success factors in shareware. “To the degree to which you fail to master any one of these skills, that is the degree to which you limit your own success.” The factors he writes about are:

  1. Decide
  2. Create
  3. Promote
  4. Sell
  5. Serve
  6. Measure
  7. Improve

I rated myself in each category. Then I rated myself again, this time trying to question whether or not I was being overly optimistic in any area. That’s when I pinpointed my number one issue: my ability to create a product is almost nonexistent.

I can program. I’m not some master hacker, but I can write decent code. At least, I believe I can. Unfortunately I haven’t had much experience working outside of the classroom. It may be that the classroom is totally different and impractical in real life. I’ve read books such as Code Complete and Game Architecture and Design. I just haven’t given myself the opportunity to use what I’ve learned.

For years I’ve studied game development articles and books. I have quite the collection. Still, the last game I successfully created was a Pac-man clone in QBasic. And that was in 1998, before I knew how to code properly. It’s all spaghetti code! I know I can do a better job these days.

I used to think I was way ahead of the average newbie who posts “I WANT TO MAKE TEH BEST RPG EVAH!!” Turns out that I am only one step ahead: I know better than to think I can do something like an RPG with the lack of experience and skill I have. But what made me think that I can do something like a Tetris game right now?

When I asked myself that, I found out that I couldn’t. My ability to create a product I could sell was essentially nonexistent.

So I set myself to work on that issue. I wrote down a number of skills that I would need to learn to improve my ability to create. I needed to learn how to program, and properly. I needed to learn how to use development tools such as Gnu Make, Subversion, and the Gnu Debugger. I needed to become familiar with the STL (I am using C++), SDL, and any other libraries that will help me build programs.

It’s almost a month later. My C++ knowledge has defintely improved, and with it came the use of tools like Make and Subversion. The standard template library is definitely not the mystery they made it seem like when I took C++ at DePaul years ago. I haven’t messed with the debugger much, and I’m finding that there haven’t been many compelling reasons to use it.

Still, I can’t say that my goal of making my ability to create a 5/10 has been accomplished without being a very bold liar. I might be able to say it is a 2/10, but I would have to be a bit generous. The main reason why I have failed to improve much: time. But at least this time I know it isn’t some vague Outside Thing that is acting on me. I know the blame lies squarely on my shoulders. I didn’t give myself the time I knew I needed to work on these skills. I work as an intern for 40 hours a week, go to graduate school full-time (two night classes a week), and I commute about 10-20 hours. I have a social life. I sleep. I know I could make room for my skill development, but I also know that something needs to give. I originally thought I could just time manage my way through it, but it’s more than that. I need to set my priorities.

So now I am questioning the wisdom of my previous decisions: why grad school? why the non-software development internship? I realized that while I had learned how a lot of my situations are the result of my decisions, it hadn’t occurred to me that I found myself in a situation I didn’t want to be in. Robert Tracy had a line that repeated in his books a lot that went something like: if I wasn’t doing it today, knowing what I know now, would I start doing it? If not, don’t do it anymore!

So I’ve given myself some things to think about. I’ve identified some things I could do to help improve my skills, such as reading more source code (open source is great for providing Freedom #1). I’ve identified some things that are slowing me down, such as school. The question is: what’s my next step?