• What do you need help with? V. 3.0
    4,884 replies, posted
[QUOTE=mechanarchy;32605846]You only mentioned looking in the right-click build options menu, so I thought I'd mention it anyway. I'm not sure what the problem is - you're using CB 10.05 like me, and the platform shouldn't make any difference in this case. The only thing I thought might have been an issue was if it was a virtual target, did you try looking for the search directories tab under 'OgreNewt' instead of 'all'? :S If all else fails, you can do what I do - write your own makefiles :v:[/QUOTE] Nope. It's the same menu for all of them. Also, using the complete directory wouldn't do much good because I'd have to edit all the boost files for that to work. Well, I guess I can just try making the project myself, but the only instruction to do that which was included was "Good luck", so that might take a while. Anyways I'm having tests so I'll leave this stuff for next week. Thanks for trying to help though :smile:
Alright, I'm new to C++, to help me improve I am recreating a simple text-game I made in Python. But I can't figure out how do the following properly in C++. In python I have: [code] def debugmenu(): -debug stuff with an option to go back to the main menu that calls menu()- return def menu(): -menu stuff with an option to go to the debug menu that calls debugmenu()- return [/code] I tried to re-create this in C++ like this: [code] void debugmenu () { -debug stuff with an option to go back to the main menu that calls menu ()- } void menu () { -menu stuff with an option to go to the debug menu that calls debugmenu ()- } [/code] I get the error: error: 'menu' was not declared in this scope I tried moving the debug menu to be below the main menu but then I get the same error but about debugmenu. Any ideas on how to fix this?
[QUOTE=AntonFTW;32606209]I get the error: error: 'menu' was not declared in this scope I tried moving the debug menu to be below the main menu but then I get the same error but about debugmenu. Any ideas on how to fix this?[/QUOTE] Write a header. Prototype the function in the header. It [i]should[/i] work if you moved debugmenu after menu, but write a header anyway. That's the clean way to do these things.
[QUOTE=AntonFTW;32606209]Alright, I'm new to C++, to help me improve I am recreating a simple text-game I made in Python. But I can't figure out how do the following properly in C++. In python I have: [code] def debugmenu(): -debug stuff with an option to go back to the main menu that calls menu()- return def menu(): -menu stuff with an option to go to the debug menu that calls debugmenu()- return [/code] I tried to re-create this in C++ like this: [code] void debugmenu () { -debug stuff with an option to go back to the main menu that calls menu ()- } void menu () { -menu stuff with an option to go to the debug menu that calls debugmenu ()- } [/code] I get the error: error: 'menu' was not declared in this scope I tried moving the debug menu to be below the main menu but then I get the same error but about debugmenu. Any ideas on how to fix this?[/QUOTE] Comments in C++ are "//" or "/*" and "*/". For example: [cpp] // This is a one-line comment /* This is a multi-line comment */ [/cpp]
God I haven't posted in programming for ages, decided to work on my game some more. Quick question, whats a good way of going about gravity? I currently have it at yvelocity += 1.f * t (t = time), but it starts off too slow for my liking. I was thinking of starting it off at say 5 pixels per second, but I have it so that the player is not grounded unless proven grounded. Anyone have any other better ideas? Also, my jumping is way off. I was it to start off fast but slow down closer to the end, kind of like a parabola. I'm currently setting the velocity to be -40.f, and then decreasing it each frame by the gravity, however with the way things are right now the player shoots up indefinitely. I guess the second question will be solved once I get gravity down though.
[QUOTE=AntonFTW;32606209]I get the error: error: 'menu' was not declared in this scope I tried moving the debug menu to be below the main menu but then I get the same error but about debugmenu. Any ideas on how to fix this?[/QUOTE] To clarify what ROBO_DONUT was saying, your code in 'debugmenu' is basically saying it has no idea there's a function called 'menu' that exists. You can swap the order, like you did, but that doesn't work. So the solution is to basically have a huge list of everything up the top and say "These are all the functions that exist", then later on you'll say what they actually do. So in our scenario, [cpp] // Tell the compiler we have these two functions void debugmenu(); void menu(); void debugmenu() { // now we can actually call menu() without issues ... menu(); } void menu() { // same thing for debugmenu ... debugmenu(); } [/cpp] This, of course, starts getting very messy when you have more than one source file. So now we move on to having Header files (.h) and Source files (.cpp). In your headers, you'll say what the functions exist (like the two lines at the top of my example) and in the source files, you'll say what those functions actually do (like the two function blocks in my example). It gets a bit more complicated too when you start having dependency issues but we'll get to that later :)
[QUOTE=AntonFTW;32606209]I get the error: error: 'menu' was not declared in this scope I tried moving the debug menu to be below the main menu but then I get the same error but about debugmenu. Any ideas on how to fix this?[/QUOTE] Sounds like your debugmenu() function is calling your menu() function, and vice versa. That's not a good way to structure your program. If menu() has called debugmenu(), and debugmenu() then calls menu(), that's not going [i]back[/i] to where you were, it's starting [i]another[/i] instance of menu(). If the player goes back and forth between the main menu and the debug menu a few times, you end up with main() waiting for debugmenu() to finish, but debugmenu() is waiting for another invocation of main() to finish, but that main() is waiting for yet another invocation of debugmenu() to finish, and so on. Two better ways you could do this: First, have main() call debugmenu(), but when the debug menu is "done", let it [i]return[/i] back to its caller &#8212; either with an explicit "return;" statement, or just by letting execution reach the end of the function. When it returns, control goes back to the place it was called from, which in this case would be the line in main() that follows the debugmenu() call. Doing it this way means your menu navigation must have a tree-like structure: from a parent menu, the user can choose to go to a submenu, and when they leave the submenu, they automatically return back to the parent menu. Second, you could (instead) define an enumeration for the different kinds of menus: [cpp] enum MenuType { MENU_MAIN, MENU_DEBUG, MENU_SOMETHING_ELSE, // etc. }; [/cpp] and have a variable somewhere that keeps track of what the "current" menu is: [cpp] MenuType current_menu; [/cpp] and use it to decide what to do, like this: [cpp] void menu_driver() { while (!quit) { switch (current_menu) { case MENU_MAIN: mainmenu(); break; case MENU_DEBUG: debugmenu(); break; case MENU_SOMETHING_ELSE: someothermenu(); break; default: std::cerr << "Internal error: unknown menu type" << std::endl; quit = true; } } } [/cpp] and mainmenu(), debugmenu(), etc. would each display a menu, read the user's input, assign a new value to current_menu if appropriate, and return so that menu_driver() can call whatever menu function should be called next. This design is more complex, but it lets any menu send the user directly to any other menu; it's not limited to tree-like navigation.
[QUOTE=WTF Nuke;32612989]God I haven't posted in programming for ages, decided to work on my game some more. Quick question, whats a good way of going about gravity? I currently have it at yvelocity += 1.f * t (t = time), but it starts off too slow for my liking. I was thinking of starting it off at say 5 pixels per second, but I have it so that the player is not grounded unless proven grounded. Anyone have any other better ideas? Also, my jumping is way off. I was it to start off fast but slow down closer to the end, kind of like a parabola. I'm currently setting the velocity to be -40.f, and then decreasing it each frame by the gravity, however with the way things are right now the player shoots up indefinitely. I guess the second question will be solved once I get gravity down though.[/QUOTE] Gravity should be squared I believe. So yvelocity += (1.f * t)^2.
The y velocity increases downwards at a constant rate due to gravity. Hence, your first equation is correct. Just set a maximum velocity at a certain value.
Anyone know a way in java to rotate an image without making all the other objects in that panel to also rotate?
Sorry. I'll post my solution. So here's my celsius to Fahrenheit conversion [code]def temp(): celsius = raw_input("Enter a temperature in Celsius: ") try: float(celsius) except ValueError: print ("Please enter a real number.") return temp() else: fahr = float (celsius) * 9 / 5 + 32 print celsius, 'degrees C =', fahr, 'degrees F' temp()[/code] Works perfectly, see? Now I had broken code as shown below. [code]def temp(): fahr = raw_input("Enter a temperature in Fahrenheit: ") try: float(fahr) except ValueError: print ("Please enter a real number.") return temp() else: celsius = [highlight]float (fahr) - 32) / 1.8[/highlight] print fahr, 'degrees F =', celsius, 'degrees C' temp()[/code] What I realized was that my float(fahr) with the exception wasn't actually converting the variable to a float because of the else statement. I thus made the corrections as shown below. [code]def temp(): fahr = raw_input("Enter a temperature in Fahrenheit: ") try: float(fahr) except ValueError: print ("Please enter a real number.") return temp() else: celsius = [highlight](float(fahr) - 32) / 1.8[/highlight] print fahr, 'degrees F =', celsius, 'degrees C' temp()[/code] Sorry for not sharing my answer. This is my first post in this section, haha. My apologies. [sp]In short: I was trying to subtract an integer from a string. You can't subtract numbers from characters.[/sp]
[QUOTE=Tukimoshi;32626704][b]I figured it out. Thanks for being a good source for help though! :D[/b][/QUOTE] Don't bother telling us your problems and how you fixed it, you know, in case somebody also has the same problem in future.
[QUOTE=Jookia;32627747]Don't bother telling us your problems and how you fixed it, you know, in case somebody also has the same problem in future.[/QUOTE] Omg guys I have cancer what do. [b]Edit:[/b] nvm figured it out
[QUOTE=Samuka97;32628526]Omg guys I have cancer what do. [b]Edit:[/b] nvm figured it out[/QUOTE] what happened
[QUOTE=Jookia;32627747]Don't bother telling us your problems and how you fixed it, you know, in case somebody also has the same problem in future.[/QUOTE] This is why I try, the times I post for help, to post again later with the answer if I find it. I dont know how many times I have searched google for a problem, found a forum with someone who had the same one, with "never mind, someone told me" written as an edit.
[QUOTE=nekosune;32628984]This is why I try, the times I post for help, to post again later with the answer if I find it. I dont know how many times I have searched google for a problem, found a forum with someone who had the same one, with "never mind, someone told me" written as an edit.[/QUOTE] Yeah, sorry guys. I was lacking common sense, so I edited my post with my 'changelog'. It was a very simple problem on my part (Failing at order of operations) but I'm sure someone might have the same problem one-day so :D
buy zithromax 500mg in usa without prescription fast shipping zithromax package insert [url=http://buy-azithromycin.weebly.com]buy zithromax 250mg in usa online[/url] - buy online azithromycin buy azithromycin in usa online zithromax order online [highlight](User was permabanned for this post ("Spambot" - Swebonny))[/highlight]
Ok I fixed my jumping. This is what I did [cpp]if (GUI->W && grounded){ jumpvelocity = -185.f *3; grounded = false; } if (jumpvelocity < 0){ yvelocity = jumpvelocity * t; jumpvelocity += 185.f*t *9; } else if(!grounded){ yvelocity += 1.f * t; } else{ yvelocity = 0.f; }[/cpp] Basically I made it so that if there is jumping velocity, it applies that instead of 1 pixel per second acceleration. It travels 185 pixel up, however I multiplied the value by 3 to make it go faster, and I multiplied the gravity adder by 9 because I forget why but it works so I left it at that.
Simple question, Is CodeBlocks an okay compiler... I MEAN, IDE for a beginner in C++? [B]Edit:[/B] Thanks Jookia. (I didn't want to needlessly bump the thread)
[QUOTE=littlefoot;32631099]Simple question, Is CodeBlocks an okay compiler... I MEAN, IDE for a beginner in C++?[/QUOTE] Yep.
Okay so I feel like this is a dumb question but I can't seem to figure it out nor find any help on google. I'm using visual studio, a project using XNA and a physics library. I was using the provided .dll of the library previous to my issue, but now I want to use the most recent revision, which is all source code and not compiled. How the hell do I use it? Like integrate it back into my project like the .dll was?
Either compile it yourself and reference the compiled dll or add the project to your VS solution and reference it from there.
[QUOTE=Fox-Face;32632931]Either compile it yourself and reference the compiled dll or add the project to your VS solution and reference it from there.[/QUOTE] Yeah I just now got it working... figures. Thanks!
How would you match both of these with 1 regex and capture the key/value? [key] value key = value
Kso I'm trying to create a program that encrypts text (using the "Caesar Cipher" method) but I'm having problems taking the individual characters from the text that the user wants encrypted and replacing them with another letter. So if the user enters the letter "a" and they chose a number between 1-26 to "shift" the letter (If they chose 13, you would count 13 letters down the alphabet from "a", which would be "m"). Sorry I'm terrible at explaining this, what I'm trying to do is get the individual letter, and replace it with the letter that is 'x' letters down in the alphabet (x being the number between 1-26). I was thinking something along the lines of taking the letter, assigning it to a variable and then somehow increasing that variable by 'x' which would correspond to the letter that is 'x' letters away from the 'independantCharacter' and yeah... Sigh. Here's what I have so far, probably explains what I'm trying to do better than all that <---. [CODE]#include <iostream> #include <sstream> #include <string> using namespace std; int main() { string userText,indChar,shiftHold; int userTextSize,uTpos,shifts; cout<<"Enter some text to encrypt: "<<endl; getline(cin,userText); userTextSize=userText.size(); uTpos=0; //'uTpos' will hold '0' for the do..while loop. cout<<endl; /*cout<<"Enter a number between 1 and 26 (the closer the number is to 13, the better): "<<endl; getline(cin, shiftHold); stringstream(shiftHold)>>shifts;*/ do{ indChar=userText[uTpos]; //if (shifts<0 || shifts>25) continue; cout<<"Slot "<<uTpos<<":\t"<<indChar<<endl; //Adding a tab makes the decrypted and encrypted letters cleaner when uTpos hits double digits. uTpos++; }while(uTpos<userTextSize); char cont; cout<<endl<<"Press any key and enter to continue..."<<endl; cin>>cont; return 0; }[/CODE] [QUOTE]Output: Enter some text to encrypt: Blah blah blah Slot 0: B Slot 1: l Slot 2: a Slot 3: h Slot 4: Slot 5: b Slot 6: l Slot 7: a Slot 8: h Slot 9: Slot 10: b Slot 11: l Slot 12: a Slot 13: h Press any key and enter to continue... [/QUOTE]
[QUOTE=high;32634274]How would you match both of these with 1 regex and capture the key/value? [key] value key = value[/QUOTE] [i]^\[?(.+?)]?(\s=)?\s(.+)$[/i] Works in Perl, no promises it'll work in what you're using. (Or if you give it anything other than that data)
[QUOTE=DeltaSmash;32634383]Kso I'm trying to create a program that encrypts text (using the "Caesar Cipher" method) but I'm having problems taking the individual characters from the text that the user wants encrypted and replacing them with another letter.[/QUOTE] What you'd need to do is: * Convert the character to uppercase using toupper() (#include <cctype> for this). Making everything the same case simplifies the steps that follow, and the cipher would be less effective if it didn't conceal capitalization anyway. * Check that the character is actually a letter. If it's less than 'A' or greater than 'Z', pass it through unchanged or abort with an error message or something. The reason for doing this [i]after[/i] calling toupper() is that now you don't have to include lowercase letters in the range you check against. And toupper() passes non-letters through unchanged. * Subtract 'A' from the letter to get its position in the alphabet. That is, 'A' becomes 0, 'B' becomes 1, and so on. * Add your "key" number, and take the result modulo 26. That's done with the modulus operator, %, which makes things "wrap around" to zero if they go past the maximum you specify: 25 % 26 == 25, 26 % 26 == 0, 27 % 26 == 1, and so on. Rather than hard-coding the number 26 in your program, it'd be better to write something like (('Z' - 'A') + 1). * Add 'A' to convert the modified alphabet position back into an actual letter. 0 becomes 'A', 1 becomes 'B', and so on.
[QUOTE=high;32634274]How would you match both of these with 1 regex and capture the key/value? [key] value key = value[/QUOTE] It's best [I]not[/I] to do it in one regex pattern, because it will also match a lot of invalid entries like: key] = value
[QUOTE=jA_cOp;32637598]It's best [I]not[/I] to do it in one regex pattern, because it will also match a lot of invalid entries like: key] = value[/QUOTE] Can't you have a OR operator to differ between the 2 different cases? I'm not that good with regex though. EDIT: I put together this: ^(\w+ = \w+)|(\[\w+\] \w+)$ I'm not sure about capture groups, but would they work if put around \w+ ?
how do i make a program read an input number as percent? [QUOTE] if (number1 > number2 && number3) { cout << "The first number is greater than the other two" << endl; } else if (number2 > number1 && number3) { cout << "The second number is greater than the other two" << endl; } else if (number3 > number1 && number2) { cout << "The third number is greater than the other two" << endl; } else if (number1 == number2 == number3) { cout << "The numbers are equal" << endl; } else { cout << "Two numbers are equal, the third is not" << endl; }[/QUOTE] also why doesnt this work correctly? it keeps saying number2 is greater these are just school tasks that are run in cmd or whatever its called
Sorry, you need to Log In to post a reply to this thread.