ok could you please see my code

srand(time(NULL));
    system("MODE CON: COLS=90 LINES=360");
    system("TITLE Press ^<ESC^> to exit");
    cout <<      "Press <ESC> to exit\n\n";
    int   milliseconds = 500;
    char  key=0, esc=27;
    while(key != esc)
    {
	
     int villain = rand();
     system("cls");
   
       char wall = 177, flute = 14, hero = 2,
        life_hero = 3,life_evil = 3,villain1=1, bomb = 15,
        fish = 21;
         keys();       
         cout <<"                   +------------------+                          "<<endl;
         cout <<"                   |                  |                          "<<endl;
         cout <<"                   |         "<<fish<<"        |                          "<<endl;            
         cout <<"                   |                  |                          "<<endl;
         cout <<"                   |                  |                          "<<endl;
         cout <<"  +----------------+--------   -------+---------------+     "<<endl;
         cout <<"  |                         "<<life_evil<<""<<life_evil<<""<<life_evil<<"                       |     "<<endl;
         cout <<"  |                         "<<villain<<"                       |     "<<endl;
         cout <<"  |                          "<<hero<<"                        |     "<<endl;
         cout <<"  |                         "<<life_hero<<""<<life_hero<<""<<life_hero<<"                       |     "<<endl;
         cout <<"  +----------------+--------   -----+-----------------+     "<<endl;
         cout <<"  |                |                |                 |     "<<endl;
         cout <<"  |                |                |                 |     "<<endl;
         cout <<"  |                                                   |     "<<endl;
         cout <<"  |                |                |                 |     "<<endl;
         cout <<"  |                |                |                 |     "<<endl;
         cout <<"  +----------------+----------------+-----------------+     "<<endl;

please compiler this code to test it

now can you see the 'vallian' varible?

every time i want the villaian to move right,middle,left randomly

please help

waiing for you

Recommended Answers

All 11 Replies

Hmm you didn't include the headers in the code above.
And you're using system a lot, I probably won't be able to test it then, because it seems like Windows commands, and I'm on Linux.

yes because my problem is in this code only thats why *_^

thanks for your help

But you told us to compile it.. Can't compile half a code.

And you didn't actually write what your problem is, but that we had to guess it from how it runs on our computer. In my case a problem with platform dependency would occur.

i apologise but pleaaaase help me i need the help by today :(

my program is the evil and the hero , i want the evil to move randomly to right and left and to the middle

how can i do it

You apologize, but you don't bother to correct the situation. Like everyone else, I don't know what you need help with since you can't be bothered to explain it.

why you always angry?? calm down man ^_^

i explained the situation and i'll repeated again

"my program is the evil and the hero , i want the evil to move randomly to right and left and to the middle

how can i do it "

it's just randomly move and could you please show me in code

thank you

Look at this example... Every step (which is very fast, you probably want the user to input something or put a delay, otherwise it will move in matter of nanoseconds), the code will generate a number between 1 and 3.
In the case the number is 1, it will move Left. Case that number is 2, move middle. Case number is 3, move to the right.

Of course you have to replace those functions I made with how you actually want to move the evil guy or whatever.

bool gameRunning = true;
while(gameRunning)
{
    int event = rand()%3+1;
    switch(event)
    {
         case 1:
             moveLeft();
             break;
         case 2:
              moveMiddle();
              break;
         case 3:
              moveRight();
              break;
     }
     // Maybe wait for the users action, or wait x seconds before repeating this loop?
}

thanks bro i'll test the code now

wow greaaaaaaaat

thank you so so much for your help

No problem, buy me an ice cream now :)

commented: <8 (it's icecream rotated 90 degrees) +12
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.