• What do you need help with? V4 (January 2012)
    966 replies, posted
[QUOTE=reevezy67;34046984]Nothing wrong with that from what I can see. it's obviously something wrong with your placement of some code or even a random key you didn't mean to press. Like how this returns the error you get. [csharp]using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { HI HERE IS THE ERROR class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); } } }[/csharp][/QUOTE] But the error points in the text file, not in my code.
[QUOTE=Funley;34047030]But the error points in the text file, not in my code.[/QUOTE] No matter what I do I can't seem to recreate the error. Can you post the full error with filepaths.
[QUOTE=reevezy67;34047153]No matter what I do I can't seem to recreate the error. Can you post the full error with filepaths.[/QUOTE] Error 1 A namespace cannot directly contain members such as fields or methods C:\Users\S\Documents\Visual Studio 2010\Projects\NewLand\NewLand\NewLand\titles.txt 1 2 NewLand
delete/rename titles.txt and compile it.
[QUOTE=reevezy67;34047187]delete/rename titles.txt and compile it.[/QUOTE] Now it wont error until i run the program as it cant find the file.
Because it's in a try/catch if its text file related it will just show an error in console. Do it and see if the error when you compile is gone. [editline]5th January 2012[/editline] I'm still lost as to why you are getting this error the text file should have nothing to do with an error when you try compile.
[QUOTE=reevezy67;34047229]Because it's in a try/catch if its text file related it will just show an error in console. Do it and see if the error when you compile is gone. [editline]5th January 2012[/editline] I'm still lost as to why you are getting this error the text file should have nothing to do with an error when you try compile.[/QUOTE] I took the code out of the try/catch and it gives the error: "Could not find file 'C:\Users\S\Documents\Visual Studio 2010\Projects\NewLand\NewLand\NewLand\bin\x86\Debug\title.txt'." I checked the project files and the problem is that VS is compiling the program, it does not add the text file to the project files.
oh where did you have title? By default if you just give the streamreader a filename it will look in the same folder as the executable otherwise you have to define the whole file path. I usually do something like this which looks in a folder that is in the same directory as the exe for it so you don't get all the clutter with the exe. = new StreamReader(@"\Data\tiles.txt");
You have the text file included in your project. Right-click it and make it either a resource or exclude it. e: To elaborate: right-click the text file inside VS, select Properties. Set 'Build Action' to None and 'Copy to Output' to Copy Always or Copy if Newer. This way it copies the text file automatically when you build your project.
[QUOTE=raBBish;34047328]You have the text file included in your project. Right-click it and make it either a resource or exclude it. e: To elaborate: right-click the text file inside VS, select Properties. Set 'Build Action' to None and 'Copy to Output' to Copy Always or Copy if Newer. This way it copies the text file automatically when you build your project.[/QUOTE] Yes, it works. Thanks!
I'm using Slick and all my sprites are drawing about 20 pixels higher than they should be, but only when I run in windowed mode. Wat? [editline]4th January 2012[/editline] Scratch that, 40 pixels.
[QUOTE=Nigey Nige;34048152]I'm using Slick and all my sprites are drawing about 20 pixels higher than they should be, but only when I run in windowed mode. Wat? [editline]4th January 2012[/editline] Scratch that, 40 pixels.[/QUOTE] Sounds like you're not taking the window title into account. Graphics APIs usually have some kind of inner height/width which you should use.
So, I run FFT through samples. Then I get two frequency spectrum s, one real and another imaginary. How can I join those two together to gain only real data?
Why does XNA continue to the end of the current function after Game.Exit() is called?
[QUOTE=Funley;34060784]Why does XNA continue to the end of the current function after Game.Exit() is called?[/QUOTE] It doesn't change the control flow, the game will only exit once and pending updates/draws are done. It might be an idea to 'queue' an exit, i.e. have a flag to remember if the game is exited and if it's set, call Game.Exit() at the end of update.
I really want to learn about artificial neural networks, genetic algorithms and so on. Does anybody know a decent source to learn from?
What's the best way to separate playable characters from NPC's?
[QUOTE=NotoriousSpy;34062958]What's the best way to separate playable characters from NPC's?[/QUOTE] Abstract a "Character" class, then derive an NPC class and Player Class.
[QUOTE=thisBrad;34062984]Abstract a "Character" class, then derive an NPC class and Player Class.[/QUOTE] Would I store my game objects in a System.Collections.Generic.List?
[QUOTE=NotoriousSpy;34062958]What's the best way to separate playable characters from NPC's?[/QUOTE] 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.
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?
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(); [/code] I need to know how to get the iterator to move to the item a user tells it to.
[QUOTE=muckuruxx;34071827]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(); [/code] I need to know how to get the iterator to move to the item a user tells it to.[/QUOTE] [cpp]auto it = std::find(your_vector.cbegin(), your_vector.cend(), gameToRemove);[/cpp] 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.
[QUOTE=raBBish;34072085][cpp]auto it = std::find(your_vector.cbegin(), your_vector.cend(), gameToRemove);[/cpp] 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.[/QUOTE] Thanks!
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 [I]want[/I] to have the overlay being left out. Its a bit of a pickle, I'm not sure how to approach it :/
I'm writing the FFI side of a virtual machine, code is here: [url]http://pastebin.com/wDm3k7cn[/url] 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: [url]http://haible.de/bruno/documentation/ffcall/avcall/avcall.html[/url] 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 [I]store[/I], and an arbitrary number of arguments. It finds the lookup table, the function inside it, checks the value of [I]store[/I] 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 &#8216;int main()&#8217;: sample.cpp:86:5: error: address of overloaded function with no contextual type information[/CODE] Line 86 being: [CODE] av_start_void(L,&findLookupTable); [/CODE] 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); [/CODE] Which returns: [CODE] $ g++ sample.cpp -I/usr/include -lavcall -std=gnu++0x sample.cpp: In function &#8216;int main()&#8217;: sample.cpp:85:5: error: expected primary-expression before &#8216;void&#8217; sample.cpp:85:5: error: expected &#8216;)&#8217; before &#8216;void&#8217; sample.cpp:85:68: error: expected &#8216;)&#8217; before &#8216;;&#8217; token sample.cpp:85:68: error: expected &#8216;)&#8217; before &#8216;;&#8217; token [/CODE]
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
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; [/code] I know I could do a readline until fFile.eof() but that is kinda hacky , isn't it?
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.
[QUOTE=marcin1337;34082296]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; [/code] I know I could do a readline until fFile.eof() but that is kinda hacky , isn't it?[/QUOTE] while(fFile.good()) sFileBuffer << fFile << std::endl; [editline]6th January 2012[/editline] 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. [cpp] 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; } [/cpp] [code] a N2ws5tools5hooks12_GLOBAL__N_111hookmanagerIIPNS_2ui2wm6windowEEEE 0x4f8618 c N2ws5tools5hooks12_GLOBAL__N_111hookmanagerIIPNS_2ui2wm6windowEEEE 0x4f8400 [/code] It only doesn't work for some argument lists. Does anyone know why it creates a static object twice for the same template arguments?
Sorry, you need to Log In to post a reply to this thread.