Page 2 of 2 First 12
  • Jump to page:
    #16
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    9
    Rep Power
    0
    no ! it is not for a class i was getting bored so i decided to make some thing , so i tried out this but unluckly i got stuck so that is why i am asking you people to help me ,

    and thanks Nichademus for giving it a try

    any body else who would like to help me !

    suhailkaleem
  2. #17
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Sydney, NSW, Australia
    Posts
    40
    Rep Power
    14
    First off to make sure its a square you'll want to make sure that the two diagonals of the square have the same length. Easiest way to make sure its a square.

    Think about pythagorus to do this. I could give you a formula, but from what I have read you wouldn't understand it. Have a think about pythagorus and how you can use it to find the length of the diagnols, then sub in the (x,y) values to your working...

    If you want the square to be "flat", as in not on an angle, Y1 will equal Y2, and X1 will equal X3, with the coordinates being

    (x1,y1) (x2,y2)
    (x3,y3) (x4,y4)

    Hope that helps.
    Cheers,
    Michael Bray
  4. #18
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    9
    Rep Power
    0

    here is the code


    i already know the lengs of the sides ,
    ok here is the code see for yr self wat i am trying to tell you !


    *************************************************

    #include <iostream.h>
    #include <conio.h>
    #include <stdio.h>
    #include <stdlib.h>

    int main(void)

    {
    clrscr();
    int vary =9 ,varx =15 ,var_d =5;
    int x,y,y1,x1,x2,y2,x3,y3,key,key2,key3,key_d=1,key_l=varx,key_u=vary,key_r=1,z ;


    y =var_d ;
    x=var_d ;
    do
    {
    key3 =getch();


    char t ='.',mask='',vars='l',sm ='*' ;
    y1 =var_d ;
    for (y3=0 ;y3<vary ; y3++ )
    {
    x1 =var_d ;
    for(x3=0;x3<varx;x3++)
    {
    gotoxy(x1,y1);
    textcolor(RED);
    printf("%c",t);
    x1=x1+var_d ;
    }
    y1=y1+var_d ;

    }

    do
    {
    //vars ='l' ;
    // printf ("%c", vars );
    key =getch ();
    if (key =='x')
    {
    exit(1) ;
    }
    if (key==80)
    if ( key_d < vary)
    if (vars !='s')
    {

    {
    {
    key_d ++ ;
    key_u--;

    y =y+var_d;
    gotoxy(x,y);
    printf (" ") ;
    gotoxy(x,y);
    printf("%c",mask);
    y=y-var_d ;
    gotoxy(x,y) ;
    printf("%c",t);
    y=y+var_d;

    gotoxy(10,40);
    printf("x=%d ,y=%d",x,y);


    }
    }
    }
    if (key==72)
    if( key_u < vary)
    if ( vars !='s')
    {
    {
    {
    key_u++ ;
    key_d--;

    y =y-var_d;
    gotoxy(x,y);
    printf (" ") ;
    gotoxy(x,y);
    printf("%c",mask);
    y=y+var_d ;
    gotoxy(x,y);
    printf("%c",t);
    y=y-var_d;
    gotoxy(10,40);
    printf("x=%d ,y=%d",x,y);

    }
    }

    }
    if ( key==77 )

    if ( key_r < varx )
    if (vars !='s' )
    {
    {
    {
    key_r++;
    key_l --;

    x =x+var_d;
    gotoxy(x,y);
    printf (" ") ;
    gotoxy(x,y);
    printf("%c",mask);
    x=x-var_d ;
    gotoxy(x,y);
    printf("%c",t);
    x=x+var_d ;

    gotoxy(10,40);
    printf("x=%d ,y=%d",x,y);
    }
    }
    }

    if (key==75)
    if ( key_l < varx)
    if (vars != 's')
    {
    {
    {
    key_l++;
    key_r--;

    x =x-var_d;
    gotoxy(x,y);
    printf (" ") ;
    gotoxy(x,y);
    printf("%c",mask);
    x=x+var_d ;
    gotoxy(x,y) ;
    printf("%c",t);
    x=x-var_d;
    gotoxy(10,40);
    printf("x=%d ,y=%d",x,y);
    }
    } }


    }



    while (key!=13) ;





    x2= x;
    y2= y ;


    do
    {


    if (key == 13)
    {
    vars ='s';
    {

    key2 =getch();
    if (key2 =='x')
    {
    exit(1) ;
    }
    if ( key2==80)

    if (vars =='s')
    {
    {

    y=y-var_d ;
    gotoxy(x,y) ;
    printf("%c",sm);
    x=x+var_d ;
    y=y+var_d ;
    gotoxy(x,y);
    printf("%c",sm);
    x=x-2*var_d ;
    gotoxy(x,y);
    printf("%c",sm);
    x=x+var_d;
    y=y+var_d ;
    gotoxy(x,y);
    printf("%c",mask);
    y=y-var_d ;
    key2 = getch();
    if (key2 ==13)
    {

    for ( z =0 ; z <=var_d ; z++)
    {
    gotoxy(x2,y2);
    printf ("|");
    y2++ ;

    }
    // y2=y2-var_d ;
    // int n=y2+var_d ;
    // int p=0 ;
    //int array[100] ;
    // array[p] = n ;

    // printf("%d",array[p]);
    //p++ ;


    vars='l' ;
    }
    }
    }
    if ( key2==72)
    if (vars =='s')
    {
    {
    y=y-var_d ;
    gotoxy(x,y) ;
    printf("%c",mask);
    x=x+var_d ;
    y=y+var_d ;
    gotoxy(x,y);
    printf("%c",sm);
    x=x-2*var_d ;
    gotoxy(x,y);
    printf("%c",sm);
    x=x+var_d;
    y=y+var_d ;
    gotoxy(x,y);
    printf("%c",sm);
    y=y-var_d ;

    key2 = getch();
    if (key2 ==13)
    {

    for ( z =0 ; z <=var_d ; z++)
    {
    gotoxy(x2,y2);
    printf ("|");
    y2-- ;
    }
    y2=y2+var_d ;
    vars='l' ;
    }

    }
    }

    if ( key2==77)
    if (vars =='s')
    {
    {
    y=y-var_d ;
    gotoxy(x,y) ;
    printf("%c",sm);
    x=x+var_d ;
    y=y+var_d ;
    gotoxy(x,y);
    printf("%c",mask);
    x=x-2*var_d ;
    gotoxy(x,y);
    printf("%c",sm);
    x=x+var_d;
    y=y+var_d ;
    gotoxy(x,y);
    printf("%c",sm);
    y =y-var_d ;



    key2 = getch();
    if (key2 ==13)
    {
    for ( z =0 ; z <=var_d ; z++)
    {
    gotoxy(x2,y2);
    printf ("-");
    x2++ ;
    }
    x2 =x2-var_d ;
    vars='l' ;
    }
    }
    }


    if ( key2==75)
    if (vars =='s')
    {
    {
    y=y-var_d ;
    gotoxy(x,y) ;
    printf("%c",sm);
    x=x+var_d ;
    y=y+var_d ;
    gotoxy(x,y);
    printf("%c",sm);
    x=x-2*var_d ;
    gotoxy(x,y);
    printf("%c",mask);
    x=x+var_d;
    y=y+var_d ;
    gotoxy(x,y);
    printf("%c",sm);
    y=y-var_d;



    key2 = getch();
    if (key2 ==13)
    {
    for ( z =0 ; z <=var_d; z++)
    {
    gotoxy(x2,y2);
    printf ("-");
    x2-- ;
    }
    x2 =x2+var_d ;
    vars='l' ;
    }

    }
    }

    }
    }


    }

    while (vars!='l');
    }
    while (key3!='x');

    }



    *************************************************


    the code runs on tc ,
    u will know wat the codes do if anything is not clear do ask me
    suhailkaleem
  6. #19
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2002
    Posts
    9
    Rep Power
    0
    no help ?
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo