• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Tutorial Doctor

How does your Pseudocode look?

23 posts in this topic

Okay, so I have to look for ways to do stuff fast since I am a lone developer who is new to all of this stuff. So far I know I can get a working game going, my only hangups are quality animation and the time it takes to code and debug the code. So, I am trying to speed up my coding skills (not focusing on optimization) so that I can get an idea up and going. 

 

I have found that the best way to start out the coding process is by:

 

1) Thinking about what you want to do

3) Write pseudocode for what you want to do
2) Determining the PROGRAMMING COUNTERPARTS. For example, the programming counterpart to jumping is adding a force in the up direction). 
3) Figuring out how the API does it
4) Fill in the pseudocode with the API stuff. 

 

So, say I wanted to make a character jump simply by typing the name of the character, and the word "jump."

 

man.Jump()

 

This is how I would want it to work. So it seems I need a class and a function that adds a force in the up direction when it is called. 

 

Another example:

 

cut_scene.Begin()
cut_scene.End()

 

I need a function that starts video playback and another that stops it. Etc. Perhaps the cut_scene part would be a class or something?

 

So, how do you do your pseudocode? Or do you even use pseudocode? I just want some ideas on how others do it. 

 

0

Share this post


Link to post
Share on other sites

Haha, you always have good keywords. I guess the idea I am thinking of is a "sketch." Yeah, just like when you draw you sketch out the idea, and from there it is easier to get a feel of the thing as a whole. 

 

It isn't really the programming langauge that gets me as much as it is the API I might be using. 

Edited by Tutorial Doctor
0

Share this post


Link to post
Share on other sites

Great tips Servant. I like the layout of that style. I need to find a good cross between commenting and pseudocode. 

0

Share this post


Link to post
Share on other sites
I do is sort of like what servant does: Start with stubbed code, write comments to describe the steps, then implement each step using real code. The original comments are kept (except when the code is trivial).
0

Share this post


Link to post
Share on other sites

Mine mostly looks like decision diagrams so that it is easy to translate in to real code, or it just takes the shape of english text. When it is code time it is time to write it in a language :)

1

Share this post


Link to post
Share on other sites

Great variation of approaches. Looks like I am going to stick to the PDL design, which seems to be the common factor of the posts here, for most of my projects. I am sure there are times when I will do something like you NightCreature, especially if I happen to be doing some type of program for a robot or something. Thanks again! I am going to go and practice PDL to see how quickly I can get something done using that method. 

0

Share this post


Link to post
Share on other sites

Oh Yeah! This is going to do just fine. 

--while a key is pressed, start the character walking. When the key is released, stop walking. 
-- walking is playing an animation while translating the character. "Stop walking" should not only stop the animation, but set the animation to it's first frame one the walk animation has finished.
--Use two booleans to turn walking on and off. If walking is on, thhe walking function plays. If walking is off, the walking function stops. 

walking = false
idling = true

function walk(character,speed) --character and speed not added yet.
	if onKeyDown(key) and idling then
		walking = true
		idling = false
		playAnimation(walk_animation)
	else if onKeyUP(key) and walking then
		idling = true
		walking = false
		playAnimation(idling_animation)
	end
end



--Game Loop
function onSceneUpdate()
	walk(joe,2)-- joe walks at 2 units per second/frame.
end

--Turn a light on when a button is pressed:
 
--if a key is pressed down, turn on a light and play a sound. When it is released, the light should be on still, and another sound should play. 
 
 
if isKeyPressed(key) then
    turnOnLight(light) --sets a light variable to true and turns a gameObject light brighteness to 100%
    playSound(sound) --plays a sound
end
 
if isKeyReleased(key)
    playSound(sound2) --plays a sound
end
Wow. When did you start learning C++?
0

Share this post


Link to post
Share on other sites

Pseudocode? What's that? XD

 

I have two approaches:

1) When explaining to others, I usually write short amounts of code, cutting out any unnecessarry stuff with "// snip" line (or replacing them with arbitrary methods), similar to what Servant does.

2) When doing it for myself, I write it mostly from head; when dealing with a complex problem, I usually take pencil and paper and sketch what it has to do, simulate algorithm behavior or some other things without writing any (pseudo)code,  depending on the simulation. For example, if I need to simulate cannon fire, I'd sketch the path of cannon fire and write formulas for sling etc., then try to implement that in the code.

Edited by Aurioch
2

Share this post


Link to post
Share on other sites
IMO it doesn't make sense to write psudocode in most cases. I might use a UML diagram to design objects and their responsibility, but for functions the approach is different. I just write out set by step, what the function does in actual function calls and control flow. Then for each function call I stub out the definition. Then you fill in each function so created by the same process, possibly adding parameters as needed.

So using Servant of the Lord's example, a first pass would look something like this
bool LoadConfigFile(std::vector<result> &results, const std::string &filepath){
     auto file = load_file(filepath);
     if(!file) {
           log_error("Could not open file");
           return false;
     }
     while (auto line = read_line(file) ){
           if(line_is_comment(line) ) 
               continue;
           auto var_name = get_var_name(line);
           auto var_value = get_var_value();            
           results.emplace_back({var_name, var_value});           
     }  
     return true;
}
Notice that that function a nice and short 13 lines. That's about as short as I try to make my functions. About 20 lines is the cutoff for when I'd think about splitting code out into another function. So if say, the while loop became too busy and long, I'd try to replace the while body with just a function or close to it.
1

Share this post


Link to post
Share on other sites

Wow. When did you start learning C++?

Assuming the first part of each snippet is the pseudo-code, followed by the proper implementation, the stuff you quoted is not C++:
- Comments in C++ do not start with "--", they start with "//" (or "/*" ended with "*/").
- Expressions in C++ end with a ";".
- When declaring variables, you need to include the data type (in this case, most likely "bool" before "walking" and "idling").
- Function definitions in C++ do not start with the word "function". They start with the return type of the function (e.g. "void", "int", "float"). "function" could be a badly named data type, but the function doesn't return anything, so it isn't.
- Function definitions in C++ include the data type before the parameter. 
- Functions and if statements in C++ do not end with "end". Scope is indicated by "{" and "}".
- If statements with multiple conditionals do not use "and" as a keyword. In this case, "&&" would be the correct operator.
- If statements do not have a "then" in them to signify start of block.
- If statements with multiple expressions in C++ are scoped using the "{" and "}". Failure to do so can lead to stuff like the "goto fail" Apple bug that was recently discovered.
 
There are potential other issues as well, but for the sake of this reply I'm assuming those things were done correctly outside of the code snippet in a C++ scenario.
---
EDIT: On-topic: I tend to do the same as Servant.
I knew it wasn't c++ but it was good pseudocode
0

Share this post


Link to post
Share on other sites

My pseudocode is always a fuzzy C++, with some inaccuracies to allow laziness in expressing thoughts.

 

To be honest, I hate pseudocode. When writing pseudocode, I find that I have to revise my ad-hoc grammar repeatedly to allow the rest of the pseudocode to make any sense at all. At the end, I've about made a new language, and it was no simpler. I may as well basically use an existing language as a basis; after all, my usual goal of pseudocode is not to pass through pseudolint, but to quickly prototype and explain ideas to others, where the reader can fill in blanks.

 

So, for me, I write in fuzzy, untested C++. In communicating with others, a fuzzy C. Who doesn't know C?

Edited by Ectara
1

Share this post


Link to post
Share on other sites

I'll do hand drawn flow charts if the program is very complex, but I usually don't do pseudocode. I just write it in a real programing language with some dummy methods for things that aren't clear.

0

Share this post


Link to post
Share on other sites
Question. So, in the event that you are dealing with a foreign API, you all still don't use pseudo code? It's usually the API that makes getting things done a bit slower for me. I am using a game engine on the PC that uses lua, as well as game IDE called CODEA on the ipad that uses lua. I find instances where I don't know how to do something using their API, so I have to use some sort of fill in until I find out how to do it.
0

Share this post


Link to post
Share on other sites

Question. So, in the event that you are dealing with a foreign API, you all still don't use pseudo code? It's usually the API that makes getting things done a bit slower for me. I am using a game engine on the PC that uses lua, as well as game IDE called CODEA on the ipad that uses lua. I find instances where I don't know how to do something using their API, so I have to use some sort of fill in until I find out how to do it.

 

No. Empty methods again can be useful and even filled with dummy code but I fail to see the point personally in writing things out step-by-step in psuedo then translating it into API calls. If I have an empty method called paintControl() it is obvious what it needs to do, then as I am implementing the details I refer to the API documentation.

 

But there's nothing wrong with using psuedocode in the way you describe. Not sure why you are asking this. If it works for you, great. Who cares what other people do?

0

Share this post


Link to post
Share on other sites


Not sure why you are asking this

 

Just wondering how other people do it, because there might be a better way than what I do. I am trying to find the fastest ways to get things done since I am making things by myself. Then I can iterate over the project with details as needed. Trying to use this process for my 3d modeling as well as my programming. For instance, thanks to your response in the other thread about the behavior system, and the responses here on how I might lay out the code before I have all the parts, I was able to get it working in less than 5 minutes. Adding features this quickly speeds up my workflow tremendously, and I get less annoyed at myself. 

 

I do see where I might use some of the other techniques mentioned here though. Perhaps I might do the layout diagramming thing mixed with a little mind mapping to display how the 3d models interact with the code. 

0

Share this post


Link to post
Share on other sites

I either use C, Lua, my custom language or the language I'll be using at the end.

 

My custom language is something like this:

class MyClass inherits object as(abstract);

enum UselessEnum
{
    EnumsHere,
    WorkLikeIn,
    CSharp, //UselessEnum.CSharp
};

struct Vector2
{
    float x, y;
}
struct Vector3 inherits Vector2 // same as declaring x and y before z
{
    float z;
}
struct Vector4 inherits Vector2
{    
    float w;
    
    defaults // can be useful
    {
        w = 1.0f;
    }
}

/* A block comment */
var int myinteger;

// A single line comment
var private string mystring;
var private string[] mystringarray;

/**
 * A documentation block comment.
 */
function MyFunction(bool booleanarg, float floatingpointarg, optional int optionalintegerarg = 0)
{
    myinteger = (booleanarg ? (int) floatingpointarg : (int) floatingpointarg - optionalintegerarg);
}

function string OtherFunction()
{
    if (myinteger < 0 || myinteger >= mystringarray.Length) {
        return mystring;
    }
    
    return mystringarray[myinteger];
}

defaults
{
    mystring = "default string";
    mystringarray = { "zero", "hyper zero", "too", "tree", "floor", "fly V" };
}

It's a mix of UnrealScript, C# and Java. Its rules are not completely defined yet so sometimes it has namespaces and the guts of the classes get wrapped in a body.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0