How could i...?

This is a discussion on How could i...? within the C Programming forums, part of the General Programming Boards category; What I want to do is the be able to basically have the program print a print statement with variables ...

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    49

    How could i...?

    What I want to do is the be able to basically have the program print a print statement with variables in it after a cls mutiple times.

    ok that doenst make sense but let me explain...

    I am working on a console app rpg combat system. At the top I have health bars and energy ect... I have weapons that are fast like automatics that attack you mutiple times in on turn. Each ATTACK I want to cls the screen to update my health bars so it looks more action oritientated.

    Well I want to print something like this for each multiple instance:

    Code:
    printf("%s attacked you for %d pts of damage!",cpuName,damage);
    well easy... but i dont understand how I cold do it the way i want to! I want it to printf this after every attack, but the problem is that every attack will have to cls the screen to update the health bars. But cls'ing the screen would mean the previous printfs are gone! So how do I KEEP all previous printf's as I cls the screen and print new ones?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Don't clear the screen. Use VT100, ANSI escape codes, BGI cursor movement, Curses, etc etc etc...


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >So how do I KEEP all previous printf's as I cls the screen and print new ones?
    Without a more controlled clear function, you're looking at completely redrawing the screen after you clear it, not just the parts that changed.
    My best code is written with the delete key.

  4. #4
    Registered User
    Join Date
    Apr 2006
    Posts
    49
    yes but I would have to basically always have to "cls" PART of the screen? I dotn udnerstand how.

  5. #5
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,161
    You don't need to clear the screen. Just overwrite the part of the screen you want to change. Move the cursor and output.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  6. #6
    Registered User
    Join Date
    Apr 2006
    Posts
    49
    how do i mopve the coursor and then get it back to where it was? And even if I did, wouldnt it just print it again on top and not write over it?

  7. #7
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,762
    >> wouldnt it just print it again on top and not write over it?
    This means the same thing to me. Writing over it is printing on top of it.

    conio.h might have a function called goto() to set the cursor somewhere on the screen. Or use curses.h or something like that. There is always a way.

  8. #8
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,812
    This is one of those not in the realm of standard C issues. There are many libs available to do said above. Quzah suggested some. Also if you are on the Windows side you can use http://www.adrianxw.dk/SoftwareSite/index.html. I think there is stuff there about windows consoles(DOS ).
    Woop?

  9. #9
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    I think there is stuff there about windows consoles(DOS ).
    I so want to hurt you now.

    ROFLMAO.

Popular pages Recent additions subscribe to a feed

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