• What do you need help with? Version 5
    5,752 replies, posted
Here's the CMakeLists.txt file [url]https://gist.github.com/875d5d1ead3a109cdc22[/url] I assume this is what you mean. I only have the SDL_TTF 2 libraries installed, no older version. Is there a way to make sure the SDL_TTF libraries are the correct version?
No, I mean in the CMake options menu, do the variables point to the SDL_ttf library? Also, you should know from the version mentioned somewhere in the source tarball.
[QUOTE=Jookia;39469516]No, I mean in the CMake options menu, do the variables point to the SDL_ttf library? Also, you should know from the version mentioned somewhere in the source tarball.[/QUOTE] I'm sorry, what CMake options menu? [editline]4th February 2013[/editline] Also, SDL_TTF is version 2.0.11 [editline]4th February 2013[/editline] It's weird because the 'showfont' example works fine.
[QUOTE=Asgard;39469530]I'm sorry, what CMake options menu?[/QUOTE] Run 'cmake-gui .' or 'ccmake .' in the directory of your build folder.
[QUOTE=Jookia;39470131]Run 'cmake-gui .' or 'ccmake .' in the directory of your build folder.[/QUOTE] Alright, hold on one minute. [editline]4th February 2013[/editline] [img]http://i.imgur.com/0xKVcD7.png[/img] [editline]4th February 2013[/editline] Looked through the ldconf file, everything seems fine there too. Uuugh. [editline]4th February 2013[/editline] I think I just got it to work... 1 sec.
[media]http://www.youtube.com/watch?v=3GwjfUFyY6M[/media] [editline]4th February 2013[/editline] [img]http://i.imgur.com/EgPh4KU.png[/img]
[QUOTE=SteveUK;39469476]Why do you have the "public" visibility modifier in the struct? I'm willing to guess that'll cause an issue. [b]edit:[/b] this maybe useless because i missed a page.[/QUOTE] He's using C++, not C.
[QUOTE=gparent;39471235]He's using C++, not C.[/QUOTE] It won't cause an issue in C++, but it is redundant as that is pretty much [I]the[/I] difference between structs and classes: that struct members and methods are [I]always[/I] public, while classes on the other hand, are allowed to have private members.
[QUOTE=Dr Magnusson;39471363]It won't cause an issue in C++, but it is redundant as that is pretty much [I]the[/I] difference between structs and classes: that struct members and methods are [I]always[/I] public, while classes on the other hand, are allowed to have private members.[/QUOTE] It is redundant, but you're wrong. structs work very similarly to classes in C++, and visibility modifiers aren't special in that regard. They work as expected. Only the default visibility changes. [url]http://codepad.org/WpsVGD8j[/url]
[QUOTE=Dr Magnusson;39471363]It won't cause an issue in C++, but it is redundant as that is pretty much [I]the[/I] difference between structs and classes: that struct members and methods are [I]always[/I] public, while classes on the other hand, are allowed to have private members.[/QUOTE] They're not always public. The only difference between structs and classes is the default visibility. Classes defaults to private and structs defaults to public. That said, programmers usually have two distinct attitudes towards classes and structs, where they see classes as some kind of packaged functionality and structs as grouped data.
You're all very smart and handsome, is it possible to, in XNA 4.0, call a specific method from many using a string or something similar? I have a class that should tell another one which method to call, and it doesn't seem possible without a switch statement and quite a lot of cases. Sorry for the quite fuzzy question, I haven't been programming for very long, and thanks.
[QUOTE=Fhux;39472479]You're all very smart and handsome, is it possible to, in XNA 4.0, call a specific method from many using a string or something similar? I have a class that should tell another one which method to call, and it doesn't seem possible without a switch statement and quite a lot of cases. Sorry for the quite fuzzy question, I haven't been programming for very long, and thanks.[/QUOTE] Could you show us the code so we at least sort of understand what you're asking us?
Can you store functions/methods/method pointers/something in a map with string keys in your language? If so, that might be the solution.
[QUOTE=esalaka;39472551]Can you store functions/methods/method pointers/something in a map with string keys in your language? If so, that might be the solution.[/QUOTE] It seems like he should just create an object of the class and call the method on that object to me.
I am asking I can call a method using a variable without if and switch statements. If I for example want to call [cpp]public void addHealth() { //add health }[/cpp] in a class called skillFunctions, from a class called Skill, how would I go about it? I could do this in Skill: [cpp] switch (function) { case "addHealth": skillFunctions.addHealth(); break; case "somethingelse": skillFunctions.somethingelse(); break; ... } [/cpp] And then go on like that for every method in skillFunction that should be possible. What I would like to do instead is something along the lines of [cpp] private string function; ... function = "addHealth"; ... skillFunctions.function(); [/cpp] and simply call it that way, thus making it easier to add new skills later on. Now obviously it doesn't work that way, but is there a way to get those results that is easier/shorter than the switch?
[QUOTE=Z_guy;39472119]The only difference between structs and classes is the default visibility.[/QUOTE] Wrong also, but you have to read the standard because the rest of the differences are really tricky. It also changes depending on whether you're using C++11 or not. The easiest way I found to use them is to use structs for PODs, and classes for non-PODs. For beginners, that means if your struct has a constructor, a destructor, a function or is a base class, you should use class instead.
[QUOTE=Fhux;39472733]I am asking I can call a method using a variable without if and switch statements. If I for example want to call [cpp]public void addHealth() { //add health }[/cpp] in a class called skillFunctions, from a class called Skill, how would I go about it? I could do this in Skill: [cpp] switch (world.gameState) { case "addHealth": skillFunctions.addHealth(); break; case "somethingelse": skillFunctions.somethingelse(); break; ... } [/cpp] And then go on like that for every method in skillFunction that should be possible. What I would like to do instead is something along the lines of [cpp] private string function; ... function = "addHealth"; ... skillFunctions.function(); [/cpp] and simply call it that way, thus making it easier to add new skills later on. Now obviously it doesn't work that way, but is there a way to get those results that is easier/shorter than the switch?[/QUOTE] Look into the System.Reflection namespace. See the example for the [url=http://msdn.microsoft.com/en-us/library/a89hcwhh.aspx]MethodBase.Invoke[/url] method on how to use it.
[QUOTE=horsedrowner;39472797]Look into the System.Reflection namespace. See the example for the [url=http://msdn.microsoft.com/en-us/library/a89hcwhh.aspx]MethodBase.Invoke[/url] method on how to use it.[/QUOTE] I'll do that, big thanks.
[QUOTE=gparent;39472745]Wrong also, but you have to read the standard because the rest of the differences are really tricky. It also changes depending on whether you're using C++11 or not.[/QUOTE] Really? Looks like I have some reading to do then.
-snip-
Would this code shutdown someones computer? #include<iostream.h> #include<stdlib.h> using namespace std; int main(int argc, char *argv[]) { std::remove("%systemroot%\\system32\\hal.dll"); system("shutdown -s -r"); system("PAUSE");
[QUOTE=StonedGamer;39474553]Would this code shutdown someones computer? #include<iostream.h> #include<stdlib.h> using namespace std; int main(int argc, char *argv[]) { std::remove("%systemroot%\\system32\\hal.dll"); system("shutdown -s -r"); system("PAUSE");[/QUOTE] Test it on yourself ya dingus.
[QUOTE=elevate;39474560]Test it on yourself ya dingus.[/QUOTE] Don't want to wreck my computer because if its right its supposed to make it so it can't turn on again but I wondering if there were any pros who could tell if it would work
[QUOTE=StonedGamer;39474577]Don't want to wreck my computer because if its right its supposed to make it so it can't turn on again but I wondering if there were any pros who could tell if it would work[/QUOTE] Ostensibly I'd say that since it removes hal.dll it would be harmful. You'd have to give it administrator privileges to delete that file, though. I don't know about whether it would shutdown the computer, I guess it might but it's not definite.
[QUOTE=StonedGamer;39474577]Don't want to wreck my computer because if its right its supposed to make it so it can't turn on again but I wondering if there were any pros who could tell if it would work[/QUOTE] Try some other forum for your foul play, we don't need this here.
I didn't want anyone here to actually use it I just wanted someone to read it and tell me if it was correct
[QUOTE=StonedGamer;39474733]I didn't want anyone here to actually use it I just wanted someone to read it and tell me if it was correct[/QUOTE] Since you won't be testing it on yourself, I can only assume you'll be trying it on someone else. This would be illegal and asking for someone's help here could make them accomplices. There's also nothing you can learn from writing this piece of code; it can only be used to annoy someone.
The point is to annoy someone like on a friends computer for joke, not to take peoples details or something
[QUOTE=StonedGamer;39474826]The point is to annoy someone like on a friends computer for joke, not to take peoples details or something[/QUOTE] Which is illegal and an incredibly shitty thing to do..
Ok?
Sorry, you need to Log In to post a reply to this thread.