Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 16 Mar 2005
Offline Last Active Today, 01:20 AM

#4853380 MSVC++ paths in #pragma

Posted by rip-off on 24 August 2011 - 02:58 PM

What are a "bunch of errors"?

You generally don't put absolute paths anywhere in your source, because that is a great way to break this later when you've long forgotten them and start re-organising your hard drive, or try to build your program on another computer.

Instead, you should configure your IDE to point at any additional library paths. For instance, I have a folder C:\programming\infrastructure\c++\VC\ with include and lib sub-directories. I configure Visual Studio to search these for header files and libraries.

I'd recommend doing something similar. It makes it easy to backup my development directories, because everything (bar the IDE itself) is under C:\programming. Moving it to a separate drive would require fixing up a handful of references to C:, and moving it under my user directory would be likewise reasonably easy.

#4853256 Trouble Defining Error macro

Posted by rip-off on 24 August 2011 - 10:23 AM

Why not use an inline function, rather than abusing the preprocessor? Likewise, you could use "const int" rather than #define for those constants.

#4852726 Does VC++ allow triple pointers?

Posted by rip-off on 23 August 2011 - 04:30 AM

Try it out...
#include <iostream>

int main()
    int a = 42;
    int *b = &a;
    int **c = &b;
    int ***d = &c;
    int ****e = &d;
    int *****f = &e;
    int ******g = &f;
    int *******h = &g;
    int ********i = &h;
    int *********j = &i;
    int **********k = &j;
    int ***********l = &k;
    int ************m = &l;
    int *************n = &m;
    int **************o = &n;
    int ***************p = &o;

    std::cout << a << ' ' << ***************p << '\n';
There is nothing particularly special about a double pointer, or a triple pointer. Higher orders get rarer though. The head of a linked list of size N can be though of N level pointer to the tail.

#4852335 [SDL] How to copy the screen to another surface?

Posted by rip-off on 22 August 2011 - 09:09 AM

Here is such a reasonably minimal example:
#include "SDL.h"
#include <iostream>
#include <cstdlib>
#include <ctime>

int main(int, char **)

    if(SDL_Init(SDL_INIT_VIDEO) < 0)
        std::cerr << "Failed to initialise SDL: " << SDL_GetError() << '\n';
        return 1;
    SDL_Surface *screen = SDL_SetVideoMode(400, 400, 0, 0);
        std::cerr << "Failed to initialise SDL: " << SDL_GetError() << '\n';
        return 1;
    bool running = true;
        SDL_Event event;
            if(event.type == SDL_QUIT)
                running = false;
            else if((event.type == SDL_KEYUP) && (event.key.keysym.sym == SDLK_ESCAPE))
                running = false;
        SDL_FillRect(screen, NULL, 0);
        for(int i = 0 ; i < 10 ; ++i)
            SDL_Rect r;
            r.w = ((std::rand() % 5) + 1) * 10;
            r.h = ((std::rand() % 5) + 1) * 10;
            r.x = std::rand() % (screen->w - r.w);
            r.y = std::rand() % (screen->h - r.h);
            SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0xff * ((i % 3) == 0), 0xff * ((i % 3) == 1), 0xff * ((i % 3) == 2)));

    SDL_Surface *copy = SDL_DisplayFormat(screen);
        std::cerr << "Failed to copy surface: " << SDL_GetError() << '\n';
        return 1; 
    if(SDL_SaveBMP(copy, "out.bmp") != 0)
        std::cerr << "Failed to save output: " << SDL_GetError() << '\n';
        return 1;
    std::cout << "Success!\n";
    return 0;
Works for meTM.

#4852209 Cut down on memory usage

Posted by rip-off on 22 August 2011 - 04:15 AM

Doesn't matter if the computer is or is not outdated. This single line, is evidence that they cannot run it.

Of course the hardware isn't capable of running the current implementation of application! My speculation is that the hardware should be capable - i.e. the application is doing something wrong.

By the usage of "just" which indicates more than one person was involved in testing should bring the conclusion that their hardware is not capable of running the program. Also indicated by "just" is that others are not having the same problem.

It really depends on the range of hardware tested. You're inferring an awful lot that should be stated explicitly before being relied upon.

Is the computer outdated by standards of today? Yes(Which makes my statement not an opinion, but rather a observation of the standards of today). Is it outdated in the standards of running a 2D game made with basic SDL? No. Could the computer have other problems that would interrupt the games ability to effectively run? Possible, but inconclusive as no relevant data can be ascertained about the said computer. Does the game run fine for every other person who tried to run it? Yes.

Should the OP have kept the password the same on the source so that one of us could possibly look through the code instead of having 2 people speculate on what could be the cause instead of actually finding the real cause? Yes. Will they allow the code to be looked over again? Maybe. Is this discussion now pointless without further data on the subject? Yes.

Is starting every second sentence with a question incredibly annoying? Yes. :P

High Resource can be defined as an excessive or large amount of memory being used by an application that exceeds the standard.
Standard can be defined the average expected usage of a given program.

Sounds like circular logic.

This aside, I cannot think of any reasonable definition of a "standard" 2D SDL game that requires 1GB of RAM and whatever a N260 is - a dual core processor means probably exceeds 1GHZ at least. Just because there might exist games that tax such a system, doesn't mean anything. They could be written poorly.

Average 2D games will not exceed said computers system specs...

That is exactly my point!

...but the op did say:

its actually not that simple when i think of it...

Emphasis added.

He said it was not simple. Not simple doesn't mean complex, it doesn't even mean his game is above average in terms of its resource demands.

#4851723 Access to one program from another

Posted by rip-off on 20 August 2011 - 02:53 PM

Addresses are meaningless between different processes.

A unix solution to this problem would be for the first application to write the array to stdout, and the second application to sum the integers arriving on stdin. You would combine them by using the shell to pipe the output from the first program to the second.

#4851619 Access to one program from another

Posted by rip-off on 20 August 2011 - 09:27 AM

Is there any name for such technology

Its called the filesystem.

#4851160 Char Arrays and system()

Posted by rip-off on 19 August 2011 - 05:52 AM

Use std::string:

std::string command = "title ";
command += title;

Note that using system() like this is dangerous, and could allow for executing code that you didn't expect. In addition, it is expensive to spawn a sub-process just to change these properties.

An alternative is to use the Win32 api functions SetConsoleTitle() and SetConsoleTextAttribute().

#4850183 SDL: why the texts in my game jumpy? wxdev-c++

Posted by rip-off on 17 August 2011 - 02:06 AM

Your previous post is here. You can change your notification options here.

Please use the default font when typing your posts. Only change font to emphasise a particular part of your post. It is considered very rude to use such a large font for your entire post.

#4849751 Heeeeeeelp.

Posted by rip-off on 16 August 2011 - 02:29 AM

This is a forum for people interested in making games, not for technical support.

#4849749 Nub question about srand/rand

Posted by rip-off on 16 August 2011 - 02:26 AM

Note that using a fixed value for rand() can be helpful if you want to debug something, or you want to deterministic unit testing. In lock-step multiplayer games the peers want to start with a known random seed too (in fact de-sync bugs in lock-step games are often caused by incorrectly handling random values).

#4849569 Vectors in copy constructor causes heap corruption.

Posted by rip-off on 15 August 2011 - 03:09 PM

Also, I'm not sure how it's supposed to work for me with the const reference, I need the event class to be able to be changed, doesn't const lock it from editing?

Passing a parameter as a const reference doesn't "lock" the original object. Declaring an object const "sortof" does (in standardese) it isn't legal to make changes to an object that was originally declared declared const.

Can you post your EventResolver class header/source, and your Event class source?

#4849487 Vectors in copy constructor causes heap corruption.

Posted by rip-off on 15 August 2011 - 12:37 PM

Are you sure that all your events have valid "solid" values. Consider adding an assert in your ccomparison function to ensure you aren't stepping outside the bounds of the array:
template<class T, size_t N>
size_t array_size(T (&)[N])
     return N;

bool compareEvents(const Event &a, const Event &b)
    if(a.solid == b.solid)
        return a.y < b.y; 
    static const int lookup[] = {1, 0, 2, 1};

    assert(a.solid >= 0 && a.solid < array_length(lookup));
    assert(b.solid >= 0 && b.solid < array_length(lookup));

    return lookup[a.solid] < lookup[b.solid];
Note that your event class is rather large, I'd recommend passing it by const reference to functions.

#4849308 Questions regarding copyright and licenses

Posted by rip-off on 15 August 2011 - 03:15 AM

When you say "lines of source" from the internet, was it from a tutorial-style source? In this case, the author probably won't pursue you. If they did, it should be easy enough to replace that code with something you will write yourself (tutorial style material is usually basic enough). The risk here is rather low anyway, as the benefit for anyone pursuing you is negligible compared to the time and effort it would take.

If you have taken a large amount of code from a source that didn't provide an explicit, permissive license, the risk is obviously higher. However, you have the option of contacting the author of the source and seeing if they will consent to your use of it.

I am not a lawyer, and if you're serious about making this a commercial game you should talk to one. As Tom's FAQ points out, it is all about understanding the risk and deeming what risk you are willing to accept and what you cannot.

#4849284 adding a queue to a class

Posted by rip-off on 15 August 2011 - 01:54 AM

It is advised against putting using directives in header files, as there is no way to "un-use" a namespace.