Making footstep sound effects

In the current course, we are creating a game based on another group’s concept. My group chose a concept called Fancy Mansion, in which you play as a burglar and have to find valuables while avoiding the owner of the house, Mr. Fancy. This week I have mainly been designing sound effects; footstep sound effects. These sounds will have an important role in gameplay as the player will listen to what kind of footstep sounds come from Mr. Fancy and hence know what kind of floor he is walking on, which will give an indication of his position. I started by listening through all the footstep sounds of a sound database that the university provides for all Game Design students. As decided in the concept, three different type of footstep sounds are needed: wooden floor, stone floor and carpeted floor. I figured the easiest would be the wooden one because it could easily be made recognizable among the three by exaggerating the creaky part of the sound. (I am yet to decide how to enable the player to tell the stone and carpet sounds apart. Possibly I will just make the carpet one really faint and the player will know that when there’s very little sound at all, Mr. Fancy is walking on the carpeted part of the floor.) So I started with the wooden one. I found a suitably creaky one in the database which I suspect is actually sampled from a staircase and not a floor, but I think it works fine anyway. This original recording straight from the database can be heard here:

I then imported it in Cubase 7, which is the software I normally use to compose music. The raw recording is obviously recorded with the microphone fairly close to the source, which means I had to alter it for it to sound somewhat convincing as the footsteps of the man you are sneaking around to avoid. I messed around with different effects and ended up with two different reverb effects on it. One standard reverb and one called VirtualSoundStage (VSS), which is used primarily on orchestral instruments to artificially place them in a specific spot of a room such as a concert hall or a scoring stage. The result is this first draft:

For the time being I was satisfied, but after a while I realized (as one of my teammates also pointed out) that it no longer sounds like a wooden floor but instead slightly metallic. This is beacuse one of the effects give the sound a reverb much more prominent than one would expect to hear in a house (or a mansion for that matter). So I removed that backfiring reverb effect which left me with only the VSS one. I continued experimenting with settings and other effects until I settled for a very simple solution: I kept only VSS and removed the reverb part of it, letting it work as only an artificial microphone distance. (This is done by selecting a “free field” instead of one of the preset rooms, which essentially removes the walls.) The VSS interface is depicted below; the lower icon in the black field is the microphone, and the upper one is the sound source. The observant can see that the little header text on the source is upside down. This is because I turned it to face away from the microphone as I preferred the result of this for some reason. Whatever works.

Skärmklipp 2015-02-12 21.27.30

The result can be heard below. I still call it a draft because I will experiment with the sound effects that can be added with code in the game engine, as this may present a way to make the sound dynamically respond to the distance between Mr. Fancy and the player. I will also split the sound files into individual footsteps for added versatility.

Advertisements

Frogger project going forward

Of course I forgot to update when I meant to. The project is going forward. We now have correct background colors and the purple sidewalks are in place. Since we have a sprite sheet, we figured the easiest way to draw the sidewalks was to make a class for the sidewalk tile, and make several instances of that class. The frog can be moved using the arrow keys, but there is no animation. We decided to postpone implementation of all features that aren’t absolutely necessary.

We also have a moving car, but we need to develop the system that will handle the spawning of those cars. There was a discussion on this because problems arose: since every car is an instance of the same class, there is no simple way for the manager class to tell them apart, so the easiest way to handle the cars is to make each car move and get destroyed when it disappears outside the screen. It can send a message to the GameState class so it can keep track of how many number of cars are on the screen. The reason we were hesitant to use this method is that we used to draw objects in the same order they were created, and if the game destroys and creates new cars, the frog will no longer be drawn on top like we wanted to. So I changed our draw function to draw on different depths. Three different is all we need: bottom for the background tiles, top for the frog, and middle for all other objects. This was achieved with a public method in each entity that returns the depth of that particular object: one of three enum values. Then I changed the drawing loop to what can be seen below.


void GameState::Draw()
{
    m_systems.draw_manager->DrawBackground(m_systems.width, m_systems.height);

    // Only for clarity. Datatype enum 'EDepth' could cast automatically to 'unsigned int'.
    unsigned int bottom = static_cast<unsigned int>(DEPTH_BOTTOM);
    unsigned int middle = static_cast<unsigned int>(DEPTH_MIDDLE);
    unsigned int top = static_cast<unsigned int>(DEPTH_TOP);

    // Inner loop draws all entities of a certain depth. Outer loop repeats the process for each depth.
    for (unsigned int drawDepth = bottom; drawDepth <= top; drawDepth++)
    {
        for (unsigned int i = 0; i < m_entities.size(); i++)
        {
            if (static_cast<unsigned int>(m_entities[i]->GetDepth()) == drawDepth) // Cast would also here happen automatically.
            {
                Sprite* sprite = m_entities[i]->GetSprite();
                if (sprite)
                    m_systems.draw_manager->Draw(sprite, m_entities[i]->GetX(), m_entities[i]->GetY());
            }
        }
    }
}

Fifth weekly programming post

OK, so the naming scheme of my “weekly” programming posts seemed like a good idea when I was still positive I would actually write a post each week. I am going to refer to this as the fifth post because it is my fifth week of programming; and a mismatch between these two numbers is prone to make me terribly confused in the future, should I ever come back to read an old blog post for whatever reason. I’m foreseeing like that. (It may also have the effect that it seems like I actually was ambitious enough two write the second, third and fourth posts, but they were then lost in cyberspace for reasons beyond my control.) Anyway, this seems like a good time to resume the blogging since I have just started making my first game. It will be made in Visual Studio using SDL2 and shamelessly imitate the classic arcade game Frogger. (Note that the reason I don’t feel any shame is not because I’m a bad person but because copying a classic game was part of the assignment.) I have a teammate by the way. We have started writing the basic engine for the game, following the structure of the engine live-coded by our teacher in class. What I find most difficult to grasp is the structure of the engine: what goes in which class and why. I constantly get the feeling that while I understand the code written by the teacher, I could not write it myself from scratch and get all the class relations to work. The plan, however, is that the deeper understanding will come when I start adding functions to the program, thus being forced to use the structure of the engine as opposed to just looking at it from outside.

From now on, I will try to update properly every week with the additions we make to the game, with examples of code in the posts.

Programming update

So here is the finished guessing game. I should have posted it way earlier because it already feels like I could do it better with the knowledge from the first lectures of this week. But I figure this is too basic a game to put any more time into, because regardless how perfect, it will always be a boring game to play.


#include <iostream>
#include <time.h>
#include <stdlib.h>

int random(int min, int max)
{
    return min + (rand() % (max - min + 1));
}

int main(int argc, char* argv[])
{
    int tries = 0;
    srand((unsigned int)time(0));
    int randomnumber = random(1, 100);
    bool victory = false;
    std::cout << "Guess the number between 1 and 100." << std::endl << std::endl;
    
    //std::cout << "random(): " << randomnumber << std::endl;

    while (true)
    {
        int guess = 0;    
        std::cin >> guess;

        if (guess >= 1 && guess <= 100)
        {
            if (guess == randomnumber)
            {
                std::cout << "Correct! You win! ";
                tries++;
                break;
            }

            else if (guess < randomnumber)
            {
                std::cout << "Too low. Try again.\n" << std::endl;
                tries++;
            }

            else if (guess > randomnumber)
            {
                std::cout << "Too high. Try again.\n" << std::endl;
                tries++;
            }
        }

        else
        {
            std::cout << guess << " is not between 1 and 100, stupid! Counts as a guess anyway.\n" << std::endl;
            tries++;
        }
    }

    if (tries == 1)
    {
        std::cout << "And on the first guess, too! You're a natural!\nPress Enter to exit.\n";
    }
    
    else
    {
        std::cout << "You needed " << tries << " guesses. Press Enter to exit.\n" << std::endl;
    }

    std::cin.ignore(1024, '\n');
    std::cin.get();
    return 0;
}

Featured image

First weekly programming post

This week has been the first week of the “Game Programming I” course. Since the course doesn’t require any previous knowledge of programming, the material has been pretty basic so far. Which suits me well, I realize now. I have a tiny bit of programming experience from playing around in GameMaker years ago, but GameMaker has its own programming language which in my opinion is a lot easier to use than the more powerful “C++” we are learning now. Even the basic stuff gets complicated when you actually start working with it yourself, as opposed to listening to it in a lecture. We got a bunch of exercises to do for practice of which the last one was the most comprehensive: to make a (ridiculously) simple guessing game. The game is played by typing numbers, guessing on a number between 1 and 100. After each incorrect guess, the game tells the player whether the guess was too high or too low. A correct guess results in a congratulation as well as a display of how many guesses were needed to get to the right answer, after which the only option is to exit the game. Deadly simple, right? Nope. My “game engine” is perfectly functional only without the random generation of a number, which sadly is the very core of the game. Apparently, generating a random number is not as simple as it sounds, and code for this was included in the sheet of exercises; code which I happily copied into my project; code which I still can’t get to work properly. I originally planned to finish all the exercises before writing this post, but alas; after a while of battling the error messages with everything I’ve got (desperately Googling bits of the randomization code), I have now decided to postpone the completion of the game until tomorrow, when I will have time to thoroughly go through the randomization code and actually understand it completely. Which I obviously should have done from the start. Lesson learned.

A proper update with the finished guessing game will follow. Pre-order now and play it on release day! Or something.

Welcome to my blog

My name is Johan Öhman and I am a first year student of game design at Uppsala University, Campus Gotland. The program is called “Game Design & Programming” and so obviously includes programming too, something I hope I will come to enjoy as much as design. Games is not my only main interest; I am an amateur composer as well. The music I compose is in the genre of film music, which kind of means that it doesn’t belong in only one genre but at least can be said to always aim to build upon a source of inspiration from another medium; like a film, picture or… that’s right: a GAME! I hope that my interest in music and audio in general will be beneficial in the game projects I will do during my time here.

So this is my first blog post ever, but I will try and get used to blogging and update as often as I can. Updates will probably often be a recap of things I’ve learned to help remember or to deepen my understanding. Or maybe just random thoughts about games. I have those sometimes.