• What Do You Need Help With? V6
    7,544 replies, posted
You could use std::reference_wrapper, although then you have to bind to a C& to leverage the implicit conversion operator or do c.get().doStuff(). As an alternative to the whole thing you could also consider using a container that preserves iterators for the operations you use.
[QUOTE=ZeekyHBomb;41869935]You could use std::reference_wrapper, although then you have to bind to a C& to leverage the implicit conversion operator or do c.get().doStuff(). As an alternative to the whole thing you could also consider using a container that preserves iterators for the operations you use.[/QUOTE] The struct constructs both b and c though, does a std::reference_wrapper do that?
Do what? It can be constructed from from a T& (where T is the wrapped type). You still need to manually re-assign the reference_wrapper when the address changes.
[QUOTE=ZeekyHBomb;41870009]Do what? It can be constructed from from a T& (where T is the wrapped type). You still need to manually re-assign the reference_wrapper when the address changes.[/QUOTE] What I think is something like this: [cpp] struct A { std::unique_ptr<B> b; // initialized with "new B()" C c; // c keeps a reference to the thing pointed to by b }; [/cpp] If I now move an A, there shouldn't be any problem. I'm asking there is an even simpler solution than this. Also, I tried to implement this. It gives me "cannot access private member declared in class 'std::unique_ptr<_Ty>'".
I’m using Qt to create a little game with SFML. It compiles normally, but when it starts the gdb shows a error code. [img]http://img32.imageshack.us/img32/7172/fcg.png[/img] What can I do?
[QUOTE=thf;41870080]What I think is something like this: [cpp] struct A { std::unique_ptr<B> b; // initialized with "new B()" C c; // c keeps a reference to the thing pointed to by b }; [/cpp] If I now move an A, there shouldn't be any problem. I'm asking there is an even simpler solution than this. Also, I tried to implement this. It gives me "cannot access private member declared in class 'std::unique_ptr<_Ty>'".[/QUOTE] Does it specify which member it tries to access? Can you give me a complete test-case? I wanna look what my compiler says. [editline]17th August 2013[/editline] [QUOTE=Cesar Augusto;41870871]I’m using Qt to create a little game with SFML. It compiles normally, but when it starts the gdb shows a error code. [img]http://img32.imageshack.us/img32/7172/fcg.png[/img] What can I do?[/QUOTE] Can you run it without gdb?
[QUOTE=ZeekyHBomb] Can you run it without gdb?[/QUOTE] Thank you! My program wasn't finding the dlls! Now I got it! :D
[QUOTE=ZeekyHBomb;41870949]Does it specify which member it tries to access? Can you give me a complete test-case? I wanna look what my compiler says.[/QUOTE] Never mind man, it turns out I tried to copy the structs when looping over them: [cpp] for (auto a : as) { // ... } [/cpp] Changed it to this and it works: [cpp] for (auto& a : as) { // ... } [/cpp]
Maybe you should A(const A&) = delete;.
<snip> Never mind, I should read code more carefully.
Does anyone have any recommendations for a modern OpenGL book?
[QUOTE=reevezy67;41877108]Does anyone have any recommendations for a modern OpenGL book?[/QUOTE] No books, but here are the sites I learned from: [url]http://www.arcsynthesis.org/gltut/[/url] [url]http://www.opengl-tutorial.org/[/url] [url]http://www.open.gl/[/url]
Regarding the recent discussion in WAYWO about how Uplink uses a long if-elseif chain for the task manager, what would be the best way of calling specific functions based upon a given input string? For example, given console input "roll", the program would call an appropriate dice rolling function. I was thinking about using an std::unordered_map of function pointers, but I'm not sure if this is the best way. Any ideas?
If you can trust some random guy on the internet [url=http://stackoverflow.com/a/11907992/1874964]hash maps are the typical approach[/url]. You could also peek at how shells, like bash, or game engines, like id Tech 4, do it.
Mapping a string to a function is the usual approach. Some low-level implementations I've seen in C use GCC's computed goto to avoid the overhead of function calls - or to access locals. But this is more of a curiosity than practical advice. In high-level languages like C#, a "switch" statement with strings probably translates to something very similar. It's also common in RPC where you don't need to do the conversion from string to index, but can directly use integer indices. [cpp]// Mapping function for string -> index in table // Implemented e.g. with strcmp + bsearch, // or with a manually constructed hash table. size_t stridx(const char *func, size_t count, const char *functable []); void do_code(const char *func) { // Names const char *functable [] = { "label0", "label1" }; // Labels corresponding to names void *jumptable [] = { &&label0, &&label1 }; // Amount of names in table size_t ftcount = sizeof(functable) / sizeof(functable[0]); goto *jumptable[stridx(func, ftcount, functable)]; // Code to execute label0: printf("label0\n"); label1: printf("label1\n"); }[/cpp]
So in c# I have a set of PictureBoxes. I also have a Location called currentLocation. What is the best way to have the currentLocation make the matching PictureBox to that Location visible and all the other ones not visible? Do I do a List? I am pretty new to c# and Visual Studio. Basically it is a house with rooms. I want the graphic for the room (currentLocation) to be visible if I am in that room. But there are other rooms and the graphics are all stacked on each other so I need all the other rooms to not be visible.
Can someone explain hashtags to me like I was 5 years old?
[QUOTE=Funley;41887948]Can someone explain hashtags to me like I was 5 years old?[/QUOTE] Sure, it makes stuff easier to find by marking certain words as #important, so they can be put into a #database. #thatsit [editline]19th August 2013[/editline] If the system doesn't support them, you can still search for the #hashtag with the hash, as the search will only find the marked (important) instances that way (as a hash is an otherwise uncommon character in front of a word).
[QUOTE=Jitterz;41887487]So in c# I have a set of PictureBoxes. I also have a Location called currentLocation. What is the best way to have the currentLocation make the matching PictureBox to that Location visible and all the other ones not visible? Do I do a List? I am pretty new to c# and Visual Studio. Basically it is a house with rooms. I want the graphic for the room (currentLocation) to be visible if I am in that room. But there are other rooms and the graphics are all stacked on each other so I need all the other rooms to not be visible.[/QUOTE] If your currentLocation is the cursor position, you can use the OnEnter and OnLeave function to toggle visibility. Otherwise you can check if the currentLocation is within the bounds of the PictureBox and if not check the neighbors. You can also be smart about it and guess the neighbor from the previous location, unless it was at an edge, where two, or three if you can update the location diagonally, PictureBoxes the location can be in. I think a 2-dimensional array would suffice as data structure. If all rooms have the same size, you can also do [code]Room[width, height] rooms int x, y = currentLocation / (width, height) curRoom.Hide() curRoom = rooms[x, y] curRoom.Show()[/code] (pseudocode)
I'm looking to start making some basic Windows applications (Not metro) using web API's such as the YouTube GDATA API, but I really don't like using C# to do it, to me it just seems to overcomplicate things where in other languages, like PHP and Javascript/jQuery, it's pretty simple. Are there any alternatives to C# for making Windows and potentially Linux apps too which supports a drag-and-drop type IDE for designing the forms?
[QUOTE=benbb;41890301]I'm looking to start making some basic Windows applications (Not metro) using web API's such as the YouTube GDATA API, but I really don't like using C# to do it, to me it just seems to overcomplicate things where in other languages, like PHP and Javascript/jQuery, it's pretty simple. Are there any alternatives to C# for making Windows and potentially Linux apps too which supports a drag-and-drop type IDE for designing the forms?[/QUOTE] There's of course Java, but that arguably complicates stuff even more. Can you give me an example of how it complicates things?
[QUOTE=thf;41890316]There's of course Java, but that arguably complicates stuff even more. Can you give me an example of how it complicates things?[/QUOTE] Like using XML. With PHP there's the SimpleXML library which makes things really darn easy to use. With C# you've got to create a webclient object, then use that to download the XML to a string, and then parsing it with C# is a lot harder too even with XDocument. I don't know, maybe it's that I just need to read up a bit more.
You don't need to parse the string by hand. There's [url=http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx]System.Xml.XmlReader[/url]. [editline]19th August 2013[/editline] XmlReader seems not any easier (or harder) than XDocument. Though I couldn't think of a way to make traversing an XML document easier, other than using some method to deserialize into a class instance representing the information.
[QUOTE=ZeekyHBomb;41859231]Is m_Database.PropertyChanged still correct after you deserialize the Database?[/QUOTE] No it is not, it is a null but I implemented the property changed as I thought that might be the solution for the problem. So if I remove the INotifyPropertyChanged it still works until I sync it.
[QUOTE=benbb;41890301]I'm looking to start making some basic Windows applications (Not metro) using web API's such as the YouTube GDATA API, but I really don't like using C# to do it, to me it just seems to overcomplicate things where in other languages, like PHP and Javascript/jQuery, it's pretty simple. Are there any alternatives to C# for making Windows and potentially Linux apps too which supports a drag-and-drop type IDE for designing the forms?[/QUOTE] You could try running a web application in a window, I [I]think[/I] there's a solution somewhere, but if that fails you could use an embedded web-thing like Awesomium to host the API. Another option would be to use Google's JS code, but [URL="https://jurassic.codeplex.com/"]run it natively in the .NET VM[/URL]. If you do that, you [b]really[/b] should not hotlink it from their servers but ship all code with your app, as there's no sandbox that way afaik. [editline]edit[/editline] It seems Jurassic doesn't automatically expose any system calls, so it may be safe to just run the API normally. I haven't really checked thoroughly though.
[QUOTE=quincy18;41891952]No it is not, it is a null but I implemented the property changed as I thought that might be the solution for the problem. So if I remove the INotifyPropertyChanged it still works until I sync it.[/QUOTE] Well then JsonConvert does not serialize the PropertyChangedEventHandler. When deserializing JsonConvert creates a new Object, so the Database will have a null as EventHandler. Try JsonConvert.PopulateObject(a_Data, m_Database) instead. It keeps the old instance and just sets any members that have been serialized, so I think the EventHandler will be kept alone then.
[QUOTE=ZeekyHBomb;41893169]Well then JsonConvert does not serialize the PropertyChangedEventHandler. When deserializing JsonConvert creates a new Object, so the Database will have a null as EventHandler. Try JsonConvert.PopulateObject(a_Data, m_Database) instead. It keeps the old instance and just sets any members that have been serialized, so I think the EventHandler will be kept alone then.[/QUOTE] Thanks ! It finally works :D
Has anyone used Bullet with Blender? I'm trying to export .bullet files from a Blender scene, however when I load this file my character doesn't collide and begins moving in the -Z direction. Not sure why this is. All I'm doing is this: [cpp]fileLoader = new btBulletWorldImporter(dynamicsWorld); fileLoader->loadFile("test.bullet");[/cpp] However, from the name of the function, it seems to import the whole world, which is not what I want. I want to just import rigid/static bodies, not other things like the solver or dispatcher or anything like that. This is the issue: blender uses the right handed coord system, however it is rotated 90 degrees on the x axis. So when you export as an obj, you get to specify the forward and up axes. However, this is not true for .bullet files. So the solution is simple but stupid. You rotate everything by -90 degrees before you export the scene into a .bullet file.
Anyone know of any guides on how to program fps bot ai? Stuff like behavior, determining where to move, or anything else?
There are book about AI in game programming. If I'm lucky I get to write an AI for a 3D space simulator, but that's still a few months out. But I don't have any real experience beyond Tic-Tac-Toe. General useful techniques are FSMs and Fu (Fuzzy) SMs. Some sort of influence map can also be useful to get the AI to adapt to different surroundings. It'll be easiest if the map designer puts that information on the map, but if the environment is dynamic or you want account for areas the map designer did not think about or just make their work easier (and yours harder) you'll need to somehow analyze the terrain for certain properties. Some interesting properties might be how open or closed it is, the size of it ("can I easily become a target for someone far away?" "is this a good place for mines?" "would an explosives hurt myself here?"), the number of entries/exits ("from how many angles can I be attacked?" "can I easily escape when my heath gets low?"), perhaps also dangers inherent to the map ("can I fall to my death on a narrow path I might easily get pushed off from?"). And some kind of learning system would be interesting, to adapt to the players style or help patch over logic bugs in the AI. You have to gather various statistics for that any apply that information in an appropriate manner. You could also look into neural networks. It's probably not the best tool to base the whole AI on, but perhaps it's a good tool to influence the behavior to some degree. [editline]20th August 2013[/editline] As for path finding, the traditional approach is (or at least used to be in games like Quake, GoldSrc and Source stuff) is a waypoint-system. Either also placed by the map designer or generated by analyzing the map (pre-computed and stored on persistent memory). Then you can use your normal graph-based pathfinding algorithms. I don't know how modern engines like CryEngine or the Unreal Engine do it. You can also take a look at open-source shooters like Xonotic and Red Eclipse.
Sorry, you need to Log In to post a reply to this thread.