Thread: My 2nd C++ Game

  1. #1
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683

    My 2nd C++ Game

    Well i have created another silly game.. Something similar to PAC man. But here the AI(Artifical Intelegence) i have used is so dumb. Is there any way you can make the circles more intelegent in capturing the users circle instead of just blindly followin it..

    Here is the source.. User num pad key 4,6,8,and 2 to move around. Still in my previous question the problem of program freezing while input has not been completely been solved. The same problem occurs here..

    # include <graphics.h>
    # include <conio.h>
    # include <dos.h>
    # include <iostream.h>
    # include <stdlib.h>
    int x=10,y=10,x1=100,y1=100,x2=300,y2=300;
    int val;
    inig()
    {

    int gdriver = DETECT, gmode, errorcode;
    initgraph(&gdriver, &gmode, "");


    }

    calc()
    {

    if(x1>x)
    x1--;
    if(x1<x)
    x1++;
    if(y1>y)
    y1--;
    if(y1<y)
    y1++;


    }
    calc1()
    {

    if(x2>x)
    x2=x2-2;
    if(x2<x)
    x2=x2+2;
    if(y2>y)
    y2=y2-2;
    if(y2<y)
    y2=y2+2;


    }

    catch()
    {
    if((x==x1 && y==y1) || (x==x2 && y==y2))
    {
    for(int q=0;q<100;q++)
    {
    circle(x,y,q);
    delay(5);

    }
    cout<<" Game Over";
    getche();
    exit(0);



    }


    }

    start()
    {
    prog:
    clearviewport();
    circle(x,y,10);
    circle(x1,y1,5);
    circle(x2,y2,15
    );
    val=getche();
    if(val==52)
    x=x-5;
    if(val==54)
    x=x+5;
    if(val==50)
    y=y+5;
    if(val==56)
    y=y-5;
    if(val==27)
    exit(0);
    calc();
    calc1();
    catch();
    goto prog;





    }



    main()
    {
    clrscr();
    inig();
    start();

    }

  2. #2
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,212
    edit it to put the [code] tag before your code and the [/code ] (without the space) tag after, makes it easier to read.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do the game engine and the api interact?
    By Shadow12345 in forum Game Programming
    Replies: 9
    Last Post: 12-08-2010, 12:08 AM
  2. 2D RPG Online Game Project. 30% Complete. To be released and marketed.
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 10-28-2006, 12:48 AM
  3. C++ Game of Life Program
    By rayrayj52 in forum C++ Programming
    Replies: 16
    Last Post: 09-26-2004, 03:58 PM
  4. Game Design Topic #1 - AI Behavior
    By TechWins in forum Game Programming
    Replies: 13
    Last Post: 10-11-2002, 10:35 AM
  5. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-24-2002, 11:00 PM