Categories
Game Development Geek / Technical Personal Development

Learning Game Software Architecture

Note: I wrote a significant amount of this post in 2011, back when I was actively working on Stop That Hero!, and enough still resonates today that I decided to publish it.

It’s only in the last few years that I’ve started to appreciate the importance of software architecture, and especially as I write the game engine for “Stop That Hero!” Before “STH!”, I haven’t had much experience with writing entire programs from scratch. Most of the code I’ve written professionally fit into an existing framework or architecture, so high level architectural work wasn’t something I had to worry about in my day-to-day work.

Beginner Programmer Woes

When I first learned how to program, I was focused on getting the syntax correct. Programs, even if they were completely original and not copied out of a book or magazine, were simple. More complex programs usually didn’t get finished before I lost interest. Any non-trivial programs that were successfully completed were the epitome of what we in the biz call “spaghetti code,” which means I was lucky to get something working at all. See my Pac-man clone in QBasic as an example of what teaching yourself how to program can result in.

Then I got to college, and I learned C++, and concepts such as recursion and stacks and objects. I was still using QBasic as a hobby, and my new code was definitely cleaner, but I struggled with putting everything together in a cohesive whole. And programming on a modern OS required a message pump, which meant I had to change the way I did things drastically. You couldn’t add empty loops if you needed a delay anymore.

Ok, so most likely, you’ve been there before, too. My story above isn’t unique. Lots of programmers went from DOS to a multitasking OS. The thing is, I think I fell behind in terms of learning how to program in this new world order. When I stopped using QBasic, I didn’t write a lot of C++ code outside of class requirements until I nearly had my degree. It turned out that I learned C++ wrong at first, which is why I didn’t enjoy programming in it as much as I did with QBasic. Once I read Accelerated C++ by Koenig and Moo, it made a lot more sense and was a joy to work with. That book is a great way to learn C++ for a beginner. Even though C++11 has since been released, I still highly recommend the book today.

Program Design Is Hard

But it still didn’t change the fact that larger applications were hard to make. If I knew what class or function was needed, I could write the code just fine. It was determining what class or function was needed that was the hard part. Or to put it another way, I struggled with “where should this code live” questions. Basically, software architecture was hard, and I didn’t know it was even a thing to be concerned about. Heck, years ago, I was concerned with how to put together a basic game loop. Solving that problem means I had everything I needed, right?

What I knew about game engines is based on what I read. Countless books and articles broke down the anatomy of a game engine by talking about its subsystems: audio, video, input, networking, etc. At the time, I believed this subsystem knowledge was enough to make a game. If you had a way to render to a screen and detect input, you had the bare basics to make a game. It’s just a matter of implementation, right?

Since I taught myself QBasic, and my first projects we isolated endeavors, I thought I knew how to put a piece of software together. I was able to put together an entire game, so how hard could it be? After all, they don’t give 70% reviews to just any QBasic games, right? I’ve even managed to put together complete Ludum Dare entries.

Why Is Everyone Else So Much Faster?

But I was also aware that some of the other Ludum Dare participants were able to make their entries way more impressive within hours of starting than my games end up by the deadline. Ludum Dare was historically a “write your game from scratch” competition, so it’s not as if they had full game engines available (although that’s changed with Unity entries). What was I missing?

Well, experience, for one. Some of those impressive entries are made by people who have been making games for way longer than I have. Even if we started at the same time, I haven’t been working on as many games as they have. They might have worked in the game industry and so know how to make games on a deadline. Even if they didn’t have game dev experience, they might have worked on financial software. Either way, they’ve likely written a lot more code than I have, so putting the software together to implement their game designs is possibly second nature.

Another thing people seem to have is boiler-plate code, such as code for menus, buttons, and sprites. XNA users have a huge advantage here, and Unity users are practically cheating. As I run and deploy to GNU/Linux, neither option is available to me, and since I work in 2D, there aren’t a lot of game engines available. A lot of the libraries that I could piece together also don’t fit my needs. Either they do things in a way I don’t want to do (GUIchan versus IMGUI), or they are not cross-platform. Instead, since my first Ludum Dare, I’ve written a lot of boilerplate code as I needed it. Each competition, I created more and more base code to leverage for the next project.

But I was oblivious to some of the fundamental architecture needs of a game engine, and so I still struggled to put together a finished, playable game in 48 hours. After all, the subsystems were everything. Just tie input to what’s happening in the game, and make sure the player can see feedback on the screen. Why is this so hard?

Learning Software Architecture

Most people will tell you to get a copy of the book Design Patterns by the Gang of Four. It’s a great book and features a number of patterns. Now, if you want to refresh yourself on what a pattern entails, it’s fine, but it isn’t great for learning about them in the first place.

I found Head First Design Patterns to be a great, easy-to-read introduction to major patterns.

But patterns knowledge isn’t enough to know how to organize a major software project. If I want to be able to provide a single interface to a bunch of disparate pieces of code, the Facade pattern is what I need. But what about determining that I need a single interface to those pieces of code in the first place?

And Test-Driven Development is supposed to be about code design. By writing tests, you already have a user of the code you’re writing, so you know how to design the functions and interfaces. TDD can help you design a single class, but it’s not going to help you drive the design of a full application. More and more, I realize that my lack of experience with writing larger applications is making my TDD efforts more of a struggle than they need to be. Uncle Bob Martin wrote about this topic in TDD Triage (the link has since died):

Here’s the bottom line. You cannot derive a complete architecture with TDD. TDD can inform some of your architectural decisions, but you cannot begin a project without an architectural vision. So some up front architecture is necessary. One of the most important up front architectural activities is deciding which architectural elements can be deferred and which cannot.

So patterns and TDD aren’t enough. Some architecture decisions are necessary, and I hadn’t made any. No wonder I had trouble in the past!

Conclusion

Ok, it’s 2014 again. Since 2011 when I first wrote this post, I’ve learned quite a bit about software architecture and designing software. Experience is one of the greatest teachers.

I’ve learned to focus on the data flow. Where does data come from, and where is it heading? I’ve learned to focus on what large pieces I need and worry about how to hook them up to each other later. I’ve learned how to separate the GUI from the internals, and that each has their own massive design decisions to worry about. I’ve learned that software architecture is less about the overall design of a software project as much as it is about the constraints on it.

I also learned that software architecture concerns don’t come into play as much if you are hacking together quick prototypes, but addressing the major software constraints can be huge if you intend to have a reusable set of code to use from project to project.

I’ll write more about the specifics in a later post, but it seemed important to document to struggle, especially as I did not identify my lack of knowledge about software architecture as an issue at first.

If you’re an indie developer, what were your major insights into software architecture? Do it come into play for you, or do you find that it isn’t anything to be concerned about in your day to day?

Categories
Game Design Game Development

The Indie Interview Series

Interview recording equipment

During the last half of 2013, Ben W. Savage conducted The Indie Interview Series “to inspire those who are considering game development” as well as those game developers looking for practical advice.

He asked the same series of questions of everyone, and prominent indies such as Christer “McFunkypants” Kaitila and Chevy Ray “Chevy Ray” Johnston spent anywhere from five minutes to a quarter of an hour answering. The topics ranged from how to get started in the game industry to who were major influences and what are major mistakes new developers make.

Adam “Atomic” Saltsman, creator of Candabalt, suggests that taking too big of a bite is a common problem. “Learning how to do a project is its own discipline … Start small, learn about the process, and then refine. That’s the key.” Nina “[insert nickname here]” Freeman of Code Liberation Foundation agrees in her own answer to the same question, repeating “simple prototypes, simple prototypes, simple prototypes” and suggests working in steps.

These are bite-sized nuggets of wisdom, and I wish there were more.

What’s your favorite interview? Did any of the answers resonate with you?

(Photo: https://www.flickr.com/photos/39781145@N00/254759786 | CC BY 2.0)

Categories
Personal Development

Anyone Going to the Extreme Leadership Summit?

Fom April 11th through the 13th, I’ll be at the Extreme Leadership Summit in Chicago.

Last year, I met Steve Farber, author of The Radical Leap and The Radical Edge and founder of the Extreme Leadership Institute.

His books are novels about the nature of leadership and what’s needed from it in today’s world. According to Farber, LEAP stands for:

  • Love
  • Energy
  • Audacity
  • Proof

Being a leader “is intensely personal and intrinsically scary” so you have to love what you do and love the process of making change, even if you don’t know how things are going to turn out. “Do what you love in the service of people who love what you do.”

Energy comes from having a good purpose. Without one, you are likely to falter just when you need the energy most.

As a leader, you need to inspire audacity. Are you planning on changing the world, or the world of your customers? If not, are you holding back your potential?

And you need to walk your talk. Do what you say you will do.

Farber isn’t a fan of passive conferences with a lot of fluff that make you feel good but leave you the same person as when you came in.

It’s described as a “hands-on, entertaining, productive, and interactive experience where you’ll learn, develop, and apply profound leadership practices to your current work and life opportunities.”

I’ll be there. Will you be there? If so, let’s meet up!

Categories
Personal Development

How to Be Prolific

Shakespeare's complete works

Sometime back, I read the article How to Be Prolific: Guidelines For Getting It Done From Joss Whedon.

The interview was published shortly after Whedon’s Much Ado About Nothing, filmed while The Avengers was still in post-production, hit theaters. Being able to put together a second film on the side while working on a major Hollywood production is impressive enough. Whedon is also active in comics and television shows. The guy is just everywhere.

The main points, from what I gathered:

  • Get specific with what you’re trying to accomplish
  • Reward yourself for doing even one small thing
  • Get exposure to diverse ideas
  • Ensure your friendships support your purpose
  • Don’t make excuses because there aren’t any

You can read the full article to get the meat of each of those things.

What I think linked everything, however, was his focus on being purposeful. If you don’t know what you’re trying to accomplish, it is easy to let things happen to you.

That paragraph might not sound mind-blowing. Stephen Covey wrote about keeping the end in mind in The Seven Habits of Highly Creative People decades ago. Being results-oriented isn’t a new idea.

But Whedon brings it to everything: his process, his downtime, his friendships, his life.

As a part-time indie game developer, I could say, “This evening is dedicated to game development”, and then find at the end of a few hours that I’ve gotten nowhere. On the other hand, if I task myself with coming up with an interesting core mechanic or introducing a new character, it’s specific and focused work that by its nature gets done. It’s about focusing on results, no matter how small, on your way to get the larger result, no matter how big.

I could spend each night vegging out in front of the TV, or I could schedule time to go to game developer meetups, conferences, seminars, and panels. I could read books, play boardgames, or write blog posts. Or if I am going to watch TV, it should be for the higher purpose of spending time with my wife, or learning about ancient 90s culture (seriously, Frasier is amazing), or something besides merely not being creative enough or motivated enough to think about doing something else.

I could play video games to pass the time, or I could play them to critically analyze the hell out of them for the purpose of understanding game design better. Even better, I could play the heck out of games that are both incredibly similar and incredibly different from what I want to create right now to get a sense of what’s been done and what’s possible.

I knew someone who went to the library after his day job to work on games for four hours a night every night. Over the course of a few years, he went from knowing nothing about game development to being able to publish a number of games in a short span of time. That developer knew what he wanted.

The older I get, the more I realize how precious my time is. Time is the only thing we really have to invest in anything.

If you want to be more prolific, if you want to create well-received works, stop and look at how you spend your time. Is it on purpose? Are you taking responsibility for what you are doing with your limited time, or are you going with the flow, allowing the agenda of other people to exert more force in your life than your own choices?

Doing creative work, you will struggle at times. It’s not going to be enough to say you’re making what interests you. You need that higher purpose to get you through the game developer equivalent of writer’s block. You’ll need to know the results you’re trying to achieve when you’ve scrapped months of work because you find it doesn’t actually work.

And frankly, you’ll need it when you look back and wonder what you’ve really accomplished. Did you do what you set out to do, or did you merely do?

The other day, Dan Cook tweeted about this concept:

It’s fine to have a list of tasks to accomplish for your current project. After all, it makes sense to break down the tasks and get it done.

But did you similarly think about the point of your current project? How does it fit into your vision for the future?

Last year, Notch posted about the news that broke when people found out he wasn’t working on 0x10c anymore. In So That’s What I’m Going to Do:

What I hadn’t considered was that a lot more people cared about my games now. People got incredibly excited, and the pressure of suddenly having people care if the game got made or not started zapping the fun out of the project. I spent a lot of time thinking about if I even wanted to make games any more.

And then there was Dong Nguyen, creator of Flappy Bird. The game was making him $50,000 per day, and he pulled it down. Why? According to this Rolling Stone interview, it was partly because he felt responsibility for the people who blame the game for losing their jobs or becoming isolated from their families.

In both cases, what did these games mean for the developers besides interesting experiments?

Or put it another way: when you think of a company like Mojang, what do you think of besides “they made Minecraft”? When the company publishes a new game, what can you expect? I’m not sure, because there doesn’t seem to be a larger purpose to the organization. It’s a company that happens to have a major hit to fund it, but it isn’t clear what principles or values it has that dictate what they do next other than “This seems interesting today”.

There’s nothing wrong with it, and it is great that they have the freedom to explore whatever they want, but compare it to a company such as Toca Boca, creator of Toca Hair Salon and other fascinating children’s games, including one that seems very similar to Minecraft:

Toca Boca is a play studio that makes digital toys for kids. We think playing and having fun is the best way to learn about the world. Therefore we make digital toys and games that help stimulate the imagination, and that you can play together with your kids. Best of all – we do it in a safe way without advertising or in-app purchases.

If you hear that Toca Boca is publishing a new game, you know in general what you’re going to get. They have a purpose, and they are organizing everything towards that purpose. You won’t see them publishing a very eclectic collection of games. They won’t be exploring survival horror or creating the next major FPS because they would be distractions from their larger purpose.

What you achieve in your life is going to be a direct result of what you do today. At the micro level, you have the tasks you’ve identified in front of you for a given project, but at the macro level, you choose the project to work on in the first place.

Or I suppose another way to say it is that if you execute everything perfectly but you did the wrong thing, you’ve wasted a colossal amount of time.

What’s your common thread that ties everything together? If you want to be prolific, it’s not enough to churn out random work. Having that vision about what you really want to accomplish is incredibly vital.

Do you have one?

(Photo: https://www.flickr.com/photos/revstan/5205092926 | CC BY 2.0)

Categories
Personal Development

Free Programming Books

Books

Last month I came across a GitHub project which is primarily a list of free programming books.

Originally a clone of a StackOverflow listing, it has been updated with dead links removed and is now collaborative. If you know if any freely available programming books out there, you can submit your own updates.

It comes in multiple non-programming languages, too. B-)

There are books organized by language, such as C++, Ada, JavaScript, and TeX. Other books are language-agnostic, so you can find tomes on algorithms, cellular automata, mathematics, programming paradigms, and regular expressions, among others.

Besides the language-specific and math books, there are books on networking, licensing, open source culture, operating systems, and security.

Some books are about professional development. Others are about architecture.

But it’s amazing how many books there happen to be out there, freely available.

The downside? There are two I can think of.

One, many of these resources are somewhat older. To be fair, not all of them are. Still, enough of them are that you sometimes feel like you’re reading a history of computing, which may not be a bad thing if you’re curious about how things have evolved to today’s state of the art.

Two, most of these freely available books require you to be connected to the Internet to peruse. I wish more were available in PDF or epub format, but most are much like Eric S. Raymond’s The Cathedral and the Bazaar: there are a series of web pages to read, but there is no ebook there.

Now, I purchased the hardcopy version of Cathedral back when it was first released, but that’s besides the point. Many other resources linked to from this book list don’t have an ebook version.

Some of the links to free books are to PDFs and are labeled as such.

Others do have either bound books forms or ebook formats, but if you want it, you need to pay. It’s basically shareware applied to books. You get to to try out the free version, and if you like it enough, you can pay for the full version to read on your tablet at your leisure. And some of these links show more aggressive marketing than others, so there’s something else to learn there if you pay attention. B-)

What’s your favorite free book from this list?

Categories
Personal Development

The First 20 Hours of Learning

Early in the life of this blog, I wrote about practice and talent. In it, I mention the now very commonly known idea that it takes 10,000 hours of deliberate practice to become an expert in something.

In the years since, I was part of the Thousander Club, which was started by Scott Hsu-Storaker after he read that post. The idea was to practice some skill for 1,000 hours in a year, which meant practicing roughly 3 hours a day. With a day job and a vague skill, I fell woefully short over the years, but it was a good experience to track just how much time I was spending on something that I thought was important enough to learn.

Still, 3 hours a day is a lot of time for people, especially people who are new parents or otherwise have a lot of demands. It’s easy to feel spread thin.

Plus, you don’t necessarily want to be an expert in something. You might just want to learn enough to have fun. Playing guitar, skillfully playing StarCraft, and drawing realistic portraits? You can learn any of these things enough to enjoy it, and maybe that’s enough. You aren’t necessarily interested in joining a band as lead guitarist. You may just want to be able to play love songs to your significant other without them sounding terrible.

Josh Kaufman, who wrote The Personal MBA, also wrote The First 20 Hours: How to Learn Anything…Fast!.

In this Tedx talk from last year, Kaufman says his research tells us that to learn something, it takes 20 hours to get past the fear of feeling incompetent.

Merely doing something for 20 hours isn’t enough. It’s like the idea that practice doesn’t make perfect. Perfect practice makes perfect. You have to do it in a deliberate way to learn in an accelerated manner.

There is a method. He says that there are four steps:

  1. Deconstruct the skill. What do you actually want? Practice those first.
  2. Learn enough to self-correct. Don’t procrastinate by reading books or websites. Get to the point where you can practice.
  3. Remove barriers and distractions to practice.
  4. Practice at least 20 hours.

Last month, I dedicated myself to learning Android app development, and to start, I thought I’d pull up the Android Developer resource, but it was quickly clear to me that the docs were not updated along with the tools. It was like the instructions said, “To learn how to drive a car, first put your key in the ignition, then…draft behind the pole position before overtaking” with no mention of the basics of how to accelerate or brake. I don’t know if there was an expectation that I knew how to load specific resources in Eclipse considering I just learned that loading resources was a thing, but that’s how it felt. The Getting Started pages seem to have gaps if you treat them as a tutorial.

So I found Programming Mobile Applications for Android Handheld Systems on Coursera. Rather than take the actual course, I watched the videos. Partway through, I knew enough about what Android apps could do to be dangerous, but I watched all the way through the videos before allowing myself to do much development myself.

While I am glad the course is offered and that I could get this insight, I could have started practicing earlier. You don’t learn from watching videos. You learn from doing. By not taking action, and deluding myself that I was still learning, I was merely procrastinating.

It’s daunting to start something new. I already know how to make games for GNU/Linux, and yet Android seemed to be a different beast altogether. How long was I going to have to go through the steps of learning everything I needed to learn before I was capable of delivering games to Android users?

The good news is that I am not starting from scratch. I already know how to do so software development fairly well (hey, Self from 2006! You did good in practicing all these years!). Also, Android development is less about learning how to program and more about understanding what capabilities are available and what deployment procedures there are.

But once I started applying what I supposedly learned, then I was really learning. And once you get past that initial frustration with how ignorant you are, once you get a little confidence in your abilities, you can start enjoying the process.

Categories
Geek / Technical

Is There Creativity in Programming?

Binary

A colleague of mine was complaining about pair programming. He said one of the problems was that it restricted his coding creativity when he had to argue or discuss what he wants to do with someone else.

I was reminded of a forum post I made many years ago in which I similarly said something about creativity in code. Someone replied and said something to the effect of, “No, software development is engineering, not creativity.”

I have since thought about that response often, and it made an impression on me.

So I told my colleague that if you’re being creative while programming, it probably means you don’t know enough or have enough experience to know what to do.

An example I gave to him was some work we had done together in the past. We created a set of classes to handle filtering some data based on some criteria. We had come up with some very good work here. It was test-driven, very clean, and worked well. We spent about a week on it.

It was a creative solution.

But only because it wasn’t until months later that someone pointed out that what we had implemented was already provided by the 3rd party framework most of our software was based on.

Had we known that there was an existing solution, there would be no need for creativity. We would have simply solved the problem and moved on.

On the other hand, we’ve learned that incremental development results in better software. Rather than do the waterfall approach of big design up front, we implement a working piece of value, then build on it.

Often, the process of building the software is the way we learn how to build it. Coding, then, isn’t merely a matter of giving form to requirements, but a way of exploring the problem space. Write some test code, see what happens, and gain a more accurate understanding of what you’re making. Rinse, and repeat.

Software is malleable and allows such experimentation. The end result is a working program to run. We have created.

But can we call it creativity?

Many years ago, I was creating the best RPG ever! a walking demo of an RPG. I wanted the ability to talk to villagers and have conversations instead of merely receiving a single canned message.

I wrote a bunch of logic to load messages, identify if there were branches based on certain things being available such as a quest item, and even provided a way to choose options as replies. You could buy and sell things, which allowed you to change your inventory and your money supply. Inspired by Final Fantasy III‘s thief town, you could even lose money just by talking to certain characters.

I was very proud of the system I came up with and put together in QBasic. I came up with a very creative solution, I thought. It wasn’t until years later that I realized I basically reinvented what’s called a scripting engine.

Had I known about the scripting engine concept, I probably would have realized that it was exactly what I needed. Instead, I stumbled into it over many days of hacking together something that did more and more as I thought of it.

Then again, even if I know the concept, isn’t there some creativity in the specific implementation? Or am I mixing up the roles of the programmer and the game designer here?

If I write some code to calculate mortgage interest for a bank and realize that a side-effect of my effort is that it is easier to get data for some strategic analysis, that’s not programming creativity so much as business insight. Similarly, realizing that I could add another cool feature to the scripting engine is more about adding to my game design capability than about being creative with code. The code was just the way I expressed the creativity of game design, and so therefore incidental to it.

One of the things I believe is that being cute with programming means more headaches than it is worth. There’s a bug in your OS you can exploit to accomplish some data manipulation faster? Great, until it is patched. Best to stick with documented features and not trust that what happens to work today is what is right.

Similarly, writing “creative” code seems like a recipe for disaster. How clear can your code be if you’re being creative when you write it? You want to be creative? Experiment with code katas. Hack away for fun on a side project. Join the The International Obfuscated C Code Contest. But I don’t think “creative” code belongs in released production.

I think creativity in code is just another way of saying, “I’m guessing that this might work. Let’s see what happens.” It’s like throwing things into a fire and observing the results. It’s not creativity so much as experimentation.

When I learned about design patterns, entire concepts were made clearer to me, and my programming capability improved. I didn’t have to be as creative to write code to solve a problem or accomplish a task. If I’m ever trying to be creative while writing code, I think it says more about my lack of knowledge in the area than with the nature of programming.

What do you think? Is there creativity in programming?

(Photo: http://www.flickr.com/photos/chrisjrn/8058863952/ | CC BY-SA 2.0)

Categories
Geek / Technical

Converting from UnitTest++ to Google Test

Converting UnitTest++ To Google Test

In 2008, I wrote Test-Driven Game Development, which was more about being reintroduced to Test-Driven Development (TDD) and asking if other game developers use it regularly.

Around the time, Noel Llopis had written a survey of C++ unit test frameworks, and eventually co-wrote UnitTest++ as none of the existing frameworks were sufficient for his needs.

I’ve used it ever since.

At my day job, I’ve been introduced to Google Test. It’s so much more full-featured, and paired with Google Mock, it means I don’t need to handroll my own mocks and fakes.

Since UnitTest++ isn’t actively maintained anymore, and Google Test does so much more, I’m switching my development to it.

I do my development on a Linux-based system. I use CMake to manage my builds which allows me to produce a game and port it to Windows easily.

It took me an hour to switch a project over to Google Test. Actually, it took mere minutes to change the code:

TEST_FIXTURE(ParticleFixture, ParticleInitializedWithPositionAndImpulse)
{
CHECK(particle.isAlive());
CHECK(initializedPosition == particle.position);
CHECK(impulse == particle.velocity);
CHECK_EQUAL(maxLifeTime, particle.lifeTime);
CHECK_EQUAL(maxLifeTime, particle.maxLifeTime);
}

turned into:

TEST_F(ParticleFixture, ParticleInitializedWithPositionAndImpulse)
{
EXPECT_TRUE(particle.isAlive());
EXPECT_TRUE(initializedPosition == particle.position);
EXPECT_TRUE(impulse == particle.velocity);
EXPECT_EQ(maxLifeTime, particle.lifeTime);
EXPECT_EQ(maxLifeTime, particle.maxLifeTime);
}

What took longer was figuring out how to add Google Test to my project’s structure.

With UnitTest++, I built it once and had a copy that all of my projects could leverage.

Google Test started out allowing you to “make install”, but citing C++’s
One-Definition Rule, the developers say:

we recommend to avoid installing pre-compiled Google Test libraries. Instead, each project should compile Google Test itself such that it can be sure that the same flags are used for both Google Test and the tests.

I spent quite a bit of time seeing if there was an example of how to do it, but build configurations are based on the needs of individual projects and I suppose it is hard to make such recommendations. So I had to figure out how to write the CMake file, and that’s always a painful process of figuring out what abstract implementation detail is provided by CMake to do the specific work you want.

So here’s my solution.

First, I added the gtest-1.7.0 directory to my project’s test directory. I suppose I could take steps to make this more generic and allow for upgrades without requiring me to change more than necessary, but it works, and it can be tweaked.

Second, I changed my CMakeLists.txt file.

INCLUDE_DIRECTORIES (${BUILD_ENV_LIB}/UnitTest++/src/ ${PROJECT_SOURCE_DIR}/source/game ${PROJECT_BINARY_DIR}/source/game ${PROJECT_SOURCE_DIR}/source/tests/Mocks)
ADD_EXECUTABLE (Test${GB_PROJECT_NAME}-bin ${TEST_SOURCES})
TARGET_LINK_LIBRARIES (Test${GB_PROJECT_NAME}-bin ${GB_PROJECT_NAME}-lib ${BUILD_ENV_LIB}/UnitTest++/libUnitTest++.a) # ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${SDLMIXER_LIBRARY} ${SDLTTF_LIBRARY})
# Run the test executable.
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/RunTest.sh ${PROJECT_BINARY_DIR})
EXECUTE_PROCESS(COMMAND chmod +x ${PROJECT_BINARY_DIR}/RunTest.sh)
ADD_CUSTOM_COMMAND(TARGET Test${GB_PROJECT_NAME}-bin POST_BUILD COMMAND ${PROJECT_BINARY_DIR}/RunTest.sh ARGS ${PROJECT_BINARY_DIR}/Test${GB_PROJECT_NAME}-bin VERBATIM)

became


ADD_SUBDIRECTORY (gtest-1.7.0)
enable_testing()
INCLUDE_DIRECTORIES (${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/source/game ${PROJECT_BINARY_DIR}/source/game ${PROJECT_SOURCE_DIR}/source/tests/Mocks)
TARGET_LINK_LIBRARIES (Test${GB_PROJECT_NAME}-bin ${GB_PROJECT_NAME}-lib gtest gtest_main) # ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${SDLMIXER_LIBRARY} ${SDLTTF_LIBRARY})
ADD_TEST( Test${GB_PROJECT_NAME}-bin Test${GB_PROJECT_NAME}-bin )
ADD_CUSTOM_COMMAND(TARGET Test${GB_PROJECT_NAME}-bin POST_BUILD COMMAND ${PROJECT_BINARY_DIR}/Test${GB_PROJECT_NAME}-bin)

I used to have my own script run the tests because UnitTest++ didn’t do color-coding. I wanted to see red on failure and green on success. Binaries created using Google Test has red-green colors built-in so I could get rid of my RunTest.sh script.

I’ll be honest, though, I’m not sure what ADD_TEST() is providing. I kept seeing it recommended in the blog posts I could find out there, but as far as I can tell, no one says “I want to run my Google Test tests immediately after a build”.

Supposedly it adds a “test” target to your Makefile, but it seems to be broken. Hence, the ADD_CUSTOM_COMMAND() to actually run the command. I wish the official Google documents would say, “If you want to run your tests as part of the build instead of having to explicitly ask for it, do this.” Instead, I had to cobble together bits and pieces of information from a variety of sources.

So I hope this post helps you if you’re trying to integrate Google Test into your project. And if you see anything I’m doing that can be improved upon, please let me know. It seems project structure and CMake is a dark art to me, and I’m sure there is some workflow improvement I’m missing out on.

Categories
Game Design Games Marketing/Business

A Shameful Game Backlog, or a Glorious Library?

Last week, cliffski once again went on the offensive against the trend of selling games at deeply discounted prices. In We Need to Talk About Unplayed Games, he argued that the constant sales of games results in bad news for everyone.

People buy games based on almost nothing but a screenshot and a low price in an almost Pavlovian response to the announcement of a deep discount. They don’t even play the games, which sit on hard drives and rarely get considered. In fact, some people buy the games over and over again simply because they are in bundles with other games or they forgot that they already purchased them.

The results? Players Game buyers don’t value quality, the organizers of sales become gatekeepers, and the games themselves are devalued. If developers optimize for results, what role does game development have? Most players won’t see even a small percentage of the actual game, so why focus there? It’s similar to the concerns about narrative in games: if people don’t finish them and never see the story play out to completion, then why invest so much on game writing and elaborate plots in the first place?

It becomes less about the games themselves. People buy into the deep discount, no matter what is being offered, and for what? A backlog of games they ignore? That’s terrible!

Or is it? Ben Kuchera thinks otherwise in Your stack of shame is a lantern for your future, and a gift to the industry:

We respect people with large libraries of books, but we tend to look down on people with shelves and shelves of games.

Oof. When you put it that way, yeah. I suppose when I look at my shelves, I see books I haven’t read yet, as well as games that I obtained partially because they weren’t at full price. I have a copy of Civilization III still in shrink wrap when I found it at the store for only $15. Two incarnations of the series have since been released. I also have a number of Neal Stephenson books that are waiting for me to read them.

Kuchera’s argues that even if you don’t play the games now, what you are doing is sending a message to the developers and the industry about what kinds of games you want to support.

On the topic of sales, both cliffski and Kuchera agree. They work. To illustrate, I was at a party recently talking about these posts (I’m a pretty wild and crazy guy!), and a colleague told me that you don’t have to look further than JCPenny to see what happens when you buck the trend there.

In early 2012, JCPenny changed its pricing strategy. Instead of markups and sales, there would be “every day” prices.

Late last year, the company announced it was reversing the decision, citing dismal sales figures.

So, JCPenny discovers the hard way that despite the logic that a low price is a low price, there is some psychology to a sale price, to the idea of getting a bargain. Now we get to benefit from that information.

But Kuchera says the biggest benefit is that increasing your catalog of games is good for you.

Maybe you’re not ready for the pace of a game like Gone Home today, but you can never tell when the game will satisfy an itch you don’t know you had. Buying games on sale allows us to browse our own selections, be surprised at something we had forgotten we had bought, and find that finally, we’re ready for that game.

I can relate. When I was a child and had no way to earn money but a weekly allowance, I would save my money for months in order to go to Toys R Us and browse the game selection. One time, I picked up Wizardry: Proving Grounds of the Mad Overlord. I might have been 10 years old at the time. I had no idea what the game was, but the back of the box had illustrations of dragons, knights, and skeletons. COOL!

I tried to play it, but I couldn’t figure it out. I mean, I understood the mechanics of walking around the first-person maze, entering selections to fight, and casting spells. But I had no idea what I was doing. I would fight incredibly tough enemies and have a total party kill before I knew what happened. It was too much, and the game wasn’t what I expected at all.

It was a few years later when I pulled it out of my collection of games to try it out again, and my more mature self was able to grok it way better. Oh, I have to map out the maze I’m exploring! I need to make sure that I gain experience and skills and purchase good equipment before venturing too far into it. It all clicked. It all made sense. I wasn’t ready to play the game when I bought it, but I’m glad I did all those years ago because the Wizardry series became one of my favorites.

I appreciate what cliffski is concerned about. It would be nice if when a new piece of entertainment is released that everyone played it together. Around 10 years ago, I bought Total Annihilation and Homeworld: Cataclysm due to the recommendations of a friend, both times years after the games had come out. Cavedog’s Boneyards and Sierra’s WON.net were mostly empty before eventually being shutdown entirely, but I was told that they used to be filled with active gamers ready for your challenge. Had I bought the games on release, I might have experienced it, but as I was late to the party, I missed out.

It’s captured perfectly in this xkcd comic.

The alt-text: “I remember trying to log in to the original Command and Conquer servers a year or two back and feeling like I was knocking on the boarded-up gates of a ghost town.”

Similarly, the Steve Jobs biography that was all the rage a couple of years ago? The local library had a high double-digit long waiting list. I never ended up reading it, although I still want to. But when I do finally get to read it, it would have been years after the book was topical. Am I similarly missing out by reading it so much later than everyone else?

Or isn’t that the point of books, that they are there for me to read whenever I feel like it?

And so it is with games. For years, I’ve always wondered how people can be so comfortable selling their old games to get credit towards the purchase of new games. I, on the other hand, still have my Atari 2600. I still have my NES, SNES, N64, and original Game Boy. Despite being able to play any Gamecube games on the Wii, I still have my Gamecube.

But more important than my inclination to keep consoles beyond the point that might be reasonable, I still have the games I bought for those systems. I’m still unhappy with the discovery that my father gave away the Apple II c+ from my childhood to his coworker, which means I lost my copies of Troll’s Tale, Snooper Troops, Below the Root, Bill Budge’s Pinball Construction Set, and other games. Some of them were beyond my capabilities at the time, but I’d be ready for them today.

But being able to pull out my older consoles and play games from almost two decades ago is a capability I enjoy having.

I currently have two large six-shelf bookcases in my office filled with books. I have a computer rack with a few shelves taken up by CD cases for computer games. In the living room are the console games. In another room is a set of shelves filled with boardgames and card games.

I used to fantasize about having an entire room of a house dedicated to being a library, with books and games stored from floor to ceiling.

Video games these days end up being in the cloud. I have 30 games across 7 virtual shelves on GOG.com, quite a few Humble Bundle bundles, and a few games in Steam. If not you then people you know have much larger catalogs of games stored as bits on a server.

It’s not as tactile, but we still enjoy having those collections to pick up and play whenever we allow ourselves to do so.

What I am not sure we’re seeing is a change in the game design efforts of developers, which is I think cliffski’s biggest concern. While some developers put out buggy and shoddy games, I don’t think they last long. Even if most games don’t get played, I don’t think a pretty screenshot and a sale is enough to get people to reward the developer. Reputation still matters.

How do you feel about your backlog? What impact, if any, do you believe the constant sales and discounts has on game design and the efforts of a developer?

Categories
Game Design

On Game Narrative, Again

Dan Cox said the following in reply to my recent post Plot Ignored + Unfinished Games = Useless Effort?

I’m fearful that the take-away for many developers will be to not attempt much of a story now. If people can’t remember their favorite game’s story, would go the logic, there’s not much of a reason to try at all.

Of course, I would argue that the problem is not that any particular game’s story is memorable or not, but more that, in general, they aren’t very good. Some are, sure, but way too many AAA games have very little story.

I imagine that there will be some industrial momentum that will keep writers employed in the game industry for some time.

That said, frankly, I think it’s difficult to make a good game with a fully authored story.

In game design, there’s the concept of meaningful play. If you give the player agency, then the player should expect to be able to express it. If you are trying to enforce a specific story, however, then that agency is an illusion. No matter what action the player takes, it won’t affect the story in any meaningful way, which reduces the quality of the game.

At the extreme, you have “press button to turn the page” kinds of games. Years ago, a friend of mine was excited to find a cheat code that allowed him to instantly finish missions of Star Trek: Armada because he just wanted to see the story. To him, he wasn’t playing a game, and in fact the game seemed to be an obstacle to his enjoyment of the narrative. He would have been happier if it was a a movie or new episode of Star Trek.

But many gamers want their actions to matter. So then you have games that allow you to go through XYZ branches of a story, where XYZ isn’t unlimited but is in fact quite limited, relatively speaking. But, hey, your choices affect the story!

I’ll admit to loving Wing Commander for its branching storylines. If you did poorly in a mission, you didn’t retry it until you got it right. If you survived, you kept going, and your ability to escort a supply ship or strike at a key base affected the war effort.

My favorite moment from the game, in fact, was the final mission in the branch of the story where the Tiger’s Claw is being forced out of the sector by the overwhelming Kilrathi. You were tasked with fighting off the enemy while the Tiger’s Claw slowly makes its way to the jump point to safety…and it was made clear that if you aren’t on the carrier when it leaves, you’re stranded. Everything I’ve failed to do throughout the game comes to mind as I realize that this is my last chance at doing something well.

Still, as enjoyable as the story was in that game, it was limited. There are only so many branches, scenarios, and missions.

And then you have games with no inherit story, yet the stories they generate can arguably be the most memorable. I have posted stories that were generated by the playing of NetHack plenty of times. And I’m overdue for one. B-)

Over half a decade ago (!!!), I wrote about the importance of stories:

In general, I suppose stories are important for games. I just think that they don’t necessarily have to be dictated from within the game. There is nothing wrong with games that tell a story, but games that do tell stories shouldn’t let the story get in the way of the game. Some people might prefer games that let them figure out their own stories. When I play Flatspace, I like to be a trader, but I like to hunt pirates as well. I don’t have to fight the pirates, but I’m just taking the law into my own hands, hoping to get my hands on the pirate who destroyed my life in my made-up past. There is no actual support for the story in the game, but there isn’t anything that gets in the way of that story, either. I enjoy the act of creation, even if it is only in my mind.

Amazingly, I still agree with my past self. The more games have fully authored stories, the less game-like I think they can be because authored story demands less meaningful game play. I don’t think there is anything inherently wrong with such games. They are wildly popular and have an audience, so it isn’t hurting them.

But when I play games, I’m not as interested in someone else telling me what my experience will be. My experience is my story, which gets generated during play. The more a game allows me to craft my own story, the more I think it is leveraging the strengths it inherently has. Minecraft allows so much story to be generated out of the interaction of play and mechanics, for instance. The Last of Us, on the other hand, only allows so much.

Games are meant to allow players meaningful interactions within a play area. While the game design can guide a player towards moods, ideas, and concepts, the story should be the player’s to generate. Otherwise, the meaning of play is nothing more than what the player needs to do to watch the rest of the movie that’s marketed as a game.