PulsarScript 0 Junior Poster
here is the code 
#include "stdafx.h"
using namespace std;

void GetPicture( ifstream& infile, int picture[8][8]);
void GetCanvas( ifstream& infile, int canvas[45][75]);
void InitBlank( int blank[8][8]);
void InsertPictureInCanvas( int picture[8][8], int canvas[45][75], int startrow, int startcol);
void ShowCanvas( int canvas[45][75] );
void Delay(int time);
int _tmain(int argc, _TCHAR* argv[])
{
    //load the canvas
    ifstream canvasfile("TextFile1.dat");
    int canvas[45][75];
    system("color 1");
    GetCanvas(canvasfile, canvas);


    //load the dogs
    ifstream dogfile1("dog1.dat");
    int dog1[8][8];

    GetPicture(dogfile1,dog1);



    ifstream dogfile2("dog2.dat");
    int dog2[8][8];
    GetPicture(dogfile2,dog2);

    ifstream dogfile3("dog3.dat");
    int dog3[8][8];
    GetPicture(dogfile3,dog3);

    //initialize blank
    int blank[8][8];
    InitBlank(blank);

    Delay(5000);


    int startrow, startcol;
    for ( int frame = 0; frame < 11; frame++)
    {

        system("CLS");
        //decide position for dog
        if ( frame % 2 == 0 )
            startrow = 30;
        else
            startrow = 15;
        startcol = 2 +  frame * 8;

        //insert dog in canvas
        if ( frame < 8 )
        {
            if  ( frame % 2 == 0 )
                InsertPictureInCanvas(dog1, canvas, startrow, startcol);
            else
                InsertPictureInCanvas(dog2, canvas, startrow, startcol);

        }
        if ( frame == 8 )
            InsertPictureInCanvas(dog3, canvas, startrow, startcol);
        if ( frame == 9)
        {
                startrow = 27;
                startcol -= 8;
                InsertPictureInCanvas(dog3, canvas, startrow, startcol);
        }
        if ( frame == 10)
        {
                startrow = 30;
                startcol -= 16;
                InsertPictureInCanvas(dog3, canvas, startrow, startcol);

        }


        //display the canvas
        ShowCanvas(canvas);
        //delay
        Delay(250);
        //blank dog
        InsertPictureInCanvas(blank,canvas, startrow, startcol);

    }

    return 0;
}

void GetPicture( ifstream& infile, int picture[8][8])
{
    for ( int row = 0; row < 8; row++ )
        for ( int col = 0; col < 8; col++)
            infile >> picture[row][col];

}

void InitBlank( int blank[8][8])
{
        for ( int row = 0; row < 8; row++ )
            for ( int col = 0; col < 8; col++)
                blank[row][col] = 0;
}

void GetCanvas( ifstream& infile, int canvas[45][75])
{
    for ( int row = 0; row < 45; row++ )
        for ( int col = 0; col < 75; col++)
            infile >> canvas[row][col];
}

void InsertPictureInCanvas( int picture[8][8], int canvas[45][75] , int startrow, int startcol)
{
    for ( int row = 0; row < 8; row++ )
            for ( int col = 0; col < 8; col++)
                canvas[startrow+row][startcol+col] = picture[row][col];
}


void ShowCanvas( int canvas[45][75] )
{
    for ( int row = 0; row < 45; row++ )
        {
            for ( int col = 0; col < 75; col++)
                if ( canvas[row][col] == 1 )
                    cout << (char)0xDB;
                else
                    cout << ' ';
            cout << endl;
    }

}


void Delay(int time)
{
    int z = 0;
    int stop = time*1000000;
    for ( int i= 0; i < stop; i++)
        z++;
}

How will i change the color of the dog image? I have set the color of the canvas blue. And another question is how to apply different colors to the different parts of the code?Regards
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.