• What Do You Need Help With? V6
    7,544 replies, posted
anyone know a thing about making mysql databases in PHP that would be willing to troubleshoot some issues I'm having? I'm doing a short database lab for a server side scripting class and having trouble wrapping my head around table creation and viewing
[QUOTE=Rofl my Waff;42735978]anyone know a thing about making mysql databases in PHP that would be willing to troubleshoot some issues I'm having? I'm doing a short database lab for a server side scripting class and having trouble wrapping my head around table creation and viewing[/QUOTE] Sure, I can help if you want.
[QUOTE=mobrockers;42736012]Sure, I can help if you want.[/QUOTE] Cool! I just need to be pointed in the right direction. I'm going to add you on steam if you don't mind
[QUOTE=Rofl my Waff;42736036]Cool! I just need to be pointed in the right direction. I'm going to add you on steam if you don't mind[/QUOTE] Yeah sure
So I have a bunch of angles in degrees, how would I convert that in to a directional Vector2 ? e.g. 90 degrees would be 1,0.
x = sin(ang) y = cos(ang) [editline]3rd November 2013[/editline] You may have to convert the angle into radians.
Awesome thanks, I should really work on my math. [t]http://puu.sh/57sZg.png[/t]
[QUOTE=Richy19;42731682]Out of curiosity, could this be a permission issue? Try running codeblocks as admin I used to have this issue all the time, tho codeblocks errored saying the location .../sfoo.exe was inaccessible[/QUOTE] I tried that too, and it didn't solve the problem. I have been working on my project for two days using the terminal to compile after the problem appeared, and today I tried to compile in Code::Blocks and it appears that the problem magically disappeared. What the fuck.
[QUOTE=reevezy67;42741987]Awesome thanks, I should really work on my math. [t]http://puu.sh/57sZg.png[/t][/QUOTE] If you have repeating angles like that you can also multiply the (unit) vectors as imaginary numbers to find the next ones: x' = x² - y² y' = 2xy That doubles the angle in relation to the x axis in mathematical/OpenGL coordinates (and squares the length). If you multiply again x'' = x³ - 3xy² y'' = 2x²y + x²y - y³ that's three times the angle and the length cubed. It's probably faster to just solve this iteratively with x = x_1 * x_2 - y_1 * y_2 y = x_1 * y_2 + x_2 * y_1 though if you need the intermediary steps anyway. The most interesting property of this method for your application is probably that it outputs logarithmic spirals with any vector length other than 1. [editline]3rd November 2013[/editline] I mean complex numbers, not imaginary ones. Edit's broken again. Multiplying them adds the angles.
I just did: bullet number * (360/amount of bullets) to get the angles for each bullet. Good enough. :suicide:
my professor is certain that this program i wrote does not work. i have tested it multiple times on my computer and notice no problems with it. anyone mind compiling it and seeing if it works? its supposed to not do anything unless the letter c is inputted followed by the letter s(so c - enter - s), then print a congratulatory message. he says it skips to the message as soon as you type in c. [code] #include <stdio.h> int main() { char ch; // Input character int done = 0; // Flag that signals when the loop should // terminate; that is, when 'c' followed by ’s’ // has been input. puts("You have before you a closed door."); scanf("%c", &ch); // Insert a loop that keeps reading and processing characters // until the user inputs the character 'c' followed by the // character 's' (if ever) while(!done) { if(ch == 'c') { //Second input character, to check if the user enteres in 's' char ch2; scanf("%c", &ch2); if(ch2 == 's') done = 1; } else scanf("%c", &ch); } //Open the door. puts("The door opens. Congratulations!"); } [/code]
[img]http://puu.sh/58hCe/a73e59d18b.png[/img] No problems here.
-snip
Guys, i have an issue. In visual basic(I'm taking a programming class and my teacher is less than helpful) how do i make it so that when i click certain radio buttons, multiple images pop up on a single picture box? She's trying to imply that i should stack multiple picture boxes and use a Show() segment when i click the buttons to display each one.
You can modify the [url=http://msdn.microsoft.com/en-us/library/system.windows.forms.picturebox.image.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1]Image[/url]-property.
How do I read and write to a file, an ArrayList of HashMaps? i.e public ArrayList<HashMap<String, String>> readDataFromFile(String file) and public void writeDataToFile(ArrayList<HashMap<String, String>> data, String file)
[QUOTE=bull3tmagn3t;42755573]How do I read and write to a file, an ArrayList of HashMaps? i.e public ArrayList<HashMap<String, String>> readDataFromFile(String file) and public void writeDataToFile(ArrayList<HashMap<String, String>> data, String file)[/QUOTE] Write: [cpp] try { ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(yourFileName)); out.writeObject(yourArrayList); } catch(IOException e) { e.printStackTrace(); } [/cpp] Read: [cpp] try { ObjectInputStream in = new ObjectInputStream(new FileInputStream(yourFileName)); ArrayList<yourObject> yourArrayList = (ArrayList<>)in.readObject(); } catch(IOException | ClassNotFoundException e ) { e.printStackTrace(); } [/cpp] From: [url]http://stackoverflow.com/a/16536064[/url]
Hey guys, so I've been in a beginner C++ course for the past semester and I'm having a little trouble with my types of variables, perhaps you can help me out. So pretty much my code is showing the comparison between the Babylonian method of square roots, Halley method of square roots, and the cmath library sqrt function. The problem is I can't get my code to be precise enough. My professor's example showed the result 20 decimal points over, and I can only get it to 12. I know it has to do something with my variable size, since I changed line 33 from int to double, which brought it from where it was originally to my 12 now. However, I'm not sure if there's somewhere else in the code that I'm missing that requires itself to be double, or if it needs to be a double long. When I add double to other parts of the code, the result is wrong. But when I switch line 33 to a double long, the compiler doesn't show any results, it just sits there executing and not showing any results. Here's the code. The input I'm using is 9922338833 [cpp]#include <iostream> #include <cmath> #include <iomanip> using namespace std; double babylonianSquareRoot(int digits, double initial, int value); double halleySquareRoot(int digits, double initial, int estimate); int wholeNumberOfDigits(int number); int main() { double digits, initialnumber, x0=3; // Used in calling functions. This is line 33 cout << "Enter a number to find the square root : "; cin >> initialnumber; // User inputted initial value digits = wholeNumberOfDigits(initialnumber); // Figure out number of digits required for baby/halley for (int n = 1; n < digits; n++){ x0 *= 3; } cout << "\n\nSquare root approximation by using the Babylonian Method is\n" // 43 to 50 is simply calling functions << setprecision(20) << fixed << babylonianSquareRoot(digits, initialnumber, x0); cout << "\n\nSquare root approximation by using the Halley Method is\n" << halleySquareRoot(digits,initialnumber,x0); cout << "\n\nSquare root by cmath function sqrt is\n" << sqrt(initialnumber) << endl << endl; return 0; } int wholeNumberOfDigits(int number){ // Required for halley and baby functions. int result; while (number > 0) { number /= 10; result++; } return result; } double babylonianSquareRoot(int digits, double initialvalue, int estimate){ double result, x0; x0 = estimate; for (int i=0; i <= digits; i++){ result = ((x0 + (initialvalue/x0))/2); // Previous result(or initial estimate) multiplied by the result of the user inputted number divided by previous result x0 = result; //All of it is divided by two. } return result; } double halleySquareRoot(int digits, double initialvalue, int estimate){ double result, x0; x0 = estimate; for (int i=0; i <= digits; i++){ result = ((x0*((x0*x0)+3*initialvalue))/(3*(x0*x0)+initialvalue)); //Pretty much the same function as babylonian, just with a different forumla x0 = result; } return result; }[/cpp]
I need a little help when it comes to choosing exactly how to expose frametime for smoothing movement and controls in my engine. I've been scratching my head over 2 main possible solutions, if you have any insight on what would be the best choice long term it would be very helpful. 1. lastFrameTime, a variable updated each frame which is exposed directly to scripting. This is the easiest option by far since I can hook into my profiler to get the value. This would match what XNA and other API's expose. 2. scale(targetValue, ticksPerSecond), called on demand by code which will internally hook into the profiler or a variable. My thinking with this is to reduce the work required to scale the frametime factor depending on the context. If you have any other ideas on what approach to take they would also be helpful.
Learning about OpenGL, could anyone give an elegant description of the most used/vital steps in the render pipeline openGL has? Like: "Vertex shader lets you modify the points of a shape on a screen", etc
[QUOTE=Vbits;42761769]I need a little help when it comes to choosing exactly how to expose frametime for smoothing movement and controls in my engine. I've been scratching my head over 2 main possible solutions, if you have any insight on what would be the best choice long term it would be very helpful. 1. lastFrameTime, a variable updated each frame which is exposed directly to scripting. This is the easiest option by far since I can hook into my profiler to get the value. This would match what XNA and other API's expose. 2. scale(targetValue, ticksPerSecond), called on demand by code which will internally hook into the profiler or a variable. My thinking with this is to reduce the work required to scale the frametime factor depending on the context. If you have any other ideas on what approach to take they would also be helpful.[/QUOTE] You'll need the raw value more often I think, so always expose that to scripts. With the scale funtion you're trading a multiplication for a function call + multiplication + division, which is hardly better.
[QUOTE=Tamschi;42762986]You'll need the raw value more often I think, so always expose that to scripts. With the scale funtion you're trading a multiplication for a function call + multiplication + division, which is hardly better.[/QUOTE] Quite true. Looking into how other engines handle the same issue it seems that lastFrameTime would be the best option but renamed to deltaTime fit in with other engines.
Having an issue with my logic in a C++ project. Here's my code [URL]http://pastebin.com/SrP8EVZE[/URL] The issue is, I'm trying to grab all the names from a file that looks like this [code]brock lee 5 260 adam balm 8 110 ophelia payne 9 114 sarah sunshine 3 102 pikupann dropov 4 112 duane pipe 5 85 [/code] And put them on an output file. but the results of my while loop are coming out like this [code]adam balm 8 110 ophelia payne 9 114 sarah sunshine 3 102 pikupann dropov 4 112 duane pipe 5 85 duane pipe 5 85[/code] I want it to be essentially an exact dublicate of the original file.
Hello again, everyone. So, I'm working on a project where we create a file for "retiring" and you get the age of the person from a .dat file. I'm cruising along just fine, until i get to the point of needing to pull the age to do the math. My inputLine.subsr part works just fine with the string data, to get the names, but i feel like i'm missing something from the actual numbers. [code] const int RETIREMENT_AGE = 67; string lastName; string firstName; string inputLine; int currentAge; int yearsleft; double age; //get input //cout << "What is your name? "; //cin >> name; //cout << "How old are you?"; //cin >> currentAge; //cout << "At what age would you like to retire? "; //cin >> retirementAge; //open files for use/declare them: ifstream input; ofstream output; input.open("C:\\Retire.dat"); output.open("C:\\Retire.out"); //pull info from file. //"Aaron White Age: 27" getline(input, inputLine); lastName = inputLine.substr(6,5); firstName = inputLine.substr(0,5); currentAge = inputLine.substr(17,2); //perform calculations yearsleft = RETIREMENT_AGE - currentAge ; [/code] That's what i've got. I feel like i'm just missing something super simple with pulling the number to use as the age. I've tried double, and int, but neither of those worked either. What do you all think?
[QUOTE=JohnStamosFan;42770372]Hello again, everyone. So, I'm working on a project where we create a file for "retiring" and you get the age of the person from a .dat file. I'm cruising along just fine, until i get to the point of needing to pull the age to do the math. My inputLine.subsr part works just fine with the string data, to get the names, but i feel like i'm missing something from the actual numbers. [code] const int RETIREMENT_AGE = 67; string lastName; string firstName; string inputLine; int currentAge; int yearsleft; double age; //get input //cout << "What is your name? "; //cin >> name; //cout << "How old are you?"; //cin >> currentAge; //cout << "At what age would you like to retire? "; //cin >> retirementAge; //open files for use/declare them: ifstream input; ofstream output; input.open("C:\\Retire.dat"); output.open("C:\\Retire.out"); //pull info from file. //"Aaron White Age: 27" getline(input, inputLine); lastName = inputLine.substr(6,5); firstName = inputLine.substr(0,5); currentAge = inputLine.substr(17,2); //perform calculations yearsleft = RETIREMENT_AGE - currentAge ; [/code] That's what i've got. I feel like i'm just missing something super simple with pulling the number to use as the age. I've tried double, and int, but neither of those worked either. What do you all think?[/QUOTE] What do you mean? The datatype int should work just fine for an age. Sounds more like there is an issue with where the needle is pointing to at inputLine.substr(17,2). what happens if you do cout << currentAge; underneath the string manipulation statements?
[QUOTE=JohnStamosFan;42770372]Hello again, everyone. So, I'm working on a project where we create a file for "retiring" and you get the age of the person from a .dat file. I'm cruising along just fine, until i get to the point of needing to pull the age to do the math. My inputLine.subsr part works just fine with the string data, to get the names, but i feel like i'm missing something from the actual numbers. That's what i've got. I feel like i'm just missing something super simple with pulling the number to use as the age. I've tried double, and int, but neither of those worked either. What do you all think?[/QUOTE] [code] #include <iostream> #include <fstream> #include <string> #include <conio.h> int main() { std::ofstream Output("D:/output.dat", std::ios::binary); std::ifstream Input1("D:/input1.dat", std::ios::binary); std::string outp; { std::string firstname, lastname; unsigned int age; // Input file format: Aaron White 27 Input1 >> firstname >> lastname >> age; // ifstream breaks at whitespace, newline or end of file so we can just presume the format in the input file is correct outp = firstname + " has " + std::to_string(67 - age) + " years left to retirement"; } std::cout << outp << std::endl; Output << outp; _getch(); return 0; }[/code] This method does not stick to a fixed amount of characters. At the moment everything will break if the formatting is not completely as expected, you could implement that functionality if you wish.
I'm relying in some external libraries. However it is a pain to always copy/paste the dll's into the debug or release folder. Is there a way to automate this?
You can copy them into system32, which kinda pollutes a system directory though. Alternatively you can look into build-systems like CMake. I'm not sure if they take care of the dll also or if it just sets the required flags for the compiler and linker though. And you would need to maintain the build-script. What are you using right now to manage your builds? Visual Studio? You could write a batch script to fetch the dlls from somewhere and execute it as a post-build step.
[QUOTE=Sergesosio;42775747]I'm relying in some external libraries. However it is a pain to always copy/paste the dll's into the debug or release folder. Is there a way to automate this?[/QUOTE] Seeing as you say dll's im guessing you are using VS? You can add them as a project file and set to copy to output, or setup a post build command and have them copy over automatically that way
[QUOTE=Rofl my Waff;42769672]Having an issue with my logic in a C++ project. Here's my code [URL]http://pastebin.com/SrP8EVZE[/URL] The issue is, I'm trying to grab all the names from a file that looks like this [code]brock lee 5 260 adam balm 8 110 ophelia payne 9 114 sarah sunshine 3 102 pikupann dropov 4 112 duane pipe 5 85 [/code] And put them on an output file. but the results of my while loop are coming out like this [code]adam balm 8 110 ophelia payne 9 114 sarah sunshine 3 102 pikupann dropov 4 112 duane pipe 5 85 duane pipe 5 85[/code] I want it to be essentially an exact dublicate of the original file.[/QUOTE] I'm not sure why the last line appears twice, but the missing first line can be fixed simply by removing line 48. You can more easily write the whole contents using dout << din.rdbuf();, but I'm guessing you did this just to debug something. A few other things: Usage of system("pause") and system("cls") is discouraged. You should easily find stuff on the internet about that. The general consensus is, that you should declare/define variables as late as it makes sense. There's usually little reason to declare them all at the top. I personally find the names "fName" and "lName" rather unhelpful. What's wrong with "firstName" and "lastName"? Readability gets increased a lot and you only need to type a little more. "userWght" also. When in doubt, prefer double over float. You have constants for the welcome message, which seem to allow easy changes to the message, but the alignment in the console seems to depend on a fixed length of the messages. And further more, it seems to require a certain terminal size. There are ways to obtain the dimensions of the console buffer on Windows through the WinAPI if you want to go through the trouble of making sure it always looks well. You don't need to manually close the files; they will close themselves when the variable goes out of scope. This is a pattern called RAII. And the spacing looks weird in some places, like all but the first the cout-lines being alinged and ... what is this even in the commented CalcBAC line? Though I'm guessing this might be due to some pastebin or edit-after-paste error.
Sorry, you need to Log In to post a reply to this thread.