Anda di halaman 1dari 106

A

MAJOR PROJECT REPORT


ON
“ANIMATION SERIES USING C GRAPHICS”

SUBMITTED IN PARTIAL FULFILLMENT OF THE


REQUIREMENT FOR THE AWARD OF THE DEGREE
OF
BACHELOR OF ENGINEERING
IN
ELECTRONICS AND COMMUNICATION ENGINEERING

Guided by: - Submitted by: -


Mr. Nilesh Parihar Ashish Garg
Asst. Prof. (E.C.E Deptt.) Narendra Bagoria
Nidhi Sharma
Yojana Biyani
Final Year (E.C.E)

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

SOBHASARIA ENGINEERING COLLEGE, SIKAR


UNIVERSITY OF RAJASTHAN

1
2007-2008

SOBHASARIA ENGINEERING COLLEGE, SIKAR


DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

CERTIFICATE

THIS IS TO CERTIFY THAT THE WORK, WHICH IS BEING PRESENTED IN THE SEMINAR
ENTITLED “ANIMATION SERIES USING C GRAPHICS” SUBMITTED BY ASHISH GARG,
NARENDRA BAGORIA, NIDHI SHARMA, YOJANA BIYANI, STUDENTS OF FINAL YEAR B.E.
IN ELECTRONICS & COMMUNICATION ENGINEERING AS A PARTIAL FULFILLMENT FOR
THE AWARD OF DEGREE OF BACHELOR OF ENGINEERING IS A RECORD OF STUDENT’S
WORK CARRIED OUT UNDER MY GUIDANCE AND SUPERVISION.
THIS WORK HAS NOT BEEN SUBMITTED ELSEWHERE FOR THE AWARD OF ANY OTHER
DEGREE.

DATE: ___/___/2008 (Mr. NILESH PARIHAR)


PLACE: S.E.C., SIKAR (PROJECT GUIDE)

(Mr. NILESH PARIHAR) (PROF. K. B.SINGH)


(PROJECT INCHARGE) (H.O.D. E.C.E. DEPTT.)

CANDIDATE’S DECLARATION

2
This is to certify that work, which is being presented in the project entitled
“Animation Series Using C Graphics” submitted by undersigned students
of final year B.E. in Electronics & Communication Engineering in partial
fulfillment for award of degree of bachelor of engineering is a record of our
own work carried out by us guidance and supervision of Mr. NILESH
PARIHAR (Asst. Prof.), Department of Electronics & communication
Engineering.
This work has not submitted elsewhere for award of any other degree.

( )
DATE: - ___/___/2008 Ashish Garg
PLACE: S.E.C., SIKAR Enroll. No: 04/13062

( )
Narendra Bagoria
Enroll. No: 04/13050

( )
Nidhi Sharma
Enroll. No: 04/13065

( )
Yojana Biyani
Enroll. No: 04/13017

ACKNOWLEDGEMENT

3
Expressing gratitude is not just a ritual that has to be carried out. Rather it is an opportunity to
sincerely thank all those who extended their much-needed help.
It gives us immense pleasure in acknowledging the help we have received during our tenure at
Sobhasaria Engineering College. We owe our all the obligations and our sincere feelings to our guide Mr.
Nilesh Parihar (Asst. Prof., ECE) to provide us valuable guidance and encouragement through out the
stages of presentation of our project as well as preparation of report. We regard him for all time he could
devote for the project and for helping us grasps the technical wiz-a-wiz of the “”. We gladly appreciate the
time and patience they could spare their busy schedule.
We are highly obliged to Mr. K.B.Singh (H.O.D., ECE) for their appreciation.
At last but the most we would like to extend our thanks to all faculty members of Department of
Electronics & Communication Engineering, faculty of Communication Lab, our friends and colleague
for their support and cooperation.

( )
Ashish Garg
( )
Narendra Bagoria
( )
Nidhi Sharma
( )
Yojana Biyani
(Final Year ECE)

ABSTRACT

Our project is related to "COMPUTER GRAPHICS" in C-language. This program will show "the
hare and tortoise story" graphically. We have designed the images of hare, tortoise, trees, grass, bushes,
clouds, road etc. Also we created more sophisticated animations of hare and tortoise. The entire program is
written in C-language with approx 3200 lines of source code.

4
The show is divided into 15 modules. In first module, titles of the story will appear. From 2nd module
to module-12, the whole play can be seen. 13th and 14th modules are the demos of the design of tortoise,
and hare respectively. Demo will explain graphically how we have designed the images of hare and tortoise
in step by step procedure.15th module will present the end titles.

INDEX

Page no.

Chapter 1 Introduction
1.1 Introduction 1
1.2 Introduction to C 1
1.2.1 Basic structure of a C program 2
1.2.2 C Keyword 3
1.2.3 Constants and Variables 4
1.2.4 C Operators 5
1.2.5 Decision control statements 8

5
1.2.6 Arrays 12
1.2.7 Strings 14
1.2.8 Functions 15
1.2.9 Structures 18
1.2.10 Pointers 19
1.2.11 C Preprocessor 21

Chapter 2 Introduction to C Graphics


2.1 Computer graphics 24
2.2 C graphics 24
2.2.1 Basic shapes and colors 27
2.2.2 Various functions used in project 30

Chapter 3 Coding 31

Conclusion 99

Reference 100

6
Chapter: 1

Introduction

1.1 Introduction
The software is based on "COMPUTER GRAPHICS" in C-language. This
program will show "the hare and tortoise story" graphically. The entire program is written
in C-language. We have designed the images of hare, tortoise, trees, grass, bushes,
clouds, road etc. Also we created more sophisticated animations of hare and tortoise.

1.2 Introduction to C
C is a general-purpose programming language with features economy of
expression, modern flow control and data structures, and a rich set of operators. C is not a
``very high level'' language, nor a ``big'' one, and is not specialized to any particular area
of application. But its absence of restrictions and its generality make it more convenient
and effective for many tasks than supposedly more powerful languages.
C was originally designed for and implemented on the UNIX operating system on
the DEC PDP-11, by Dennis Ritchie. The operating system, the C compiler, and
essentially all UNIX applications programs are written in C. Production compilers also
exist for several other machines, including the IBM System/370, the Honeywell 6000,
and the Interdata 8/32. C is not tied to any particular hardware or system.

1.2.1 Basic Structure of a C program


A C program consists of a group of building blocks called functions. A function is
a subroutine that may include one or more statements designed to perform a specific task.
To write a C program, we first create functions and put them together. C program may
contain one or more sections as described below:-
• Documentation Section – It consists of a set of comment lines giving name of
program, the author and other details which the programmer would like to use later.

7
• Link Section – This section provides instruction to complier to link function from
the system library.
• Definition Section – It defines all symbolic constants.
• Global Declaration Section – There are some variables that are used in more than
one function. Such variables are called global variables and are declared in global
declaration section. That is outside of all the functions. This is section also declares
all the user-defined functions.
• main ( ) Function Section – Every C program must have one main ( ) function
section. This section contains two parts, declaration part and executable part. The
declaration part declares all the variables used in the executable part. There is at
least one statement in the executable part. All statements in the declaration and
executable part end with a semicolon.

Documentation Section
Link section
Definition Section
Global Declaration Section
main ( ) Function section
{

Declaration
Part
Executable Part }

Subprogram Section
Function 1
Function 2
-
-
Function n

(User-defined Functions)

8
• Subprogram Section - It contains all the user-defined functions that are called in the
main function. User-defined functions are generally placed immediately after the
main function, although they may appear in any order.

1.2.2 C Keyword
Keywords are the words whose meaning has already been explained to the
compiler. The keywords cannot be used as variable names because if we do so we are
trying to assign a new meaning to the keyword, which is not allowed by the computer.
Some C compiler allows you to construct variable names which exactly resemble the
keyword. However, it would be safer not to mix up the variable names and keywords.
The keywords are also called ‘Reserved Words’.
There are only 32 keywords available in C. Following is the list of keywords. A
detailed discussion of each of these keywords would be taken up in later topics wherever
their use is relevant.

auto int
break long
case register
char return
const short
continue signed
default sizeof
do static
double struct
else switch
enum typedef
extern union
float unsigned
for void
goto volatile
if while
9
1.2.3 Constants and Variables
The alphabets, numbers and special symbol when properly combined form
constant and variables. A constant is a quantity that doesn’t change. This quantity can be
stored at a location in the memory of the computer.
A variable can be considered as a name given to the location in memory where
this constant is stored. Naturally the contents of the variable can change.

Types of C constant
C constant can be divided into two major categories:
(a) Primary Constants
(b) Secondary Constant
These constant are further categorized as shown.

C Constants

Primary Constants Secondary Constants

Integer Constant Array


Real Constant Pointer
Character Constant Structure
Union
Enum etc.

Variables
A variable is a data name that may be used to store data value. Unlike constant
that remain unchanged during the execution of the program, a variable may take different

10
values at different times during execution. A variable name can be chosen by the
programmer in a meaningful way so as to reflect its function or nature in the program.

Type of Variables

C Variables

Integer Variable Character Variable Float and Double Variable

short signed int signed char float


short unsigned int unsigned char double
long signed int long double
long unsigned int

1.2.4 C Operators
C supports a rich set of operators. An operator is a symbol that tells the compiler
to perform certain mathematical or logical manipulations. Operators are used in program
to manipulate data and variables. C operators can be classified into a number of
categories. They include:
(1) Arithmetic Operators.
(2) Relational Operators.
(3) Logical Operators.
(4) Assignments Operators.
(5) Increment and Decrement Operators.
(6) Conditional Operators.
(7) Bitwise Operators.
(8) Special Operators.

11
Arithmetic Operators
C provides all the basic arithmetic operators.

They are:

Operator Meaning

+ Addition or unary plus.

- Subtraction or unary minus.

* Multiplication.

/ Division.

% Modulo Division.

Relational Operators
We often compare two quantities, and depending on their relation, take certain
decisions. C supports six relational operators in all.

These are:
Operators Meaning
< Is less than
<= Is less than or equal to
> Is greater than
>= Is greater than or equal to
== Is equal to
!= Is not equal to

Logical Operators
In addition to the relational operators, C has the three logical operators.

12
They are:

Operators Meaning
&& Logical AND
¦¦ Logical OR
! Logical NOT

Assignments Operators
Assignment operators are used to assign the result of an expression to a variable.
C has a set of ‘shorthand’ assignment operator of the form:

v op = exp;

Where v is a variable, exp is an expression and op is a C binary operator. The


operator op= is known as the shorthand assignment operator.

Increment and Decrement Operators


C has two very useful operators not generally found in other languages. These are
the increment and decrement operators.

++ and --

The operator ++ adds 1 to the operand while -- subtract 1. Both are unary
operators.

Bitwise Operators
C has a distinction of supporting special operations known as bitwise operators
for manipulation of data at bit level. These operators are used for testing the bits, or
shifting them right or left.

13
They are:
Operator Meaning
& Bitwise AND
| Bitwise OR
<< Shift left
>> Shift right
~ One’s complement

Special Operators
C supports some operators of interest such as operator comma (,) sizeof()
operators. The comma (,) operator can be used to link the related expressions together.
For example,
value = (x = 10, y=5 , x+y);
The sizeof() operator is a compiler time operator and , when used with an
operand, it returns the number of bytes the operand occupies.

1.2.5 Decision Control Statement


Many a times, we want a set of instruction to be executed in one situation, and an
entirely different set of instruction to be executed in another situation. This kind of
situation is dealt in C programs using a decision control instruction. A decision control
instruction can be implemented in C using:
(a) The if statement
(b) The if-else statement
(c) The conditional operators

The if statement
Like most language, C uses the keyword if to implement the decision control
instruction. The general form of if statement looks like this:
if(this condition is true) execute this statement;
The key if tells the compiler that what follows is a decision control instruction.
The condition following the keyword if is always enclosed within a pair of parentheses. If
the condition, whatever it is, is true, then the statement is executed.

14
The if-else Statement
The if statement by itself will execute statement, or a group of statements, when
the expression following if evaluates to true. Otherwise it will execute the statements
written in else part.

Nested if-else
It is perfectly all right if we write an entire if-else construct within either the body
of the if statement or the body of an else statement. This is called ‘nesting’ of ifs. This is
shown below

main()
{
int i;
printf(“Enter either 1 or 2”); scanf(“%d”,&i);
if(i==1)
printf(“You would fine ”);
else
{
if(i==2)
printf(“You will not be fine”);
else
printf(“How are you”);
}
}

The Conditional Operators


The conditional operator ? and : are sometimes called ternary operators since
they take three arguments. In fact, they form a kind of foreshortened if-then-else.

Their general form is,


expression 1 ? expression2 : expression 3

What this expression says is:” if expression 1 is true then the value returned will
be expression2 otherwise the value returned will be expression 3”
The limitation of the conditional operator is that after the ? or after the : only one
C statements can occur. In practice rarely is this the requirement. Therefore, in serious C
programming conditional operators aren’t as frequently used as the if-else.

15
Loop Controls Statement
The versatility of the computer lies in its ability to perform a set of instruction
repeatedly. This involves repeating some portion of the program either a specified
number of times or until a particular condition is being satisfied.
There are three methods by which we can repeat a part of a program. They are:
(a) Using a for statement
(b) Using a while statement
(c) Using a do-while statement

The while Loop


It is often the case in programming that you want to do something a fixed number of
times. Perhaps you want to calculate gross salaries of ten different persons or you want to
convert temperatures from centigrade to Fahrenheit for 15 different cities. While loop is
ideally suitable for such cases. The general form of while is as shown below:
initialize loop counter;
while(test loop counter using a condition)
{
do this;
and this;
increment loop counter;
}

The for Loop


The for lop allows us to specify three things about a loop in a single line:
(a) Setting a loop counter to an initial value.
(b) Testing the loop counter to determine whether its value has reached the
number of repetition desired.
(c) Increasing the value of loop counter each time the program segment
within the loop has executed.
The general form of for statement is as under:

16
for(initialize counter ; test counter ; increment counter)
{
do this;
and this;
and also this;
}

The do-while Loop


The do-while loop looks like this:
do
{
this;
and this;
}while(this condition is true);

There is minor difference between the working of while and do-while loop. This
difference is the place where the condition is tested. The while test the condition before
executing any of the statements within the while loop. As against this, the do-while tests
the condition after having executed the statements within the loop.

Case Controls Statement


The control statement that allows you to make a decision from the number of
choices is called a switch, or more correctly a switch-case-default, since these keywords
go together to make up the control statements. They most appear as follows:
switch (integer expression)
{
case constant 1: do this; break;
case constant 2: do this: break;
case constant 3: do this; break;
default: do this; break;
}
The integer expression following the keyword switch is any C yield an integer
value. It could be an integer constant like 1, 2, or 3, or an expression that evaluates to an
integer.

The break statement

17
We often come across situation where we want to jump out of a loop instantly,
without waiting to get back to the conditional test. The keyword break allows us to do
this. When break is encountered inside any loop, control automatically passes to the first
statement after the loop.

The continue statement


In some programming situations we want to take the control to the beginning of
the loop, bypassing the statement inside the loop, which have not yet been executed. The
keyword continues allows us to do this. When continue is encountered inside any loop,
control automatically passes to the beginning of the loop.

1.2.6 Arrays
Array is a variable which is capable of holding more than one value at a time.
Thus, an array is a collection of similar elements. These similar elements could be all
ints, or all floats or all chars, etc. usually, the array of character is called a ‘string’,
whereas an array of int or floats is called simply an array. The following are some points
about arrays:
(a) An array is a collection of data.
(b) The first element in the array is number 0, so the last element is one less than
the size of the array.
(c) An array is also known as a subscripted variable.
(d) Before using array its type and dimension must be declared.
(e) However big an array its elements are always stored in contiguous memory
location.
(f) Till the array elements are not given any specific values, they are supposed to
contain garbage values.
(g) If the array is initialized where it is declared mentioning the dimension of the
array is optional.

Array Initialization

int num[]={2,5,7,9,1,22};

18
char ch[10];
float per[]={1.9,2.24,3.14,7.8};
long int sal[]={12000,490000,546000,423123,29980,112500};

65500 65504 65508 65512 65516 65520

Two Dimensional Arrays

12000 490000 546000 423123 29980 112500

It is also possible for arrays to have two or more dimensions. The two-
dimensional array is also called a matrix. A simple program that uses a 2-D array is
shown below:
main()
{
int stud[4][2];
int i,j;
for(i=0;i<4;i++)
{
printf(“\nEnter roll no. and marks: ”):
scanf(“%d%d”,stud[i][0],stud[i][1]);
}
for(i=0;i<4;i++)
printf(“\n%d %d”,stud[i][0],stud[i][1]);
}

Initializing a 2-Dimensional Array


A 2-Dimensional array is initialized as follows:

int stud[4][2]={
{ 1234 , 56},
{ 1212 , 33},
{ 1434 , 80},
{ 1312 , 78}
};
It is important to remember that while initializing a 2-D array it is necessary to
mention the second (column) dimension, whereas the first dimension (row) is optional.
Thus the declarations,
int arr[2][3]={12,34,45,56,78};
int arr [][3] ={12,34,45,56,78};
are perfectly acceptable.

19
1.2.7 Strings
The way a group of integers can be stored in an array, similarly a group of
characters can be stored in a character array. Character array are many a times also called
‘strings’. Character array or strings are used by programming languages to manipulate
text such as word and sentences.
A string constant is a one-dimensional array of characters terminated by a null
(‘\0’). For example:
char name[]={‘R’, ‘A’, ‘V’, ‘I’};
Each character in the array occupies one byte of memory and the last character is
always ‘\0’. The terminating null is important, because it is only way the function that
work with a string can know where the string ends. A string can also be initialized by
another way,
char name[]=”VIKAS”;
While entering the string using scanf() we must be caution about two things:
(a) The length of the string should not exceed the dimension of the character
array. This is because the C compiler doesn’t perform bounds checking on
character arrays. Hence, if you carelessly exceed the bounds there is always a
danger of overwriting something important.
(b) scanf() is not capable of receiving multi-word strings. Therefore names such
as “Vikas Parihar” would be unacceptable. The way to get around this
limitation is by using the function gets ().

Standard Library String Functions

Function Use
strlen() Finds length of a string.
strlwr() Converts a string to lowercase.
strupr() Converts a string to uppercase.
strcat() Appends one string at the end of another.
strncat() Appends first n characters of a string at the end of another.

20
strcpy() Copies a string into another.
strncpy() Copies first n characters of one string into another.
strcmp() Compares two strings.
strncmp() Compares first n characters of two strings.
strcmpi() Compares two strings without regards to case.
stricmp() Compares two strings without regards to case.
strnicmp() Compare first n character of strings without regard to case.
strdup() Duplicates a string.
strchr() Finds first occurrence of a given character in a string.
strrchr() Finds last occurrence of a given string in another string.
strstr() Finds first occurrence of a given string in another string.
strset() Sets all characters of string to a given character.
strnset() Sets first n character of a string to a given character.
strrev() Reverses string.

1.2.8 Functions
A function is a self-contained block of statements that perform a coherent task of
some kind. Every C program can be thought of as a collection of this function. The
general form of a function is:
function(arg1,arg2,arg3)
type arg1,arg2,arg3;
{
statement1;
statement2;
statement3;
}
The following are some points about functions:
(a) Any C program contains at least one function.
(b) If a program contains only one function, it must be main().
(c) In a C program if there are more than one function present, then one of these
must be main() because program execution always begins with main().
(d) There is no limit on the number of function that might be present in a C
program.
(e) Each function in a program is called in the sequence specified by the function
calls in the main().

21
(f) After each function has done its thing, control returns to main(). When main()
runs out of function call, the program ends.
(g) A function gets called when the function name is followed by a semicolon.
(h) A function is defined when function name is followed by a pair of braces in
which one or more statements may be present.
(i) Any function can be called from any function. Even main() can be called
from other function.
(j) A function can be called any number of times.
(k) The order in which the functions are defined in a program and the order in
which they get called need not necessarily be same.
(l) A function can call itself. Such a process is called ‘recursion’.
(m) A function can be called from other function, but a function cannot be defined
in another function.
(n) There are basically two types of functions:
• Library functions
• User defined functions
Library functions are nothing but commonly required functions grouped together
and stored in what is called library. This library of function is present on the disk and is
written for us by people who write compiler for us.
Function Prototype, Calling, Definition
(1) float power( int m, float n ); (Function Prototype)
(2) power(m, n); (Function call)
(3) float power( int a, float b) (Function Definition)
{
return(a*b);
}
Passing Values between Functions
main()
{
int a,b,c,sum;
prinntf(“\nEnter any three numbers: ”):
scanf(“%d%d%d”,&a,&b,&c);
sum=calsum(a,b,c);

22
printf(“\nSUM=%d”):
}
calsum(int x,int y,int z)
{
return(x+y+z);
}
The number of things to note about this program:

(a) The variable a, b and c are called ‘actual arguments’, whereas the variable x, y
and z are called ‘formal arguments’.
(b) Any number of arguments can be passed to a function being called. However,
the type, order and number of the actual and formal arguments must always be
same.
(c) The return statement serves two purpose:

(1) On executing the return statement it immediately transfers the control


back to the calling program.
(2) It returns the value present in the parentheses after return, to the calling
program. In the above program. In the above program the value of sum of
three numbers is being returned.

(d) There is no restriction on the number of return statements that may be present
in a function
(e) Whenever the control returns from a function some value is definitely
returned.
(f) If we want that a called function should not return any value, in that case, we
must mention so by using keyword void.
A function can return only one value at a time.
1.2.9 Structures
A structure contains a number of data types grouped together. These data types
may or may not be of the same type. The general form of declaring structure type is,
struct book
{
char name;
float price;
int pages;
}
sturct book b1,b2,b3;

The following points must be noted while declaring a structure type:


(a) The closing brace in the structure type declaration must be followed by a
semicolon.

23
(b) It is important to understand that a structure type declaration does not tell the
compiler to reserve any space in memory. All a structure declaration does is, it
defines the ‘form’ of the structure.
(c) Usually structure type declaration appears at the top of the source code file,
before any variable or functions are defined. In very large programs they are
usually put in a separate header file, and the file is included in whichever
program we want to use this structure type.
(d)
Accessing Structure Elements
In arrays we can access individual elements of an array using a subscript.
Structures use a different scheme. They use a dot (.) operator. So to refer to pages of the
structure defined in our example we use,
b1.pages
How Structure Elements are Stored
Whatever be the elements of a structure, they are always stored in contiguous
memory location.
b1.name b1.price b1.pages

‘B’ 130.00 550

Use of Structures

They can be used for a variety of purpose like:


(1) Changing the size of the cursor.
(2) Clearing the contents of the screen.
(3) Placing the cursor at an appropriate position on screen.
(4) Drawing any graphics shapes on the screen.
(5) Receiving a key from the keyboard.
(6) Checking the memory size of the computer.
(7) Finding out the list of equipment attached to the computer.
(8) Formatting a floppy.
(9) Hiding a file from the directory.

24
(10) Displaying the directory of a disk.
(11) Sending the output to printer.
(12) Interacting with the mouse.

1.2.10 Pointers
A pointer is a variable that contains the address of a variable. To understand
pointers let us consider a declaration:
int a=10;
This declaration tells the compiler to:
(a) Reserve space in memory to hold the integer value.
(b) Associate the name a with this memory location.
(c) Store the value 10 at this location.

a Location name
Value at location
6670
10
6670 Location no. (Address)

The & and * Operators


The ‘&’ operator in a statement is ‘address of’ operator in C program. The
expression &a returns the address of variable a, which in this case happens to be 6670.
The other pointer operator available in C is ‘*’, called ‘value at address’ operator. It
returns the value store at a particular address. The ‘value at address’ operator is also
called as ‘indirection’ operator.
main()
{
int a=10;
printf(“\nAddress of a =%u”,&a);

25
printf(“\nValue of a=%d %d”,a,*(&a));
}
We se that &a returns the address of a. This address can be collected in a variable by
saying,
b=&a;
Since b is a variable it must be declared. It holds an address of a variable, so it is declared
as,
int *b;
Thus this means that the value at the address contained in b is an int;

a b

10 6670
6670 2383

Pointer we know is a variable, which contains address of another variable. Now this
variable itself could be another pointer. Thus, we now have a pointer which contains
another pointer’s address.
main()
{
int a=10,*b,**c;
printf(“\nAddress of a=%u”,&a);
printf(“\nAddress of a=%u”,b);
printf(“\nAddress of a=%u”,*c);
printf(“\nAddress of a=%u”,&b);
printf(“\nAddress of a=%u”,c);
printf(“\nAddress of a=%u”,&k);

printf(“\nVaule of b= %u”,b);
printf(“\nVaule of c= %u”,c);

26
printf(“\nVaule of a= %u”,*(&a));
printf(“\nVaule of a= %u”,*b);
printf(“\nVaule of a= %u”,**c);
}

a b c

10 6670 2383
6660 2383 5120

1.2.11 C Preprocessor
The C preprocessor is a program that processes our source program before it is
passed to the compiler. Preprocessor commands from what can almost be consider a
language within C language.
Features of C Preprocessor
The preprocessor offers several features called preprocessor directives. Each of these
preprocessor directives begins with a ‘#’ symbol. The directives can be placed any where
in a program but are most often placed at the beginning of a program, before the first
function definition. There are four types of preprocessor directives,
(a) Macro expansion
(b) File inclusion
(c) Conditional Compilation
(d) Miscellaneous directives

Macro Expansion
Let us consider a program,
#define COUNT 35
main()
{
int i;
for(i=0;i<=COUNT;i++)
printf(“\n%d”,i);

27
}
The statement “#define COUNT 35” is called ‘macro definition’ or commonly
just a ‘macro’. During the preprocessing, the preprocessor replace every occurrence of
COUNT in the program with 35.

File inclusion
This directive causes one file to be included in another. The preprocessor
command for file inclusion looks likes this:
#include “file name”
And it simply causes the entire contents of filename to be inserted into the source code at
that point in the program. There exits two ways to write #include statement. These are:
(1) #include “file name” This command would look for the file in the current
directory as well as the specified list of directories as mentioned in the include
search path.

(2) #include<file name> This command would look for the file in the specified list of
directories only.
It is common for the files that are to be included to have an .h extension. This
extension stands for ‘header file’, possibly because it contains statements which when
included go to the head of your program. The prototype of all the library function are
grouped into different categories and then stored in different header files. For example
prototype of all mathematics related function are stored in the header file ‘math.h’,
prototypes of console input/output function are stored in the header files ‘conio.h’ and so
on.

Conditional Compilation
We can, if we want, have the compiler skip over part of a source code by inserting the
preprocessing commands #ifdef and #endif, which have the general form:
#ifdef macroname
statement 1;
statement 2;
statement 3;
#endif

28
If macroname has been #defined, the block of code will be processed as usual, otherwise
not.

Miscellaneous Directives
There are two more preprocessor directives available, through they not very
commonly used. They are:
(1) #undef
(2) #pragma
On some occasions it may desirable to cause a defined name to become
‘undefined’. This can be accomplished by means of the #undef directive. In order to
undefined a macro that has been earlier #defined, the directive,
#undef macro template
This directive is another special-purpose directive that you can use to turn on or off
certain features. Pragmas vary from one compiler to another. Turbo C/C++ compiler has
got a pragma that allows you to suppress warning generated by the compiler. Some
pragmas are listed below:
(a) #pragma startup
(b) #pragma exit
(c) #pragma warn
(d) #pragma inline

Chapter: 2

Introduction to C Graphics

2.1 Computer Graphics:


Computer graphics is a sub-field of computer science and is concerned with
digitally synthesizing and manipulating visual content. Although the term often refers to
three-dimensional computer graphics, it also encompasses two-dimensional graphics and

29
image processing. Computer graphics is often differentiated from the field of
visualization, although the two have many similarities.
A broad classification of major subfields in computer graphics might be:
1. Geometry: studies ways to represent and process surfaces.
2. Animation: studies with ways to represent and manipulate motion.
3. Rendering: studies algorithms to reproduce light transport.
4. Imaging: studies image acquisition or image editing.

2.2 C Graphics:
Computer graphics is one of the most powerful and interesting facet of computers.
Apart from drawing figures of various shapes using computer graphics, all video games,
animation and multimedia predominantly works using computer graphics. To start with
graphics programming, Turbo C is a good choice.
Even though DOS has its own limitations, it is having a large number of useful
functions and is easy to program. To implement graphics algorithms, to give graphical
display of statistics, to view signals from any source, we can use C graphics. Turbo C has
a good collection of graphics libraries. To start programming, let us write a small
program that displays a circle on the screen.

/*Simple example to draw circle*/


#include<graphics.h>
#include<conio.h>
void main()
{
int gd= DETECT,gm;
initgraph(&gd,&gm,,”c:/tc/bgi”);
circle(330,180,100);
getch();
closegraph();
}

30
When we start drawing any graphics on the screen we need header file called
GRAPHICS.H and a library file GRAPHICS.LIB. The header file contains definitions
and explanations of all the functions and constants we need, and the graphics functions
are kept in the graphics library file. Both these files are provided as part of TURBO C.

Graphics mode initialization


First thing that we need before we can carry out any drawing activity is, switch
over to the graphic mode. To switch over to graphics mode that offers the best resolution
we need to call the function initgraph().

Initgraph
initgraph function initializes the graphics mode and clears the screen. closegraph()
function switches back the screen from graphics mode to text mode. It clears the screen
also.

Declaration
void initgraph(int far *graphdriver, int far *graphmode, char far *pathtodriver);
initgraph initializes the graphics system by loading a graphics driver from disk (or
validating a registered driver) then putting the system into graphics mode. Initgraph also
resets all graphics settings (color, palette, current position, viewport, etc.) to their
defaults, then resets graphresult to 0.

Arguments

*graphdriver
Integer that specifies the graphics driver to be used. You can give graphdriver a
value using a constant of the graphics _drivers enumeration type.

31
*graphmode
Integer that specifies the initial graphics mode (unless *graphdriver = DETECT).
If *graphdriver= DETECT, initgraph sets *graphmode to the highest resolution available
for the detected driver. You can give *graphmode a value using a constant of the
graphics_modes enumeration type.

Pathtodriver
Specifies the directory path where initgraph looks for graphics drivers (*.BGI)
first.
1. If they're not there, initgraph looks in the current directory.
2. If pathtodriver is null, the driver files must be in the current directory. This is also the
path settextstyle searches for the stroked character font files (*.CHR).
After a call to initgraph, *graphdriver is set to the current graphics driver, and
*graphmode is set to the current graphics mode. You can tell initgraph to use a particular
graphics driver and mode, or to autodetect the attached video adapter at run time and pick
the corresponding driver. If you tell initgraph to autodetect, it calls detectgraph to select a
graphics driver and mode.
Normally, initgraph loads a graphics driver by allocating memory for the driver
(through graphgetmem), then loading the appropriate .BGI file from disk. As an
alternative to this dynamic loading scheme, you can link a graphics driver file (or several
of them) directly into your executable program file.
A graphics program should have a closegraph function at the end of graphics.
Otherwise DOS screen will not go to text mode after running the program. Here,
closegraph() is called after getch() since screen should not clear until user hits a key.
If you have the BGI file in the same folder of your program, you can just leave it
as "" only. you need not mention *graphmode if you give *graphdriver as DETECT.

2.2.1 Basic Shapes and Colors


Let us take a program to draw basic shapes.

32
/* Program to draw various geometrical shapes */
#include<graphics.h>
#include<conio.h>
void main()
{
int gd=DETECT, gm;
int poly[12]={350,450, 350,410, 430,400, 350,350, 300,430, 350,450 };
initgraph(&gd, &gm, "");
circle(100,100,50);
outtextxy(75,170, "Circle");
rectangle(200,50,350,150);
outtextxy(240, 170, "Rectangle");
ellipse(500, 100,0,360, 100,50);
outtextxy(480, 170, "Ellipse");
line(100,250,540,250);
outtextxy(300,260,"Line");
sector(150, 400, 30, 300, 100,50);
outtextxy(120, 460, "Sector");
drawpoly(6, poly);
outtextxy(340, 460, "Polygon");
getch();
closegraph();
}

The above program produces the output as:

33
Here, circle() function takes x, y coordinates of the circle with respect to left top
of the screen and radius of the circle in terms of pixels as arguments. Note that, in
graphics, almost all the screen parameters are measured in terms of pixels.
Function outtextxy() displays a string in graphical mode. Parameters passed are x
and y coordinates of the position on the screen where text is to be displayed. There is
another function outtext() that displays a text in the current position. Current position is
the place where last drawing is ended. These functions are declared as follows:

void far outtextxy(int x, int y, char *text);


void far outtext(char *text);

Some of the functions for needed for drawing shapes and to fill colors are listed below:

34
Function Meaning
circle(int x, int y, int rad); Draws a circle with center(x,y) and rad.
arc(int x,int y, int start, int end, int rad); Draws an arc with (x,y) as center, rad as
radius and start and end as the starting and
ending angles.
rectangle(int left ,int top, int right, int Draws a rectangle with (left,top) as the
bottom ); upper left corner and (right,bottom) as the
lower right corner.
ellipse(int x, int y, int start, int end, int Draws an ellipse with (x,y ) as center and
xrad, int yrad); xrad and yrad as x and y radius with start
and end as start and end angle.
line(int x, int y, int a, int b); Draws a line from (x,y) to (a,b).
sector(int x, int y, int start, int end, int Draw sector with (x,y) as center and xrad
xrad, int yrad); as x and yrad as y radius. The sector is
drawn from angle start to end.
fillellipse(int x, int y, int xrad, int yrad); It fills the ellipse with current fill color.
fillpoly(int num, int *polypoints); Draws the outlines of a polygon with num
points in current line style in color and
then fill polygon using current fill color.
lineto(int x, int y); Draws line from CP to (x,y).
linerel(int dx, int dy); Draws a line from CP to point that is
relative distance (dx,dy) from CP.
setcolor(int color); Set the current drawing color using the
palette.

2.2.2 Various functions used in project


Here is the list of various functions which we used in our project:

Function Meaning
cleardevice(); Clear the graphics screen and moves the

35
current position (CP) to home.
getimage(int left, int top, int right, int Copies an image from the screen to
bottom, void *bitmap); memory.
outtextxy(int x, int y, char *str); Display a text string in the viewport at the
specified location.
putimage(int left, int right, void *ptr, int Outputs a bit image onto the screen.
op);
setfillstyle(int pattern, int color); Sets the current fill pattern and fill color.
settextjustify(int horiz, int vert); Sets text justification for graphics
functions.

CHAPTER: 3

CODING

#include<graphics.h>
#include<stdlib.h>
#include<dos.h>
void *hare2;

36
void *hare1;
void *tortoise1;
void *tortoise2;
void *haretree;
void init_rabbit1();
void init_rabbit2();
void init_tortoise1();
void init_tortoise2();
void text();
void frame1();
void frame2();
void frame3();
void frame4();
void frame5();
void frame4();
void frame7();
void frame41();
void frame8();
void frame31();
void frame11();
void tort_demo();
void hare_demo();
void endtitle();
void main()
{
int gd=DETECT,gm,i,j,temp;
/*void init_rabbit1();
void init_rabbit2();
void init_tortoise1();
void init_tortoise2();
void text();
void frame1();
void frame2();
void frame3();
void frame4();
void frame5();
void frame4();
void frame7();
void frame41();
void frame8();
void frame31();
void frame11();
void tort_demo();
void hare_demo();
void endtitle();*/
/*path(like "c:\\tc","d:\\","c:\\tc\bgi",etc) should be given to

37
initilise graphic system */
initgraph(&gd,&gm,"c:\\tc\\bgi");
init_rabbit1();
init_rabbit2();
init_tortoise1();
init_tortoise2();
text();
cleardevice();
frame1();
cleardevice();
frame2();
cleardevice();
frame3();
cleardevice();
frame4();
cleardevice();
frame5();
sleep(4);
cleardevice();
frame4();
cleardevice();
frame7();
cleardevice();
frame41();
cleardevice();
frame8();
cleardevice();
frame31();
cleardevice();
frame11();
sleep(5);
cleardevice();
tort_demo();
cleardevice();
hare_demo();
endtitle();
cleardevice();
getch();
}
//////////////////////////////////////grass///////////////////////////////////
void put_grass(int x,int y)
{
int i;
for(i=0;i<=20;i++)
{
setcolor(LIGHTGREEN);

38
line(x,y,x+random(40)-30,y-random(40));
setcolor(BROWN);
line(x-random(40),y,x+random(40),y);
line(x-random(40),y,x+random(40),y+2);
line(x-random(40),y,x+random(40),y+4);
line(x-random(40),y,x+random(40),y+6);
}}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////bigtree////////////////////////////////////
void put_bigtree(int x,int y)
{
int stem[10]={200,150,190,300,200,306,220,300,215,145};
unsigned int size;
int stem1[10],i;
for(i=0;i<=10;i+=2)
{
stem1[i]=stem[i]+x;
stem1[i+1]=stem[i+1]+y;
}
setcolor(BROWN);
setfillstyle(SOLID_FILL,BROWN);
fillpoly(5,stem1);
setcolor(LIGHTGREEN);
setfillstyle(SOLID_FILL,LIGHTGREEN);
fillellipse(208+x,128+y,30,30);
fillellipse(226+x,168+y,10,5);
fillellipse(240+x,170+y,10,20);
fillellipse(240+x,140+y,30,20);
fillellipse(235+x,115+y,30,30);
fillellipse(225+x,80+y,15,15);
fillellipse(200+x,87+y,19,19);
fillellipse(170+x,110+y,30,30);
fillellipse(150+x,140+y,20,20);
fillellipse(152+x,155+y,15,15);
fillellipse(166+x,163+y,16,16);
fillellipse(180+x,160+y,11,28);
}
///////////////////////////////////////////////////////////////////////////////
//////////////////////////////////clouds///////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
void put_clouds(int x,int y)
{
int i;
setcolor(WHITE);
setfillstyle(SOLID_FILL,WHITE);
fillellipse(150+x,150+y,25,25);

39
fillellipse(173+x,145+y,10,5);
fillellipse(150+x,125+y,10,10);
fillellipse(130+x,153+y,15,15);
fillellipse(175+x,168+y,9,13);
fillellipse(140+x,121+y,4,4);
fillellipse(140+x,125+y,8,4);
fillellipse(133+x,130+y,6,3);
fillellipse(123+x,141+y,6,3);
fillellipse(121+x,144+y,6,3);
fillellipse(118+x,147+y,6,3);
fillellipse(124+x,157+y,7,12);
fillellipse(128+x,171+y,4,4);
fillellipse(134+x,170+y,4,8);
fillellipse(126+x,160+y,15,6);
fillellipse(143+x,175+y,12,7);
fillellipse(154+x,175-7+y,6,9);
fillellipse(154+16+x,175-14+y,25,12);
fillellipse(160+x,178+y,10,10);
setcolor(LIGHTBLUE);
setfillstyle(SOLID_FILL,LIGHTBLUE);
for(i=0;i<=3;i++)
ellipse(160+x,170+i+y,220,340,8,5);
for(i=0;i<=2;i++)
ellipse(146+x,171+i+y,200,340,10,5);
for(i=0;i<=5;i++)
ellipse(140+x,143+i+y,130,230,8,10);
for(i=0;i<=4;i++)
line(159-i+x,128+y,166-i+x,136+y);
for(i=0;i<=4;i++)
ellipse(170-i+x,162+y,300,50,20,10);
}
/////////////////////////////////////////////////////////////////////////
//////////////////////////////////hare1//////////////////////////////////
/////////////////////////////////////////////////////////////////////////
void hare(int x,int y,int color1,int color2)
{
int i;
int poly[10]={ 304,276,313,269,316,269,318,270,324,271};
int mouthpoly[8]={351,283,353,282,354,280,356,283};
int frontleg[70] ={307,312-3,305,313-3,303,314-3,300,314-3,296,313-3,293,312+2,
293,310+5,294,311+5,297,311+5,301,311+5,304,310+4,315,310+4,317,314+2,320,314+
2,325,314+2,327,314+3,329,314+3,332,314+3,334,314+3,336,314+2,337,314+2,337-
2,314+1,337-7,314+1,337-7,314,337,312,337,310,337-7,308,340,312,341,311,342,310,
342,309,341,308,342,306,341,307,340,308};
int frontleg1[70];
int poly1[10];

40
int mouthpoly1[8];
for(i=0;i<84;i++)
{
if(i%2==0)
frontleg1[i]=frontleg[i]+x;
else
frontleg1[i]=frontleg[i]+y;
}
for(i=0;i<10;i++)
{
if(i%2==0)
poly1[i]=poly[i]+x;
else
poly1[i]=poly[i]+y;
}
for(i=0;i<8;i++)
{
if(i%2==0)
mouthpoly1[i]=mouthpoly[i]+x;
else
mouthpoly1[i]=mouthpoly[i]+y;
}
//TO LOCATE THE POINT FOR THE LEG
//line(307,314,307,320);
setcolor(color1);
setfillstyle(SOLID_FILL,color2);
fillpoly(35,frontleg1);
/*upper body lines to fill the upper part*/
setcolor(color2);
for(i=0;i<=12;i++)
line(317-5+x,270-1+i+y,336+3+x,272+1+i+y);
for(;i<=15;i++)
line(317+x,270-1+i+y,336+3+7+x,272+1+i+y);
setcolor(color2);
line(310+x,284+y,346+x,288+y);
line(310+x,285+y,346+x,289+y);
line(310+x,286+y,347+x,290+y);
line(310+x,287+y,346+x,291+y);
line(310+x,288+y,345+x,292+y);
line(310+x,289+y,344+x,293+y);
line(310+x,290+y,340+x,294+y);
line(305+x,291+y,338+x,295+y);
line(305+x,292+y,336+x,296+y);
line(305+x,293+y,336+x,297+y);
line(305+x,294+y,336+x,298+y);
line(305+x,295+y,335+x,299+y);

41
line(305+x,296+y,335+x,300+y);
line(305+x,297+y,335+x,301+y);
line(305+x,298+y,334+x,302+y);
line(305+x,298+y,333+x,303+y);
line(304+x,299+y,333+x,303+y);
line(304+x,300+y,332+x,304+y);
line(304+x,301+y,331+x,305+y);
for(i=18;i<=23;i++)
line(317+x,269+i+y,336+x,273+i+y);
ellipse(332+x,286+y,359,111,10,14);
/*head and ears*/
setcolor(color2);
setfillstyle(SOLID_FILL,color2);
setcolor(color1);
fillellipse(346+x,279+y,8,8);
fillellipse(346+x,262+y,4,12);
fillellipse(340+x,262+y,4,12);
/*EYE*/
circle(350+x,277+y,1);
/*MOUTH*/
fillpoly(3,mouthpoly1);
setcolor(color2);
setfillstyle(SOLID_FILL,color2);
/* main body */
fillellipse(313+x,292+y,20,20);
/*tail*/
fillellipse(295+x,302+y,10,2);
setcolor(BLACK);
ellipse(321+x,296+y,365,180,17,9);
setfillstyle(SOLID_FILL,color2);
setcolor(color2);
}
/////////////////////////////////////////////////////////////////////////
/////////////////////////////tor1///////////////////////////////////////
////////////////////////////////////////////////////////////////////////
void tor1(int x,int y,int color1,int color2,int color3,int color4,int color5)
{
int backleg[12]={284,263,284,267,287-1,270,287+1,270,290,267,289,263};
int backlegcap[6]={284,267,287,271,290,267};
int frontleg[16]={321,258,307,267,305,272,313,269,318,266,
325,265,327,258,321,258};
int frontlegcap[8]={307,267,305,272,313,269,307,267};
int i;
int frontleg1[16];
int backlegcap1[6];
int backleg1[12];

42
int frontlegcap1[8];
for(i=0;i<16;i++)
{
if(i%2==0)
frontleg1[i]=frontleg[i]+x;
else
frontleg1[i]=frontleg[i]+y;
}
for(i=0;i<12;i++)
{
if(i%2==0)
backleg1[i]=backleg[i]+x;
else
backleg1[i]=backleg[i]+y;
}
for(i=0;i<6;i++)
{
if(i%2==0)
backlegcap1[i]=backlegcap[i]+x;
else
backlegcap1[i]=backlegcap[i]+y;
}
for(i=0;i<8;i++)
{
if(i%2==0)
frontlegcap1[i]=frontlegcap[i]+x;
else
frontlegcap1[i]=frontlegcap[i]+y;
}
setcolor(color3);
/* outline of the upper part of the body*/
ellipse(300+x,248+y,0,170,24,15);
setcolor(color1);
/* to fill upper part of the body*/
for(i=14;i>=12;i--)
ellipse(300+x,248+y,0,170,24,i);
setcolor(color1);
setfillstyle(SOLID_FILL,color1);
fillellipse(300+x,248+y,24,12);
/* outline of tail */
setcolor(color3);
line(269+x,250+y,276+x,246+y);
line(269+x,250+y,274+x,256+y);
/*to fill tail in lightgreen color*/
setcolor(color1);
for(i=1;i<=5;i++)

43
line(269+i+x,250+y,276+i+x,246+y);
for(i=1;i<=5;i++)
line(269+i+x,250+y,274+i+x,256+y);
/* outline of bottom part of body*/
setcolor(color3);
ellipse(298+x,251+y,200,10,25,13);
/* to fill the bottom part of body in LIGHTGREEN COLOR*/
setcolor(color1);
ellipse(299+x,250+y,200,10,25,13);
ellipse(300+x,249+y,200,330,25,13);
ellipse(301+x,248+y,200,335,25,13);
/* HEAD*/
fillellipse(321+x,252+y,17,5);
/*EYE*/
setcolor(color5);
setfillstyle(SOLID_FILL,color4);
fillellipse(333+x,251+y,3,2);
/* for backleg*/
setcolor(color3);
setfillstyle(SOLID_FILL,color1);
fillpoly(6,backleg1);
/* backleg cap*/
setcolor(color3);
setfillstyle(SOLID_FILL,color2);
fillpoly(3,backlegcap1);
/*just for frontleg point*/
line(321+x,258+y,307+x,267+y);
moveto(307+x,267+y);
lineto(305+x,272+y);
//lineto(309,273);
lineto(313+x,269+y);
lineto(318+x,266+y);
lineto(325+x,265+y);
lineto(327+x,258+y);
lineto(321+x,258+y);
setcolor(color3);
setfillstyle(SOLID_FILL,color1);
fillpoly(8,frontleg1);
/* for frontleg cap*/
line(307+x,267+y,313+x,269+y);
setcolor(color2);
setfillstyle(SOLID_FILL,color2);
fillpoly(4,frontlegcap1);
/* filling body with green ellipses */
setcolor(BLACK);
fillellipse(300+x,248+y,6,4);

44
fillellipse(313+x,249+y,5,3);
fillellipse(289+x,250+y,4,3);
fillellipse(304+x,257+y,7,4);
fillellipse(296+x,253+y,4,2);
fillellipse(294+x,260+y,5,4);
fillellipse(302+x,262+y,4,2);
fillellipse(308+x,261+y,2,2);
fillellipse(312+x,260+y,2,2);
fillellipse(317+x,256+y,6,4);
fillellipse(310+x,252+y,2,2);
fillellipse(305+x,252+y,3,3);
fillellipse(307+x,245+y,7,4);
fillellipse(321+x,253+y,4,2);
fillellipse(320+x,248+y,4,4);
fillellipse(317+x,245+y,2,2);
fillellipse(320+x,243+y,2,2);
fillellipse(314+x,240+y,4,4);
fillellipse(306+x,238+y,6,4);
fillellipse(300+x,236+y,4,2);
fillellipse(296+x,241+y,5,3);
fillellipse(294+x,236+y,4,3);
fillellipse(288+x,239+y,5,3);
fillellipse(282+x,241+y,2,2);
fillellipse(280+x,246+y,3,4);
fillellipse(289+x,245+y,6,4);
fillellipse(287+x,252+y,7,4);
fillellipse(285+x,255+y,8,4);
fillellipse(286+x,260+y,2,2);
fillellipse(277+x,253+y,4,3);
fillellipse(275+x,250+y,2,2);
fillellipse(273+x,251+y,2,2);
}
//////////////////////////////////////////////////////////////////////////
///////////////////////////////////////rabbit-2/////////////////////////////
/////////////////////////////////////////////////////////////////////////
void rabbit2(int x, int y,int color1,int color2)
{
int i;
int poly[10]={ 304,276,313,269,316,269,318,270,324,271};
int mouthpoly[8]={351,283,353,282,354,280,356,283};
int legs[70] ={307,312-3,305,313-3,303,314-3,300,314-3,296,313-3,293,312+2,293,
310+5,294,311+5,297,311+5,301,311+5,304,310+4,315,310+4,317,314+2,
320,314+2,325,314+2,327,314+3,329,314+3,332,314+3,334,314+3,
336,314+2,337,314+2,337-2,314+1,337-7,314+1,337-7,314,337,312,
337,310,337-7,308,340,312,341,311,342,310,
342,309,341,308,342,306,341,307,340,308};

45
int legs1[70];
int poly1[10];
int mouthpoly1[8];
for(i=0;i<70;i++)
{
if(i%2==0)
legs1[i]=legs[i]+x;
else
legs1[i]=legs[i]+y;
}
for(i=0;i<10;i++)
{
if(i%2==0)
poly1[i]=poly[i]+x;
else
poly1[i]=poly[i]+y;
}
for(i=0;i<8;i++)
{
if(i%2==0)
mouthpoly1[i]=mouthpoly[i]+x;
else
mouthpoly1[i]=mouthpoly[i]+y;
}
//TO LOCATE THE POINT FOR THE LEG
//line(307,314,307,320);
setcolor(BLACK);
setfillstyle(SOLID_FILL,color2);
fillpoly(35,legs1);
/*upper body line*/
setcolor(color2);
for(i=0;i<=8;i++)
ellipse(332+x,286+i+y,359,125,9,14);
/*head && ears*/
setcolor(BLACK);
setcolor(BLACK);
fillellipse(346+x,262+y,4,12);
fillellipse(340+x,262+y,4,12);
setcolor(color1);
/* throat*/
setcolor(color2);
for(i=0;i<=5;i++)
line(340-i+x,298+y,349-i+x,285+y);
/*head*/
setcolor(BLACK);
fillellipse(346+x,279+y,8,8);

46
/*EYE*/
setcolor(color1);
circle(350+x,277+y,1);
/*MOUTH*/
fillpoly(3,mouthpoly1);
setcolor(color1);
moveto(341+x,293+y);
linerel(-3,2);
linerel(-1,2);
linerel(-1,3);
linerel(-4,4);
linerel(-5,3);
linerel(-3,0);
linerel(-5,0);
setcolor(color2);
setfillstyle(SOLID_FILL,color2);
/*main body*/
fillellipse(313+x,292+y,29,17);
/*tail*/
fillellipse(295+x,302+y,17,2);
setcolor(BLACK);
ellipse(312+x,297+y,340,140,16,14);
setfillstyle(SOLID_FILL,color2);
setcolor(color2);
}
////////////////////////////////////////////////////////////////////////
///////////////////////////////bushes////////////////////////////////////
////////////////////////////////////////////////////////////////////////
void bushes(int x, int y, int r1,int r2,int color)
{
setcolor(color);
setfillstyle(SOLID_FILL,color);
fillellipse(x,y,r1,r2);
}
////////////////////////////////////////////////////////////////////////////
/////////////////////tor2/////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void tor2(int x,int y, int color1,int color2,int color3,int color5)
{
int backleg[12]={284,263,284+3,267,287-
1+3,270+1,287+1+3,270,290+3,267,289+3,263};
int backlegcap[6]={284+4,267,287+4,271,290+4,267};
int frontleg[20]={321,258,321,267,323,272,325,272,327,267,328,260,
324,252};
int frontlegcap[20]={321,267,323,272,325,272,327,267};
int i;

47
int backleg1[12];
int backlegcap1[6];
int frontleg1[20];
int frontlegcap1[20];
for(i=0;i<14;i++)
{
if(i%2==0)
frontleg1[i]=frontleg[i]+x;
frontleg1[i]=frontleg[i]+y;
}
for(i=0;i<12;i++)
{
if(i%2==0)
backleg1[i]=backleg[i]+x;
else
backleg1[i]=backleg[i]+y;
}
for(i=0;i<6;i++)
{
if(i%2==0)
backlegcap1[i]=backlegcap[i]+x;
else
backlegcap1[i]=backlegcap[i]+y;
}
for(i=0;i<8;i++)
{
if(i%2==0)
frontlegcap1[i]=frontlegcap[i]+x;
else
frontlegcap1[i]=frontlegcap[i]+y;
}
setcolor(color3);
/* outline of the upper part of the body*/
ellipse(300+x,248+y,0,170,24,15);
setcolor(color1);
/* to fill upper part of the body*/
for(i=14;i>=12;i--)
ellipse(300+x,248+y,0,170,24,i);
setcolor(color1);
setfillstyle(SOLID_FILL,color1);
fillellipse(300+x,248+y,24,12);
/* outline of tail */
setcolor(color3);
line(269+x,250+y,276+x,246+y);
line(269+x,250+y,274+x,256+y);
/*to fill tail in lightgreen color*/

48
setcolor(color1);
for(i=1;i<=5;i++)
line(269+i+x,250+y,276+i+x,246+y);
for(i=1;i<=5;i++)
line(269+i+x,250+y,274+i+x,256+y);
/* outline of bottom part of body*/
setcolor(color3);
ellipse(298+x,251+y,200,10,25,13);
/* to fill the bottom part of body in LIGHTGREEN COLOR*/
setcolor(color1);
ellipse(299+x,250+y,200,10,25,13);
ellipse(300+x,249+y,200,330,25,13);
ellipse(301+x,248+y,200,335,25,13);
/* HEAD*/
fillellipse(321+x,244+y,17-6,5);
/*EYE*/
setcolor(color5);
setfillstyle(SOLID_FILL,BLACK);
fillellipse(333-4+x,244+y,3,2);
/* for backleg*/
setcolor(color3);
setfillstyle(SOLID_FILL,color1);
fillpoly(6,backleg1);
/* backleg cap*/
setcolor(color3);
setfillstyle(SOLID_FILL,color2);
fillpoly(3,backlegcap1);
setcolor(color3);
setfillstyle(SOLID_FILL,color1);
fillpoly(7,frontleg1);
/* for frontleg cap*/
setcolor(color2);
setfillstyle(SOLID_FILL,color2);
fillpoly(4,frontlegcap1);
/* filling body with green ellipses */
setcolor(BLACK);
fillellipse(300+x,248+y,6,4);
fillellipse(313+x,249+y,5,3);
fillellipse(289+x,250+y,4,3);
fillellipse(304+x,257+y,7,4);
fillellipse(296+x,253+y,4,2);
fillellipse(294+x,260+y,5,4);
fillellipse(302+x,262+y,4,2);
fillellipse(308+x,261+y,2,2);
fillellipse(312+x,260+y,2,2);
fillellipse(317+x,256+y,6,4);

49
fillellipse(310+x,252+y,2,2);
fillellipse(305+x,252+y,3,3);
fillellipse(307+x,245+y,7,4);
fillellipse(321+x,253+y,4,2);
fillellipse(320+x,248+y,4,4);
fillellipse(317+x,245+y,2,2);
fillellipse(320+x,243+y,2,2);
fillellipse(314+x,240+y,4,4);
fillellipse(306+x,238+y,6,4);
fillellipse(300+x,236+y,4,2);
fillellipse(296+x,241+y,5,3);
fillellipse(294+x,236+y,4,3);
fillellipse(288+x,239+y,5,3);
fillellipse(282+x,241+y,2,2);
fillellipse(280+x,246+y,3,4);
fillellipse(289+x,245+y,6,4);
fillellipse(287+x,252+y,7,4);
fillellipse(285+x,255+y,8,4);
fillellipse(286+x,260+y,2,2);
fillellipse(277+x,253+y,4,3);
fillellipse(275+x,250+y,2,2);
fillellipse(273+x,251+y,2,2);
}
///////////////////////////////////////////////////////////////////////////
/////////////////////////////init_rabbit()1////////////////////////////////
///////////////////////////////////////////////////////////////////////////
void init_rabbit1()
{
unsigned int size;
int i;
int poly[10]={ 304,276,313,269,316,269,318,270,324,271};
int mouthpoly[20]={351,283,353,282,354,280,356,283};
int frontleg[84] ={307,312-3,305,313-3,303,314-3,300,314-3,296,313-3,293,312+2,

293,310+5,294,311+5,297,311+5,301,311+5,304,310+4,315,310+4,317,314+2,
320,314+2,325,314+2,327,314+3,329,314+3,332,314+3,334,314+3,
336,314+2,337,314+2,337-2,314+1,337-7,314+1,337-7,314,337,312,
337,310,337-7,308,340,312,341,311,342,310,
342,309,341,308,342,306,341,307,340,308};

//TO LOCATE THE POINT FOR THE LEG


//line(307,314,307,320);
setcolor(RED);
setfillstyle(SOLID_FILL,WHITE);
fillpoly(35,frontleg);
//setcolor(LIGHTGRAY);

50
/*upper body lines to fill the upper part*/
setcolor(WHITE);
for(i=0;i<=12;i++)
line(317-5,270-1+i,336+3,272+1+i);
for(;i<=15;i++)
line(317,270-1+i,336+3+7,272+1+i);
setcolor(WHITE);
line(310,284,346,288);
line(310,285,346,289);
line(310,286,347,290);
line(310,287,346,291);
line(310,288,345,292);
line(310,289,344,293);
line(310,290,340,294);
line(305,291,338,295);
line(305,292,336,296);
line(305,293,336,297);
line(305,294,336,298);
line(305,295,335,299);
line(305,296,335,300);
line(305,297,335,301);
line(305,298,334,302);
line(305,298,333,303);
line(304,299,333,303);
line(304,300,332,304);
line(304,301,331,305);
for(i=18;i<=23;i++)
line(317,269+i,336,273+i);
ellipse(332,286,359,111,10,14);
/*head*/
setcolor(RED);
fillellipse(346,279,8,8);
/*ears*/
fillellipse(346+3,262,4,12);
fillellipse(340-1,262,4,12);
/*EYE*/
circle(350,277,1);
/*MOUTH*/
fillpoly(3,mouthpoly);
ellipse(343,288,257,0,4,5);
moveto(341,293);
linerel(-3,2);
linerel(-1,2);
linerel(-1,3);
linerel(-4,4);
linerel(-5,3);

51
linerel(-3,0);
linerel(-5,0);
setcolor(WHITE);
setfillstyle(SOLID_FILL,WHITE);
/* main body */
fillellipse(313,292,20,20);
/*tail*/
fillellipse(295,302,10,2);
setcolor(BLACK);
ellipse(321,296,45,180,17,9);
setfillstyle(SOLID_FILL,WHITE);
setcolor(WHITE);
fillpoly(3,poly);
size=imagesize(280-15-7,240,380-25,340);
hare1=malloc(size);
getimage(280-15-7,240,380-25,340,hare1);
putimage(280-15-7,240,hare1,XOR_PUT);
}
void move_hare1(int x,int y)
{
putimage(x,y,hare1,COPY_PUT);
}
//////////////////////////////////////////////////////////////////////////
///////////////////////////init_rabbit2()////////////////////////////////
/////////////////////////////////////////////////////////////////////////
void init_rabbit2()
{
unsigned int size;
int i;
int mouthpoly[8]={351,283,353,282,354,280,356,283};
int legs[84] ={307,312-3,305,313-3,303,314-3,300,314-3,296,313-3,293,312+2,

293,310+5,294,311+5,297,311+5,301,311+5,304,310+4,315,310+4,317,314+2,
320,314+2,325,314+2,327,314+3,329,314+3,332,314+3,334,314+3,
336,314+2,337,314+2,337-2,314+1,337-7,314+1,337-7,314,337,312,
337,310,337-7,308,340,312,341,311,342,310,
342,309,341,308,342,306,341,307,340,308};
//TO LOCATE THE POINT FOR THE LEG
//line(307,314,307,320);
setcolor(BLACK);
setfillstyle(SOLID_FILL,WHITE);
fillpoly(35,legs);
//setcolor(LIGHTGRAY);
/*upper body line*/
setcolor(WHITE);
for(i=0;i<=8;i++)

52
ellipse(332,286+i,359,125,9,14);
/*ears*/
setcolor(BLACK);
fillellipse(346,262,4,12);
fillellipse(340,262,4,12);
setcolor(RED);
/* throat*/
setcolor(WHITE);
for(i=0;i<=5;i++)
line(340-i,298,349-i,285);
/*head*/
setcolor(BLACK);
fillellipse(346,279,8,8);
/*EYE*/
setcolor(RED);
circle(350,277,1);
/*MOUTH*/
fillpoly(3,mouthpoly);
setcolor(RED);
moveto(341,293);
linerel(-3,2);
linerel(-1,2);
linerel(-1,3);
linerel(-4,4);
linerel(-5,3);
linerel(-3,0);
linerel(-5,0);
setcolor(WHITE);
setfillstyle(SOLID_FILL,WHITE);
/*main body*/
fillellipse(313,292,29,17);
/*tail*/
fillellipse(295,302,17,2);
setcolor(BLACK);
ellipse(312,297,340,140,16,14);
setfillstyle(SOLID_FILL,WHITE);
setcolor(WHITE);
size=imagesize(265-7,240,380-25,340);
hare2=malloc(size);
getimage(265-7,240,380-25,340,hare2);
putimage(265-7,240,hare2,XOR_PUT);
}
void move_hare2(int x,int y)
{
putimage(x,y,hare2,0);
}

53
/////////////////////////////////////////////////////////////////////////
///////////////////////////////init_tortoise1()//////////////////////////
/////////////////////////////////////////////////////////////////////////
void init_tortoise1()
{
int backleg[12]={284,263,284,267,287-1,270,287+1,270,290,267,289,263};
int backlegcap[6]={284,267,287,271,290,267};
int frontleg[20]={321,258,307,267,305,272,313,269,318,266,
325,265,327,258,321,258};
int frontlegcap[20]={307,267,305,272,313,269,307,267};
unsigned int size;
int i;
setcolor(BROWN);
/* outline of the upper part of the body*/
ellipse(300,248,0,170,24,15);
setcolor(LIGHTGREEN);
/* to fill upper part of the body*/
for(i=14;i>=12;i--)
ellipse(300,248,0,170,24,i);
setcolor(LIGHTGREEN);
setfillstyle(SOLID_FILL,LIGHTGREEN);
fillellipse(300,248,24,12);
/* outline of tail */
setcolor(BROWN);
line(269,250,276,246);
line(269,250,274,256);
/*to fill tail in lightgreen color*/
setcolor(LIGHTGREEN);
for(i=1;i<=5;i++)
line(269+i,250,276+i,246);
for(i=1;i<=5;i++)
line(269+i,250,274+i,256);
/* outline of bottom part of body*/
setcolor(BROWN);
ellipse(298,251,200,10,25,13);
/* to fill the bottom part of body in LIGHTGREEN COLOR*/
setcolor(LIGHTGREEN);
ellipse(299,250,200,10,25,13);
ellipse(300,249,200,330,25,13);
ellipse(301,248,200,335,25,13);
/* HEAD*/
fillellipse(321,252,17,5);
/*EYE*/
setcolor(WHITE);
setfillstyle(SOLID_FILL,BLUE);
fillellipse(333,251,3,2);

54
/* for backleg*/
setcolor(BROWN);
setfillstyle(SOLID_FILL,LIGHTGREEN);
fillpoly(6,backleg);
/* backleg cap*/
setcolor(BROWN);
setfillstyle(SOLID_FILL,GREEN);
fillpoly(3,backlegcap);
/*just for frontleg point*/
line(321,258,307,267);
moveto(307,267);
lineto(305,272);
lineto(313,269);
lineto(318,266);
lineto(325,265);
lineto(327,258);
lineto(321,258);
setcolor(BROWN);
setfillstyle(SOLID_FILL,LIGHTGREEN);
fillpoly(8,frontleg);
line(307,267,313,269);
setcolor(GREEN);
setfillstyle(SOLID_FILL,GREEN);
fillpoly(4,frontlegcap);
/* filling body with green ellipses */
setcolor(BLACK);
fillellipse(300,248,6,4);
fillellipse(313,249,5,3);
fillellipse(289,250,4,3);
fillellipse(304,257,7,4);
fillellipse(296,253,4,2);
fillellipse(294,260,5,4);
fillellipse(302,262,4,2);
fillellipse(308,261,2,2);
fillellipse(312,260,2,2);
fillellipse(317,256,6,4);
fillellipse(310,252,2,2);
fillellipse(305,252,3,3);
fillellipse(307,245,7,4);
fillellipse(321,253,4,2);
fillellipse(320,248,4,4);
fillellipse(317,245,2,2);
fillellipse(320,243,2,2);
fillellipse(314,240,4,4);
fillellipse(306,238,6,4);
fillellipse(300,236,4,2);

55
fillellipse(296,241,5,3);
fillellipse(294,236,4,3);
fillellipse(288,239,5,3);
fillellipse(282,241,2,2);
fillellipse(280,246,3,4);
fillellipse(289,245,6,4);
fillellipse(287,252,7,4);
fillellipse(285,255,8,4);
fillellipse(286,260,2,2);
fillellipse(277,253,4,3);
fillellipse(275,250,2,2);
fillellipse(273,251,2,2);
size=imagesize(265-5,225,345,285-7);
tortoise1=malloc(size);
getimage(265-5,225,345,285-7,tortoise1);
putimage(265-5,225,tortoise1,XOR_PUT);
}
void put_tortoise1(int x,int y)
{
putimage(x,y,tortoise1,0);
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////init_tortoise2()////////////////////////////
void init_tortoise2()
{
int backleg[12]={284,263,284+3,267,287-
1+3,270+1,287+1+3,270,290+3,267,289+3,263};
int backlegcap[6]={284+4,267,287+4,271,290+4,267};
int frontleg[20]={321,258,321,267,323,272,325,272,327,267,328,260,
324,252};

int frontlegcap[20]={321,267,323,272,325,272,327,267};
int i;
unsigned int size;
setcolor(BROWN);
/* outline of the upper part of the body*/
ellipse(300,248,0,170,24,15);
setcolor(LIGHTGREEN);
/* to fill upper part of the body*/
for(i=14;i>=12;i--)
ellipse(300,248,0,170,24,i);
setcolor(LIGHTGREEN);
setfillstyle(SOLID_FILL,LIGHTGREEN);
fillellipse(300,248,24,12);
/* outline of tail */
setcolor(BROWN);

56
line(269,250,276,246);
line(269,250,274,256);
/* to fill tail in lightgreen color*/
setcolor(LIGHTGREEN);
for(i=1;i<=5;i++)
line(269+i,250,276+i,246);
for(i=1;i<=5;i++)
line(269+i,250,274+i,256);
/* outline of bottom part of body*/
setcolor(BROWN);
ellipse(298,251,200,10,25,13);
/* to fill the bottom part of body in LIGHTGREEN COLOR*/
setcolor(LIGHTGREEN);
ellipse(299,250,200,10,25,13);
ellipse(300,249,200,330,25,13);
ellipse(301,248,200,335,25,13);
/*fillellipse(298,251,23,11);*/
/* HEAD*/
fillellipse(321,244,17-6,5);
/*EYE*/
setcolor(WHITE);
setfillstyle(SOLID_FILL,BLACK);
fillellipse(333-4,244,3,2);
/*for backleg*/
setcolor(BROWN);
setfillstyle(SOLID_FILL,LIGHTGREEN);
fillpoly(6,backleg);
/*backleg cap*/
setcolor(BROWN);
setfillstyle(SOLID_FILL,GREEN);
fillpoly(3,backlegcap);
/*just for frontleg point*/
line(321,258,321,267);
moveto(321,267);
lineto(323,272);
lineto(325,272);
lineto(327,267);
lineto(328,260);
lineto(324,252);
/*lineto(327,258);
lineto(321,258);*/
setcolor(BROWN);
setfillstyle(SOLID_FILL,LIGHTGREEN);
fillpoly(7,frontleg);
/* for frontleg cap*/
/*line(307,267,313,269);*/

57
setcolor(GREEN);
setfillstyle(SOLID_FILL,GREEN);
fillpoly(4,frontlegcap);
/*filling body with green ellipses */
setcolor(BLACK);
fillellipse(300,248,6,4);
fillellipse(313,249,5,3);
fillellipse(289,250,4,3);
fillellipse(304,257,7,4);
fillellipse(296,253,4,2);
fillellipse(294,260,5,4);
fillellipse(302,262,4,2);
fillellipse(308,261,2,2);
fillellipse(312,260,2,2);
fillellipse(317,256,6,4);
fillellipse(310,252,2,2);
fillellipse(305,252,3,3);
fillellipse(307,245,7,4);
fillellipse(321,253,4,2);
fillellipse(320,248,4,4);
fillellipse(317,245,2,2);
fillellipse(320,243,2,2);
fillellipse(314,240,4,4);
fillellipse(306,238,6,4);
fillellipse(300,236,4,2);
fillellipse(296,241,5,3);
fillellipse(294,236,4,3);
fillellipse(288,239,5,3);
fillellipse(282,241,2,2);
fillellipse(280,246,3,4);
fillellipse(289,245,6,4);
fillellipse(287,252,7,4);
fillellipse(285,255,8,4);
fillellipse(286,260,2,2);
fillellipse(277,253,4,3);
fillellipse(275,250,2,2);
fillellipse(273,251,2,2);
setcolor(WHITE);
size=imagesize(265-5,225,345,285-7);
tortoise2=malloc(size);
getimage(265-5,225,345,285-7,tortoise2);
putimage(265-5,225,tortoise2,XOR_PUT);
}
void put_tortoise2(int x,int y)
{
putimage(x,y,tortoise2,0);

58
}
/////////////////////////////////////////////////////////////////////////////
///////////////////////////////////haretree//////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void put_haretree(int x,int y)
{
unsigned int size;
int i;
int stem[88]=
{
273,236,286,222,295,229,308,221,318,226,
325,226,332,231,334,225,333,210,332,206,
328,196,328,189,336,180,335,169,321,177,
325,171,325,165,327,154,324,130,325,126,
328,120,333,115,350,98,347,88,320,115,
322,100,319,87,354,53,346,47,299,86,
300,56,284,54,281,89,250,56,240,70,
270,102,271,134,267,130,262,134,266,152,
273,146,279,172,278,193,280,216

};
int stem1[88];
for(i=0;i<88;i+=2)
{
stem1[i]=stem[i]+x;
stem1[i+1]=stem[i+1]+y;
}
setcolor(BLACK);
setfillstyle(SOLID_FILL,BROWN);
fillpoly(44,stem1);
setcolor(GREEN);
setfillstyle(SOLID_FILL,GREEN);
fillellipse(245+x,98+y,20,10);
fillellipse(235+x,110+y,17,12);
fillellipse(231+x,88+y,25,17);
fillellipse(200+x,70+y,21,29);
fillellipse(200+x,40+y,20,20);
fillellipse(210+x,25+y,15,15);
fillellipse(228+x,22+y,15,15);
fillellipse(228+x,40+y,15,15);
fillellipse(228+x,60+y,15,15);
fillellipse(248+x,52+y,15,15);
fillellipse(268+x,63+y,10,10);
fillellipse(273+x,70+y,7,7);
fillellipse(273+x,76+y,3,3);
fillellipse(275+x,80+y,3,3);

59
fillellipse(275+x,84+y,2,2);
fillellipse(280+x,85+y,2,3);
fillellipse(280+x,83+y,2,2);
fillellipse(280+x,78+y,3,3);
fillellipse(280+x,75+y,3,6);
fillellipse(279+x,73+y,2,2);
fillellipse(278+x,71+y,2,2);
fillellipse(279+x,67+y,3,6);
fillellipse(280+x,61+y,3,6);
fillellipse(274+x,50+y,16,8);
fillellipse(285+x,50+y,12,8);
fillellipse(295+x,50+y,7,7);
fillellipse(301+x,83+y,2,2);
fillellipse(300+x,79+y,2,2);
fillellipse(304+x,80+y,2,2);
fillellipse(304+x,76+y,4,4);
fillellipse(304+x,70+y,3,7);
fillellipse(304+x,65+y,3,7);
fillellipse(304+x,57+y,6,6);
fillellipse(310+x,76+y,3,3);
fillellipse(310+x,74+y,3,3);
fillellipse(313+x,71+y,3,3);
fillellipse(318+x,68+y,3,3);
fillellipse(310+x,64+y,4,8);
fillellipse(312+x,60+y,7,7);
fillellipse(322+x,58+y,8,8);
fillellipse(332+x,53+y,9,9);
fillellipse(339+x,44+y,7,7);
fillellipse(350+x,48+y,6,6);
fillellipse(359+x,55+y,6,6);
fillellipse(355+x,65+y,10,10);
fillellipse(348+x,70+y,10,10);
fillellipse(342+x,84+y,4,7);
fillellipse(339+x,87+y,6,7);
fillellipse(339+x,75+y,9,9);
fillellipse(355+x,86+y,13,13);
fillellipse(351+x,104+y,5,5);
fillellipse(343+x,108+y,5,5);
fillellipse(343+x,116+y,10,14);
fillellipse(353+x,110+y,7,14);
fillellipse(363+x,107+y,12,12);
fillellipse(371+x,90+y,7,13);
fillellipse(379+x,76+y,30,15);
fillellipse(390+x,76+y,30,18);
fillellipse(380+x,60+y,30,30);
fillellipse(403+x,30+y,24,24);

60
fillellipse(375+x,23+y,20,20);
fillellipse(352+x,21+y,20,20);
fillellipse(332+x,20+y,17,17);
fillellipse(307+x,30+y,27,27);
fillellipse(265+x,30+y,25,25);
}
//////////////////////////////////////////////////////////////////////////////
////////////////////////////////rabbit1///////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
void rabbit1(int x,int y,int color1,int color2)
{
int i;
int poly[10]={ 304,276,313,269,316,269,318,270,324,271};
int mouthpoly[8]={351,283,353,282,354,280,356,283};
int frontleg[70] ={307,312-3,305,313-3,303,314-3,300,314-3,296,313-3,293,312+2,
293,310+5,294,311+5,297,311+5,301,311+5,304,310+4,315,310+4,317,314+2,
320,314+2,325,314+2,327,314+3,329,314+3,332,314+3,334,314+3,
336,314+2,337,314+2,337-2,314+1,337-7,314+1,337-7,314,337,312,
337,310,337-7,308,340,312,341,311,342,310,
342,309,341,308,342,306,341,307,340,308};
int frontleg1[70];
int poly1[10];
int mouthpoly1[8];
for(i=0;i<84;i++)
{
if(i%2==0)
frontleg1[i]=frontleg[i]+x;
else
frontleg1[i]=frontleg[i]+y;
}
for(i=0;i<10;i++)
{
if(i%2==0)
poly1[i]=poly[i]+x;
else
poly1[i]=poly[i]+y;
}
for(i=0;i<8;i++)
{
if(i%2==0)
mouthpoly1[i]=mouthpoly[i]+x;
else
mouthpoly1[i]=mouthpoly[i]+y;
}
//TO LOCATE THE POINT FOR THE LEG
//line(307,314,307,320);

61
setcolor(color1);
setfillstyle(SOLID_FILL,color2);
fillpoly(35,frontleg1);
/*upper body lines to fill the upper part*/
setcolor(color2);
for(i=0;i<=12;i++)
line(317-5+x,270-1+i+y,336+3+x,272+1+i+y);
for(;i<=15;i++)
line(317+x,270-1+i+y,336+3+7+x,272+1+i+y);
setcolor(color2);
line(310+x,284+y,346+x,288+y);
line(310+x,285+y,346+x,289+y);
line(310+x,286+y,347+x,290+y);
line(310+x,287+y,346+x,291+y);
line(310+x,288+y,345+x,292+y);
line(310+x,289+y,344+x,293+y);
line(310+x,290+y,340+x,294+y);
line(305+x,291+y,338+x,295+y);
line(305+x,292+y,336+x,296+y);
line(305+x,293+y,336+x,297+y);
line(305+x,294+y,336+x,298+y);
line(305+x,295+y,335+x,299+y);
line(305+x,296+y,335+x,300+y);
line(305+x,297+y,335+x,301+y);
line(305+x,298+y,334+x,302+y);
line(305+x,298+y,333+x,303+y);
line(304+x,299+y,333+x,303+y);
line(304+x,300+y,332+x,304+y);
line(304+x,301+y,331+x,305+y);
for(i=18;i<=23;i++)
line(317+x,269+i+y,336+x,273+i+y);
ellipse(332+x,286+y,359,111,10,14);
/*head and ears*/
setcolor(color2);
setfillstyle(SOLID_FILL,color2);
setcolor(color1);
fillellipse(346+x,279+y,8,8);
fillellipse(346+x,262+y,4,12);
fillellipse(340+x,262+y,4,12);
/*EYE*/
circle(350+x,277+y,1);
/*MOUTH*/
fillpoly(3,mouthpoly1);
setcolor(color2);
setfillstyle(SOLID_FILL,color2);
/* main body */

62
fillellipse(313+x,292+y,20,20);
/*tail*/
fillellipse(295+x,302+y,10,2);
setcolor(BLACK);
ellipse(321+x,296+y,365,180,17,9);
setfillstyle(SOLID_FILL,color2);
setcolor(color2);
}
void func1(char *str,int font,int size,int color,int direction,int a,int b)
{
int x,y,midx,midy;
settextstyle(font,HORIZ_DIR,size);
settextjustify(CENTER_TEXT,CENTER_TEXT);
setcolor(color);
midx=a;
midy=b;
switch(direction)
{
case 1:/* from up to center */
x=midx;
y=0;
for(;y<midy;y+=5)
{
outtextxy(x,y,str);
delay(120);
setcolor(0);
outtextxy(x,y,str);
setcolor(color);
}
outtextxy(midx,midy,str);
break;
case 2:/* from botom to center */
x=midx;
y=midy*2;
for(;y>midy;y-=5)
{
outtextxy(x,y,str);
delay(20);
setcolor(0);
outtextxy(x,y,str);
setcolor(color);
}
outtextxy(midx,midy,str);
break;
case 3:/* from center to left */
x=midx;

63
y=midy;
for(;x>-20;x-=5)
{
outtextxy(x,y,str);
delay(20);
setcolor(0);
outtextxy(x,y,str);
setcolor(color);
}
break;
case 4:/* from center to right */
x=midx;
y=midy;
for(;x<midx*2+20;x+=5)
{
outtextxy(x,y,str);
delay(20);
setcolor(0);
outtextxy(x,y,str);
setcolor(color);
}
break;
case 5:/* from left to right */
x=0;
y=midy;
for(;x<midx;x+=5)
{
outtextxy(x,y,str);
delay(5);
setcolor(0);
outtextxy(x,y,str);
setcolor(color);
}
setcolor(color);
outtextxy(x-5,y,str);
break;
case 6:/* from right to left */
x=700;
y=midy;
for(;x>midx;x-=5)
{
outtextxy(x,y,str);
delay(5);
setcolor(0);
outtextxy(x,y,str);
setcolor(color);

64
}
setcolor(color);
outtextxy(x+5,y,str);
break;
}
}
void zoom(int x,int y,char *str,int color,int style)
/* This function Zooms the given string */
{
int i,j;
settextjustify(CENTER_TEXT,CENTER_TEXT);
setcolor(color);
for(i=1;i<=10;i++)
{
settextstyle(style,HORIZ_DIR,i);
outtextxy(x,y,str);
delay(220);
setcolor(0);
outtextxy(x,y,str);
setcolor(color);
}
outtextxy(x,y,str);
}
void disappear(int x,int y,char *str,int color,int style)
/* This function reduces and disappears the given string */
{
int i,j;
settextjustify(CENTER_TEXT,CENTER_TEXT);
setcolor(color);
for(i=10;i>=1;i--)
{
settextstyle(style,HORIZ_DIR,i);
outtextxy(x,y,str);
delay(20);
setcolor(0);
outtextxy(x,y,str);
setcolor(color);
}
}
void text()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc");
randomize();
cleardevice();
delay(500);

65
settextstyle(7,HORIZ_DIR,5);
outtextxy(170,160,"PROGRAM BY");
outtextxy(20,200,"ASHISH GARG");
outtextxy(20,220,"NARENDRA BAGORIA");
outtextxy(20,240,"NIDHI SHARMA");
outtextxy(20,240,"YOJANA BIYANI ");
outtextxy(20,260,"ECE FINAL YEAR ");
outtextxy(125,340,"SEC,SIKAR,RAJ.");
sleep(10);
delay(100);
cleardevice();
zoom(335,225,"PRESENTS",12,8);
delay(100);
cleardevice();
func1("JO",7,9,15,5,320,50);
func1("JEETA",7,9,15,6,310,150);
func1("WAHI",7,9,15,5,312,250);
func1("SIKANDAR",7,9,15,6,306,350);
sleep(4);
cleardevice();
zoom(getmaxx()/2,150,"ENJOY!!!",5,7);
zoom(getmaxx()/2,320,"THE SHOW",9,7);
delay(100);
disappear(getmaxx()/2,150,"ENJOY!!!",5,7);
disappear(getmaxx()/2,320,"THE SHOW",5,7);
cleardevice();
}

///////////////////////////frame1//////////////////////////////////////////
///////////////////////////program///////////////////////////////////////
void frame1()
{
void road();
void put_clouds(int,int);
void hare(int,int,int,int);
void tor1(int,int,int,int,int,int,int);
void rabbit2(int,int,int,int);
void gbushes();
void put_bigtree(int,int);
void put_startboard(int,int);
void g_grass();
void put_haretree(int,int);
void animation();
road();
put_clouds(440,-100);
put_clouds(100,-120);

66
put_clouds(70,-110);
hare(-170,-60,RED,WHITE);
tor1(-260,60,LIGHTGREEN,GREEN,BROWN,BLUE,WHITE);
tor1(-260,100,LIGHTGREEN,GREEN,BROWN,BLUE,WHITE);
tor1(-185,70,LIGHTGREEN,GREEN,BROWN,BLUE,WHITE);
tor1(-190,90,LIGHTGREEN,GREEN,BROWN,BLUE,WHITE);
rabbit2(-260,130,RED,WHITE);
hare(-185,120,RED,WHITE);
gbushes();
put_bigtree(-100,-35);
put_startboard(300,170);
g_grass();
put_haretree(185,-25);
animation();
}
///////////////////////////////grass group///////////////////////////
void g_grass()
{
put_grass(500,206);
put_grass(490,216);
put_grass(530,206);
put_grass(560,205);
put_grass(590,205);
put_grass(625,205);
put_grass(650,200);
put_grass(20,250);
put_grass(60,200);
put_grass(300,160);
put_grass(230,200);
put_grass(270,230);
put_grass(210,170);
put_grass(440,220);
put_grass(397,225);
//put_grass(397,435);
put_grass(450,430);
put_grass(500,429);
put_grass(550,445);
put_grass(580,445);
put_grass(620,455);
//put_grass(400,435);
put_grass(350,438+25);
put_grass(300,440+25);
put_grass(250,445+25);
}
////////////////////////////animation/////////////////////////////////////
void animation()

67
{
int i,j;
put_tortoise1(160,267);
move_hare1(240,330);
sleep(5);
putimage(240,330,hare1,XOR_PUT);
for(i=0;i<=65;i+=5)
{
if(i%2==0)
j=9;
else
j=0;
move_hare1(240+i,330-j);
delay(100);
move_hare2(240+i,330-j);
delay(100);
}
for(i=0;i<=114;i+=4)
{
put_tortoise1(160+i,267);
delay(180);
put_tortoise2(160+i,267);
delay(180);
}
sleep(1);
putimage(160+i-4,267,tortoise2,XOR_PUT);
putimage(240+65,330-j,hare2,XOR_PUT);
put_tortoise1(160+250,267);
rabbit2(230,90-9,BLACK,WHITE);
for(i=0;i<=145;i+=3)
{
if(i%2==0)
j=9;
else
j=0;
rabbit2(230+(i*3),90-j,BLACK,WHITE);
delay(50);
put_tortoise1(160+i+250,267);
delay(180);
rabbit2(230+(3*i),90-j,BLACK,BLACK);
hare(230+(3*i),90-j,BLACK,WHITE);
delay(180);
put_tortoise2(160+i+250,267);
delay(180);
hare(230+(3*i),90-j,BLACK,BLACK);
}

68
}
/////////////////////////////////////group of bushes////////////////////////
void gbushes()
{
bushes(10,120,15,15,GREEN);
bushes(20,120,15,15,GREEN);
bushes(55,130,25,15,GREEN);
bushes(90,130,20,15,GREEN);
bushes(120,140,20,15,GREEN);
bushes(100,110,25,25,GREEN);
bushes(160,145,30,20,GREEN);
bushes(174,126,17,10,GREEN);
bushes(195,128,17,12,GREEN);
bushes(230,132,25,15,GREEN);
bushes(213,110,15,15,GREEN);
bushes(255,132,15,13,GREEN);
bushes(270,137,15,15,GREEN);
bushes(290,137,15,15,GREEN);
bushes(275,115,25,20,GREEN);
bushes(305,137,20,17,GREEN);
bushes(335,137,20,15,GREEN);
bushes(355,139,20,15,GREEN);
bushes(385,138,22,17,GREEN);
bushes(410,138,17,15,GREEN);
bushes(380,115,22,20,GREEN);
bushes(435,139,22,19,GREEN);
bushes(465,140,17,15,GREEN);
bushes(487,140,15,12,GREEN);
bushes(508,141,17,15,GREEN);
bushes(535,142,20,19,GREEN);
bushes(490,120,25,15,GREEN);
bushes(556,143,20,18,GREEN);
bushes(580,143,25,15,GREEN);
bushes(605,144,20,15,GREEN);
bushes(625,146,20,10,GREEN);
bushes(580,120,25,15,GREEN);
}
////////////////////////////start board///////////////////////////////////
void put_startboard(int x,int y)
{
int i;
setcolor(LIGHTBLUE);
setfillstyle(SOLID_FILL,4);
rectangle(x,y,x+90,y+20);
floodfill(x+4,y+4,LIGHTBLUE);
rectangle(x+40,y+20,x+50,y+70);

69
floodfill(x+44,y+23,LIGHTBLUE);
rectangle(x+40,y+20,x+50,y+70);
line(x+90,y,x+115,y+10);
line(x+90,y+20,x+115,y+10);
floodfill(x+92,y+3,LIGHTBLUE);
setcolor(WHITE);
settextstyle(6,HORIZ_DIR,1);
outtextxy(x+10+12+18,y+4,"START");
setcolor(LIGHTBLUE);
rectangle(x,y,x+90,y+20);
rectangle(x+40,y+20,x+50,y+70);
line(x+90,y,x+115,y+10);
line(x+90,y+20,x+115,y+10);
for(i=0;i<=10;i++)
line(x+40+i,y+70,x+175+i,y+254+3);
line(x+50,y+70,x+185,y+255+2);
}
/////////////////////////// road //////////////////////////////////////////
void road()
{
int poly[8]={0,470,0,650,700,650,700,408};
setcolor(WHITE);
line(-10,290,700,190);
line(-10,470,700,390+18);
setfillstyle(SOLID_FILL,GREEN);
fillpoly(4,poly);
}
///////////////////////////////frame2//////////////////////////////////////
void frame2()
{

void put_clouds(int,int);
void put_haretree(int,int);
void road2();
void g_bushes2();
void g_grass2();
void animation2();
put_clouds(200,-120);
put_clouds(240,-110);
put_clouds(-140,-100);
put_clouds(-100,-95);
put_haretree(250,10);
put_haretree(-60,10);
road2();
g_bushes2();
g_grass2();

70
animation2();
}
////////////////////////group of bushes///////////////////////////////////
void g_bushes2()
{
bushes(200,230,25,20,2);
bushes(235,230,35,25,2);
bushes(270,230,25,20,2);
bushes(240,200,35,25,2);
bushes(300,230,25,20,2);
bushes(385,230,25,20,2);
bushes(409,230,25,20,2);
bushes(450,230,35,23,2);
bushes(480,230,25,20,2);
bushes(510,230,30,25,2);
bushes(430,200,25,20,2);
bushes(470,200,30,25,2);
}
////////////////////////////////grassgroup//////////////////////////////////
void g_grass2()
{
int z;
put_grass(2,420);
put_grass(20,420);
put_grass(20,435);
put_grass(40,435);
put_grass(60,435);
put_grass(10,455);
put_grass(30,455);
put_grass(50,455);
for(z=1;z<660;z+=25)
{
put_grass(0+z,475);
put_grass(200+z,273);
}
put_grass(140,250);
put_grass(160,270);
put_grass(170,250);
put_grass(100,200);
put_grass(100,230);
put_grass(70,200);
put_grass(50,180);
put_grass(30,160);
put_grass(250,250);
}
/////////////////////////////////animation/////////////////////////////////////

71
void animation2()
{
int i,j,k=0,l=0;
/////////////////////////in slant direction////////////////////////////
for(i=0;i<=45;i+=5,k+=1)
{
if(i%2==0)
j=9;
else
j=0;
move_hare1(3+i,243-j+k+18+30);
delay(100);
move_hare2(3+i,243-j+k+18+30);
delay(100);
}
///////////////////////in horizontal direction//////////////////////////////
for(i=0,l=0,k=0;i<=120;i+=5,l+=20,k--)
{
if(i%2==0)
j=9;
else
j=0;
move_hare1(52+l,330-j-10);
delay(180);
put_tortoise1(i-20,250-k+50);
delay(180);
move_hare2(52+l,330-j-10);
delay(180);
put_tortoise2(i-20,250-k+50);
delay(180);
}
///////////TO ERASE THE HARE PRODUCED BY GET-PUT IMAGE
FUNCTIONS/////////////
setcolor(BLACK);
setfillstyle(SOLID_FILL,BLACK);
fillellipse(570,370,74,68);
l=440;i=110;k=-100;
for(;i<=550;i+=5,l+=2,k--)
{
if(i%2==0)
j=9;
else
j=0;
rabbit1(230+l,75-j,RED,WHITE);
delay(100);
put_tortoise1(i-20,250+50+25);

72
delay(180);
rabbit1(230+l,75-j,BLACK,BLACK);
rabbit2(230+l,75-j,RED,WHITE);
delay(100);
put_tortoise2(i-20,250+50+25);
delay(180);
rabbit2(230+l,75-j,BLACK,BLACK);
}}
////////////////////////////////ROAD////////////////////////////////////////
void road2()
{
int poly[10]={140,470,0,410,0,600,660,600,660,470};
arc(270,-70,90,270,350);
line(270,280,660,280);
arc(270,70,90,252,400+20);
line(140,470,660,470);
setfillstyle(SOLID_FILL,GREEN);
fillpoly(4,poly);
}
/////////////////////////////////frame3///////////////////////////////////////
void frame3()
{
void put_clouds(int,int);
void put_bigtree(int,int);
void road4();
void g_bushes4();
void g_grass4();
void animation3();
put_clouds(300,-100);
put_clouds(340,-90);
put_clouds(50,-100);
put_clouds(90,-110);
put_clouds(-120,-130);
put_bigtree(-100,-22);
put_bigtree(140,-30);
put_bigtree(350,-40);
road4();
g_bushes4();
g_grass4();
animation3();
}
////////////////////////group of bushes///////////////////////////////////
void g_bushes3()
{
bushes(200,230,25,20,2);
bushes(235,230,35,25,2);

73
bushes(270,230,25,20,2);
bushes(240,200,35,25,2);
bushes(300,230,25,20,2);
bushes(385,230,25,20,2);
bushes(409,230,25,20,2);
bushes(450,230,35,23,2);
bushes(480,230,25,20,2);
bushes(510,230,30,25,2);
bushes(430,200,25,20,2);
bushes(470,200,30,25,2);
}
////////////////////////////////grassgroup//////////////////////////////////
void g_grass3()
{
int z;
put_grass(2,420);
put_grass(20,420);
put_grass(20,435);
put_grass(40,435);
put_grass(60,435);
put_grass(10,455);
put_grass(30,455);
put_grass(50,455);
for(z=1;z<660;z+=25)
{
put_grass(0+z,475);
put_grass(200+z,273);
}
put_grass(140,250);
put_grass(160,270);
put_grass(170,250);
put_grass(100,200);
put_grass(100,230);
put_grass(70,200);
put_grass(50,180);
put_grass(30,160);
put_grass(250,250);
}
/////////////////////////////////animation/////////////////////////////////////
void animation3()
{
int i,j;
for(i=0;i<=45;i+=5)
{
if(i%2==0)
j=9;

74
else
j=0;
move_hare1(3+i,243-j+60);
delay(200);
move_hare2(3+i,243-j+60);
delay(200);
}
for(i=0;i<=500;i+=5)
{
if(i%2==0)
j=9;
else
j=0;
move_hare1(52+i,330-j-30-5);
delay(200);
move_hare2(52+i,330-j-30-5);
delay(200);
}}
////////////////////////////////ROAD////////////////////////////////////////
void road3()
{
arc(270,-70,90,270,350);
line(270,280,660,280);
arc(270,70,90,252,400+20);
line(140,470,660,470);
}
///////////////////////////////////////////frame4///////////////////////////
void frame4()
{
void put_clouds(int,int);
void put_bigtree(int,int);
void road4();
void put_bigtree(int,int);
void put_bigtree(int,int);
void g_bushes4();
void g_grass4();
void animation4();
put_clouds(300,-100);
put_clouds(340,-90);
put_clouds(50,-100);
put_clouds(90,-110);
put_clouds(-120,-130);
put_bigtree(-100,-22);
road4();
put_bigtree(140,-30);
put_bigtree(350,-55);

75
g_bushes4();
g_grass4();
animation4();
}
//////////////////////////////group of bushes///////////////////////////
void g_bushes4()
{
bushes(20,250,30,25,2);
bushes(57,250,35,30,2);
bushes(150,250,30,25,2);
bushes(190,250,35,25,2);
bushes(240,250,30,25,2);
bushes(270,250,35,25,2);
bushes(190,220,30,25,2);
bushes(240,220,35,35,2);
bushes(390,230,30,25,2);
bushes(440,225,35,35,2);
bushes(490,230,30,25,2);
bushes(520,230,35,30,2);
bushes(550,230,30,25,2);
bushes(600,225,35,35,2);
bushes(430,190,35,35,2);
bushes(490,190,35,35,2);
bushes(460,150,30,20,2);
}
//////////////////////////grass-group/////////////////////////////////
void g_grass4()
{
int z,o;
for(z=1,o=0;z<300,o<10;z+=30,o++)
put_grass(10+z,280-o);
for(z=1,o=0;z<300,o<10;z+=30,o++)
put_grass(370+z,260-o);
put_grass(320,270);
put_grass(340,268);
put_grass(20,455);
put_grass(70,453);
put_grass(150,450);
put_grass(175,450);
put_grass(100,453);
put_grass(220,448);
put_grass(397,435);
put_grass(450,430);
put_grass(500,429);
put_grass(550,430);
put_grass(580,430);

76
put_grass(620,430);
put_grass(400,435);
put_grass(350,438);
put_grass(300,440);
put_grass(250,445);
}
////////////////////////////////road//////////////////////////////////
void road4()
{
int poly[8]={0,460,0,500,700,500,660,420};
line(0,290,660,242);
line(0,460,660,420);
setfillstyle(SOLID_FILL,GREEN);
fillpoly(4,poly);
}
///////////////////////////animation/////////////////////////////////////
void animation4()
{
int i;
for(i=0;i<=550;i+=4)
{
put_tortoise1(i,320);
delay(180);
put_tortoise2(i,320);
delay(180);
}
}
///////////////////////////////////FRAME5///////////////////////////////////
void frame5()
{
void put_clouds(int,int);
void put_haretree(int,int);
void road5();
void gbushes5();
void ggrass();
void animation5();
put_clouds(-40,-110);
put_clouds(-70,-105);
put_clouds(-10,-110);
put_clouds(10,-110);
put_clouds(-20,-105);
put_clouds(40,-110);
put_clouds(10,-110+20);
put_clouds(-20,-105+20);
put_clouds(40,-110+20);
put_clouds(-40+250,-110);

77
put_clouds(-70+250,-105);
put_clouds(-10+250,-110);
put_haretree(210,25);
road5();
gbushes5();
ggrass();
animation5();
}
//////////////////////////////animation////////////////////////////////////
void animation5()
{
int i,j,k=0;
for(i=0;i<=400;i+=5,k++)
{
if(i%2==0)
j=9;
else
j=0;
move_hare1(30+i,350-j-k);
delay(200);
move_hare2(30+i,350-j-k);
delay(200);
}
putimage(30+i-5,350-j-k+1,hare2,XOR_PUT);
putimage(480,165,hare2,OR_PUT);
put_grass(550,240);
put_grass(575,243);
sleep(4);
}
/////////////////////////group of grass/////////////////////////////////////
void ggrass()
{
put_grass(58,285);
put_grass(140,280);
put_grass(225,267);
put_grass(303,262);
put_grass(475,240);
put_grass(460,249);
put_grass(485,249);
put_grass(550,240);
put_grass(575,243);
put_grass(600,243);
put_grass(625,243);
put_grass(20,460);
put_grass(100,485);
put_grass(190,470);

78
put_grass(240,475);
put_grass(350,460);
put_grass(460,435);
put_grass(530,430);
put_grass(630,425);
put_grass(580,425);
put_grass(500,430);
}
////////////////////////////////group of bushes//////////////////////////////
void gbushes5()
{
bushes(20,247,50,40,GREEN);
bushes(90,247,60,40,GREEN);
bushes(135,245,45,30,GREEN);
bushes(170,240,60,45,GREEN);
bushes(93,190,60,45,GREEN);
bushes(260,220,70,50,GREEN);
bushes(350,220,65,50,GREEN);
bushes(300,150,60,45,GREEN);
bushes(410,225,41,35,GREEN);
}
/////////////////////////////////ROAD///////////////////////////////////////
void road5()
{
int poly[8]={0,460,0,500,700,500,660,420};
line(0,290,660,242);
line(0,460,660,420);
setfillstyle(SOLID_FILL,GREEN);
fillpoly(4,poly);
}
////////////////////////////////////FRAME7//////////////////////////////////
void frame7()
{
void put_clouds(int,int);
void put_haretree(int,int);
void road7();
void gbushes7();
void ggrass7();
void animation7();
put_clouds(-40,-110);
put_clouds(-70,-105);
put_clouds(-10,-110);
put_clouds(10,-110);
put_clouds(-20,-105);
put_clouds(10,-110+20);
put_clouds(-20,-105+20);

79
put_clouds(40,-110+20);
put_clouds(-40+250,-110);
put_clouds(-70+250,-105);
put_clouds(-10+250,-110);
put_haretree(210,25);
road7();
gbushes7();
ggrass7();
animation7();
}
//////////////////////////////animation////////////////////////////////////
void animation7()
{
int i,j,k=0;
putimage(30+i-5,350-j-k+1,hare2,XOR_PUT);
putimage(480,165,hare2,OR_PUT);
put_grass(550,240);
put_grass(575,243);
for(i=0;i<=500;i+=4)
{
put_tortoise1(i+50,320);
delay(180);
put_tortoise2(i+50,320);
delay(180);
}}
/////////////////////////group of grass/////////////////////////////////////
void ggrass7()
{
put_grass(58,285);
put_grass(140,280);
put_grass(225,267);
put_grass(303,262);
put_grass(475,240);
put_grass(460,249);
put_grass(485,249);
put_grass(550,240);
put_grass(575,243);
put_grass(600,243);
put_grass(625,243);
put_grass(20,460);
put_grass(100,475);
put_grass(190,470);
put_grass(240,475);
put_grass(350,440);
put_grass(460,435);
put_grass(530,430);

80
put_grass(630,425);
put_grass(580,425);
put_grass(500,430);
}
////////////////////////////////group of bushes//////////////////////////////
void gbushes7()
{
bushes(20,247,50,40,GREEN);
bushes(90,247,60,40,GREEN);
bushes(135,245,45,30,GREEN);
bushes(170,240,60,45,GREEN);
bushes(93,190,60,45,GREEN);
bushes(260,220,70,50,GREEN);
bushes(350,220,65,50,GREEN);
bushes(300,150,60,45,GREEN);
bushes(410,225,41,35,GREEN);
}
/////////////////////////////////ROAD///////////////////////////////////////
void road7()
{
int poly[8]={0,460,0,500,700,500,660,420};
line(0,290,660,242);
line(0,460,660,420);
setfillstyle(SOLID_FILL,GREEN);
fillpoly(4,poly);
}
/////////////////////////////////FRAME8//////////////////////////////////////
void frame8()
{
void put_clouds(int,int);
void put_haretree(int,int);
void road8();
void gbushes8();
void ggrass8();
void animation8();
put_clouds(-40,-110);
put_clouds(-70,-105);
put_clouds(-10,-110);
put_clouds(10,-110);
put_clouds(-20,-105);
put_clouds(40,-110);
put_clouds(10,-110+20);
put_clouds(-20,-105+20);
put_clouds(40,-110+20);
put_clouds(-40+250,-110);
put_clouds(-70+250,-105);

81
put_clouds(-10+250,-110);
put_haretree(210,25);
road8();
gbushes8();
ggrass8();
animation8();
}
//////////////////////////////animation////////////////////////////////////
void animation8()
{
int k,j,i;
void ggrass8();
void rabit1();
void rabit2();
putimage(480,165,hare2,OR_PUT);
sleep(6);
putimage(480,165,hare2,XOR_PUT);
ggrass8();
put_haretree(210,25);

for(i=0;i<=55;i+=3)
{
if(i%2==0)
j=9;
else
j=0;
rabit2(230+(i*3),20-j,BLACK,WHITE);
delay(125);
rabit2(230+(3*i),20-j,BLACK,BLACK);
rabit1(230+(3*i),20-j,BLACK,WHITE);
delay(125);
rabit1(230+(3*i),20-j,BLACK,BLACK);
}
}
/////////////////////////group of grass/////////////////////////////////////
void ggrass8()
{
void rabbit1();
put_grass(58,285);
put_grass(140,280);
put_grass(225,267);
put_grass(303,262);
put_grass(475,240);
put_grass(460,249);
put_grass(485,249);
put_grass(550,240);

82
put_grass(575,243);
put_grass(600,243);
put_grass(625,243);
put_grass(20,460);
put_grass(100,475);
put_grass(190,470);
put_grass(240,475);
put_grass(350,440);
put_grass(460,435);
put_grass(530,430);
put_grass(630,425);
put_grass(580,425);
put_grass(500,430);
}
////////////////////////////////group of bushes//////////////////////////////
void gbushes8()
{
bushes(20,247,50,40,GREEN);
bushes(90,247,60,40,GREEN);
bushes(135,245,45,30,GREEN);
bushes(170,240,60,45,GREEN);
bushes(93,190,60,45,GREEN);
bushes(260,220,70,50,GREEN);
bushes(350,220,65,50,GREEN);
bushes(300,150,60,45,GREEN);
bushes(410,225,41,35,GREEN);
}
/////////////////////////////////ROAD///////////////////////////////////////
void road8()
{
int poly[8]={0,460,0,500,700,500,660,420};
line(0,290,660,242);
line(0,460,660,420);
setfillstyle(SOLID_FILL,GREEN);
fillpoly(4,poly);
}
//////////////////harefunction with colors as arguments////////////////////
void rabit1(int x,int y,int color1,int color2)
{
unsigned int size;
int i;
void *hare1;
int poly[10]={ 304,276,313,269,316,269,318,270,324,271};
int mouthpoly[8]={351,283,353,282,354,280,356,283};
int frontleg[70] ={307,312-3,305,313-3,303,314-3,300,314-3,296,313-3,293,312+2,
293,310+5,294,311+5,297,311+5,301,311+5,304,310+4,315,310+4,317,314+2,

83
320,314+2,325,314+2,327,314+3,329,314+3,332,314+3,334,314+3,
336,314+2,337,314+2,337-2,314+1,337-7,314+1,337-7,314,337,312,
337,310,337-7,308,340,312,341,311,342,310,
342,309,341,308,342,306,341,307,340,308};
int frontleg1[70];
int poly1[10];
int mouthpoly1[8];
for(i=0;i<84;i++)
{
if(i%2==0)
frontleg1[i]=frontleg[i]+x;
else
frontleg1[i]=frontleg[i]+y;
}
for(i=0;i<10;i++)
{
if(i%2==0)
poly1[i]=poly[i]+x;
else
poly1[i]=poly[i]+y;
}
for(i=0;i<8;i++)
{
if(i%2==0)
mouthpoly1[i]=mouthpoly[i]+x;
else
mouthpoly1[i]=mouthpoly[i]+y;
}
//TO LOCATE THE POINT FOR THE LEG
//line(307,314,307,320);
setcolor(color1);
setfillstyle(SOLID_FILL,color2);
fillpoly(35,frontleg1);
//upper body lines to fill the upper part
setcolor(color2);
for(i=0;i<=12;i++)
line(317-5+x,270-1+i+y,336+3+x,272+1+i+y);
for(;i<=15;i++)
line(317+x,270-1+i+y,336+3+7+x,272+1+i+y);
setcolor(color2);
line(310+x,284+y,346+x,288+y);
line(310+x,285+y,346+x,289+y);
line(310+x,286+y,347+x,290+y);
line(310+x,287+y,346+x,291+y);
line(310+x,288+y,345+x,292+y);
line(310+x,289+y,344+x,293+y);

84
line(310+x,290+y,340+x,294+y);
line(305+x,291+y,338+x,295+y);
line(305+x,292+y,336+x,296+y);
line(305+x,293+y,336+x,297+y);
line(305+x,294+y,336+x,298+y);
line(305+x,295+y,335+x,299+y);
line(305+x,296+y,335+x,300+y);
line(305+x,297+y,335+x,301+y);
line(305+x,298+y,334+x,302+y);
line(305+x,298+y,333+x,303+y);
line(304+x,299+y,333+x,303+y);
line(304+x,300+y,332+x,304+y);
line(304+x,301+y,331+x,305+y);
for(i=18;i<=23;i++)
line(317+x,269+i+y,336+x,273+i+y);
ellipse(332+x,286+y,359,111,10,14);
//head and ears
setcolor(color2);
setfillstyle(SOLID_FILL,color2);
setcolor(color1);
fillellipse(346+x,279+y,8,8);
fillellipse(346+x,262+y,4,12);
fillellipse(340+x,262+y,4,12);
//EYE
circle(350+x,277+y,1);
//MOUTH
fillpoly(3,mouthpoly1);
setcolor(color2);
setfillstyle(SOLID_FILL,color2);
// main body
fillellipse(313+x,292+y,20,20);
//tail
fillellipse(295+x,302+y,10,2);
setcolor(BLACK);
ellipse(321+x,296+y,365,180,17,9);
setfillstyle(SOLID_FILL,color2);
setcolor(color2);
}
///////////////hare-2 with colors as arguments///////////////////////////////
void rabit2(int x, int y,int color1,int color2)
{
unsigned int size;
int i;
int poly[10]={ 304,276,313,269,316,269,318,270,324,271};
int mouthpoly[8]={351,283,353,282,354,280,356,283};
int legs[70] ={307,312-3,305,313-3,303,314-3,300,314-3,296,313-3,293,312+2,

85
293,310+5,294,311+5,297,311+5,301,311+5,304,310+4,315,310+4,317,314+2,
320,314+2,325,314+2,327,314+3,329,314+3,332,314+3,334,314+3,
336,314+2,337,314+2,337-2,314+1,337-7,314+1,337-7,314,337,312,
337,310,337-7,308,340,312,341,311,342,310,
342,309,341,308,342,306,341,307,340,308};
int legs1[70];
int poly1[10];
int mouthpoly1[8];
for(i=0;i<70;i++)
{
if(i%2==0)
legs1[i]=legs[i]+x;
else
legs1[i]=legs[i]+y;
}
for(i=0;i<10;i++)
{
if(i%2==0)
poly1[i]=poly[i]+x;
else
poly1[i]=poly[i]+y;
}
for(i=0;i<8;i++)
{
if(i%2==0)
mouthpoly1[i]=mouthpoly[i]+x;
else
mouthpoly1[i]=mouthpoly[i]+y;
}
//TO LOCATE THE POINT FOR THE LEG
//line(307,314,307,320);
setcolor(BLACK);
setfillstyle(SOLID_FILL,color2);
fillpoly(35,legs1);
/*upper body line*/
setcolor(color2);
for(i=0;i<=8;i++)
ellipse(332+x,286+i+y,359,125,9,14);
/*head && ears*/
setcolor(BLACK);
setcolor(BLACK);
fillellipse(346+x,262+y,4,12);
fillellipse(340+x,262+y,4,12);
setcolor(color1);
/* throat*/
setcolor(color2);

86
for(i=0;i<=5;i++)
line(340-i+x,298+y,349-i+x,285+y);
/*head*/
setcolor(BLACK);
fillellipse(346+x,279+y,8,8);
/*EYE*/
setcolor(color1);
circle(350+x,277+y,1);
/*MOUTH*/
fillpoly(3,mouthpoly1);
setcolor(color1);
moveto(341+x,293+y);
linerel(-3,2);
linerel(-1,2);
linerel(-1,3);
linerel(-4,4);
linerel(-5,3);
linerel(-3,0);
linerel(-5,0);
setcolor(color2);
setfillstyle(SOLID_FILL,color2);
/*main body*/
fillellipse(313+x,292+y,29,17);
/*tail*/
fillellipse(295+x,302+y,17,2);
setcolor(BLACK);
ellipse(312+x,297+y,340,140,16,14);
setfillstyle(SOLID_FILL,color2);
setcolor(color2);
}
///////////////////////////////////FRAME11///////////////////////////////////
///////////////////////////////////program///////////////////////////////////
void frame11()
{
void road11();
void put_clouds(int,int);
void put_clouds(int,int);
void gbushes11();
void put_bigtree(int,int);
void g_grass11();
void put_stopboard(int,int);
void animation11();
road11();
put_clouds(400,-100);
put_clouds(200,-120);
gbushes11();

87
put_bigtree(-130,-30);
g_grass11();
put_bigtree(-10,-70);
put_stopboard(300,170);
animation11();
}
///////////////////////////////grass group///////////////////////////
void g_grass11()
{
put_grass(500,200);
put_grass(20,250);
put_grass(60,270);
put_grass(100,260);
put_grass(120,250);
put_grass(160,240);
put_grass(140,200);
put_grass(160,200);
put_grass(180,200);
put_grass(130,190);
put_grass(120,190);
put_grass(30,190);
put_grass(20,190);
put_grass(60,190);
put_grass(500,165);
put_grass(300,160);
put_grass(230,200);
put_grass(270,230);
put_grass(210,170);
put_grass(440,200);
put_grass(397,225);
put_grass(397,445);
put_grass(450,430);
put_grass(500,429);
put_grass(550,425);
put_grass(580,420);
put_grass(620,415);
put_grass(400,445);
put_grass(350,468);
put_grass(300,460);
put_grass(250,465);
}
//////////////////////////////animation11/////////////////////////////////////
void animation11()
{
int i=0,j,k=0;
/////////////TORTOISE MOVEMENT////////////////////////

88
for(i=0,k=0;i<=272;i+=5,k=k+10)
{
int j;
if(i%2==0)
j=9;
else
j=0;
put_tortoise1(i,295);
delay(180);
move_hare1(40+k-420,320-j);
delay(180);
put_tortoise2(i,295);
delay(180);
move_hare2(40+k-420,320-j);
delay(180);
}
setcolor(BLACK);
setfillstyle(SOLID_FILL,BLACK);
fillellipse(118+5+115+59,308,55,50);
put_tortoise1(160+255,277);
////////////////////////////////hare movement////////////////////////
for(;k<=660;k+=5)
{
if(k%2==0)
j=9;
else
j=0;
move_hare1(40+k-420,320-j);
put_tortoise1(160+255,277);
delay(180);
move_hare2(40+k-420,320-j);
put_tortoise1(160+255,277);
delay(180);
}
putimage(40+k-420-5,320-j,hare2,XOR_PUT);
putimage(40+k-420+150,320-j,hare2,OR_PUT);
}
/////////////////////////////////////group of bushes////////////////////////
void gbushes11()
{
bushes(10,120,15,15,GREEN);
bushes(20,120,15,15,GREEN);
bushes(55,130,25,15,GREEN);
bushes(90,130,20,15,GREEN);
bushes(120,140,20,15,GREEN);
bushes(100,110,25,25,GREEN);

89
bushes(160,145,30,20,GREEN);
bushes(174,126,17,10,GREEN);
bushes(195,128,17,12,GREEN);
bushes(230,132,25,15,GREEN);
bushes(213,110,15,15,GREEN);
bushes(255,132,15,13,GREEN);
bushes(270,137,15,15,GREEN);
bushes(290,137,15,15,GREEN);
bushes(275,115,25,20,GREEN);
bushes(305,137,20,17,GREEN);
bushes(335,137,20,15,GREEN);
bushes(355,139,20,15,GREEN);
bushes(385,138,22,17,GREEN);
bushes(410,138,17,15,GREEN);
bushes(380,115,22,20,GREEN);
bushes(435,139,22,19,GREEN);
bushes(465,140,17,15,GREEN);
bushes(487,140,15,12,GREEN);
bushes(508,141,17,15,GREEN);
bushes(535,142,20,19,GREEN);
bushes(490,120,25,15,GREEN);
bushes(556,143,20,18,GREEN);
bushes(580,143,25,15,GREEN);
bushes(605,144,20,15,GREEN);
bushes(625,146,20,10,GREEN);
bushes(580,120,25,15,GREEN);
}
////////////////////////////start board///////////////////////////////////
void put_stopboard(int x,int y)
{
int i;
setcolor(LIGHTBLUE);
setfillstyle(SOLID_FILL,4);
rectangle(x,y,x+90,y+20);
floodfill(x+4,y+4,LIGHTBLUE);
rectangle(x+40,y+20,x+50,y+70);
floodfill(x+44,y+23,LIGHTBLUE);
rectangle(x+40,y+20,x+50,y+70);
setcolor(WHITE);
settextstyle(6,HORIZ_DIR,1);
outtextxy(x+10+12+20,y-3-2+10,"STOP");
setcolor(LIGHTBLUE);
rectangle(x,y,x+90,y+20);
rectangle(x+40,y+20,x+50,y+70);
for(i=0;i<=10;i++)
line(x+40+i,y+70,x+175+i,y+254+3);

90
line(x+50,y+70,x+185,y+255+2);
}
/////////////////////////// road //////////////////////////////////////////
void road11()
{
int poly[8]={0,470,0,650,700,650,700,408};
setcolor(WHITE);
line(-10,290,700,190);
line(-10,470,700,390+18);
setfillstyle(SOLID_FILL,GREEN);
fillpoly(4,poly);
}
/////////////////////////////////////FRAME41/////////////////////////////////
/////////////////////////////////////program/////////////////////////////////
void frame41()
{
void put_clouds(int,int);
void put_bigtree(int,int);
void road41();
void put_haretree(int,int);
void put_bigtree(int,int);
void g_bushes41();
void g_grass41();
void animation41();
put_clouds(300,-100);
put_clouds(340,-90);
put_clouds(50,-100);
put_clouds(90,-110);
put_clouds(-120,-130);
put_bigtree(-100,-22);
road41();
put_haretree(20,40);
put_bigtree(350,-55);
g_bushes41();
g_grass41();
animation41();
}
//////////////////////////////group of bushes///////////////////////////
void g_bushes41()
{
bushes(20,250,30,25,2);
bushes(57,250,35,30,2);
bushes(150,250,30,25,2);
bushes(190,250,35,25,2);
bushes(240,250,30,25,2);
bushes(270,250,35,25,2);

91
bushes(190,220,30,25,2);
bushes(240,220,35,35,2);
bushes(390,230,30,25,2);
bushes(440,225,35,35,2);
bushes(490,230,30,25,2);
bushes(520,230,35,30,2);
bushes(550,230,30,25,2);
bushes(600,225,35,35,2);
bushes(430,190,35,35,2);
bushes(490,190,35,35,2);
bushes(460,150,30,20,2);
}
//////////////////////////grass-group/////////////////////////////////
void g_grass41()
{
int z,o;
for(z=1,o=0;z<300,o<10;z+=30,o++)
put_grass(10+z,280-o);
for(z=1,o=0;z<300,o<10;z+=30,o++)
put_grass(370+z,260-o);
put_grass(320,270);
put_grass(340,268);
put_grass(20,455);
put_grass(70,453);
put_grass(150,450);
put_grass(175,450);
put_grass(100,453);
put_grass(220,448);
put_grass(397,435);
put_grass(450,430);
put_grass(500,429);
put_grass(550,425);
put_grass(580,420);
put_grass(620,415);
put_grass(400,435);
put_grass(350,438);
put_grass(300,440);
put_grass(250,445);
}
////////////////////////////////road//////////////////////////////////
void road41()
{
int poly[8]={0,460,0,500,700,500,660,420};
line(0,290,660,242);
line(0,460,660,420);
setfillstyle(SOLID_FILL,GREEN);

92
fillpoly(4,poly);
}
///////////////////////////animation/////////////////////////////////////
void animation41()
{
int i;
for(i=0;i<=550;i+=4)
{
put_tortoise1(i,320);
delay(180);
put_tortoise2(i,320);
delay(180);
}}
/////////////////////////////////////FRAME31/////////////////////////////////
/////////////////////////////////////program/////////////////////////////////
void frame31()
{
void put_bigtree(int,int);
void road31();
void put_haretree(int,int);
void put_bigtree(int,int);
void g_bushes31();
void g_grass31();
void animation31();
put_clouds(300,-100);
put_clouds(340,-90);
put_clouds(50,-100);
put_clouds(90,-110);
put_clouds(-120,-130);
put_bigtree(-100,-22);
road31();
put_haretree(20,40);
put_bigtree(350,-55);
g_bushes31();
g_grass31();
animation31();
}
//////////////////////////////group of bushes///////////////////////////
void g_bushes31()
{
bushes(20,250,30,25,2);
bushes(57,250,35,30,2);
bushes(150,250,30,25,2);
bushes(190,250,35,25,2);
bushes(240,250,30,25,2);
bushes(270,250,35,25,2);

93
bushes(190,220,30,25,2);
bushes(240,220,35,35,2);
bushes(390,230,30,25,2);
bushes(440,225,35,35,2);
bushes(490,230,30,25,2);
bushes(520,230,35,30,2);
bushes(550,230,30,25,2);
bushes(600,225,35,35,2);
bushes(430,190,35,35,2);
bushes(490,190,35,35,2);
bushes(460,150,30,20,2);
}
//////////////////////////grass-group/////////////////////////////////
void g_grass31()
{
int z,o;
for(z=1,o=0;z<300,o<10;z+=30,o++)
put_grass(10+z,280-o);
for(z=1,o=0;z<300,o<10;z+=30,o++)
put_grass(370+z,260-o);
put_grass(320,270);
put_grass(340,268);
put_grass(20,455);
put_grass(70,453);
put_grass(150,450);
put_grass(175,450);
put_grass(100,453);
put_grass(220,448);
put_grass(397,435);
put_grass(450,430);
put_grass(500,439);
put_grass(550,445);
put_grass(580,440);
put_grass(620,435);
put_grass(400,435);
put_grass(350,438);
put_grass(300,440);
put_grass(250,445);
}
////////////////////////////////road//////////////////////////////////
void road31()
{
int poly[8]={0,460,0,500,700,500,660,420};
line(0,290,660,242);
line(0,460,660,420);
setfillstyle(SOLID_FILL,GREEN);

94
fillpoly(4,poly);
}
///////////////////////////animation/////////////////////////////////////
void animation31()
{
int i,j;
for(i=0;i<=45;i+=5)
{
if(i%2==0)
j=9;
else
j=0;
move_hare1(3+i,243-j+60-7);
delay(200);
move_hare2(3+i,243-j+60-7);
delay(200);
}
for(i=0;i<=500;i+=5)
{
if(i%2==0)
j=9;
else
j=0;
move_hare1(52+i,330-j-30-7);
delay(200);
move_hare2(52+i,330-j-30-7);
delay(200);
}}
void tort_demo()
{
int backleg[12]={284,263,284+3,267,287-
1+3,270+1,287+1+3,270,290+3,267,289+3,263};
int backlegcap[6]={284+4,267,287+4,271,290+4,267};
int frontleg[20]={321,258,321,267,323,272,325,272,327,267,328,260,
324,252};
int frontlegcap[20]={321,267,323,272,325,272,327,267};
int i;
unsigned int size;
zoom(getmaxx()/2-30,150,"COMING SOON....",15,8);
zoom(getmaxx()/2,320,"THE DEMO",15,8);
delay(100);
disappear(getmaxx()/2-30,150,"COMING SOON....",15,8);
disappear(getmaxx()/2,320,"THE DEMO",15,8);
setcolor(BROWN);
/* outline of the upper part of the body*/
ellipse(300,248,0,170,24,15);

95
setcolor(LIGHTGREEN);
sleep(1);
/* to fill upper part of the body*/
for(i=14;i>=12;i--)
{
ellipse(300,248,0,170,24,i);
delay(200);
}
setcolor(LIGHTGREEN);
setfillstyle(SOLID_FILL,LIGHTGREEN);
fillellipse(300,248,24,12);
sleep(1);
/* outline of tail */
setcolor(BROWN);
line(269,250,276,246);
line(269,250,274,256);
sleep(1);
/* to fill tail in lightgreen color*/
setcolor(LIGHTGREEN);
for(i=1;i<=5;i++)
{
line(269+i,250,276+i,246);
delay(200);
}
for(i=1;i<=5;i++)
{
line(269+i,250,274+i,256);
delay(500);
}
sleep(1);
/* outline of bottom part of body*/
setcolor(BROWN);
ellipse(298,251,200,10,25,13);
sleep(1);
/* to fill the bottom part of body in LIGHTGREEN COLOR*/
setcolor(LIGHTGREEN);
ellipse(299,250,200,10,25,13);
delay(500);
ellipse(300,249,200,330,25,13);
delay(500);
ellipse(301,248,200,335,25,13);
/*fillellipse(298,251,23,11);*/
sleep(1);
/* HEAD*/
fillellipse(321,244,17-6,5);
sleep(1);

96
/*EYE*/
setcolor(WHITE);
setfillstyle(SOLID_FILL,BLACK);
fillellipse(333-4,244,3,2);
sleep(1);
/*for backleg*/
setcolor(BROWN);
setfillstyle(SOLID_FILL,LIGHTGREEN);
fillpoly(6,backleg);
sleep(1);
/*backleg cap*/
setcolor(BROWN);
setfillstyle(SOLID_FILL,GREEN);
fillpoly(3,backlegcap);
sleep(1);
/*just for frontleg point*/
line(321,258,321,267);
delay(300);
moveto(321,267);
lineto(323,272);
delay(300);
lineto(325,272);
delay(300);
lineto(327,267);
delay(300);
lineto(328,260);
delay(300);
lineto(324,252);
sleep(1);
setcolor(BROWN);
setfillstyle(SOLID_FILL,LIGHTGREEN);
fillpoly(7,frontleg);
/* for frontleg cap*/
sleep(1);
setcolor(GREEN);
setfillstyle(SOLID_FILL,GREEN);
fillpoly(4,frontlegcap);
/*filling body with green ellipses */
setcolor(BLACK);
fillellipse(300,248,6,4);
delay(100);
fillellipse(313,249,5,3);
delay(100);
fillellipse(289,250,4,3);
delay(100);
fillellipse(304,257,7,4);

97
delay(100);
fillellipse(296,253,4,2);
delay(100);
fillellipse(294,260,5,4);
delay(100);
fillellipse(302,262,4,2);
delay(100);
fillellipse(308,261,2,2);
delay(100);
fillellipse(312,260,2,2);
delay(100);
fillellipse(317,256,6,4);
delay(100);
fillellipse(310,252,2,2);
delay(100);
fillellipse(305,252,3,3);
delay(100);
fillellipse(307,245,7,4);
delay(100);
fillellipse(321,253,4,2);
delay(100);
fillellipse(320,248,4,4);
delay(100);
fillellipse(317,245,2,2);
delay(100);
delay(100);
fillellipse(320,243,2,2);
delay(100);
fillellipse(314,240,4,4);
delay(100);
fillellipse(306,238,6,4);
delay(100);
fillellipse(300,236,4,2);
delay(100);
fillellipse(296,241,5,3);
delay(100);
fillellipse(294,236,4,3);
delay(100);
fillellipse(288,239,5,3);
delay(100);
fillellipse(282,241,2,2);
delay(100);
fillellipse(280,246,3,4);
delay(100);
fillellipse(289,245,6,4);
delay(100);

98
fillellipse(287,252,7,4);
delay(100);
fillellipse(285,255,8,4);
delay(100);
fillellipse(286,260,2,2);
delay(100);
fillellipse(277,253,4,3);
delay(100);
fillellipse(275,250,2,2);
delay(100);
fillellipse(273,251,2,2);
setcolor(WHITE);
sleep(1);
rectangle(265,225,345,285);
sleep(1);
rectangle(265,225,345,285);
sleep(2);
}

/////////////////////////////////HARE-DEMO/////////////////////////////////
void hare_demo()
{
int i;
int poly[10]={ 304,276,313,269,316,269,318,270,324,271};
int mouthpoly[20]={351,283,353,282,354,280,356,283};
int frontleg[84] ={307,312-3,305,313-3,303,314-3,300,314-3,296,313-3,293,312+2,
293,310+5,294,311+5,297,311+5,301,311+5,304,310+4,315,310+4,317,314+2,
320,314+2,325,314+2,327,314+3,329,314+3,332,314+3,334,314+3,
336,314+2,337,314+2,337-2,314+1,337-7,314+1,337-7,314,337,312,
337,310,337-7,308,340,312,341,311,342,310,
342,309,341,308,342,306,341,307,340,308};

setfillstyle(SOLID_FILL,WHITE);
setcolor(WHITE);
// main body
fillellipse(313,292,20,20);
sleep(3);
//head
setcolor(RED);
fillellipse(346,279,8,8);
sleep(2);
// upper part small polygon
setcolor(WHITE);
fillpoly(3,poly);
sleep(3);

99
//upper body lines to fill the upper part
setcolor(WHITE);
for(i=0;i<=12;i++)
{
line(317-5,270-1+i,336+3,272+1+i);
delay(1500);
}
for(;i<=15;i++)
line(317,270-1+i,336+3+7,272+1+i);
setcolor(WHITE);
delay(700);
line(310,284,346,288);
delay(700);
line(310,285,346,289);
delay(700);
line(310,286,347,290);
delay(700);
line(310,287,346,291);
delay(700);
line(310,288,345,292);
delay(700);
line(310,289,344,293);
delay(700);
line(310,290,340,294);
delay(700);
line(305,291,338,295);
delay(700);
line(305,292,336,296);
delay(700);
line(305,293,336,297);
delay(700);
line(305,294,336,298);
delay(700);
line(305,295,335,299);
delay(700);
line(305,296,335,300);
delay(700);
line(305,297,335,301);
delay(700);
line(305,298,334,302);
delay(700);
line(305,298,333,303);
delay(700);
line(304,299,333,303);
delay(700);
line(304,300,332,304);

100
delay(700);
line(304,301,331,305);
delay(700);
for(i=18;i<=23;i++)
line(317,269+i,336,273+i);
delay(700);
ellipse(332,286,359,111,10,14);
sleep(2);
//EYE
setcolor(RED);
circle(350,277,1);
sleep(2);
//MOUTH
fillpoly(3,mouthpoly);
sleep(2);
//ears
fillellipse(346+3,262,4,12);
sleep(4);
fillellipse(340+3,262,4,12);
sleep(3);
setcolor(WHITE);
//tail
fillellipse(295,302,10,2);
sleep(3);
//arc of legs
setcolor(BLACK);
ellipse(321,296,45,180,17,9);
sleep(2);
//legs
setcolor(RED);
setfillstyle(SOLID_FILL,WHITE);
fillpoly(35,frontleg);
sleep(1);
//THROAT ARC
ellipse(343,288,257,0,4,5);
sleep(1);
setcolor(WHITE);
setfillstyle(SOLID_FILL,WHITE);
rectangle(280,240,365,330);
sleep(2);
}
////////////////////////////////endtitle////////////////////////////////////
void func2(char *str,int font,int size,int color,int direction)
{
int x,y,midx,midy;
settextstyle(font,HORIZ_DIR,size);

101
settextjustify(CENTER_TEXT,CENTER_TEXT);
setcolor(color);
midx=getmaxx()/2;
midy=getmaxy()/2;
switch(direction)
{
case 1:/* from up to center */
x=midx;
y=0;
for(;y<midy;y+=5)
{
outtextxy(x,y,str);
delay(20);
setcolor(0);
outtextxy(x,y,str);
setcolor(color);
}
outtextxy(midx,midy,str);
break;
case 2:/* from botom to center */
x=midx;
y=midy*2;
for(;y>midy;y-=5)
{
outtextxy(x,y,str);
delay(20);
setcolor(0);
outtextxy(x,y,str);
setcolor(color);
}
outtextxy(midx,midy,str);
break;
case 3:/* from center to left */
x=midx;
y=midy;
for(;x>-20;x-=5)

{
outtextxy(x,y,str);
delay(20);
setcolor(0);
outtextxy(x,y,str);
setcolor(color);
}
break;

102
case 4:/* from center to right */
x=midx;
y=midy;
for(;x<midx*2+20;x+=5)
{
outtextxy(x,y,str);
delay(20);
setcolor(0);
outtextxy(x,y,str);
setcolor(color);
}
break;
case 5:/* from left to right */
x=0;
y=midy;
for(;x<midx*2+20;x+=5)
{
outtextxy(x,y,str);
delay(20);
setcolor(0);
outtextxy(x,y,str);
setcolor(color);
}
break;
case 6:/* from right to left */
x=midx*2+1;
y=midy;
for(;x>-20;x-=5)
{
outtextxy(x,y,str);
delay(20);
setcolor(0);
outtextxy(x,y,str);
setcolor(color);
}
break;
}
}
void endtitle()
{
int i;
randomize();
cleardevice();
delay(500);
func2("GRAPHICS",8,12,15,3);
cleardevice();

103
func2("CREATION",8,12,15,2);
cleardevice();
func2("AND",8,12,15,1);
cleardevice();
func2("PROGRAMMING",8,12,15,6);
cleardevice();
func2("NIDHI SHARMA",8,12,15,5);
cleardevice();
func2("YOJANA BIYANI",8,12,15,6);
cleardevice();
func2("IMAGE",8,12,15,2);
cleardevice();
func2("DESIGNING",8,12,15,1);
cleardevice();
func2("AND",8,12,15,3);
cleardevice();
func2("ANIMATION",8,12,15,2);
cleardevice();
func2("ASHISH GARG",8,12,15,1);
cleardevice();
func2("NARENDRA BAGORIA",8,12,15,2);
cleardevice();
func2("FINAL YEAR",8,12,15,5);
cleardevice();
func2("ECE",8,12,15,6);
cleardevice();
for(i=0;i<=1;i++)
{
zoom(getmaxx()/2,150,"SEC",15,8);
zoom(getmaxx()/2,320,"SIKAR",15,8);
delay(100);
disappear(getmaxx()/2,150,"SEC",15,8);
disappear(getmaxx()/2,320,"SIKAR",15,8);
}
}

Conclusion

Our project is based on computer graphics using C language. This shows the
famous “Tortoise and the Hare” story graphically. The entire program is written in C.

104
As far as image designing is concerned, we used mostly the general functions like
setcolor, circle, ellipse, arc, line, lineto, linerel, fillellipse, fillpoly, floodfill, putimage,
getimage, settextstyle, outtextxy, putpixel, imagesize functions.
After designing the image, we apply windowing-clipping method by using get
image and put image functions. In this we first, calculate the coordinates of the window
which will inscribe the required image and pass the coordinates of that window through
imagesize function and that will give you the number of bytes required to store the image
on to the memory.
Thus, we use the dynamic memory allocation to store the images in a pointer
variable. Getimage function stores the image on to the memory by passing the pointer
(address) and window coordinates to it .And once we store that image, then we can place
that image wherever we want on the display screen using putimage function.
The difficulty comes how to animate this image. Simply setting a loop and
moving the clipping in horizontal manner by changing x coordinate of the image
uniformly, we are not going to get a sophisticated animation. To implement reality,
liveliness, we designed two different images of the same object. Thus two frames for hare
and two frames for tortoise are created. The two images of the same object will be
slightly different. By placing these two images one after another simultaneously, and
changing x and y coordinates irregularly, we can see more elegant animation.

Reference

1. Yashvant Kanetkar, “Let Us C”,BPB Publications.

105
2. Byron Gottfried, “Programming with C”, Tata McGraw-Hill Publishing Company
Limited.
3. Brain W. Kernighan and Dennis M. Ritchie “The C Programming Language”, Prentice
Hall Software Series.
4. Yashvant Kanetkar, “Graphics Under C”, BPB Publications.

106