1. Post #201
    Gold Member
    TH3_L33T's Avatar
    June 2006
    1,309 Posts
    So I am having troubles with my camera and my player I have a 2D array full with tile map and the camera allows scrolling through all of it but when the camera hits the edge to let the player continue moving around relative to the camera. I am not exactly sure how to describe it but like a 2D top down view game.

    Any help would be appreciated.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  2. Post #202
    Gold Member
    Lord Ned's Avatar
    April 2006
    3,702 Posts
    Make the camera follow the player.
    Then check if the camera is past an edge. If so, align it as close as you can.

    Should let the player walk around freely (he should do his own checks against the edge of the world), and keep your camera from extending past.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Agree Agree x 1 (list)

  3. Post #203
    Tamschi's Avatar
    December 2009
    2,944 Posts
    I'm looking for a .NET library that lets me write (and read, if there's one that does both) videos by pushing frames and audio data.

    Holly would be perfect, but I'm not good enough at wrapping with P/Invoke / C++/CLI to use it.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  4. Post #204
    RUBY OVERLORD
    swift and shift's Avatar
    November 2011
    2,115 Posts
    garry wrote one, but it's in C++ so expect to do some pretty heavy binding
    Reply With Quote Edit / Delete Mac Australia Show Events Artistic Artistic x 1 (list)

  5. Post #205
    Tamschi's Avatar
    December 2009
    2,944 Posts
    garry wrote one, but it's in C++ so expect to do some pretty heavy binding
    Holly would be perfect, but I'm not good enough at wrapping with P/Invoke / C++/CLI to use it.
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  6. Post #206
    RUBY OVERLORD
    swift and shift's Avatar
    November 2011
    2,115 Posts
    oops, how did i miss that
    Reply With Quote Edit / Delete Mac Australia Show Events

  7. Post #207
    Gold Member
    Armandur's Avatar
    March 2009
    666 Posts
    After compiling SFML2 for VS2010 C++ I'm getting a strange error when building, that I can't fix.
    One of the headers in SFML (err.hpp) complains that it can't find ostream.

    Output
    Code:
    1>ClCompile:
    1>  Application.cpp
    1>C:\lib\sfml2.0\include\SFML/System/Err.hpp(32): fatal error C1083: Cannot open include file: 'ostream': No such file or directory
    1>
    1>Build FAILED.
    Application.cpp
    #include <SFML/Graphics.hpp>
    
    int main()
    {
    	sf::RenderWindow Window(sf::VideoMode(800, 600, 32), "SFML Sample Application");
    
    	while (Window.IsOpened())
    	{
    		sf::Event Event;
    		while (Window.PollEvent(Event))
    		{
    			switch (Event.Type)
    			{
    			case sf::Event::Closed:
    				Window.Close();
    				break;
    			default:
    				break;
    			}
    		}
    
    		Window.Clear(sf::Color(0, 255, 255));
    		Window.Display();
    	}
    
    	return 0;
    }
    
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  8. Post #208
    Gold Member
    mechanarchy's Avatar
    September 2009
    1,213 Posts
    I have code resembling the following.
    class Example
    {
        // ctor, dtor, etc-tor
    
        template<typename R, typename T>
        R operator()(T a, T b) { /* code */ }
    };
    

    How do I actually go about calling the functor with a specific type? In this example, the return type. Simply doing
    Example instance(ctor, args);
    instance<int, bool>(true, false);
    
    won't work. (I'm also guessing that this IS valid code, the compiler hasn't complained about it but I suppose it could be in undefined behaviour territory)
    Reply With Quote Edit / Delete Linux Australia Show Events

  9. Post #209
    AtomiCasd's Avatar
    June 2011
    588 Posts
    After compiling SFML2 for VS2010 C++ I'm getting a strange error when building, that I can't fix.
    One of the headers in SFML (err.hpp) complains that it can't find ostream.

    Output
    Code:
    1>ClCompile:
    1>  Application.cpp
    1>C:\lib\sfml2.0\include\SFML/System/Err.hpp(32): fatal error C1083: Cannot open include file: 'ostream': No such file or directory
    1>
    1>Build FAILED.
    Application.cpp
    #include <SFML/Graphics.hpp>
    
    int main()
    {
    	sf::RenderWindow Window(sf::VideoMode(800, 600, 32), "SFML Sample Application");
    
    	while (Window.IsOpened())
    	{
    		sf::Event Event;
    		while (Window.PollEvent(Event))
    		{
    			switch (Event.Type)
    			{
    			case sf::Event::Closed:
    				Window.Close();
    				break;
    			default:
    				break;
    			}
    		}
    
    		Window.Clear(sf::Color(0, 255, 255));
    		Window.Display();
    	}
    
    	return 0;
    }
    
    You should post this on the sfml-dev.org forum, I believe laurent can help you out since it's a developer build and he's the one developing it.
    Reply With Quote Edit / Delete Windows 7 Norway Show Events Agree Agree x 1 (list)

  10. Post #210
    Jaykin' Bacon: Episode Three
    Jimbomcb's Avatar
    February 2005
    22,548 Posts
    I'm trying to create a handheld effect for a camera by interpolating the camera back and forth to random points within a range, however it just looks dumb and nothing at all like I want it to.

    I know it's vague and barely a question but yeah, anyone have any input/ideas on how they would (by offsetting the position) achieve a sorta shaky handheld effect?
    Reply With Quote Edit / Delete Windows 7 Show Events

  11. Post #211
    Gold Member

    March 2005
    3,028 Posts
    I'm trying to create a handheld effect for a camera by interpolating the camera back and forth to random points within a range, however it just looks dumb and nothing at all like I want it to.

    I know it's vague and barely a question but yeah, anyone have any input/ideas on how they would (by offsetting the position) achieve a sorta shaky handheld effect?
    Try something like:
    Code:
    yaw_offset = scale * (cos(a*t) + cos(b*t) + cos(c*t));
    pitch_offset = scale * (cos(d*t) + cos(e*t) + cos(f*t));
    Where a, b, c, d, e, and f are a bunch of coprime coefficients for angular frequency.
    Reply With Quote Edit / Delete Windows 7 Show Events Programming King Programming King x 1 (list)

  12. Post #212
    Gold Member
    esalaka's Avatar
    July 2007
    10,064 Posts
    Guys

    Is this still a valid description of frustum culling or is there some ~~NEW TECHNOLOGY~~ that simplifies it or makes the process more efficient?
    Reply With Quote Edit / Delete Linux Finland Show Events

  13. Post #213
    Gold Member

    March 2005
    3,028 Posts
    Guys

    Is this still a valid description of frustum culling or is there some ~~NEW TECHNOLOGY~~ that simplifies it or makes the process more efficient?
    Frustum culling is basic geometry. The basic process doesn't change.
    Obviously, some scene structures are better suited than others (i.e. hierarchical structures are better than flat structures), but anything you read in an old article probably still works today.

    Speaking of which, I've been thinking about breaking the frustum/occlusion culling (well, it's just frustum culling now, but I've got occlusion culling planned out on paper) code from my engine and making it into a dedicated library. It's the sort of thing every game developer really needs, but AFAIK, there isn't really a good library for it right now, short of proprietary middleware.
    Reply With Quote Edit / Delete Windows 7 Show Events

  14. Post #214
    Jaykin' Bacon: Episode Three
    Jimbomcb's Avatar
    February 2005
    22,548 Posts
    Try something like:
    Code:
    yaw_offset = scale * (cos(a*t) + cos(b*t) + cos(c*t));
    pitch_offset = scale * (cos(d*t) + cos(e*t) + cos(f*t));
    Where a, b, c, d, e, and f are a bunch of coprime coefficients for angular frequency.
    looks awesome, thanks. just out of interest, why do the coefficients need to be coprime
    Reply With Quote Edit / Delete Windows 7 Show Events

  15. Post #215
    Gold Member
    mechanarchy's Avatar
    September 2009
    1,213 Posts
    This error is pissing me right the fuck off.

    Code:
    main.cpp:307: error: no matching function for call to ‘layer::debug::Library::findFunction(const char [19])’
    main.cpp
    layer::debug::Library sqlite("/usr/lib/libsqlite3.so");
    
    const char* (*whatwhat)() = sqlite.findFunction<const char*, void>("sqlite3_libversion"); // line 307
    
    const char* ver3 = whatwhat();
    
    ::layer::info("blah says \"%s\"\n", ver3); // printf-equiv
    

    Library is defined as
    class Library
    {
    public:
    	Library(const GString& path); // GString is typedef'd std::string
    	~Library();
    	
    	void* findFunction(const GString& functionName) const;
    	
    	template<typename R, typename... T>
    	R (*findFunction(const GString& funcName))(T... Ts) const
    	{
    		return (R (*)(...))findFunction(funcName);
    	}
    	
    private:
    	void* _libraryHandle;
    	
    };
    

    Compiling with -std=c++0x -pedantic -Wall

    Edited:

    if I use the non-templated function and some bullshit casting, it works fine.

    void* simple = sqlite.findFunction("sqlite3_libversion");
    
    const char* (*simpleimpl)(void) = (const char* (*)(void))(simple);
    
    ::layer::info("blah says \"%s\"\n", simpleimpl());
    
    Reply With Quote Edit / Delete Linux Australia Show Events

  16. Post #216
    halofreak472's Avatar
    August 2009
    360 Posts
    Using QT4 in Ruby, how can I set a variable equal to what was entered into lineEdit? I've spent the past hour googling this, and I haven't had any luck. The results I got showed bits of code that were of no relevance to what I'm looking for.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  17. Post #217
    Gold Member

    March 2005
    3,028 Posts
    looks awesome, thanks. just out of interest, why do the coefficients need to be coprime
    You get a longer period before the pattern repeats. It won't appear to be random movement if they have a small common factor.
    Reply With Quote Edit / Delete Windows 7 Show Events Informative Informative x 1 (list)

  18. Post #218
    Glorious GNU/Linux Master Race
    kaukassus's Avatar
    May 2010
    4,997 Posts
    creating an xml file with .net in c#, it works, but the generated file only uses 1 line like this:

    Code:
    <?xml version="1.0"?><Client><server>192.168.12.1</server></Client>
    But i want it to look much more organized, like this:

    Code:
    <?xml version="1.0"?>
    <Client>
    	<server>192.168.12.1</server>
    </Client>
    This is the code I currently have:

    Code:
                XmlTextWriter textWriter = new XmlTextWriter("preferences.xml", null);
                textWriter.WriteStartDocument();
                //Start write
    
                textWriter.WriteStartElement("Client");
                textWriter.WriteStartElement("server");
                textWriter.WriteString("192.168.12.1");
                textWriter.WriteEndElement();
                textWriter.WriteEndElement();
    
    
                //End Write
                textWriter.WriteEndDocument();
                textWriter.Close();
    Reply With Quote Edit / Delete Mac Switzerland Show Events

  19. Post #219
    NovembrDobby's Avatar
    April 2007
    1,138 Posts
    Hmm, you could try:
    Code:
    textWriter.Settings.NewLineOnAttributes = true;
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  20. Post #220
    NovembrDobby's Avatar
    April 2007
    1,138 Posts
    On ubuntu 11.10 (64 bit), my cmake can't seem to find the xrandr library:



    even though I can use it in the terminal:



    (using cmake 2.8.5).

    Edited:

    Fixed, had to install the dev versions of everything (e.g. libsndfile-dev)
    Reply With Quote Edit / Delete Linux United Kingdom Show Events Agree Agree x 1 (list)

  21. Post #221
    own-fucking-zone
    Within's Avatar
    April 2009
    4,010 Posts
    I'm getting some weird shit here. I'm writing a backup utility for all my stuff and I'm getting 'access denied' to non-system paths when using the System.IO.File.Copy method. I even changed the manifest to requireAdministrator and it didn't help.
    Any ideas?

    Edited:

    One of the paths in question is: C:\Users\.\Desktop\Minecraft\Server

    Edited:

    Haha, that's unfortunate for me, I just realized I'm using File.Copy in an attempt to copy folders. Sorry - nevermind me.
    Reply With Quote Edit / Delete Windows 7 Denmark Show Events

  22. Post #222
    CJF
    PieClock's Avatar
    August 2006
    16,084 Posts
    In LOVE is there any way I can open a directory in an explorer window?
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  23. Post #223
    Gold Member
    mechanarchy's Avatar
    September 2009
    1,213 Posts
    In LOVE is there any way I can open a directory in an explorer window?
    I'm not too crash hot with love or lua but some quick googling says there's "os.execute". Just do that and call
    Code:
    os.execute("explorer \"directory name here with spaces\"")
    Reply With Quote Edit / Delete Linux Australia Show Events Friendly Friendly x 1 (list)

  24. Post #224
    CJF
    PieClock's Avatar
    August 2006
    16,084 Posts
    Yep, just stumbled upon that myself there now. Works great. Thanks

    Though this is what I'm doing:

    Code:
    os.execute("C:\\windows\\explorer.exe /e, C:\\")
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Programming King Programming King x 1 (list)

  25. Post #225
    Plastical's Avatar
    August 2009
    583 Posts
    This is for a problem on an assignment. I'm having trouble sorting three numbers in order of ascension without the use of array, here's what I have in Java so far:

    Code:
    System.out.println("Enter the first number: ");
    int num1= input.nextInt();
    				
    System.out.println("Enter the second number: ");
    int num2 = input.nextInt();
    int minInput = Math.min(num1, num2);
    int maxInput = Math.max(num1, num2);
    		
    System.out.println("Enter the third number: ");
    int num3= input.nextInt();
    minInput = Math.min(minInput, num3);
    maxInput = Math.max(maxInput, num3);
    				
    System.out.println("Numbers in order: " + minInput + " " + maxInput);
    The problem is that I can't seem to figure out how to get the middle value. Any help appreciated.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  26. Post #226
    Gold Member
    mechanarchy's Avatar
    September 2009
    1,213 Posts
    This is for a problem on an assignment. I'm having trouble sorting three numbers in order of ascension without the use of array, here's what I have in Java so far:

    Code:
    code
    The problem is that I can't seem to figure out how to get the middle value. Any help appreciated.
    I'd skip the whole 'min' and 'max' approach and just check for all the combinations using "if a < b and a < c" sort of things.

    Edited:

    Not particularly glamorous, but it works for something of this small scale.
    Reply With Quote Edit / Delete Linux Australia Show Events

  27. Post #227
    Plastical's Avatar
    August 2009
    583 Posts
    I'd skip the whole 'min' and 'max' approach and just check for all the combinations using "if a < b and a < c" sort of things.

    Edited:

    Not particularly glamorous, but it works for something of this small scale.
    I did this using 9 if statements. It wasn't beautiful and I had to create a temporary variable, but it worked. Thanks.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Funny Funny x 1 (list)

  28. Post #228
    Gold Member
    mechanarchy's Avatar
    September 2009
    1,213 Posts
    I did this using 9 if statements. It wasn't beautiful and I had to create a temporary variable, but it worked. Thanks.
    Yeaah... I kinda expected it would look a bit dreadful.

    Edited:

    Just decided to see how it was done. Here's a working python implementation:

    Code:
    a = int(raw_input("first: "))
    b = int(raw_input("second: "))
    
    theMin = min(a, b)
    theMax = max(a, b)
    
    c = int(raw_input("third: "))
    
    theMid = 0
    
    if min(c, theMin) == theMin and max(c, theMax) == theMax:
    	# c is middle
    	theMid = c
    elif min(c, theMin) == theMin:
    	# c is max
    	theMid = theMax
    	theMax = c
    else:
    	# c is min
    	theMid = theMin
    	theMin = c
    
    print "minimum value:", theMin
    print "middle value:", theMid
    print "maximum value:", theMax
    Edited:

    It's completely different to what I suggested and far closer to what you had, but oh well. When I started writing it, this was how it turned out compared to what I'd planned.
    Reply With Quote Edit / Delete Linux Australia Show Events

  29. Post #229
    Glorious GNU/Linux Master Race
    kaukassus's Avatar
    May 2010
    4,997 Posts
    what would be the best way to integrate Lua into c#?
    Reply With Quote Edit / Delete Windows 7 Switzerland Show Events

  30. Post #230
    HQRSE FUCKER
    ief014's Avatar
    September 2009
    3,045 Posts
    what would be the best way to integrate Lua into c#?
    http://code.google.com/p/luainterface/
    Reply With Quote Edit / Delete Windows 7 Germany Show Events Useful Useful x 1 (list)

  31. Post #231
    Leonmyster's Avatar
    June 2009
    536 Posts
    I need some help with this problem. (C++)

    2. Write a program that will prompt the user for a positive integer n, and will use a recursive function to convert n to binary. For example, if n is 19, the output shold be 10011. It should then print the binary number.

    Code:
    #include <iostream>
    using namespace std;
    
    int convertToBinary(int);
    
    int main()
    {
    	int n;
    	cout << "Enter non-zero integer or 0 to stop: ";
    	cin >> n;
    	while (n != 0)
    	{
    		int binary = convertToBinary(n);
    		cout << "The binary of integer " << n << " is " << binary << ".\n";
    
    		cout << "Enter non-zero integer or 0 to stop: ";
    		cin >> n;
    	}
    	cout << "Bye!\n";
    }
    
    int convertToBinary(int n)
    {
    	if (n == 0)
    		return 0;
    	return convertToBinary(n/2) + n%2;
    }
    I don't know where to go from here, it's adding the numbers together, and that's not what I want. Any ideas on what I'm doing wrong?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  32. Post #232
    Gold Member
    Octave's Avatar
    January 2009
    2,530 Posts
    I need some help with this problem. (C++)

    2. Write a program that will prompt the user for a positive integer n, and will use a recursive function to convert n to binary. For example, if n is 19, the output shold be 10011. It should then print the binary number.

    Code:
    #include <iostream>
    using namespace std;
    
    int convertToBinary(int);
    
    int main()
    {
    	int n;
    	cout << "Enter non-zero integer or 0 to stop: ";
    	cin >> n;
    	while (n != 0)
    	{
    		int binary = convertToBinary(n);
    		cout << "The binary of integer " << n << " is " << binary << ".\n";
    
    		cout << "Enter non-zero integer or 0 to stop: ";
    		cin >> n;
    	}
    	cout << "Bye!\n";
    }
    
    int convertToBinary(int n)
    {
    	if (n == 0)
    		return 0;
    	return convertToBinary(n/2) + n%2;
    }
    I don't know where to go from here, it's adding the numbers together, and that's not what I want. Any ideas on what I'm doing wrong?
    Well for one thing, you want it to build a string, while instead it's adding integers together.
    Reply With Quote Edit / Delete Mac United States Show Events Agree Agree x 1 (list)

  33. Post #233
    Leonmyster's Avatar
    June 2009
    536 Posts
    Well for one thing, you want it to build a string, while instead it's adding integers together.
    How would I incorporate the string? From what I understand, I can't return it as a string because it's an integer, convertToBinary that is.

    My knowledge of strings aren't too good, since my previous professor never taught us string, while this one is all about it.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  34. Post #234
    Gold Member
    Octave's Avatar
    January 2009
    2,530 Posts
    How would I incorporate the string? From what I understand, I can't return it as a string because it's an integer, convertToBinary that is.

    My knowledge of strings aren't too good, since my previous professor never taught us string, while this one is all about it.
    I'd like to preface this with the fact that my C++ is very limited but for starters, you can change the return type to be a string
    Code:
    string convertToBinary(int n)
    {
    	static string result; // Static so that it will remain between calls of this function rather than being initialized every time
            if (n == 0)
    		return 0;
            result.append((n % 2) ? "1" : "0");
    	return convertToBinary(n/2);
    }
    Haven't tested this yet, but it's a start.
    Reply With Quote Edit / Delete Mac United States Show Events

  35. Post #235
    Follow me on GitHub!
    Ziks's Avatar
    June 2011
    1,982 Posts
    That would just return 0. Maybe try something like:

    Code:
    string convertToBinary( int n )
    {
        if( n == 0 )
            return "0";
    
        return convertToBinary( n / 2 ).append( toString( n % 2 ) ); 
    }
    Edited:

    No idea how to append to a string in C++ though, maybe with a stream
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  36. Post #236
    Gold Member
    esalaka's Avatar
    July 2007
    10,064 Posts
    A lot of the time you want to use stringstreams to convert things into strings.
    Read more about 'em here.

    Should explain the concept adequately, seeing as you know how streams work already (cin, cout).


    Maybe I should learn how to read
    Reply With Quote Edit / Delete Windows 7 Finland Show Events

  37. Post #237
    Gold Member
    Octave's Avatar
    January 2009
    2,530 Posts
    Okay, fixed some things, this works but the output is reversed, looking for a string reversal function now...
    string convertToBinary(int n)
    {
            static string buf;
            if (n == 0) return buf;
            buf.append((n % 2) ? "1" : "0");
            return convertToBinary(n/2);
            
    }
    Reply With Quote Edit / Delete Mac United States Show Events Programming King Programming King x 1 (list)

  38. Post #238
    Gold Member

    March 2005
    3,028 Posts
    Avoid recursion when it isn't beneficial. If you use it in places where there aren't small upper bounds on the depth of the recursion, you risk a stack overflow. Not to mention the function call overhead.
    This would probably be better:
    string convertToBinary(int n)
    {
    	int bits = 8 * sizeof(int);
    	int mask = 1 << bits - 1;
    	string result;
    	for (int i=0; i < bits; i++) {
    		result.append(n & mask ? "1" : "0");
    		mask >>= 1;
    	}
    	return result;
    }
    Reply With Quote Edit / Delete Windows 7 Show Events

  39. Post #239
    Follow me on GitHub!
    Ziks's Avatar
    June 2011
    1,982 Posts
    Instead of reversing the string at the end you could construct it in the opposite order. Also, I'm not sure you can declare static variables inside a method C++, although it has been a while since I last used it.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  40. Post #240
    Gold Member

    March 2005
    3,028 Posts
    Also, I'm not sure you can declare static variables inside a method C++, although it has been a while since I last used it.
    It's a function, not a method.
    Reply With Quote Edit / Delete Windows 7 Show Events