Hey, check out this project...

This is a discussion on Hey, check out this project... within the C++ Programming forums, part of the General Programming Boards category; Hey, check out this project!!((note: NOT for windows compilers use)) Copy paste this code. Before you compile and run, post ...

  1. #1
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269

    Hey, check out this project...

    Hey, check out this project!!((note: NOT for windows compilers use)) Copy paste this code. Before you compile and run, post a reply what you think will happen:



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

    int main()
    {
    int x = 15;
    int y = 10;
    int a = 1;
    while(a==1)
    {
    char cl = getch();
    if (cl==80)
    {
    clrscr();
    gotoxy(x, y);
    y++;
    putch('@');
    gotoxy(x, y++);
    }
    if (cl==77)
    {
    clrscr();
    gotoxy(x, y);
    y++;
    putch('@');
    gotoxy(x++, y--);
    }
    if (cl==72)
    {
    clrscr();
    gotoxy(x, y--);
    y++;
    putch('@');
    gotoxy(x, y--);
    }
    if (cl==75)
    {
    clrscr();
    gotoxy(x--, y);
    putch('@');
    gotoxy(x--, y);
    }
    if (cl==27)
    {
    exit(0);
    }
    }
    return 0;
    }




    It's a small code, but its mine



    PS: im a begginer so don't get mad
    Code:
    #if _emo
      #define stereo_type_i_dislike
    #endif

  2. #2
    William
    Guest
    Can't compile it because of gotoxy and clrscr (Ok, ok, I'm on windows, sorry...). But gotoxy and clrscr aren't std C/C++.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    30
    You can replace clrscr() with system("cls") but i dont know if there is a replacement for gotoxy() in ANSI

  4. #4
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    read the faq and you would have found these....

    Code:
    void clrscr()
    {
       COORD coordScreen = { 0, 0 };
       DWORD cCharsWritten;
       CONSOLE_SCREEN_BUFFER_INFO csbi;
       DWORD dwConSize;
       HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    
       GetConsoleScreenBufferInfo(hConsole, &csbi);
       dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
       FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, coordScreen, &cCharsWritten);
       GetConsoleScreenBufferInfo(hConsole, &csbi);
       FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten);
       SetConsoleCursorPosition(hConsole, coordScreen);
    }
    
    
    void gotoxy(int x, int y) 
    { 
        COORD point; 
        point.X = x; point.Y = y; 
        SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),point); 
    }
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  5. #5
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    oh yeah btw both of those require the header <windows.h> this should be the first header on your list of includes.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  6. #6
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    SPOILER

    Will probably make a @ move around on the screen when pressing some buttons.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  7. #7
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269
    it works, ok? i was just showing off my begginer skills
    Code:
    #if _emo
      #define stereo_type_i_dislike
    #endif

  8. #8
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    u copied my idea!

  9. #9
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    I am the only person with Beginner Skillz!!!!!

    (even though I am about intermediate now, I graduated )

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Open-source Game Project
    By Glorfindel in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 03-24-2009, 02:12 AM
  2. Commerical MMORPG Developer Opp
    By Th3Guy in forum Projects and Job Recruitment
    Replies: 19
    Last Post: 01-22-2007, 11:28 AM
  3. How to build a C project?
    By jumpjack in forum C Programming
    Replies: 5
    Last Post: 01-26-2006, 07:35 AM
  4. Game Independent Anti-cheat Project Needs Programmers
    By GIA Project Lea in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 09-15-2005, 08:41 PM
  5. How to add a file to a project in bloodshed.
    By Smeep in forum C++ Programming
    Replies: 4
    Last Post: 04-22-2005, 10:29 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21