Jump to content
  • Advertisement
Sign in to follow this  
jadybray

anyone know what wrong

This topic is 4080 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

does anyone know whats wrong with this? void Difficulty(level); Invader inv[10]; int 1,2; char level; main() { cout << "Please select difficulty level 1 or 2" << endl; cin >> level; void Difficulty(level); return 0; } void difficulty(level) { if(level == 1) { for(int i = 0; i < 10; i++) { inv.setImage("C:\\2\\Hornets.gif"); inv.setVelocity(Vector2D(2,0)); Vector2D currPos = inv.getPosition(); currPos.x = currPos.x + i * 60; inv.setPosition(currPos); } } if(level == 2) { for(int i = 0; i < 10; i++) { inv.setImage("C:\\222E3\\Hornets.gif"); inv.setVelocity(Vector2D(1,0)); Vector2D currPos = inv.getPosition(); currPos.x = currPos.x + i * 60; inv.setPosition(currPos); } } } thank you. [Edited by - jadybray on April 19, 2007 5:12:43 PM]

Share this post


Link to post
Share on other sites
Advertisement
1. Your function is called "difficulty", not "Difficulty". Verify the consistency between naming your functions and calling them.
2. Don't put the "void" in front of the difficulty function call. You only need the return type of a function in its signature.
3. main should have a return type of int and return 0.

Those are the three things that stick out the most, aside from the fact that you're missing #includes.

Share this post


Link to post
Share on other sites
I haven't been reading your code in detail but you need
to do the following:

Put these two lines in the top of your file:

#include <iostream>
using namespace std;

that code will make the use of cout and cin possible.

I suppose that you've included the required lib(s) for Vector2D and Invader?

and you should consider writing:

int main()
{
///your code here...
return 0;
}


That's all I can see right now, hope it helps.

Good luck!

Share this post


Link to post
Share on other sites
first thing that jumps out at me is:

int 1,2;

No variable names starting with numbers.

int var_1, var_2;
would be more appropriate.

If that is all your code, you are missing includes as well. Are you getting compiler errors?

Share this post


Link to post
Share on other sites
sorry I have all the #include files and classes set up properly and eveything s working fine except I keep getting this error:

error C2448: 'Difficulty' : function-style initializer appears to be a function definition

if you click on it highlights the opening brace in the function definition.

Share this post


Link to post
Share on other sites
1) the declaration of the difficulty function needs to appear before main in the file

2) you declared the function with a lower case 'd' but you are calling it with an upper case 'D'. C/C++ are case sensitive. "Difficulty" is a different name than "difficulty".

-me

Share this post


Link to post
Share on other sites
try this:


//assuming you have includes here
void difficulty(char level);
Invader inv[10];
int var_1,var_2;
char level;

int main()
{
cout << "Please select difficulty level 1 or 2" << endl;
cin >> level;
difficulty(level);

return 0;
}

void difficulty(char level)
{
if(level == '1')
{
for(int i = 0; i < 10; i++)
{
inv.setImage("C:\\2\\Hornets.gif");
inv.setVelocity(Vector2D(2,0));
Vector2D currPos = inv.getPosition();

currPos.x = currPos.x + i * 60;
inv.setPosition(currPos);

}
}
if(level == '2')
{
for(int i = 0; i < 10; i++)
{
inv.setImage("C:\\222E3\\Hornets.gif");
inv.setVelocity(Vector2D(1,0));

Vector2D currPos = inv.getPosition();

currPos.x = currPos.x + i * 60;
inv.setPosition(currPos);

}
}
}


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!