2,712 Posted Topics

Member Avatar for crapgarden

Yea so this is a problem of collision response. Once a collision is detected what do you do? Well in this case you should move your player back just before the collision point. So if there is a collision, shift back the player's position so that there is not a …

Member Avatar for mrnutty
0
186
Member Avatar for mrnutty

This question is from code chef, named Odd. I believe this is a good problem to play with for all levels. If I can solve it surely anyone else can, cough * only if pi is fake* cough*. Here is the question : [ICODE]The captain of the ship TITANIC is …

Member Avatar for nezachem
1
675
Member Avatar for vedro-compota
Member Avatar for infogirl

I think the syntax is int rowSize = 5; int colSize = 5; float **matrix = new float*[rowSize]; for(int i = 0; i < rowSize; ++i){ matrix[i] = new float[colSize]; } //do stuff with matrix[i][j] //delete for(int i = 0; i < rowSize; ++i){ delete [] matrix[i]; } delete [] …

Member Avatar for mrnutty
0
152
Member Avatar for Kulasangar

You can think an Abstract class as a class that combines the similarity of many things into one object. Thus when inheriting from the ABC, you will have to type less redundent code.

Member Avatar for mrnutty
0
140
Member Avatar for cresenia1988
Member Avatar for mrnutty
0
195
Member Avatar for phorce

If you convert the matrix of double into a matrix of chars, you might lose some data since char cannot hold the same range of data as double can. You can copy like so `std::vetor<unsigned char> pixels(matrix.begin(),matrix.end())`. What problem are you having exactly?

Member Avatar for m4ster_r0shi
0
136
Member Avatar for nuclear

glTranslate translate the current view matrix, not just one object. So it can be used for different things

Member Avatar for nuclear
0
264
Member Avatar for sarathsshanker

How are the commands stored? One approach is to do something of the following: struct Command{ /* whatever makes a command, insert variables here */ friend ostream& operator>>(ostream&, Command& cmd){ //given a stream, try to read in a command } } int main(){ //open file and stuff std::vector<Command> commands; Command …

Member Avatar for mrnutty
0
195
Member Avatar for garu525

Your Edge class can be stripped down to this class Edge { public: Edge() { } Edge(int from, int to, double weight = -1) : from (from), to (to), weight (weight) { } int from; int to; bool directed; double weight; }; Since the compiler generated functions will suffice. In …

Member Avatar for mrnutty
0
282
Member Avatar for stormik

So you are trying to read in a input from cin and you want to save only the inputs that starts with a number or a negative sign, and any other type of input you want to insert back into istream? Is that right? Do you have to reinsert them …

Member Avatar for stormik
0
327
Member Avatar for cessna172

>>Why are you taking pain by handling memory yourself. Use power of STL. Its ironic, because C++ has a stack implementation already. So why even do what you did above?

Member Avatar for mrnutty
0
2K
Member Avatar for LdaXy

[URL="http://msdn.microsoft.com/en-us/library/ewwyfdbe(v=vs.80).aspx"]Bit Fields[/URL]

Member Avatar for LdaXy
0
215
Member Avatar for FALL3N

You probably forgot to seed it. Try this: [code] #include <iostream> #include <ctime> using namespace std; int main(){ srand( time(0) ); //seed the RGN for(int i = 0; i < 10; ++i){ std::cout << (rand() % 100 + 1) << std::endl; } return 0; } [/code]

Member Avatar for FALL3N
0
279
Member Avatar for Chuckleluck

[QUOTE=Chuckleluck;1779100]Can someone give me some resources (books, online tutorials, etc.) on algorithms for 2D collision detection? I've searched a little, and all the ones I can find are for 3D collision detection. Thanks in advance. EDIT: Just to clarify, I know [I]how[/I] to do collision detection, just not efficiently.[/QUOTE] which …

Member Avatar for raptr_dflo
0
303
Member Avatar for CodeNinjaMike
Member Avatar for K0ns3rv

[URL="http://stackoverflow.com/questions/369438/smooth-spectrum-for-mandelbrot-set-rendering"]http://stackoverflow.com/questions/369438/smooth-spectrum-for-mandelbrot-set-rendering[/URL]

Member Avatar for K0ns3rv
0
410
Member Avatar for Chuckleluck

>>Now, all my pieces have no unique "rules" on how they act Well it should if c_ChessPiece has proper virtual functions? Btw, not a fan of the class-prefix. For example take a look at [URL="https://github.com/dchhetri/SFML-Chess/blob/master/ChessGame/ChessPiece.h"]this[/URL] interface. A ChessPiece should at least have some uniform functions, like move and such. So …

Member Avatar for mrnutty
0
182
Member Avatar for jtbens01

First you should be using templates. But the solution to your problem is to provide a virtual clone function. Look [URL="http://www.parashift.com/c++-faq-lite/virtual-functions.html#faq-20.8"]here[/URL] for more information.

Member Avatar for mrnutty
0
132
Member Avatar for Labdabeta

>>I am storing many variables of different types. Can you convert/encode all those variables to a string version?

Member Avatar for Labdabeta
0
250
Member Avatar for CppBuilder2006

Not sure what technique you used, but in comp Sci its usually done by making the matrix in echelon form and multiplying the diagonal numbers Nice job though.

Member Avatar for aruldave
2
461
Member Avatar for evanovan
Member Avatar for triumphost

[QUOTE=triumphost;1772191]Uhh well that's the thing.. I want to allow "empty parameters" and that's why I need to check.. so that I can do: [CODE] class DoStuff { private: void Insert(){} vector<Types> Meh; public: DoStuff() {} //This constructor doesn't get kicked in due to the one below it.. template<typename T, typename... …

Member Avatar for mrnutty
0
4K
Member Avatar for jigglymig

I'm not sure what exactly you are saying. What is a binary tree with 1 and 2? Maybe a picture would help.

Member Avatar for mrnutty
0
173
Member Avatar for _Nestor

You would want to use the concept of iterators, and just assume certain property like being able to move forward. Check out [URL="http://www.cplusplus.com/reference/algorithm/find/"]http://www.cplusplus.com/reference/algorithm/find/[/URL] for more reference.

Member Avatar for _Nestor
0
258
Member Avatar for singularity~

[QUOTE=BDove;1766255]In my opinion [B]"++"[/B] in C/C++ is just terrible. I don't even know why they allow it to be part of the language. Try [CODE]pID = pID + 1;[/CODE] [B]"++"[/B] increment its value by 1 and assigns it to the variable. However, if the operator is inserted inside a conditional …

Member Avatar for singularity~
0
239
Member Avatar for grh1107

>>[B]M- happens to be a unknown function of N[/B] That means, M = f(N), and you can't assume anything about f(N), so the runtime would be O(N * f(N)). That could be linear, polynomial, quadratice, factorial, or whatever; all depending on f(N)

Member Avatar for mrnutty
0
315
Member Avatar for rigoalhn

What do you need help with? Maybe this will get you started. [code] #include <iostream> using namespace std; bool isPrime(int number){ bool isPrimeNumber = false; //do logic here return isPrimeNumber; } int main(){ cout << boolalpha << "Is 5 prime : " << isPrime(5) << endl; //should be true cout …

Member Avatar for ravingdragoon
0
226
Member Avatar for sergent

Maybe someone will correct me, but I believe its just convention. But WinMain does have extra parameter options than int main() which might become useful. But a thing to note is that returning in WinMain really doesn't do much since its returned value is passed to ExitThread instead of ExitProcess.

Member Avatar for jmichae3
0
2K
Member Avatar for gabriellogan

I still don't know what 0R1,0R2,0S4,1S4 does! Can you give an example of what each of the instruction should do on some input

Member Avatar for gabriellogan
0
128
Member Avatar for phorce

If you want to read the file into a vector, then you can represent each pixel as a char or int. For example you can have something like so, [icode] std::vector<char> pixels; [/icode] and read from file into that vector. For example: [code] std::vector<char> pixels; ifstream fileInput("imagefile.txt"); //read from file …

Member Avatar for mrnutty
0
87
Member Avatar for solarcoder

[CODE]INPUT-BUFFER: 973 456.2 77F NEWLINE 973 456.2 77F 1) cin>> m; //m = 973 INPUT-BUFFER: 456.2 77F NEWLINE 973 456.2 77F 2) cin.clear (); //clears the state bits INPUT-BUFFER: 456.2 77F NEWLINE 973 456.2 77F 3) cin.ignore (200, '\n'); //ignores 200 characters or until a new line is reached INPUT-BUFFER: …

Member Avatar for deceptikon
0
156
Member Avatar for tom12

Check out [URL="http://www.cplusplus.com/reference/string/string/erase/"]string::erase[/URL]

Member Avatar for Ancient Dragon
0
926
Member Avatar for wildplace

You know if you use std::vector, it does that for you. [code] int main(){ std::vector<int> array; //size = 0; array.push_back( 1) ; //size = 1, [1] array.push_back(5); //size = 2, [1,5] } [/code]

Member Avatar for mrnutty
0
5K
Member Avatar for phorce

There are better ways of doing it, here is one examples. [code] typedef std::vector<int> Matrix; //alias Matrix getMatrix(){ return Matrix(10,1); //returns an array with 10 elements each initialized to 1 } int main(){ Matrix m = getMatrix(); for(int i = 0; i < m.size(); ++i){ cout << m[i] << endl; …

Member Avatar for phorce
0
205
Member Avatar for phorce

[QUOTE]Matrix 1: 0 1 0 1 0 1 0 1 0 1 1 1 1 0 1 [/QUOTE] What's the data type of Matrix?

Member Avatar for mrnutty
0
107
Member Avatar for pattmorter

>>//Given x=10 and y=5 y = 2*y++ + --x; y = (2*y++) + (--x) //substitute, not valid but easier to see y = (2 * 5++) + (--10); y = (2 * 5) + (--10) //5++ returns 5 first then increments, so 5 will be multiplied to 2 y = …

Member Avatar for Ali_2101
0
194
Member Avatar for triumphost

Adding to above, change this [code] ANew() : ArrayOfTypes(0) {}[/code] to this [code] ANew(){} [/code] The vector will be default constructed already

Member Avatar for mike_2000_17
0
162
Member Avatar for ret801

Maybe you should look at the definition of artificial. Here it is. [b]Artificial:[/b] 1) Made or produced by human beings rather than occurring naturally, typically as a copy of something natural: "artificial light". 2) Not existing naturally; contrived or false: "the artificial division of people into age groups". * found …

Member Avatar for Rashakil Fol
0
245
Member Avatar for yongj

[QUOTE=yongj;1757973]Thank you all for the replies. Do you guys have any online references? I'm mainly trying to find online resources.[/QUOTE] [URL="http://en.wikipedia.org/wiki/Hash_table"]Wiki[/URL] is usually a good place to start!

Member Avatar for yongj
0
173
Member Avatar for mrnutty

Check out the [URL="http://en.wikipedia.org/wiki/Boggle"]wiki[/URL] for boggle. You job is to create a program that generates all possible words that can be constructed given the boggle board and a dictionary. A word has to be of length three or greater and the word has to exist in the dictionary. For example …

Member Avatar for mrnutty
0
267
Member Avatar for inspire_all

Learn the concept first! When I say learn it, I mean know it inside and out. Its easy to pick up a language once you get the concept down. Stick with one language for now, and use it for your needs. Program data structures using that language and become a …

Member Avatar for WaltP
0
128
Member Avatar for Labdabeta

When you run a program, it creates a process for that program. So when you call exit within that process, the os kills that process and cleans up memory. As for its actual implementation, I do not know. It is most likely implementation specific, that is I don't think there …

Member Avatar for Labdabeta
0
224
Member Avatar for badboy11
Member Avatar for student_learner

You can look at previous days/weeks/months/years data and observe the context at which the price was stated and then look at the current situation of the stock/company then make a educated prediction based on the information.

Member Avatar for mrnutty
0
67
Member Avatar for rfrapp

Sometimes it helps to see concrete examples: [code] int r1 = rand() ; //random number from [0 , RAND_MAX] int r2 = rand() % 100; // random number from [0,100); Note doesn't include 100 int r3 = rand() % 100 + 1; //random number from [1,100]; Note includes 100 const …

Member Avatar for skorm909
0
2K
Member Avatar for triumphost
Member Avatar for mrnutty
0
234
Member Avatar for chuyauchi

[URL="http://www.cplusplus.com/reference/iostream/ios_base/precision/"]http://www.cplusplus.com/reference/iostream/ios_base/precision/[/URL]

Member Avatar for mrnutty
0
193
Member Avatar for Labdabeta

[QUOTE=NathanOliver;1752223]Yes you can Overide any operator you want. This can be done globally or at a specific level.[/QUOTE] [url]http://www.parashift.com/c++-faq-lite/operator-overloading.html#faq-13.5[/url]

Member Avatar for Labdabeta
0
200
Member Avatar for MasterGberry

You can basically do a 'binary split adding the middle every split. I tried coding something real quick and here it is: [code] #include <iostream> #include <cmath> #include <iterator> #include <vector> using namespace std; template<typename T, typename Result> void _splitImpl(T begin, T end, Result& result); template<typename RandomAccessIterator> std::vector<int> binarySplit(RandomAccessIterator begin, …

Member Avatar for mrnutty
0
199

The End.