how do i duplicate this in c++

This is a discussion on how do i duplicate this in c++ within the C++ Programming forums, part of the General Programming Boards category; Are you practicing a new language? Do you have an real world examples of what you want? Do you know ...

  1. #31
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,066
    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
    Portugal
    Posts
    7,412
    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.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    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,066
    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
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,634
    I think he means the latter. Fortunately there is a simple way.
    Click: http://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,066
    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
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,634
    > 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.

Page 3 of 3 FirstFirst 123
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, 09: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-15-2005, 11:23 PM
  4. duplicate detection algorithm
    By Gustaff in forum C Programming
    Replies: 4
    Last Post: 01-28-2003, 11:26 AM
  5. How to check duplicate line in text file?
    By ooosawaddee3 in forum C++ Programming
    Replies: 3
    Last Post: 10-30-2002, 05:35 PM

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