Thursday, April 4, 2013

Video Game Reduces Stress


Did you know that an awesome healing power had always been right at your comfort-zone? And that’s equally potent as any other antidote? Talking about video games! The joystick or the mouse, apart from offering a powerhouse of pleasure & entertainment, has a soothing effect on even the worst kind of mental fatigue- STRESS.

Your to-do-list is crowded with deadlines. The cubicle is loaded with files. Or your virtual office hardly lets you look around. Else the towering syllabi of the upcoming exam are baffling you. Pushed for the extreme, you are at your wit’s end. Or hey, may be your partner just ditched you or the other way round? Whatever it is, the result is at the end of the day, YOU ARE STRESSED OUT.

Thinking of attending a stress management workshop? But before you spend on that, why don’t you try some video game-play for some hundred bucks or even for free?

The good news is, video games reduce the stress-related hormone Cortisol by 17%. So next time you are done with your office for the day, go for at least a 30 minutes’ refreshing session of VR games. This will also increase your productivity level at work.
Of course not telling you to play at breaks in office-hours

Dear students & their worried parents- video games NEVER hinder study if played in a proper way. Rather relieve the students from the huge pressure & thus help learning to be an enjoyable experience. ‘Call of Duty’, for example, is a helping game in releasing stress for students.


Long-term young adult gamers handle stress better than non-gamer fellows & develop a more controlled response to a stressful work.



The ‘heartbreak kids’ can release the frustration through an action game, sports, fighting, social or adventure game. And some games are as if made for them! These train you how to fall in love & retain it. The intelligent games are almost like an enjoyable grooming session of how to dress makeup & cook thus boosting up your confidence. Though these are mainly tagged as girly games, as I’ve said earlier, games don’t follow a gander bias.
Angry? Try a shooting game. It will give you a vent to your anger. Indeed quite contradictory to the general studies that indicate the opposite.
Doesn’t an improved eye-sight definitely give a leash of life to your sensory organs? A game-play tests your vision to its limits thus improves the eye-sight 20 times better.
Video games are your friends of the sleepless lonely nights & days. Games like Bejewelled, Half-life etc. keep you intrigued in their mazes & will make you forget everything else.
Why you love action games? Ever wondered? In an action game the structured story & the happy ending upon winning the boss enemy offers a out of the world winning feeling. Finding hidden objects is one of the best de-stressing games.
Moreover, you can quit a game anytime you want. What can be more relieving than this?
Doesn’t the reward & punishment system pulls you again & again? Some games, like, Braid allows rewinding & correcting the mistakes, thus making the experience fun & light-hearted minus the pressure.
Reduce stress related medical disorders like cardiovascular disease, diabetes etc.
However, a particular game may not be equally de-stressing for all. One person may find it agitating while the other may find it relaxing.

Certain games seem to activate the parasympathetic nervous system, which can reduce the increased tension- a natural response to stress.
Train the brain to live in the moment.
Make you stop thinking so much.
The brand extensions of some games make game-play more interesting.


Did you know that heartbeats are linked with various emotional states? Did you know that even soldiers, military personals, surgeons need to play games to lift up their spirit & adeptness in work? Sounds awkward? Well, gaming, in fact, is perhaps the only tool that adds an edge to your personality & profession without your active knowledge.

Some games even keep a close tab on a player’s heartbeat to gain greater control over their emotional response to stressful situations.

Soldiers, who learn to control their emotions by playing games, are better able to perform under pressure & recover quickly from trauma.

Surgeons become 25% faster & 32% less erroneous.

Video game-play Vs Pain

Pain relief & video game? Possible? Let’s see-

Games distracts the attention from the pain & thus provide a kind of an Analgesic reaction.
Prepare the brain to respond more normally to painful stimuli.
Leela, for example, is a game that includes 43 interactive exercises to focus on the body’s 7 energy centres.

You may argue why you should opt for a couch tightening VR game if you can avail a playground? But where would you go & play? When will you play? The skyscrapers & the concrete roads are gulping down the green pastures.

You are always short of time. Aren’t you? In that case, a motion capture game or a VR is the best-possible solution. But don’t just play a game. Interact with it. I am not saying that you have to be a hardcore gamer. But to take out the most of the benefits, get better at the game by practicing whenever you get a chance. Most of us become aware of the stress level only when it reaches an extreme point. So nip it in the bud. At every game, a point comes when it becomes undefeatable. Avoid that for the time being if it stresses you. Enjoy a family game with the little ones. Avoid games with unclear instructions. Remember, each & every game-play, no matter what the duration is, leaves a positive impact on your mental & physical health. So enjoy every bit of your VR playtime.

Thursday, August 16, 2012

Game Development and Programming in Android, iOS, PC and Devices

Game Development Australia brings together creativity, skills and technology to develop the most fascinating and intellectual games for mobile and web. The mobile phones are no more just a communication devices. The enhanced features of mobiles have gone beyond the classic definition of these handsets. Mobile Game Applications forms a huge part of entertainment sources today. Unveil this online game store to provide yourself with the exciting game logic. Find here, the smart games for smart and easy fun. The iPhone, iPad and Android games created with iPhone SDK, Cocos2D Framework, Flash and Unity3D, Java, J SON, OpenGL, Corona give you technological fun and challenges. An amalgamation of enjoyment and entertainment through the advanced technology would end here your search for intelligent amusement.

Monday, November 7, 2011

Objective C Advantages


  1. Thin Layer around C.. like C
  2. Message Dispatch at runtime
  3. Static and Dynamic features included
  4. Got Single inheritance and interface called @protocols
  5. By default Protected 
  6. Methods are public, virtual and overridden
  7. Methods can be added to existing classes 

Tuesday, April 19, 2011

Object C An Introduction


What Is Objective-C?

Objective-C is an object-oriented language: it supports hierarchies of substitutable types, message-passing between objects, and code reuse through inheritance. Objective-C adds these features to the familiar C programming language.
Because Objective-C is an extension of C, many properties of an Objective-C program depend on the underlying C development tools. Among these properties are:
·         The size of scalar variables such as integers and floating-point numbers
·         Allowed placement of scoped declarations
·         Implicit type conversion and promotion
·         Storage of string literals
·         Preprocessor macro expansion
·         Compiler warning levels
·         Code optimization
·         Include and link search paths
For more information about these topics, consult the documentation for your development platform and tools.
Objective-C differs from C++, another object-oriented extension of C, by deferring decisions until runtime that C++ would make at compile time. Objective-C is distinguished by the following key features:
·         Dynamic dispatch
·         Dynamic typing
·         Dynamic loading

1.2.1 Dynamic Dispatch

Object-oriented languages replace function calls with messages. The difference is that the same message may trigger different code at runtime, depending on the type of the message receiver. Objective-C decides dynamically—at runtime—what code will handle a message by searching the receiver's class and parent classes. (The Objective-C runtime caches the search results for better performance.) By contrast, a C++ compiler constructs a dispatch table statically—at compile time.
Because the simple linear search for a receiver used by Objective-C mirrors the way we think about inheritance, it's easy to understand how an Objective-C program works. Dynamic dispatch can handle changes in the inheritance hierarchy at runtime. A dynamic message-sending model is also more natural for distributed objects than a table-based model.

1.2.2 Dynamic Typing

Because message-sending is dynamic, Objective-C lets you send messages to objects whose type has not been declared. The Objective-C environment determines dynamically—at runtime—the class of the message receiver and calls the appropriate code. By comparison, C++ requires the type of the receiver to be declared statically—at compile time—in order to consult dispatch tables.
Static typing allows the compiler to detect some program errors, but type checking is undecidable—that is, no algorithm can infallibly distinguish between programs that have type errors and those that do not. A compiler must either miss some errors or prohibit some safe operations. Of course, in practice compilers follow the latter course, so some programs that would run correctly will not compile. Dynamic typing admits designs whose correctness is not evident to the compiler.
Objective-C lets you use static type checking where you want it, but dynamic typing where you need it. This represents a move away from the question of What is the receiver's type at compile time? to What messages does an object respond to at runtime? Since programs run only at runtime, this is a more useful perspective.

1.2.3 Dynamic Loading

Because the process of method dispatch is simple and uniform, it's easy to defer until runtime the linking of separately-compiled code modules. Objective-C programs can be factored into components that have minimal interdependency; these components can be loaded as needed by a running program. This makes it easier to deliver code, as well as content, over a network; design applications or systems that are distributed; or write an application that can be extended by third-party plug-ins.

1.2.4 Which Objective-C?

If you are programming in a Unix environment, you probably already have an Objective-C compiler: the gcc compiler, which is part of many Unix installations and is available under the terms of the GNU Public License. Because of the wide availability of this compiler for many software and hardware platforms, this handbook documents the features of the language compiled by Version 3.1 of gcc.
Apple Computer has also adopted gcc as the compiler for its OS X platform, which is based on a Unix variant called Darwin. Darwin provides its own Objective-C runtime, and a class library called Cocoa. This handbook notes the differences between the Darwin and GNU runtime environments, and documents the root classes supplied by both GNU and Cocoa.
There is also a class library called GNUstep, distributed under the terms of the GNU Lesser (Library) Public License. GNUstep is an outgrowth of the same code that gave rise to Cocoa, and is largely compatible with Cocoa. Discussions in this book of Cocoa features such as the NSObject root class will apply equally to the GNUstep version.

1.2.5 How Do I Get Started?

Here is a minimal Objective-C program. If you can successfully compile and run it, your Objective-C installation is working correctly.
#import  
int  main(int  argc, char * argv[  ]) {
  Object* obj  = [Object new];
  return  0;
}
To build this program from a shell prompt, save it in a file named myProg.m and issue the following commands. (Your platform may require a different threading library, which is specified in the last parameter. If you are using an integrated development environment, follow its documentation for building a program.)
gcc -c myProg.m
gcc -o myProg myProg.o -lobjc -lpthread
When this little program succeeds in compiling, you are ready to start learning the language and writing Objective-C programs. 

Thursday, February 24, 2011

gaming workshops organized by virtualinfocom




Tuesday, October 26, 2010

online animation tutorial ‘Pencil2Pixels‘

Kolkata based Virtualinfocom (VIC) has launched online tutorial called ‘Pencil2Pixels‘ to help aspiring students understand and learn the basic skill sets of animation. A 20 page version of it is available online free of cost to give an idea on how animations are done and how you can create characters, shadow balance etc.
The original tutorial is a book of 135 pages which would be made available online topic wise in the due course of time. The book would be available at a cost of arount INR 350 in a month‘s time. Virtualinfocom has it cartoon character ‘Chankey‘ who trains the users on how to create animations and how to draw.Speaking to AnimationXpress.comVirtualinfocom CEO Arijit Bhattacharyya said "Pencil2Pixels is created for the people who want to draw and want to be a part of Animations and Gaming Industry. This online tutorial will help a new comer or a professional to create good animations and make good comics with proper knowledge. It is basically created to encourage people to come into animation and gaming field as there is a dearth of really talented people in this field."

Virtualinfocom is also coming up with game developments tutorial for online medium and are now creating mobile based animations and mobile based games for different clients as well coming up with mobile based comics.Various topic are covered in the tutorial such as creating diagrams, basic drawing, drawing shapes, drawing human faces, trick stuff, solid with round and rectangle, the divided ball and plane method, comic heads, methods of checking, drawing a female body, figure in action, animated figures, digital drawing, bit-map images, vector images, three-dimensional images, Indian style animations, color composition, animate the characters, the perspective view for any animation, case study for a story board, lights - camera - animate, the basic film making setup, how to choose between formats and many more.

Tuesday, July 20, 2010

how to make scripts for games

Part 3– Making stuff random


This tutorial should take around 10 minutes to complete

or this tut, we'll have a look at the random function, object positioning and also

do some more loops for practice.



For this tut, we'll have a look at the random function, object positioning and also

do some more loops for practice.



Intro

Here is our hypothetical scenario. We want to build a fence across a

field. We have made an array of tall boxes - 20 of them - for fence

posts unfortunately they look really uniform and CG like. What to

do? Maxscript to the rescue.





The Random Function

Open the listener and type in the following command:



random 1.0 35.0



Maxscript will return a float number between 1 and 35. Notice how putting .0 after the


number

made maxscript realise that we wanted it to generate floats and not integers.



Now we'll make a variable with a random integer between 1 and 6



diceThrow = random 1 6



Now whenever we access the diceThrow variable we made, it will contain the number that it

randomly chose when we first created the variable.

Randomizing post heights

Create an array of about 20 boxes. They should have their pivot on the ground and be 10 x


10 by

100 high. Make the spacing about 150 units.



I'm sure that you have a rough idea in your head by now of how we will go about this. Here


is the

code:



for obj in $ do

(

randHeight = random 90.0 110.0

obj.height = randHeight

)



We have the same loop as last time. For all the objects in the selection, execute the


following code:



randHeight = random 90.0 110.0 - Make a variable with a random float between 90 and 110 in


it.

obj.height = randHeight - Assign that variable to the objects height.



Select all your fencepost boxes and run the code. Now all the posts should have slightly


different

heights!



Position

Create a sphere in the scene and select it.



The way Maxscript accesses the position of objects is with the .position (or .pos)


property.



If you type:



$.pos



Maxscript should return: [12.3434,34.6446,0] or similar. You exact results will depend on


where

you made the sphere in your scene.

Point 3 Data type

This result is a special type of data type called a Point3 data type. It contains X Y and


Z values

always in that order. If we assign one to a variable:



ourPoint3variable = [5,4,1]



and then type this:



ourPoint3variable.y



Max will return 4 which is the Y component of our Point3. If we just type:



ourPoint3variable



Maxscript will return all the values - [5,4,1]

Position (and many other things) in 3D often needs 3 values, X, Y and Z so a Point3 is a


very

useful data type.



Moving Objects



Back to setting an objects position.

We could type the following:



$.pos = [0,0,0]



that will move our selected sphere to the center of the world. We are giving the sphere


explicit co-

ordinates to go to. What if we want to move it relative to where it is now?

maxscript provides a move function to do just that.





move $ [3,2,0]



That is simply saying "Move the selected object +3 units in X, +2 units in Y and 0 units


in Z"

type:



$.pos



Now maxscript will return the position as [3,2,0]

Execute the move line again:



move $ [3,2,0]



Then ask the position:



$.pos



You'll see that it is now at [6,4,0]

Delete the sphere. (if you want to be fancy, type: delete $)



Now we want to randomise the position of all the posts slightly.



Randomizing Position





Select all the posts again.



Here is the code we are going to use.



for obj in $ do

(

randX = random -5.0 5.0

randY = random -5.0 5.0

move obj [randX,randY,0]

)



Lets step through it.

For each object in our current selection do:

Create a random float between -5 and 5 and assign it to the variable randX

Create a random float between -5 and 5 and assign it to the variable randY

move the current object according to the following Point3. Where it says randX in the


point3,

maxscript will substitute in the random number it generated earlier. The same goes for the


randY.

we don't want the posts to move vertically so we have just put in a 0.



Highlight the code and run it.

Thursday, May 27, 2010

creating a chess game on C++

Source code to create chess game using C++
#include
#include
#include
#include
#include

#define White 0
#define Black 1

void draw_piece(int);
int marker(int,short);
int valid_move(int,int);
int previous_move_pick=0,previous_move_put=0;
void chessboard();
void pawn(int,float,float);
void rook(int,float,float);
void knight(int,float,float);
void bishop(int,float,float);
void queen(int,float,float);
void king(int,float,float);

int dx,dy;
union REGS i,o;

int Square_Color[64]= {  1,0,1,0,1,0,1,0,
             0,1,0,1,0,1,0,1,
             1,0,1,0,1,0,1,0,
             0,1,0,1,0,1,0,1,
             1,0,1,0,1,0,1,0,
             0,1,0,1,0,1,0,1,
             1,0,1,0,1,0,1,0,
             0,1,0,1,0,1,0,1  };

int Board[64]= {15,12,13,17,19,13,12,15,
             11,11,11,11,11,11,11,11,
             0,0,0,0,0,0,0,0,
             0,0,0,0,0,0,0,0,
             0,0,0,0,0,0,0,0,
             0,0,0,0,0,0,0,0,
             1,1,1,1,1,1,1,1,
             5,2,3,7,9,3,2,5       };


void main()
{

int driver=DETECT,mode;
int x,y;
union REGS ii,oo;

initgraph(&driver,&mode,"");

x=getmaxx()/2;
y=getmaxy()/2;


chessboard();

struct palettetype pal;
getpalette(&pal);
setrgbpalette(pal.colors[6],35,33,25);

setfillstyle(SOLID_FILL,6);
floodfill(x+250,y,15);

for(int b=0;b<64;b++)
draw_piece(b);

int Marker=56;
marker(Marker,1);

int pick_up,Mode=0,put_down;
int turn=White;
int checker;

while(1)
{

        if(kbhit())
        {
            ii.h.ah=0;
            int86(22,&ii,&oo);
            if(oo.h.ah==1)
            {
                closegraph();
                exit(0);
            }
            if(oo.h.ah==77)
             {

                if((Marker+1)%8!=0)
                {
                marker(Marker,0);
                Marker++;
                marker(Marker,1);
                }

             }

            if(oo.h.ah==75)
             {

                if(Marker%8!=0)
                {
                marker(Marker,0);
                Marker--;
                marker(Marker,1);
                }

             }

            if(oo.h.ah==72)
             {

                if(Marker>7)
                {
                marker(Marker,0);
                Marker-=8;
                marker(Marker,1);
                }

             }
            if(oo.h.ah==80)
             {

                if(Marker<56)
                {
                marker(Marker,0);
                Marker+=8;
                marker(Marker,1);
                }
             }
            if(oo.h.ah==28)
             {
                if(Mode==0)
                {
                 if(turn==White) {
                 if(Board[Marker]!=0&&Board[Marker]<10)
                 {
                 pick_up=Marker;
                 marker(Marker,3);
                 Mode=1;
                 } }
                 else if(turn==Black) {
                 if(Board[Marker]!=0&&Board[Marker]>10)
                 {
                 pick_up=Marker;
                 marker(Marker,3);
                 Mode=1;
                 } }
                }

               else if(Mode==1)
               {
               put_down=Marker;
               if(put_down==pick_up)
               { Mode=0; marker(put_down,4); goto cancel; }
               checker=valid_move(pick_up,put_down);
               if(checker==0)
               { Mode=0; marker(pick_up,4); goto cancel; }
               if(checker==2)  {
                   Board[pick_up]=0;
                   marker(put_down,2);
                   for( b=0;b<64;b++)
                   draw_piece(b);
                   setcolor(6);
                   outtextxy(530,50,"choose piece");
                  }
               if(checker==1)  {
               Board[put_down]=Board[pick_up];
               Board[pick_up]=0;
               marker(put_down,2);
               for(b=0;b<64;b++)
               draw_piece(b);
               }
               marker(pick_up,2);
               setcolor(15);
               rectangle(x-200,y-200,x+200,y+200);
               Mode=0;
               if(turn==White)
                 turn=Black;
               else if(turn==Black)
                 turn=White;
               previous_move_pick=pick_up;
               previous_move_put=put_down;
               cancel:
               }
             }
        }

}

}


valid_move(int pick,int put)
{

int leftup,leftdown,rightup,rightdown;
int up,down,right,left;
int sx,sy;
int i;
int x=getmaxx()/2,y=getmaxy()/2;


  if(Board[pick]<10 && Board[put]<10 && Board[put]!=0)
  return 0;
  if(Board[pick]>10 && Board[put]>10 && Board[put]!=0)
  return 0;

if(Board[pick]==1)

    {


        if(pick>=48&&pick<=55)
        {

             if(put!=pick-8&&put!=pick-16&&put!=pick-7&&put!=pick-9)
            return 0;

             if(put==pick-16)
             {
            if( Board[pick-8]!=0 || Board[pick-16]!=0)
            return 0;
             }
             else if(put==pick-8)
             {
            if(Board[pick-8]!=0)
            return 0;
             }
             else if(put==pick-7)
             {
            if(Board[pick-7]==0||Board[pick-7]<10)
            return 0;
             }
             else if(put==pick-9)
             {
            if(Board[pick-9]==0||Board[pick-9]<10)
            return 0;
             }
        }
        else if(pick<=47)
        {
             if(pick<=31 && pick>=24)
             {
              if(pick!=24)
            if(previous_move_pick==(pick-17)&&previous_move_put==(pick-1)&&put==pick-9)
            {
              Board[pick-1]=0;
              marker(pick-1,2);
              return 1;
            }
              if(pick!=31)
            if(previous_move_pick==(pick-15)&&previous_move_put==(pick+1)&&put==pick-7)
            {
              Board[pick+1]=0;
              marker(pick+1,2);
              return 1;
            }
             }

             if(put!=pick-8&&put!=pick-7&&put!=pick-9)
            return 0;

             if(put==pick-8)
             {
            if(Board[pick-8]!=0)
            return 0;
             }
             else if(put==pick-7)
             {
            if(Board[pick-7]==0||Board[pick-7]<10)
            return 0;
             }
             else if(put==pick-9)
             {
            if(Board[pick-9]==0||Board[pick-9]<10)
            return 0;
             }
        }

     if(put>=0 && put<=7)
     {
       int piece=0;
       setcolor(14);
       outtextxy(x+225,y-80,"Enter: ");
       outtextxy(x+225,y-60,"1-Queen");
       outtextxy(x+225,y-40,"2-Rook");
       outtextxy(x+225,y-20,"3-Bishop ");
       outtextxy(x+225,y,"4-Knight");
       gotoxy(72,17);
       cin>>piece;
       switch(piece)
       {
       case 1:  Board[put]=7;break;
       case 2:  Board[put]=5;break;
       case 3:  Board[put]=3;break;
       case 4:  Board[put]=2;break;
       default: Board[put]=7;break;
       }
       setcolor(6);
       outtextxy(x+225,y-80,"Enter: ");
       outtextxy(x+225,y-60,"1-Queen");
       outtextxy(x+225,y-40,"2-Rook");
       outtextxy(x+225,y-20,"3-Bishop ");
       outtextxy(x+225,y,"4-Knight");
       setfillstyle(SOLID_FILL,6);
       bar(x+225,y,x+300,y+50);
     return 2;
     }

    }

    else if(Board[pick]==11)
    {

        if(pick>=8&&pick<=15)
        {

             if(put!=pick+8&&put!=pick+16&&put!=pick+7&&put!=pick+9)
            return 0;

             if(put==pick+16)
             {
            if( Board[pick+8]!=0 || Board[pick+16]!=0)
            return 0;
             }
             else if(put==pick+8)
             {
            if(Board[pick+8]!=0)
            return 0;
             }
             else if(put==pick+7)
             {
            if(Board[pick+7]==0||Board[pick+7]>10)
            return 0;
             }
             else if(put==pick+9)
             {
            if(Board[pick+9]==0||Board[pick+9]>10)
            return 0;
             }
        }
        else if(pick>15)
        {
           if(pick<=39 && pick>=32)
           {
              if(pick!=39)
            if(previous_move_pick==(pick+17)&&previous_move_put==(pick+1)&&put==pick+9)
            {
              Board[pick+1]=0;
              marker(pick+1,2);
              return 1;
            }
              if(pick!=32)
            if(previous_move_pick==(pick+15)&&previous_move_put==(pick-1)&&put==pick+7)
            {
              Board[pick-1]=0;
              marker(pick-1,2);
              return 1;
            }
             }

             if(put!=pick+8&&put!=pick+7&&put!=pick+9)
            return 0;

             if(put==pick+8)
             {
            if(Board[pick+8]!=0)
            return 0;
             }
             else if(put==pick+7)
             {
            if(Board[pick+7]==0||Board[pick+7]>10)
            return 0;
             }
             else if(put==pick+9)
             {
            if(Board[pick+9]==0||Board[pick+9]>10)
            return 0;
             }
        }

     if(put>=56 && put<=63)
     {
       int piece=0;
       setcolor(14);
       outtextxy(x+225,y-80,"Enter: ");
       outtextxy(x+225,y-60,"1-Queen");
       outtextxy(x+225,y-40,"2-Rook");
       outtextxy(x+225,y-20,"3-Bishop ");
       outtextxy(x+225,y,"4-Knight");
       gotoxy(72,17);
       cin>>piece;
       switch(piece)
       {
       case 1:  Board[put]=17;break;
       case 2:  Board[put]=15;break;
       case 3:  Board[put]=13;break;
       case 4:  Board[put]=12;break;
       default: Board[put]=17;break;
       }
       setcolor(6);
       outtextxy(x+225,y-80,"Enter: ");
       outtextxy(x+225,y-60,"1-Queen");
       outtextxy(x+225,y-40,"2-Rook");
       outtextxy(x+225,y-20,"3-Bishop ");
       outtextxy(x+225,y,"4-Knight");
       setfillstyle(SOLID_FILL,6);
       bar(x+225,y,x+300,y+50);
     return 2;
     }

    }
    else if(Board[pick]==2||Board[pick]==12)
    {

    if(put!=pick-17&&put!=pick-15&&put!=pick+17&&put!=pick+15&&put!=pick-10&&put!=pick+6&&put!=pick+10&&put!=pick-6)
    return 0;


    if(pick%8==0)
       if(put==pick-17||put==pick+15||put==pick-10||put==pick+6)
           return 0;
    if(pick%8==1)
       if(put==pick-10||put==pick+6)
           return 0;
    if(pick%8==7)
       if(put==pick+17||put==pick-15||put==pick+10||put==pick-6)
           return 0;
    if(pick%8==6)
       if(put==pick+10||put==pick-6)
           return 0;

    if(pick>=0&&pick<=7)
       if(put==pick-17||put==pick-15||put==pick-10||put==pick-6)
           return 0;
    if(pick>=8&&pick<=15)
       if(put==pick-17||put==pick-15)
           return 0;

    if(pick>=56&&pick<=63)
       if(put==pick+17||put==pick+15||put==pick+10||put==pick+6)
           return 0;
    if(pick>=48&&pick<=55)
       if(put==pick+17||put==pick+15)
           return 0;

    }


if(Board[pick]==3||Board[pick]==13||Board[pick]==17||Board[pick]==7)
{


sx=pick%8;
sy=pick/8;

    if(sx>=sy)        leftup=sy;
    else            leftup=sx;

    if(sx>=(7-sy))        leftdown=7-sy;
    else            leftdown=sx;

    if((7-sx)>=sy)        rightup=sy;
    else            rightup=7-sx;

    if((7-sx)>=(7-sy))    rightdown=7-sy;
    else            rightdown=7-sx;

    for(i=1;i
    {
        if( put==(pick-9*i) )        return 1;
        else if( Board[pick-9*i]!=0)    break;
    }

    for(i=1;i
    {
        if( put==(pick+7*i) )        return 1;
        else if( Board[pick+7*i]!=0)    break;
    }
    for(i=1;i
    {
        if( put==(pick-7*i) )        return 1;
        else if( Board[pick-7*i]!=0)    break;
    }
    for(i=1;i
    {
        if( put==(pick+9*i) )        return 1;
        else if( Board[pick+9*i]!=0)    break;
    }


    if(Board[pick]==3||Board[pick]==13)
    return 0;

}


if(Board[pick]==5||Board[pick]==15||Board[pick]==17||Board[pick]==7)
{

sx=pick%8;
sy=pick/8;

up=sy;
down=7-sy;
right=7-sx;
left=sx;

    for(i=1;i
    {
        if( put==(pick-8*i) )        return 1;
        else if( Board[pick-8*i]!=0)    break;
    }
    for(i=1;i
    {
        if( put==(pick+8*i) )        return 1;
        else if( Board[pick+8*i]!=0)    break;
    }
    for(i=1;i
    {
        if( put==(pick-1*i) )        return 1;
        else if( Board[pick-1*i]!=0)    break;
    }
    for(i=1;i
    {
        if( put==(pick+1*i) )        return 1;
        else if( Board[pick+1*i]!=0)    break;
    }



    return 0;

}

 if(Board[pick]==9||Board[pick]==19)
 {

   if(pick==60&&put==62)
     {
     if(Board[61]==0&&Board[62]==0&&Board[63]==5)
       {
    Board[63]=0;
    Board[61]=5;
    marker(63,2);
    return 1;
       }
     }
   if(pick==60&&put==58)
     {
     if(Board[59]==0&&Board[58]==0&&Board[57]==0&&Board[56]==5)
       {
    Board[56]=0;
    Board[59]=5;
    marker(56,2);
    return 1;
       }
     }
   if(pick==4&&put==6)
     {
     if(Board[5]==0&&Board[6]==0&&Board[7]==15)
       {
    Board[7]=0;
    Board[5]=15;
    marker(7,2);
    return 1;
       }
     }
   if(pick==4&&put==2)
     {
     if(Board[3]==0&&Board[2]==0&&Board[1]==0&&Board[0]==15)
       {
    Board[0]=0;
    Board[3]=15;
    marker(0,2);
    return 1;
       }
     }


     if(pick%8==0)
     {
    if(put!=pick-8&&put!=pick+8&&put!=pick-7&&put!=pick+9&&put!=pick+1)
    return 0;
     }
     else if((pick+1)%8==0)
     {
    if(put!=pick-8&&put!=pick+8&&put!=pick-9&&put!=pick+7&&put!=pick-1)
    return 0;
     }
     else if(pick<=6&&pick>=1)
     {
    if(put!=pick+8&&put!=pick+9&&put!=pick+7&&put!=pick-1&&put!=pick+1)
    return 0;
     }
     else if(pick<=62&&pick>=57)
     {
    if(put!=pick-8&&put!=pick-9&&put!=pick-7&&put!=pick-1&&put!=pick+1)
    return 0;
     }
     else if(pick==0)
     {
    if(put!=pick+8&&put!=pick+9&&put!=pick+1)
    return 0;
     }
     else if(pick==7)
     {
    if(put!=pick+8&&put!=pick+7&&put!=pick-1)
    return 0;
     }
     else if(pick==63)
     {
    if(put!=pick-8&&put!=pick-9&&put!=pick-1)
    return 0;
     }
     else if(pick==56)
     {
    if(put!=pick-8&&put!=pick-7&&put!=pick+1)
    return 0;
     }
     else
     {
    if(put!=pick-8&&put!=pick+8&&put!=pick-9&&put!=pick+7&&put!=pick-1&&put!=pick+9&&put!=pick-7&&put!=pick+1)
    return 0;
     }

 }

return(1);
}

int marker(int position,short what)
{

int Dx,Dy;

   switch(position)
   {

        case 0:  Dx=-3; Dy=-3; break;  case 1:  Dx=-2; Dy=-3; break;
        case 2:  Dx=-1; Dy=-3; break;  case 3:  Dx=0; Dy=-3; break;
        case 4:  Dx=1; Dy=-3; break;   case 5:  Dx=2; Dy=-3; break;
        case 6:  Dx=3; Dy=-3; break;   case 7:  Dx=4; Dy=-3; break;

        case 8:  Dx=-3; Dy=-2; break;  case 9:  Dx=-2; Dy=-2; break;
        case 10:  Dx=-1; Dy=-2; break;  case 11:  Dx=0; Dy=-2; break;
        case 12:  Dx=1; Dy=-2; break;  case 13:  Dx=2; Dy=-2; break;
        case 14:  Dx=3; Dy=-2; break;  case 15:  Dx=4; Dy=-2; break;

        case 16:  Dx=-3; Dy=-1; break;  case 17:  Dx=-2; Dy=-1; break;
        case 18:  Dx=-1; Dy=-1; break;  case 19:  Dx=0; Dy=-1; break;
        case 20:  Dx=1; Dy=-1; break;  case 21:  Dx=2; Dy=-1; break;
        case 22:  Dx=3; Dy=-1; break;  case 23:  Dx=4; Dy=-1; break;

        case 24:  Dx=-3; Dy=0; break;  case 25:  Dx=-2; Dy=0; break;
        case 26:  Dx=-1; Dy=0; break;  case 27:  Dx=0; Dy=0; break;
        case 28:  Dx=1; Dy=0; break;  case 29:  Dx=2; Dy=0; break;
        case 30:  Dx=3; Dy=0; break;  case 31:  Dx=4; Dy=0; break;

        case 32:  Dx=-3; Dy=1; break;  case 33:  Dx=-2; Dy=1; break;
        case 34:  Dx=-1; Dy=1; break;  case 35:  Dx=0; Dy=1; break;
        case 36:  Dx=1; Dy=1; break;  case 37:  Dx=2; Dy=1; break;
        case 38:  Dx=3; Dy=1; break;  case 39:  Dx=4; Dy=1; break;

        case 40:  Dx=-3; Dy=2; break;  case 41:  Dx=-2; Dy=2; break;
        case 42:  Dx=-1; Dy=2; break;  case 43:  Dx=0; Dy=2; break;
        case 44:  Dx=1; Dy=2; break;  case 45:  Dx=2; Dy=2; break;
        case 46:  Dx=3; Dy=2; break;  case 47:  Dx=4; Dy=2; break;

        case 48:  Dx=-3; Dy=3; break;  case 49:  Dx=-2; Dy=3; break;
        case 50:  Dx=-1; Dy=3; break;  case 51:  Dx=0; Dy=3; break;
        case 52:  Dx=1; Dy=3; break;  case 53:  Dx=2; Dy=3; break;
        case 54:  Dx=3; Dy=3; break;  case 55:  Dx=4; Dy=3; break;

        case 56:  Dx=-3; Dy=4; break;  case 57:  Dx=-2; Dy=4; break;
        case 58:  Dx=-1; Dy=4; break;  case 59:  Dx=0; Dy=4; break;
        case 60:  Dx=1; Dy=4; break;  case 61:  Dx=2; Dy=4; break;
        case 62:  Dx=3; Dy=4; break;  case 63:  Dx=4; Dy=4; break;

        default:  gotoxy(3,3); cout<<"Error";break;

   }

int x,y;

x=getmaxx()/2+50+50*Dx;
y=getmaxy()/2-50+50*Dy;


    if(what==1)
        setcolor(7);
    else if(what==0)
        {
        if(Square_Color[position]==1)
             setcolor(15);
        else if(Square_Color[position]==0)
             setcolor(0);
        }
    else if(what==2)
        {
        x-=100;
        if(Square_Color[position]==1)
             setfillstyle(SOLID_FILL,15);
        else if(Square_Color[position]==0)
             setfillstyle(SOLID_FILL,0);
             bar(x,y,x+50,y+50);
             return 0;
        }
    else if(what==3)
        {
        x-=100;
        setcolor(LIGHTRED);
        rectangle(x+2,y+2,x+50-2,y+50-2);
        return 0;
        }
    else if(what==4)
        {
        if(Square_Color[position]==1)
             setcolor(15);
        else if(Square_Color[position]==0)
             setcolor(0);
        x-=100;
        rectangle(x+2,y+2,x+50-2,y+50-2);
        x+=100;
        }

rectangle(x-100+1,y+1,x-50-1,y+50-1);
line(x-85,y+1,x-65,y+1);
line(x-85,y+49,x-65,y+49);
line(x-99,y+15,x-99,y+35);
line(x-51,y+15,x-51,y+35);
line(x-85+1,y+1+1,x-65-1,y+1+1);
line(x-85+1,y+49-1,x-65-1,y+49-1);
line(x-99+1,y+15+1,x-99+1,y+35-1);
line(x-51-1,y+15+1,x-51-1,y+35-1);
return 0;

}


void draw_piece(int position)
{

int Dx,Dy;

 if(Board[position]!=0)
 {
   switch(position)
   {

        case 0:  Dx=-3; Dy=-3; break;  case 1:  Dx=-2; Dy=-3; break;
        case 2:  Dx=-1; Dy=-3; break;  case 3:  Dx=0; Dy=-3; break;
        case 4:  Dx=1; Dy=-3; break;   case 5:  Dx=2; Dy=-3; break;
        case 6:  Dx=3; Dy=-3; break;   case 7:  Dx=4; Dy=-3; break;

        case 8:  Dx=-3; Dy=-2; break;  case 9:  Dx=-2; Dy=-2; break;
        case 10:  Dx=-1; Dy=-2; break;  case 11:  Dx=0; Dy=-2; break;
        case 12:  Dx=1; Dy=-2; break;  case 13:  Dx=2; Dy=-2; break;
        case 14:  Dx=3; Dy=-2; break;  case 15:  Dx=4; Dy=-2; break;

        case 16:  Dx=-3; Dy=-1; break;  case 17:  Dx=-2; Dy=-1; break;
        case 18:  Dx=-1; Dy=-1; break;  case 19:  Dx=0; Dy=-1; break;
        case 20:  Dx=1; Dy=-1; break;  case 21:  Dx=2; Dy=-1; break;
        case 22:  Dx=3; Dy=-1; break;  case 23:  Dx=4; Dy=-1; break;

        case 24:  Dx=-3; Dy=0; break;  case 25:  Dx=-2; Dy=0; break;
        case 26:  Dx=-1; Dy=0; break;  case 27:  Dx=0; Dy=0; break;
        case 28:  Dx=1; Dy=0; break;  case 29:  Dx=2; Dy=0; break;
        case 30:  Dx=3; Dy=0; break;  case 31:  Dx=4; Dy=0; break;

        case 32:  Dx=-3; Dy=1; break;  case 33:  Dx=-2; Dy=1; break;
        case 34:  Dx=-1; Dy=1; break;  case 35:  Dx=0; Dy=1; break;
        case 36:  Dx=1; Dy=1; break;  case 37:  Dx=2; Dy=1; break;
        case 38:  Dx=3; Dy=1; break;  case 39:  Dx=4; Dy=1; break;

        case 40:  Dx=-3; Dy=2; break;  case 41:  Dx=-2; Dy=2; break;
        case 42:  Dx=-1; Dy=2; break;  case 43:  Dx=0; Dy=2; break;
        case 44:  Dx=1; Dy=2; break;  case 45:  Dx=2; Dy=2; break;
        case 46:  Dx=3; Dy=2; break;  case 47:  Dx=4; Dy=2; break;

        case 48:  Dx=-3; Dy=3; break;  case 49:  Dx=-2; Dy=3; break;
        case 50:  Dx=-1; Dy=3; break;  case 51:  Dx=0; Dy=3; break;
        case 52:  Dx=1; Dy=3; break;  case 53:  Dx=2; Dy=3; break;
        case 54:  Dx=3; Dy=3; break;  case 55:  Dx=4; Dy=3; break;

        case 56:  Dx=-3; Dy=4; break;  case 57:  Dx=-2; Dy=4; break;
        case 58:  Dx=-1; Dy=4; break;  case 59:  Dx=0; Dy=4; break;
        case 60:  Dx=1; Dy=4; break;  case 61:  Dx=2; Dy=4; break;
        case 62:  Dx=3; Dy=4; break;  case 63:  Dx=4; Dy=4; break;

        default:  gotoxy(3,3); cout<<"Error";break;

   }

 switch(Board[position])
   {
       case 1: pawn(White,Dx,Dy); break;
       case 11: pawn(Black,Dx,Dy); break;

       case 5: rook(White,Dx,Dy); break;
       case 15: rook(Black,Dx,Dy); break;

       case 2: knight(White,Dx,Dy); break;
       case 12: knight(Black,Dx,Dy); break;

       case 3: bishop(White,Dx,Dy); break;
       case 13: bishop(Black,Dx,Dy); break;

       case 7: queen(White,Dx,Dy); break;
       case 17: queen(Black,Dx,Dy); break;

       case 9: king(White,Dx,Dy); break;
       case 19: king(Black,Dx,Dy); break;

   }
 }
}

void chessboard()
{
int x,y,i;
x=getmaxx()/2;
y=getmaxy()/2;

///////////////////////////       chess board       ////////////////////////

//making board

for(i=0;i<450;i+=50)
{line(x-200+i,y-200,x-200+i,y+200);     }
for(i=0;i<450;i+=50)
{line(x-200,y-200+i,x+200,y-200+i);     }
setlinestyle(SOLID_LINE,1,3);

//filling color in squares

for(int g=0;g<400;g+=100)
for(int w=0;w<400;w+=100)
{floodfill(x-149+w,y-102+g,15);         }
for(g=0;g<400;g+=100)
for(w=0;w<400;w+=100)
{floodfill(x-199+w,y+102-g,15);         }

setlinestyle(SOLID_LINE,1,1);

/////////////////////////////  chess board completes  ////////////////////


}

void bishop(int color,float dx,float dy)
{
float x,y;
x=getmaxx()/2-25+50*dx;
y=getmaxy()/2-10+50*dy;
int col=0;

if(color==0)
col=4;
else if(color==1)
col=1;

setcolor(col);
ellipse(x,y,0,360,12,4);
ellipse(x,y-4,0,360,8,3);
line(x-5,y-4,x-3,y-25);
line(x+5,y-4,x+3,y-25);
ellipse(x,y-25,0,360,8,3);
circle(x,y-28,6);
circle(x,y-35,2);
line(x-3,y-24,x+3,y-24);
setcolor(0);
line(x-5,y-28,x+5,y-28);
line(x-3,y-23,x+3,y-23);
line(x-4,y-7,x+4,y-7);

setfillstyle(SOLID_FILL,col);
floodfill(x,y-36,col);

if(color==0)
setfillstyle(SOLID_FILL,14);
else if(color==1)
setfillstyle(SOLID_FILL,3);

floodfill(x-7,y-25,col);
floodfill(x+7,y-25,col);
floodfill(x,y-23,col);
floodfill(x,y-28,col);
floodfill(x,y-18,col);
floodfill(x,y,col);
setfillstyle(SOLID_FILL,col);
floodfill(x,y-3,col);
floodfill(x-6,y-4,col);
floodfill(x+6,y-4,col);
}

void knight(int color,float dx,float dy)
{
float x,y;
x=getmaxx()/2-25+50*dx;
y=getmaxy()/2-10+50*dy;
int col=0;

if(color==0)
col=4;
else if(color==1)
col=1;

setcolor(col);
ellipse(x,y,0,360,14,4);
ellipse(x,y-4,150,360,9,3);
line(x-7,y-3,x-8,y-12);
line(x-6,y-18,x-8,y-12);
line(x-6,y-18,x-3,y-22);
line(x-6,y-24,x-3,y-22);
line(x-6,y-24,x-11,y-24);

line(x+8,y-3,x+7,y-12);
line(x+6,y-20,x+7,y-12);
line(x+6,y-20,x+7,y-24);
line(x+6,y-30,x+7,y-24);
line(x+6,y-30,x+7,y-34);
line(x+4,y-31,x+7,y-34);
line(x+4,y-32,x-2,y-32);
line(x-4,y-30,x-2,y-32);
line(x-4,y-30,x-8,y-30);
line(x-11,y-29,x-8,y-30);
line(x-11,y-29,x-12,y-27);
line(x-11,y-25,x-12,y-27);
circle(x-2,y-28,1);
setcolor(0);
line(x-6,y-4,x+6,y-4);
if(color==0)
setfillstyle(SOLID_FILL,14);
else if(color==1)
setfillstyle(SOLID_FILL,3);
floodfill(x,y-18,col);
floodfill(x,y,col);
}



void rook(int color,float dx,float dy)
{
float x,y;
x=getmaxx()/2-25+50*dx;
y=getmaxy()/2-10+50*dy;
int col=0;

if(color==0)
col=4;
else if(color==1)
col=1;

setcolor(col);
ellipse(x,y,180,360,13,4);
ellipse(x,y-4,0,360,13,4);
ellipse(x,y-20-2,180,360,10,3);
ellipse(x,y-24-2,0,360,10,3);

line(x-10,y-20-2,x-10,y-24-2);
line(x+10,y-20-2,x+10,y-24-2);
line(x-13,y,x-13,y-4);
line(x+13,y,x+13,y-4);
line(x+7,y-17-2,x+7,y-5);
line(x-7,y-17-2,x-7,y-5);
line(x-10,y-25-2,x-10,y-28-2);
line(x-5,y-27-2,x-5,y-31-2);
line(x-10,y-28-2,x-5,y-31-2);
line(x+10,y-25-2,x+10,y-28-2);
line(x+5,y-27-2,x+5,y-31-2);
line(x+10,y-28-2,x+5,y-31-2);

rectangle(x-4,y-24-2,x+4,y-22-2);
putpixel(x-6,y-27-2,col);
putpixel(x+6,y-27-2,col);
setcolor(0);
line(x-6,y-8,x+6,y-8);
line(x-9,y-25-2,x-6,y-26-2);
line(x+9,y-25-2,x+6,y-26-2);

if(color==0)
setfillstyle(SOLID_FILL,14);
else if(color==1)
setfillstyle(SOLID_FILL,3);
bar(x-3,y-23-2,x+3,y-21-2);
floodfill(x,y-25-2,col);
floodfill(x,y-10,col);
floodfill(x,y+1,col);
floodfill(x,y-21-2,col);
}

void pawn(int color,float dx,float dy)
{
float x,y;
x=getmaxx()/2-25+50*dx;
y=getmaxy()/2-10+50*dy;
int col=0;

if(color==0)
col=4;
else if(color==1)
col=1;

setcolor(col);
ellipse(x,y,0,360,8,2);
ellipse(x,y-3,0,360,6,2);
ellipse(x,y-18,0,360,6,2);
line(x-3,y-5,x-3,y-17);
line(x+3,y-5,x+3,y-17);
circle(x,y-23,4);

setcolor(0);
line(x-2,y-5,x+2,y-5);
line(x-3,y-2,x+3,y-2);
line(x-1,y-20,x+1,y-20);
if(color==0)
setfillstyle(SOLID_FILL,14);
else if(color==1)
setfillstyle(SOLID_FILL,3);
floodfill(x,y,col);
floodfill(x,y-21,col);
floodfill(x,y-18,col);
floodfill(x,y-10,col);

}


void queen(int color,float dx,float dy)
{
int x,y;
x=getmaxx()/2-25+50*dx;
y=getmaxy()/2-10+50*dy;
int col=0;

if(color==0)
col=4;
else if(color==1)
col=1;

setcolor(col);
ellipse(x,y,0,360,18,4);
ellipse(x,y-4,130,45,14,3);
line(x-2,y-5,x-1,y-28);
line(x+2,y-5,x+1,y-28);
line(x-2,y-5,x-9,y-25);
line(x-5,y-5,x-10,y-24);
line(x-4,y-5,x-15,y-16);
line(x-8,y-5,x-16,y-15);
line(x+2,y-5,x+9,y-25);
line(x+5,y-5,x+10,y-24);
line(x+4,y-5,x+15,y-16);
line(x+8,y-5,x+16,y-15);
circle(x,y-32,4);
circle(x-10,y-27,2);
circle(x-18,y-18,2);
circle(x+10,y-27,2);
circle(x+18,y-18,2);

setcolor(0);
line(x-7,y-4,x+7,y-4);
line(x-8,y-3,x-10,y-3);
line(x+8,y-3,x+10,y-3);
if(color==0)
setfillstyle(SOLID_FILL,14);
else if(color==1)
setfillstyle(SOLID_FILL,3);
floodfill(x,y,col);
floodfill(x,y-14,col);
setfillstyle(SOLID_FILL,col);
floodfill(x,y-32,col);
floodfill(x-10,y-27,col);
floodfill(x-18,y-18,col);
floodfill(x+10,y-27,col);
floodfill(x+18,y-18,col);
if(color==0)
setcolor(14);
else if(color==1)
setcolor(3);

circle(x,y-32,4);
circle(x-10,y-27,2);
circle(x-18,y-18,2);
circle(x+10,y-27,2);
circle(x+18,y-18,2);
}


void king(int color,float dx,float dy)
{
float x,y;
x=getmaxx()/2-25+50*dx;
y=getmaxy()/2-10+50*dy;
int col=0;

if(color==0)
col=4;
else if(color==1)
col=1;

setcolor(col);
ellipse(x,y,0,360,18,4);
ellipse(x,y-4,130,45,14,3);

line(x-3,y-10,x,y-16);
line(x+3,y-10,x,y-16);
line(x-3,y-10,x,y-4);
line(x+3,y-10,x,y-4);

line(x-8,y-25,x,y-18);
line(x-8,y-25,x-13,y-27);
line(x-16,y-26,x-13,y-27);
line(x-17,y-25,x-16,y-26);
line(x-17,y-25,x-18,y-20);
line(x-17,y-15,x-18,y-20);
line(x-17,y-15,x-9,y-7);

line(x+8,y-25,x,y-18);
line(x+8,y-25,x+13,y-27);
line(x+16,y-26,x+13,y-27);
line(x+17,y-25,x+16,y-26);
line(x+17,y-25,x+18,y-20);
line(x+17,y-15,x+18,y-20);
line(x+17,y-15,x+9,y-7);

ellipse(x,y-25,0,360,3,5);
line(x,y-30,x,y-37);
line(x-3,y-34,x+3,y-34);
setcolor(0);
line(x-7,y-4,x+7,y-4);
line(x-8,y-3,x-10,y-3);
line(x+8,y-3,x+10,y-3);

if(color==0)
setfillstyle(SOLID_FILL,14);
else if(color==1)
setfillstyle(SOLID_FILL,3);
floodfill(x,y,col);
floodfill(x,y-11,col);
floodfill(x,y-23,col);
setfillstyle(SOLID_FILL,col);
floodfill(x-8,y-11,col);
}



Friday, May 21, 2010

gaming art works

Twitter Delicious Facebook Digg Stumbleupon Favorites More