419 Posted Topics
Re: [QUOTE]void sethpmax(){hpmax = lvlhp[lvl - 1];}; void setexpmax(){expmax = lvlexp[lvl - 1];}; Random arrays assigned to int? This should not even compile. [/QUOTE] This looks fine to me. Hes assigning the units health to whatever is at lvlhp[lvl-1] is. So if the guy is level 5 it would be lvlhp[5-1] … | |
Re: Put one do()while() within the other do()while() so it keeps looping unless you are done your game loop and when you do not want to play again. Doing this you will want to have two variables instead of having both as done. | |
Re: It will only output the last letter because a char type is only one character. You can use a string and add the letters onto that then output the word with outFile. | |
Re: You are missing return 0; at the bottom of your main function. | |
Re: Without compiling I see on line # 9 you have used T[size) instead of T[size]. | |
Re: Put a condition in where it will only output if it is not the last element or break outta the loop if it is on the last element instead of displaying a comma. [CODE]#include <iostream> using namespace std; int main() { int myArray[] = {1,2,3,4,5,6,7}; int szArray = sizeof(myArray)/sizeof(int); cout … | |
Re: That looks like you copy pasted it off someone elses post because of all the # sitting between the lines. | |
Re: You could just create an int called sum with an initial value of 0 and then make a for() loop just add all the elements to sum one by one until the end of the vector. | |
Re: Like 4olkata said use [ICODE]cin >> n1 >> n2 >> n3;[/ICODE] because the comma does not work like that in C++. Also [ICODE]abs(n1)[/ICODE] does nothing because that will just return the absolute value of n1. You want [ICODE]n1 = abs(n1);[/ICODE] because this will assign n1 to the absolute value of … | |
Re: First of all you havent declared nSel any where but you are using it, so put [ICODE]int nSel = 0;[/ICODE] before the cout lines or something (just before usage). Then for your while loop you should make it so it loops while nSel is not 1 AND 2 not or. … | |
Re: You can use the % (mod) operator to get the remainder of one number divided by another. ie 72 % 10 = 2 <--- your first digit | |
Re: First off I would switch from Dev-C++ because it is a dead IDE. Use Code::Blocks or Visual C++ that is more current (I use Code::Blocks and had switched from Dev-C++ -- the transition wasn't that hard). As for the whole having a window and cmd prompt up at the same … | |
Re: I switched made the function return a bool because you are returning false on a void function and ran it and it "broke" and made my motherboard speaker go off like a christmas song for like 3 min. | |
Re: Use a do{}while() to loop in main() I would not recommend calling main(). [CODE]int main() { char askLoop; do //do enters the loop weather or not the condition at the bottom is met on the first run { double tax, pay; termlength_determine(); cout << "how much do you get paid … | |
Re: It would take a while to write a program like this without flaws and you would have to think hard but if you look there is a pattern. There are never more than 3 of the same "digits" in a row and its always high digits to low digits, left … | |
Re: Windows uses handles for letting the user/program control elements of the Windows environment (not 100% sure how to explain this). So line 10 is getting the output handle and saving its memory address into the pointer hcon. This is then passed into SetConsoleTextAttribute() on line 11 and has its color … | |
Re: After looking over your code the problem seems to be in main(). You have it so when you input your selection it sets the choice and the space THEN checks to see if the space is 0 or not. This will never be 0 because you are setting it before … | |
Re: [CODE]#include <iostream> using namespace std; int main() { cout << "Hello world!" << endl; return 0; }[/CODE] This is the start of a program now go throw on some ints and add them together. Once that works figure out how to use a container ( list, vector, array... ) and … | |
Re: Not 100% sure why you are using an array to store your character since you are only using 1. Also when you make an array [ICODE]char answer[1];[/ICODE] that means that it has a size of 1 and it starts at 0 so you would use it like [ICODE]if( answer[0] == … | |
![]() | Re: Personally I would start with just using a single variable instead of trying to make a list work because that just adds more complexity to something that you are trying to figure out. And if you are going to then just use the std namespace to shorten and clean the … ![]() |
Re: Your expe keeps building because you keep adding itself with the new random exp to itself. If you want to just add the amount of exp for killing that goblin then you need to just assign the random exp gained to expe (like you did for loot). In other words … | |
Re: This example uses a do while loop to keep asking for the user input if it is not correct. A do while loop will enter the loop no matter what the value of the variable that you are checking against is but will check at the end. In this case … | |
Re: Way too much to see whats going on and the line numbers are off with your errors. Try to create a small program that uses your polygon class in a similar way to see whats going on with it. Plus this is C++ why not use a vector (or another … | |
Re: float rational would be of type float rational myRationalNumber would be type rational | |
Re: In the <ctime> header there is a function called clock() and it tells you in miliseconds the amount of time passed since the start of the program. If you are testing one algorithm this will mostlikly give a value of 1 or 0. A way around this is to run … | |
Re: This is an example using string stream and c++ strings using a similar format to what you posted above. [CODE]#include <iostream> #include <sstream> using namespace std; class DATE { int day, month, year; public: DATE(); DATE(string d); int GetDay(); int GetMonth(); int GetYear(); }; DATE::DATE( string d ) { stringstream … | |
Re: You can do 2 things for this. #1 save all the points into a container and plot them each time #2 make the board once outside of the infinite loop and plot the points on within the loop The following code shows #2 because I think it is the best … | |
Re: An easy way to think of a string is that its an array of characters in C and a vector of characters in C++. Meaning it can hold any character. If you want something like " ' or \ in it you need to put an escape character before it … | |
Re: I fixed it up so it actually runs but I removed the whole height_in_feet variable because it was not being used. Since there are so many errors I would suggest you relearn the basics of functions. Check this against yours and see where you went wrong. [CODE]#include <iostream> using namespace … | |
Re: The problem that really stands out for me is your output area. You are using [ICODE]cout << "text" << +a;[/ICODE] and [ICODE]cout << "text" << +a+ "moretext" << +b << endl;[/ICODE] When using cout only use + for adding numbers together. For output you just need to go [ICODE]cout << … | |
Re: Try this [CODE]slong** newarray = 0; for( int i = 0; i < limitsqr; i++ ) newarray[i] = new slong[limit];[/CODE] | |
Re: Made a few changes to it and it works fine. Read the comments. [CODE]#include <iostream> #include <string> //use string not cstring using namespace std; //move using namespace std; up here int main() { string str2; cout<<"Enter a line of input for str2: "; getline (cin, str2); //remove cin >> str2; … | |
Re: You guys know this post is 4 years old right? | |
Re: Also your formula for converting is wrong it is 5.0/9.0 not 5.0/8.0. | |
Re: The way you are doing it says int/int*(int*int)+int you want everything multiplied to be a float otherwise it converts it to an int. 1/2 gives the answer 0 because integers do not have decimals. 1.0/2.0 gives the answer 0.5 because doubles/floats do have decimals. So the way to write what … | |
Re: You need to add a break after case 1 because it just runs into case 2 which makes it output "twenty" Here is another way to do this with strings and arrays. [CODE]using std::string; int numToText(int num) //function to return text version of number entered { string ones[] = { … | |
Re: Not sure why you are making it so complicated and you are using a int function when the way you have it you could use a void function. [CODE]int SumIt(int x, int y) { if( x == y ) return x; int high = x, low = x, sum = … | |
Re: A .dll file is a dynamic linker file which has to be included with the .exe if you do not use the static linker file. If you add the .a or .lib file (static linker) then you do not need the .dll file but the size of the .exe will … | |
Re: I'm not sure what coefs is an array of (I'm guessing ints) but the pow() function returns a double so you would run into more casting problems there. I would just use the c-style casting for this problem unless you need to use C++ style type-casting. [CODE]sum += coefs[i]*(int)pow((double)x, (double)degree);[/CODE] | |
Re: Could have something to do with depth. Lets see some source code and then I'll be able to help you out more. | |
Re: I see other people have posted already but I am going to show what I did as well. In the code I just put the Date class and anything to do with Date in because the Actor class was not fully shown in the code you posted. I cleaned it … | |
Re: Those are defined in the windows.h header and they are set that way for consistency since every data-type they have defined is in all capitals. They have other ones like BYTE for char and a whole bunch more. Just look up windows typedefs and you should find lots. | |
Re: I looked through your code and you should not use perspective when you are trying to render something that is 2D. So use glOrtho() this way everything is flat (no depth). In your render() and initialize() functions remove gluLookAt(); And use this code for your SetupProject() function [CODE]void SetupProjection() { … | |
Re: As visitor11 said you need to put the variable to be assigned on the left hand side of the equals sign otherwise it will try to assign number%10 and it cannot do that. C++ uses operators to do multiplication division addition subtraction and it does not use brackets for multiplication. … | |
Re: If you aren't using the animate function right now comment it out or make the function and just don't have anything in it (currently you have the prototype but no real definition and that is what is giving the error). Also when I read through your code your stick man … | |
Re: You need to start with a simple program to understand what is going on because some of the questions you are asking are extremely basic where if you had looked at other examples (easier) you would know generally what is going on with it. '1' = player 1 '2' = … | |
Re: You should really format your code so other people can read it. I commented in a few things that I did and do not put function prototypes within other functions. [CODE]#include <iostream> #include <fstream> #include <string> #include <iostream> #include <string> #include <cctype> // for std::isspace(), etc. void print_tokens(const std::string &data); … | |
Re: You can create a window without buttons or a boarder and create your own buttons using the mac images and then bind windows functions to them. | |
Re: You have your for loops all messed up so it is outputting sections more than once in a row. [CODE]#include <iostream> using namespace std; int main() { int num = 0; cout << "How big do you want the pyramid? "; cin >> num; for( int i = 0; i … | |
Re: I bought the red book and blue book and I did get the OpenGL tutorials off gametutorials.com I would say they are good for learning a bit of stuff but not worth 35 bucks (35 for just OpenGL and DirectX tutorials). NeHe's website is really bad and I would suggest … |
The End.