1. Post #81
    Gold Member
    Electroholic's Avatar
    June 2011
    2,289 Posts
    What's the best way to separate playable characters from NPC's?
    Abstract a "Character" class, then derive an NPC class and Player Class.
    Reply With Quote Edit / Delete Windows 7 Canada Show Events Agree Agree x 9 (list)

  2. Post #82
    Gold Member
    Hypershadsy's Avatar
    February 2008
    2,406 Posts
    Abstract a "Character" class, then derive an NPC class and Player Class.
    Would I store my game objects in a System.Collections.Generic.List?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  3. Post #83
    Gold Member
    Lord Ned's Avatar
    April 2006
    3,702 Posts
    What's the best way to separate playable characters from NPC's?
    Alternatively, make your characters derive from NPC's. This way they can get all the automated bits of NPC's (automated head-looking at objects of interest, automatic guard-stance, etc). Then just have the actual movement/combat decisions made by the player.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Agree Agree x 1 (list)

  4. Post #84
    Gold Member
    CrashLemon's Avatar
    November 2007
    965 Posts
    So I'm trying to learn some Android shenanigans but I'm wondering, how would I go about showing the Java console or something so I can see my System.out.print()?

    Is there an easy way to debug with the Android Emulator in Eclipse?
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  5. Post #85
    muckuruxx's Avatar
    December 2009
    977 Posts
    So, an exercise in this book is to write a program using vectors and iterators that allows a user to add and remove game titles in a list. I understand how to add something to a vector, but not to remove something based on user input.

    This is what I've got, but assigning a string to myIterator is no good.
    Code:
    cin >> gameToRemove;
    myIterator = gameToRemove;
    (*myIterator).erase();
    I need to know how to get the iterator to move to the item a user tells it to.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  6. Post #86
    Gold Member
    raBBish's Avatar
    March 2007
    2,667 Posts
    So, an exercise in this book is to write a program using vectors and iterators that allows a user to add and remove game titles in a list. I understand how to add something to a vector, but not to remove something based on user input.

    This is what I've got, but assigning a string to myIterator is no good.
    Code:
    cin >> gameToRemove;
    myIterator = gameToRemove;
    (*myIterator).erase();
    I need to know how to get the iterator to move to the item a user tells it to.
    auto it = std::find(your_vector.cbegin(), your_vector.cend(), gameToRemove);

    The std::find function does the obvious. cbegin and cend are the const versions of begin and end iterators. If it == your_vector.cend(), then the input item wasn't found from the vector.

    e: You need to include <algorithm> for std::find.
    Reply With Quote Edit / Delete Windows 7 Finland Show Events

  7. Post #87
    muckuruxx's Avatar
    December 2009
    977 Posts
    auto it = std::find(your_vector.cbegin(), your_vector.cend(), gameToRemove);

    The std::find function does the obvious. cbegin and cend are the const versions of begin and end iterators. If it == your_vector.cend(), then the input item wasn't found from the vector.

    e: You need to include <algorithm> for std::find.
    Thanks!
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  8. Post #88
    Gold Member
    dvondrake's Avatar
    August 2006
    2,329 Posts
    How do I rotate a 3D point around the origin by so many degrees on the x and y axis in C++? I know something about quaternions or rotation matrices, but I can't find out how to use them.

    I'm trying to move a light's world space position to view space, if that helps.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  9. Post #89
    Em See's Avatar
    January 2008
    1,100 Posts
    Hmm, asked this at an unfortunately late time, near the end of the last thread, so here we go again;

    I'm using C# and I'd like to be able to tell Steam what processes to display the overlay on top of (after being launched via Steam). This is instead of just having Steam attempt to apply the overlay to any process launched by the application added to Steam, sometimes resulting in the process I actually want to have the overlay being left out.

    Its a bit of a pickle, I'm not sure how to approach it :/
    Reply With Quote Edit / Delete Windows 7 Australia Show Events

  10. Post #90
    Eudoxia's Avatar
    July 2009
    6,009 Posts
    I'm writing the FFI side of a virtual machine, code is here:

    http://pastebin.com/wDm3k7cn

    It uses the ffcall library, mind you. I think any of the avcall.h files will work just fine, as long as you have the proper g++ flags. (g++ -v -> gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)).

    I don't know if any of you have used it before (Probably not), but the documentation is short, here: http://haible.de/bruno/documentation...ll/avcall.html

    Basically I get arguments from the bytecode and pass them to findLookupTable, which takes: A table ID argument, a function ID (The ID of the function within the lookup table), a pseudo-boolean called store, and an arbitrary number of arguments. It finds the lookup table, the function inside it, checks the value of store to see whether the result should be stored in a variable or just left hanging, and passes the arguments. A direct call, with the table ID, function ID (In this case, there are two test tables and only on test function) works with arbitrary arguments and argument types. The problem is, I get this error when trying to use avcall to build the argument list incrementally and pass it:

    Code:
    $ g++ sample.cpp -I/usr/include -lavcall -std=gnu++0x
    sample.cpp: In function ‘int main()’:
    sample.cpp:86:5: error: address of overloaded function with no contextual type information
    Line 86 being:

    Code:
    av_start_void(L,&findLookupTable);
    I tried every permutation of that line I could think of, but to no avail. Google yields OOP-related things and stuff. I'm thinking maybe it's a problem with me using these template things? AVCALL was meant for C, after all, maybe I should use the varargs/stdarg.h library.

    EDIT: I also tried:

    Code:
    av_start_void(L,(void(*)(int,int,int,Args...))&findLookupTable);
    Which returns:

    Code:
    $ g++ sample.cpp -I/usr/include -lavcall -std=gnu++0x
    sample.cpp: In function ‘int main()’:
    sample.cpp:85:5: error: expected primary-expression before ‘void’
    sample.cpp:85:5: error: expected ‘)’ before ‘void’
    sample.cpp:85:68: error: expected ‘)’ before ‘;’ token
    sample.cpp:85:68: error: expected ‘)’ before ‘;’ token
    Reply With Quote Edit / Delete Linux Uruguay Show Events

  11. Post #91
    Gold Member
    WeltEnSTurm's Avatar
    December 2007
    1,867 Posts
    I'm using Sublime Text 2 and I'd like more stuff highlighted. Is there some place where I can define keywords?
    Sucks that namespace, double and all that are black :c
    Reply With Quote Edit / Delete Windows 7 Austria Show Events

  12. Post #92
    Gold Member
    marcin1337's Avatar
    May 2006
    876 Posts
    Hey guys

    How would I read an entire file to a string in c++.

    Code:
        std::fstream fFile;
        File.open( sFile ,std::ios::in );
       
            std::string sFileBuffer;
    I know I could do a readline until fFile.eof() but that is kinda hacky , isn't it?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  13. Post #93
    Gold Member
    ThePuska's Avatar
    October 2005
    3,408 Posts
    Alternatively you could fseek the EoF, ftell the position of the fcursor, frewind back to the fstart and fread as many characters as you ftold.

    I only know C though.
    Reply With Quote Edit / Delete Windows 7 Finland Show Events Funny Funny x 4Agree Agree x 1 (list)

  14. Post #94
    Gold Member
    WeltEnSTurm's Avatar
    December 2007
    1,867 Posts
    Hey guys

    How would I read an entire file to a string in c++.

    Code:
        std::fstream fFile;
        File.open( sFile ,std::ios::in );
       
            std::string sFileBuffer;
    I know I could do a readline until fFile.eof() but that is kinda hacky , isn't it?
    while(fFile.good()) sFileBuffer << fFile << std::endl;

    Edited:

    I got a small problem with C++ template arguments and that.
    It's pretty fucked up IMO.

    Basically: hookmanager should have an instance for every template variation.
    But somehow, it gets instantiated twice for the same arguments.

    template<typename... T_args>
    class hookmanager {
    	public:
    		hookmanager(){}
    		std::map<string, std::map<string, std::function<void(T_args...)>>> map;
    
    		static hookmanager& get(){
    			static hookmanager<T_args...> m;
    			return m;
    		}
    };
    }
    
    // inside namespace hooks
    	template<typename... T_args>
    	static void Call(const string& name, T_args... Arguments){
    		for(auto& p: hookmanager<T_args...>::get().map[name])
    			if(p.second)
    				p.second(Arguments...);
    		io::writeln("c % %", typeid(hookmanager<T_args...>).name(), &hookmanager<T_args...>::get());
    	}
    
    	template<typename... T_args>
    	static void Add(const string& name, const string& customName, std::function<void(T_args...)> f){
    		io::writeln("a % %", typeid(hookmanager<T_args...>).name(), &hookmanager<T_args...>::get());
    		hookmanager<T_args...>::get().map[name][customName] = f;
    	}
    
    
    Code:
    a N2ws5tools5hooks12_GLOBAL__N_111hookmanagerIIPNS_2ui2wm6windowEEEE 0x4f8618
    c N2ws5tools5hooks12_GLOBAL__N_111hookmanagerIIPNS_2ui2wm6windowEEEE 0x4f8400
    It only doesn't work for some argument lists.
    Does anyone know why it creates a static object twice for the same template arguments?
    Reply With Quote Edit / Delete Windows 7 Austria Show Events

  15. Post #95
    Gold Member
    danharibo's Avatar
    July 2006
    4,432 Posts
    What's the best way to separate playable characters from NPC's?
    In what context? How are Characters defined?
    Reply With Quote Edit / Delete Linux United Kingdom Show Events

  16. Post #96
    Gold Member
    raBBish's Avatar
    March 2007
    2,667 Posts
    Hey guys

    How would I read an entire file to a string in c++.
    std::ifstream t("file.txt");
    std::string str((std::istreambuf_iterator<char>(t)),
                     std::istreambuf_iterator<char>());

    or

    std::ifstream t("file.txt");
    std::string str;
    
    t.seekg(0, std::ios::end);   
    str.reserve(t.tellg());
    t.seekg(0, std::ios::beg);
    
    str.assign((std::istreambuf_iterator<char>(t)),
                std::istreambuf_iterator<char>());

    The first one allocates memory as it goes, relying on string's dynamic reallocation. The second one allocates all the memory up front.

    http://stackoverflow.com/questions/2...602060#2602060
    Reply With Quote Edit / Delete Windows 7 Finland Show Events Useful Useful x 1 (list)

  17. Post #97
    Gold Member
    BackwardSpy's Avatar
    May 2008
    6,335 Posts
    Alternatively you could fseek the EoF, ftell the position of the fcursor, frewind back to the fstart and fread as many characters as you ftold.

    I only know C though.
    I found reading this post strangely humorous...
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Agree Agree x 5 (list)

  18. Post #98
    rute's Avatar
    August 2009
    212 Posts
    How I debug a message to Visual Studio's output with stuff (=%s, %f..)?

    This prints it to command line. I don't use it so I can't see it.
    printf ("%s \n", "A string");

    This prints it to right place, but it doesn't allow stuff like %s
    DebugMessage("debug! \n");
    Reply With Quote Edit / Delete Windows 7 Finland Show Events

  19. Post #99
    Gold Member

    March 2005
    3,028 Posts
    So I'm trying to learn some Android shenanigans but I'm wondering, how would I go about showing the Java console or something so I can see my System.out.print()?

    Is there an easy way to debug with the Android Emulator in Eclipse?
    http://developer.android.com/referen.../util/Log.html
    Reply With Quote Edit / Delete Linux Show Events

  20. Post #100
    dajoh's Avatar
    March 2011
    625 Posts
    How I debug a message to Visual Studio's output with stuff (=%s, %f..)?

    This prints it to command line. I don't use it so I can't see it.
    printf ("%s \n", "A string");

    This prints it to right place, but it doesn't allow stuff like %s
    DebugMessage("debug! \n");
    void DbgPrint(const char *szFormat, ...)
    {
    	va_list pList;
    	char szBuffer[4096];
    
    	va_start(pList, szFormat);
    	vsnprintf_s(szBuffer, 4096, szFormat, pList);
    	va_end(pList);
    
    	OutputDebugString(szBuffer);
    }
    
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events Winner Winner x 1 (list)

  21. Post #101
    Gold Member
    CrashLemon's Avatar
    November 2007
    965 Posts
    Yeah I read about it, although I can't seem to find where's the LogCat... I've tried using the debug terminal but it says access denied.
    Reply With Quote Edit / Delete Windows Vista Canada Show Events

  22. Post #102
    Gold Member
    RoflKawpter's Avatar
    December 2007
    2,558 Posts
    In Eclipse, when you type in the name of an object and the ., you get a window with all the available methods...

    That is, if you use the default Java methods.

    How come, when I import anything from Slick to LWJGL, I can type (for example) app. and nothing shows up? am I missing something to import?
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  23. Post #103
    likesoursugar's Avatar
    January 2009
    651 Posts

    Ok so this is my G-bufer and sometimes flickering lines appear.
    Pretty sure it's because of the depth buffer precision but what can I do about it?
    Someone who've drawn voxel scenes maby know how to fix this?
    Thanks.
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  24. Post #104
    Gold Member

    March 2005
    3,028 Posts
    If you're talking about that blue line there, then yes, it probably is a depth buffer issue.

    First, try using GL_DEPTH_COMPONENT32 as the depth attachment on the FBO. Second, and ABSOLUTELY MOST IMPORTANT, make sure your near clip plane is no closer than it must be. Many rendering newbies make the near clip plane something like 0.000001 because they think 'the nearer, the better'. This is absolutely wrong. Depth buffer values are non-linear -- most of your depth precision is concentrated around the near clip plane, and if you make it too close you're throwing away a good chunk of the precision of your depth buffer.
    Reply With Quote Edit / Delete Linux Show Events Informative Informative x 2 (list)

  25. Post #105
    likesoursugar's Avatar
    January 2009
    651 Posts
    Thank you for your reply.
    I tried to set up the fbo in another way using GL_DEPTH_COMPONENT32, but the problem still remains.
    Haha no the near clip is set to 1.0.
    Any other suggestions?
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  26. Post #106
    Gold Member

    March 2005
    3,028 Posts
    The blue line is a face which shouldn't be visible at all, so the best option is probably to not draw hidden faces. How you go about this depends largely on how your voxel set is structured.
    Reply With Quote Edit / Delete Windows 7 Show Events

  27. Post #107
    likesoursugar's Avatar
    January 2009
    651 Posts
    Exactly. I have some ideas but how would you do it?
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  28. Post #108
    Ratzz's Avatar
    July 2009
    1,001 Posts
    [Obligatory double-submission]

    Hey guys, I recently just started working with the LOVE engine and I have a fairly above-average knowledge of Lua.
    What confuses me(and quite a few other people) is how I would tweak the sample map tile generator to create biomes?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  29. Post #109
    RyanDv3's Avatar
    May 2008
    999 Posts
    I've been trying to get my laptop's internal speaker to beep using python, however, winsound, as nearly every resource points me to, does not use the internal speakers as far as I can tell. (I can turn it off by muting my normal speakers)

    Is it that my laptop doesn't have an internal speaker, or...?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  30. Post #110
    Gold Member
    windwakr's Avatar
    September 2009
    4,597 Posts
    I've been trying to get my laptop's internal speaker to beep using python, however, winsound, as nearly every resource points me to, does not use the internal speakers as far as I can tell. (I can turn it off by muting my normal speakers)

    Is it that my laptop doesn't have an internal speaker, or...?
    You can't access the actual internal speaker from within Win7 unless you replace the beep.sys with one from XP(Vista may work too, I'm not sure. I've only ever used XP's beep.sys).


    Edited:

    May be 32bit only.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Informative Informative x 2 (list)

  31. Post #111
    Clops with bisousbisous daily <3
    Mr. Smartass's Avatar
    December 2010
    9,188 Posts
    So I'm working on a first person camera in XNA, and I seem to have run into an issue. The camera behaves VERY strangely, bouncing up and down with no input whatsoever. If I move my mouse very far very fast, It becomes "stuck", but if I move it the way it was going, it resumes without a hitch. What on earth am I doing wrong?

    
    
        private void processMouse()
            {
    
                MouseState mouseState = Mouse.GetState();
                
                
                currentMousePos.X = mouseState.X;
                currentMousePos.Y = mouseState.Y;
                mouseStart = currentMousePos;
                //Mouse.SetPosition(device.Viewport.Width / 2, device.Viewport.Height / 2);
                mouseStart = new Vector2(device.Viewport.Width / 2, device.Viewport.Height / 2);
                
    
                //if (currentMousePos != new Vector2(device.Viewport.Width / 2, device.Viewport.Height / 2))
                //{
                    moveDistance = mouseStart - mouseDifference;
    
                    mouseDifference = currentMousePos;
                    //rollSpeed -= (moveDistance.X / 20000);
                    //upDownRotSpeed -= (moveDistance.Y / 20000);
    
                    
                    cameraYaw += mouseDifference.Y / 10000;
                    
    
                    
                //}
    
               
    
    
    
            }
    
     private void updateCamera()
            {
         
                Vector3 cameraPosition = new Vector3(0, 0.1f, 0.6f);
    
                //cameraPosition = Vector3.Transform(cameraPosition, Matrix.CreateFromQuaternion(cameraRotation));
                cameraPosition = Vector3.Transform(cameraPosition, Matrix.CreateFromYawPitchRoll(cameraYaw, cameraPitch, cameraRoll));
                //cameraPosition += shipPosition;
    
                Vector3 cameraUp = new Vector3(0, 1, 0);
                cameraUp = Vector3.Transform(cameraUp, Matrix.CreateFromQuaternion(cameraRotation));
                viewMatrix = Matrix.CreateLookAt(cameraPosition, new Vector3(0, 0, 0), cameraUp);
                Matrix worldMatrix = Matrix.CreateScale(1f, 1f, 1f) * 
                    Matrix.CreateRotationY(MathHelper.Pi) * Matrix.CreateFromQuaternion(shipRotation) * 
                    Matrix.CreateTranslation (cameraPosition);
                projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4,
                    device.Viewport.AspectRatio, 0.2f, 500.0f);
             
            }
    
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  32. Post #112
    kill yourself
    Protocol7's Avatar
    June 2006
    25,746 Posts
    I'm no camera control guru but looking at your processMouse() function, that looks fine. I'd reckon it's another function you're using in the updateCamera() function where you're performing the math to change the camera shit.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  33. Post #113
    Clops with bisousbisous daily <3
    Mr. Smartass's Avatar
    December 2010
    9,188 Posts
    I'm no camera control guru but looking at your processMouse() function, that looks fine. I'd reckon it's another function you're using in the updateCamera() function where you're performing the math to change the camera shit.
    God damn
    You'd think rotations would be easier
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  34. Post #114
    Gold Member
    robmaister12's Avatar
    January 2008
    4,969 Posts
    God damn
    You'd think rotations would be easier
    Quaternions
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  35. Post #115
    Clops with bisousbisous daily <3
    Mr. Smartass's Avatar
    December 2010
    9,188 Posts
    I took one look at those and pretty much said "fuck this", I've been using them as little as I can.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Agree Agree x 3Funny Funny x 2Dumb Dumb x 1 (list)

  36. Post #116
    Gold Member
    robmaister12's Avatar
    January 2008
    4,969 Posts
    I took one look at those and pretty much said "fuck this", I've been using them as little as I can.
    It's nice because it avoids gimbal locking and a bunch of other issues with euler angles, but it's pretty difficult to learn. I still haven't got around to using it for my free-roam camera.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  37. Post #117
    Hello, friends. So, I've skipped most of my programming classes and one of the classes I skipped were about pointers.

    Can anyone tell me why in this code:

    Code:
    #include <stdio.h> 
    #define DIM 4 
    void proc( int v[], int i, int n )  
    {  
       int j = 0; 
       while ( j <= n )  
       { 
           if ( v[ j ] >= i ) 
              v[ j ] = i; 
           j++; 
       } 
    } 
    int main( void )  
    { 
       int q[] = { 2 , 3 , 4 , 5 }; 
        
       proc( q , q[2], DIM ); 
       printf( "%d %d %d %d\n", q[ 0 ], q[ 1 ], q[ 2 ], q[ 3 ] ); 
       return 0; 
    }
    The information in the q array changes in the printf?
    Reply With Quote Edit / Delete Windows XP Portugal Show Events Dumb Dumb x 1 (list)

  38. Post #118
    BaconScientist's Avatar
    September 2011
    37 Posts
    Hello, friends. So, I've skipped most of my programming classes and one of the classes I skipped were about pointers.

    Can anyone tell me why in this code:

    Code:
    #include <stdio.h> 
    #define DIM 4 
    void proc( int v[], int i, int n )  
    {  
       int j = 0; 
       while ( j <= n )  
       { 
           if ( v[ j ] >= i ) 
              v[ j ] = i; 
           j++; 
       } 
    } 
    int main( void )  
    { 
       int q[] = { 2 , 3 , 4 , 5 }; 
        
       proc( q , q[2], DIM ); 
       printf( "%d %d %d %d\n", q[ 0 ], q[ 1 ], q[ 2 ], q[ 3 ] ); 
       return 0; 
    }
    The information in the q array changes in the printf?
    That's because in C/C++ arrays are passed by reference. Writing your function parameters like this:

    Code:
    void proc(int v[], int i, int n)
    Is equivalent to:

    Code:
    void proc(int * v, int i, int n)
    v will contain the address of the first element of the array you passed.
    Reply With Quote Edit / Delete Windows 7 Croatia Show Events

  39. Post #119
    Gold Member
    windwakr's Avatar
    September 2009
    4,597 Posts
    *words*

    The information in the q array changes in the printf?
    It doesn't change from in the printf, but in the proc function called before it.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  40. Post #120
    Oh, I see. What if I wanted to pass the array without it being a pointer? Would I just write (int v, int i, int n)?

    I really should have paid more attention in class.

    Edited:

    Wait, can you even do that?
    Reply With Quote Edit / Delete Windows XP Portugal Show Events