• Advertisement
Sign in to follow this  

Game Engine from scratch using C++ and python - Where do I start?

This topic is 1928 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[quote name='Pointer2APointer' timestamp='1349552378' post='4987488']
To end my misfortunate and bad example code of a game engine, I'll go back and edit to better suit a problem.

As for type defining an SDL_Surface *, I always do it because it's easier and faster to write out [CODE]LOAD SDL_LoadBMP("image.bmp")[/CODE] than it is to write [CODE]SDL_Surface* LOAD = SDL_LoadBMP("image.bmp")[/CODE].

I would hope others see the time-saving benefits of using a typedef at times, aside from other use.

Now I'll go and fix what I poorly wrote out.
[/quote]

Your comparison is flawed. It should be:

[code]
SDL_Surface* image = ...
// vs
LOAD image = ...
[/code]

It's a virtually inconsequential difference, in terms of length. But even if it wasn't, SDL_Surface* is far more descriptive, and should therefore be preferred.

Anyway, I wouldn't recommend changing your previous posts; they're supposed to serve as examples of what others are not supposed to do, so just leave them as they are. If you want to show some more code for us to review, make a new post/thread, and we can take it from there.

[quote name='Vodahmin' timestamp='1349598096' post='4987625']
There is no apparent reason for typedefing SDL_Surface* but if your pointer declaration looks like "shared_ptr<SDL_Surface>" or something longer, then it can be a bit frustrating to rewrite it every time, so why not just typedefing it to "SDL_Surface"?
[/quote]

I would ask if a shared_ptr is truly necessary? Maybe that part of the system could be written in a higher-level language (one that comes with a GC).

In either case, I think that "typdefing a pointer to save a few keystrokes" is fundamentally wrong. Unless you have really good architectural reasons for doing that, you should find a better text editor that can automate those "too long to type" situations.

Share this post


Link to post
Share on other sites
Advertisement
[quote name='Goran Milovanovic' timestamp='1349608149' post='4987650']
In either case, I think that "typdefing a pointer to save a few keystrokes" is fundamentally wrong. Unless you have really good architectural reasons for doing that, you should find a better text editor that can automate those "too long to type" situations.
[/quote]
It's a matter of aesthetics. The code is also more readable, which can save you some time when debugging - that's what typedef was made for.

Share this post


Link to post
Share on other sites
It's like [CODE]using[/CODE] in C++.

After a while, when using the STD library in C++, beginners will probably learn this:

[CODE]cout << "Hello world!"[/CODE] instead of [CODE]std::cout << "Hello world!"[/CODE] .

It is less typing.

Share this post


Link to post
Share on other sites
Ugh. The amount of time spent typing in a program is less than 1% of a product's cost. Don't risk the incredible added cost of debugging or patching code errors caused by useless typedef garbage that saved you a few seconds.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement