Search found 106 matches
- January 19th, 2013, 2:26 pm
- Forum: Everything
- Topic: How to instialize an array of classes( in progress )
- Replies: 40
- Views: 15866
Re: How to instialize an array of classes
Remove "srand( (unsigned int) time ( NULL ) );" from your particle class and put it inside your Game constructor instead. Game::Game( HWND hWnd,const KeyboardServer& kServer,const MouseServer& mServer ) : gfx( hWnd ), audio( hWnd ), kbd( kServer ), mouse( mServer ) { srand( time ( NULL ) ); for(int ...
- January 19th, 2013, 1:00 am
- Forum: Everything
- Topic: How to instialize an array of classes( in progress )
- Replies: 40
- Views: 15866
Re: How to instialize an array of classes
It seems in your ComposeFrame(); function you try to iterate through 20 elements, but there are only 10 in the array.
- January 19th, 2013, 12:43 am
- Forum: Everything
- Topic: How to instialize an array of classes( in progress )
- Replies: 40
- Views: 15866
Re: How to instialize an array of classes
Ah that's because the default constructor also needs a definition. If you don't want it to do anything you can just add the curly braces in the .h file.
And yeah you can overload constructors just like you can overload functions.
Code: Select all
Particle(){}
- January 19th, 2013, 12:22 am
- Forum: Everything
- Topic: How to instialize an array of classes( in progress )
- Replies: 40
- Views: 15866
Re: How to instialize an array of classes
I might be wrong but wouldn't using 'new' create an object on the heap? and wouldn't that require the array to be an array of pointers? Anyway, if you're creating an array of classes i think the class needs a default constructor because every class calls its constructor when its created. But since t...
- January 17th, 2013, 11:35 pm
- Forum: Everything
- Topic: creating a class [solved]
- Replies: 9
- Views: 3302
Re: I'd need some help with classes please
Since pKbd and pGfx are pointers to the objects, rather than the objects themselves, you need to use -> to access them.
I named them differently than the actual objects to save confusion.
Code: Select all
pGfx->DrawLine();
- January 17th, 2013, 9:58 pm
- Forum: Everything
- Topic: creating a class [solved]
- Replies: 9
- Views: 3302
Re: I'd need some help with classes please
Do you mean it says "no default constructor"? When you create a class object you need to pass it all the things that its constructor requires. Player charlie( &gfx, &kbd ); I think the best place to create your player would be as a private member of the Game class. Now i don't think you can initiali...
- January 17th, 2013, 4:54 pm
- Forum: Everything
- Topic: creating a class [solved]
- Replies: 9
- Views: 3302
Re: I'd need some help with classes please
The way you would use private members of a class is make a public function that does what you want and then call that instead. So for your draw line problem, you could give your Player class a Draw(); function, this function would have access to Players private members. As for why you cant use the k...
- January 17th, 2013, 12:02 am
- Forum: Everything
- Topic: Making barriers with loops.
- Replies: 6
- Views: 2869
Re: Making barriers with loops.
No problem Csharp, hope you get it working. Maybe just ignore my last idea, I'm not sure how to do that myself. Stick with testing every pixel, its easier on the brain. I don't know if things get easier but the way i see it, once you learn something, you'll never have to learn it again. Thats what i...
- January 16th, 2013, 10:49 pm
- Forum: Everything
- Topic: Making barriers with loops.
- Replies: 6
- Views: 2869
Re: Making barriers with loops.
You would basically use the draw line function but not inside an if statement. Once it's found the x and y of a pixel on the line, instead of calling PutPixel to draw it, test if its inside the box. if( x >= box.x && x < box.x + box.width && y >= box.y && y < box.y + box.height ) { // There is a col...
- January 16th, 2013, 5:06 pm
- Forum: Everything
- Topic: Making barriers with loops.
- Replies: 6
- Views: 2869
Re: Making barriers with loops.
I've never done it either but it might be a lot more complicated then it sounds. I think you would have to test every pixel on the line for a collision, then you'd need find out how far away the box is from the center of the line because the further away from the center, the faster the line moves an...