C++ GAMING HELP!!!SCHOOL ASSIGNMENT

+1 Elsino Mucka · March 24, 2015
NEED HELP!!!!!!!PLEASE
I have an exercise for my school in c++(creating a game),but i have a problem it doesnt print out the guard when i m moving it.please help me.thank you



#include <iostream>
#include <ctime>
#include <cstdlib>

using namespace std;


int main() {
    char pinakas[10][10],direction;
    int k,count,random,l,dolphins=0,move;
    srand(time(NULL));
    //O prwtos pinakas
    k=(rand()%10);
    l=(rand()%10);
    random=(rand()%2);
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            pinakas[j]='_';
            if(k==i && j==0)pinakas[j]='G';//GIA TO GUARD
                //MPOREI NA 8ELEI ORIA META TO K KAI TO l
                if(random==0 && j==9){//Random gia to pou tha mpei sthn sthlh
                    if(pinakas[l][j]=='S'|| pinakas[l][j]=='D')continue;
                    pinakas[l][j]='S';
                }
                else if(random==1 && j==9){
                    if(pinakas[l][j]=='S'|| pinakas[l][j]=='D')continue;
                    pinakas[l][j]='D';
                }
            if(i<10 && j<10)
            cout<<pinakas[j]<<' ';
        }
        cout<<endl;
    }//O prwtos pinakas
    
    do{//do while loop
        cout<<"Please move (d:down, f:stay, g:go up): ";
        cin>>direction;
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                if(direction=='d'){//MOVEGUARD
                    if(pinakas[j]=='G'){
                        pinakas[j]='_';
                        int hold=i+1;
                        cout<<hold;
                        move=hold;
                        for(int i=0;i<10;i++){                        
                            if(move==i){
                                pinakas[j]='G';break;
                            }
                        }
                    }
                }
                else if(direction=='f'){
                    
                }//MOVEGUARD
                else if(direction=='g'){
                    if(pinakas[j]=='G'){
                        pinakas[j]='_';
                        move=i-1;
                        for(int i=0;i<10;i++){
                            if(move==i){
                                pinakas[j]='G';cout<<pinakas[j];}
                        }
                    }
                }//MOVEGUARD
                cout<<pinakas[j]<<' ';
            }
            cout<<endl;    
        }
    }while(dolphins<20);//do while loop    
    return 0;
}

Post a Reply

Replies

Oldest  Newest  Rating
0 Dol Lod · March 24, 2015
Honestly, how does even compile. Try compiling it on ideone.com. If you made something a two dimensional array you have to use both brackets to assign values.

Ex. 

char a[5][6];

You can't just say a[5]='H'. You have to say a[5][0]='H'. 
0 Elsino Mucka · March 25, 2015
Thank you.I will try it...oOoOoOPS
0 Elsino Mucka · March 25, 2015
Hey Arjun,I saw my code it was fine,it had both brackets..i dont why it doesnt show up here.
0 Elsino Mucka · March 25, 2015
#include 
#include
#include

using namespace std;


int main() {
    char pinakas[10][10],direction;
    int k,count,random,l,dolphins=0,move;
    srand(time(NULL));
    //O prwtos pinakas
    k=(rand()%10);
    l=(rand()%10);
    random=(rand()%2);
    for(int i=0;i
0 Dol Lod · March 25, 2015
To get the code to work somewhat better,you have to always create the post and then edit it, inserting the code.

It is cut off right now.
0 Abdirasaq Ali · March 26, 2015
Your making a game in C++, I'mm guessing ur using XNA for the ide like I did last year, correct? 
0 Samuel Palace · March 26, 2015
Ohhhh XNA, my one true love, it's been forever. <3
0 Abdirasaq Ali · March 27, 2015
XNA so simple so easy it was love at first sight, then I did understand other developing tools :( 

been 2 yrs since I programmed something.
  • 1

C++

107,025 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator