Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 02 Mar 2006
Offline Last Active Yesterday, 02:38 AM

#5313175 the very best resources I found for game programming

Posted by on 29 September 2016 - 12:20 AM

Speaking of "Pro", one can't call himself professional if he only knows one language, try and know at least 3

Actually, if you get paid to write software, you are professional. Any other metric is pretty meaningless.

#5312980 Coding-Style Poll

Posted by on 28 September 2016 - 02:29 AM

I find braces not on their own line very hard to read. Believe this is K&R style?
for(int i = 0; i < 10; ++i) {
My brain just cannot process that. I can only handle:
for(int i = 0; i < 10; ++i)
Professionally, I fit in with what others do but I'm fortunate that my current colleagues are "own-line-brace" guys too, as I would be at a major disadvantage if I had to write and follow code like my first example. But I suppose I'd just adjust to it.

My colleague has a very weird habit that I've adjusted to now:
class Foo
    const int*
    method() const;

const int*
Foo::method() const
End of the day, I hated this when I first saw it, but within a week or so I'd adjusted and I now flip between "work code" and "home code" without any problem whatsoever.

#5312978 the very best resources I found for game programming

Posted by on 28 September 2016 - 02:24 AM

But I have a problem, I can't go beyong basics in programming. I do not have ideas of what to code next, I still don't have the ability to create my own code (program) by myself. I have to follow tutorials, when I try to code by myself I dont do that good.
So my question is, what is the programming best practice??

Stop focusing on learning. Start focusing on achieving. You need to set yourself a specific goal, then learn just what you need to accomplish that goal.

Don't worry about how much you "know" or have "learned" or if you feel like an "expert". All of that is worth absolutely nothing if you can't produce an end result.

Once you have accomplished your goal or you get bored and want to move on, consider a new goal that stretches what you already know a bit further, but not so far further that it destroys your motivation.

I've been at this lark for over a quarter of a century now and I'm learning every day.

#5312052 3D World Editor - Suggestions and Ideas

Posted by on 23 September 2016 - 01:25 AM

In my experience, undo/redo needs to be designed in from the very beginning. It is a nightmare to retrofit to an existing project so I'd focus on it as soon as you can.

Then general idea is as explained above. The only way you should be able to modify your state is via Command objects, which store enough information to be able to undo and redo themselves.

I use the C++ const system to enforce my undo/redo system at the code level. I have a WorldState object that just contains bare read-write data for the world state. This is then wrapped in a World object which provides const-only access (read) to the world state. Eveything like views, toolbars etc uses the World interface to read the state.

The World also has beginCommand(Command*) and endCommand(Command*) methods that take classes deriving from Command. When one is passed to beginCommand() it is given a pointer to the WorldState so it can directly modify the values, but must take responsibility to undo itself and redo itself. When endCommand() is called, if the command is valid, it is pushed onto an UndoStack in the World object.

So the only way to modify the WorldState is via Command objects. It is not possible via any other mechanism so you can't accidentally fall outside the system.

It can feel a bit weird at first that every time you want to modify something, you have to create a Command to do it, but for me it is really the only way to ensure the system is comprehensive and you soon get used to it.

Hope this helps.

#5310742 Is this practical for a resource manager?

Posted by on 14 September 2016 - 06:54 AM

Linked lists are generally a hardware unfriendly way to structure a container these days. A vector of pointers to resources is generally more cache friendly and does not require the intrusion of the prev and next pointers into Resource.

Actually the container structure should never require the objects it stores to contain container-specific members. Take a look at std::list<T> for example.

#5310741 C++ Going Beyond Basics

Posted by on 14 September 2016 - 06:45 AM

Clearly defined goals is my input. Decide on something you want to achieve and learn what you need to know to achieve it.

There is way too much "stuff" for learning in the abstract for too long.

#5310321 Is Infinity Good Design?

Posted by on 11 September 2016 - 03:25 AM

From a technical perspective, the fact you think that as the rooms increase the framerate will inevitably drop shows a lack of understanding in the design.

No matter how large the generated content, you only need to process and draw that which you can currently see on screen, so you should be able to have an "infinite" design without this having any technical issues like that.

#5308990 Getting debug information using TextOut()

Posted by on 01 September 2016 - 06:37 AM

The flicker is inevitable if you first draw a background, then draw the text. The only way to be truly flicker free is to draw the background and then the text to an offscreen buffer, then draw the offscreen buffer to the screen in one go.


Otherwise there is a brief period where the background has been drawn but the text has not been.


When you are using DirectX this will all be handled for you. You'll be by-default drawing to an offscreen buffer which will then be dumped to the screen in one go. You can simulate it using the Win32 API but if you are planning to switch to DirectX at some point anyway, I wouldn't worry.

#5308003 Does anyone have any advice for my unique situation?

Posted by on 26 August 2016 - 04:15 AM

Here's a simple truth for you that you won't want to hear, Kavik Kang:

Ideas are the cheapest commodity in the entire games industry. They are almost worthless. They are the easy bit.

Getting ideas implemented is hard. You seem to me to lack even the interpersonal skills to make this happen, never mind the technical ability.

#5305933 Using a extern variable for a object causes linker errors

Posted by on 15 August 2016 - 04:35 AM

extern is essentially telling the compiler "this is declared elsewhere". You have to then declare the instance somewhere, usually in a cpp file.

extern int foo;

int foo = 123;

Anything including Thing.h can now access foo.

#5288404 c++ should nested switch statements be avoided?

Posted by on 24 April 2016 - 01:43 AM

Here's one from the innards of my virtual machine for handling math operations (+, -, * and /) on an exploding number of combinations of different types. I don't think there is anything wrong with this personally, others might disagree.
template<class T> bool operation(State &state, const TypedValue &a, const TypedValue &b, TypedValue &c, Om::Value &res)
        case Om::Type::Int:
                case Om::Type::Int: return op<T, int>(state, Om::Type::Int, a, b, c, res);
                case Om::Type::Float: return op<T, float>(state, Om::Type::Float, a, b, c, res);

                default: break;


        case Om::Type::Float:
                case Om::Type::Int: return op<T, float>(state, Om::Type::Float, a, b, c, res);
                case Om::Type::Float: return op<T, float>(state, Om::Type::Float, a, b, c, res);

                default: break;


        case Om::Type::String:
            if(T::type == Addition && b.realType() == Om::Type::String)
                c = TypedValue(Om::Type::String, state.allocate<StringEntity>(state.entity<StringEntity>(a.toUint()).text + state.entity<StringEntity>(b.toUint()).text));
                return true;


        default: break;

    res = Om::ValueProxy::makeError(state, error(a.userType(), b.userType()));
    return false;
It is templated on structures like Add, Sub etc, so the same method can be used for all math operations via compile-time polymorphism.

#5287083 How beneficial can personal projects be?

Posted by on 15 April 2016 - 01:24 PM

My 2D platform game and level editor got me a job developing business software.

I wouldn't personally hire a programmer who didn't have personal projects. If all you showed me was coursework, I'd assume you lacked the passion we all share here.

#5287082 Is inheritance evil?

Posted by on 15 April 2016 - 01:21 PM

Of course it isn't. It's s tool that can be used or abused.

Even deep inheritance trees can be appropriate in certain domains. Look at something like Qt for example.

There is, though, a huge amount of very bad OOP out there and a great deal of confusion about the is-a and has-a relationships.

But inheritance itself is not the cause of this. Personally I blame Java :).

#5286744 How to handle a collision in a physics library and OOP?

Posted by on 13 April 2016 - 02:12 PM

It's pretty common for a third party physics library to use some kind of void user data pointer to allow you to link back a physics object to your game object and while this is generally a bit icky, it's not really solvable in any other general purpose way without introducing unnecessary overhead.

I tend to wrap the physics library (Bullet in my case) in my own thin wrapper that hides such activity away in a central place and makes it generally more compatible with the rest of my code. I dislike using a third party API directly in the parts of the code that just use the physics.

With the void pointer, I only ever assign one type of pointer to it, so in a way I (the programmer) do "know" the class type, even if the compiler doesn't. Rules like this are hard to treat as set in stone in the real world.

Rather than dynamic_casting to lots of different classes, can't you abstractify the things the physics needs to know about into the base class and just treat all your objects as this base inside the physics code? Seems unnecessary for the physics to need to know the exact class details for every object to me.

#5286320 Access violation reading location 0xDDDDDDDD.

Posted by on 11 April 2016 - 10:58 AM

Remember you are now responsible for deleting the Sprite when you are either removing it from the list or the list is destroyed, or you'll have memory leaks.

Modern smart pointers can automate this sort of thing for you.