Thread: how do i duplicate this in c++

  1. #31
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Are you practicing a new language? Do you have an real world examples of what you want? Do you know any programs that do what you're asking?
    Sent from my iPadŽ

  2. #32
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Depends on if you want it to be portable or not because it's dependent on the operating system.

    For windows the conio library will do. With it you will be able to enter and change text at specific positions. If you want it to be portable, use PDCurses instead.

    For the timer part of your code you can simulate a sleep function with the help of the time standard library:

    Code:
    void sleep(unsigned int msec) {
        clock_t stop_ = msec + clock();
        while ( stop_ > clock() ) ;  // don't forget the semi-colon
    }
    Last edited by Mario F.; 08-15-2006 at 07:18 PM.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #33
    Registered User
    Join Date
    Sep 2005
    Posts
    196
    ok im gonna try to find the nes game this is in
    ill edit when i do but yull need the jnes emu to view it

    heh heh sorry i head the description of what i wanted a little bit wrong sorry..
    the game is final fantasy2

  4. #34
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Quote Originally Posted by lilhawk2892
    heh heh sorry i head the description of what i wanted a little bit wrong sorry..
    the game is final fantasy2
    Where? When you're choosing a name, or you mean the way they display the scrolling text in game?
    Sent from my iPadŽ

  5. #35
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    I think he means the latter. Fortunately there is a simple way.
    Click: https://cboard.cprogramming.com/showthread.php?t=78570

  6. #36
    Registered User
    Join Date
    Sep 2005
    Posts
    196
    yes ..no sortof


    well its not exactly what i wanted but i suppose its good enouph

    but download final fantasy 2 the first thing you see should be what i want
    Last edited by lilhawk2892; 08-15-2006 at 10:46 PM.

  7. #37
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Well what else did you want it to do?

    If you want the top line to disappear, then there is no standard way to do that. You can easily do it with curses or conio.h or window.h, though.
    Sent from my iPadŽ

  8. #38
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    > but download final fantasy 2 the first thing you see should be what i want
    • My fellow compatriots are not going to download something so that you can get what you want.
    • If you cannot explain coherently what you want to do then it is not worth doing.
    • Final Fantasy took a while to develop and is a big [illegal] undertaking to reproduce all by yourself, etc.

  9. #39
    Registered User
    Join Date
    Sep 2005
    Posts
    196
    you wont download ff2? its a great game well aside from that i think i can figure out what i want now

  10. #40
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267

    Thumbs down

    Quote Originally Posted by lilhawk2892
    you wont download ff2?
    Not in this lifetime! I like my computer free of viruses and other nasty things you can get from downloading stuff like that.

  11. #41
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934

    Lightbulb

    How about this?
    Code:
    #include <iostream>
    #include <string>
    #include <windows.h>
    using namespace std;
    const int screen_size = 20;
    
    void clrscr(void);
    void gotoxy(int x, int y);
    
    int main()
    {
       HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
       WORD wOldColorAttr;
       CONSOLE_SCREEN_BUFFER_INFO csbi;
       
       GetConsoleScreenBufferInfo(h, &csbi);
       wOldColorAttr = csbi.wAttributes;
       
       SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_INTENSITY);
    
       string display("FINAL FANTASY 2");
       clrscr();
       int x = 1;
       for (string::size_type i=0; i<display.length(); i++)
       {
          char ch = ' ';
          for (;;)
          {
             for (int y=0; y<screen_size; y++)
             {
                gotoxy(x, y);
                cout << ch << flush;
             }
             Sleep(50);
             if (ch == display[i])
                break;
             ch++;
          }
          Sleep(200);
          x += 2;
       }
       
       cin.get();
       SetConsoleTextAttribute(h, wOldColorAttr);
       return 0;
    }
    
    void clrscr(void)
    {
        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 coord;
      coord.X = x;
      coord.Y = y;
      SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
    }

  12. #42
    Registered User
    Join Date
    Sep 2005
    Posts
    196
    !!!! yes it is yes it is yes it is well thank you so much just wow thank you you rock thank you thank you

    but wheres the code segment that controls how many letters there are

    nvm found it just thank you so much

  13. #43
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >but wheres the code segment that controls how many letters there are
    If you make the banner to be displayed a string, there's a length() member function you can use to control your for-loop. So it would be:
    Code:
       for (string::size_type i=0; i<name_of_string.length(); i++)
    Since in this case I called the banner striing "display", it's this loop:
    Code:
       for (string::size_type i=0; i<display.length(); i++)
    I guess I could have called it title or banner. Those might be better names.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. excel (detecting duplicate data)
    By xddxogm3 in forum Tech Board
    Replies: 6
    Last Post: 01-11-2007, 10:21 PM
  2. Eliminating duplicate values from a 20x2 array
    By desipunjabi in forum C Programming
    Replies: 2
    Last Post: 10-29-2005, 09:11 PM
  3. How to duplicate a tree?
    By franziss in forum C Programming
    Replies: 2
    Last Post: 01-16-2005, 12:23 AM
  4. duplicate detection algorithm
    By Gustaff in forum C Programming
    Replies: 4
    Last Post: 01-28-2003, 12:26 PM
  5. How to check duplicate line in text file?
    By ooosawaddee3 in forum C++ Programming
    Replies: 3
    Last Post: 10-30-2002, 06:35 PM