Thread: few questions..

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    42

    few questions..

    hey everyone first post..i'm relatively new at c++ and i'm in my first semester of it. Anyways my teacher assigned us a program
    to make the game battleship. I have two questions.

    when a ship is hit, you have to display a stupid graphic such as
    "HIT" or something like that...i know that "\a" makes a beep noise...but are there other noises you can make? and if so what are they?

    also..when this "HIT" screen shows up, is there someway i can simply delay it? Say the person gets a hit, and it displays HIT, and simply clears the screen on its own in a say 2 second? Normally, i would use a system("pause"), and a system("cls"), but i don't want the user to have to hit enter after it EVERY time they get a hit...

    so any help would be appreciated..thanks!

    BODYBUILDNERD

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    30
    Include dos.h.

    There if a function called delay();

    delay(numberofmilliseconds);

    Also found in that file is a function called sleep();

    sleep(numberofmilliseconds);

    Another function found in dos.h is sound();

    sound(frequencyinhertz);

    To make the noise stop use nosound();

    nosound(void);


    so:
    Code:
    sound(150);//starts sound
    delay(3000);//waits 3 seconds
    nousound();//Stops sound

    Hope this helps.

    ~BC17


    P.S.
    I use Borland Turbo C++ Ver 3.0 Dunno if it will work with others or not.

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    42
    i tried it..brought up error man..am i doing it wrong??

    put #include "dos.h" at the top..

    then before or after my graphic do i put..


    sound(150);//starts sound
    delay(3000);//waits 3 seconds
    nousound();//Stops sound

    that basically will play sound for 3 seconds then stop correct?

    We use Visual Studio.net so its lil different than yours i'm sure..

    umm any other hints..??

  4. #4
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    Visual Studio neither builds nor has support for DOS-Applications. You are probably building a console application. Please have a look at the FAQ how to output Colors in a console. Consoles cannot output graphics, you will have to use colored text.

    The DOS stuff above will not work for console applications.

    The funtion that delays is called Sleep ( notice the capital S ) in Visual Studio.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  5. #5
    Registered User
    Join Date
    Nov 2002
    Posts
    42
    thanks man, is there a library i need to include to you Sleep??
    if so let me know...thanks...

    also where do i find the FAQ about colors in consoles?

    thanks!

    BBNERD

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >is there a library i need to include to you Sleep??
    #include <windows.h>

    >also where do i find the FAQ about colors in consoles?
    This may help some.

    -Prelude
    My best code is written with the delete key.

  7. #7
    Registered User
    Join Date
    Nov 2002
    Posts
    42
    i guess coloring text is over my head :-/

    Dunno...guess i'll stick w/ the plain black and white...

    BBNERD

  8. #8
    Registered User
    Join Date
    Jan 2002
    Posts
    25
    BBNerd, let me guess are you in Fulton's 168 course

    Van

  9. #9
    Registered User
    Join Date
    Nov 2002
    Posts
    42
    WHO IS THIS CHRIS?

    LOL

  10. #10
    Registered User
    Join Date
    Jan 2002
    Posts
    25
    Wassup Josh!! How goes the program? I haven't really started mine yet. Also what did I miss in class, I had to help my parents move into there new house. Also I am working on finding out how to do color in the console so that we can add color to our stuff when we make a hit.

    Van

  11. #11
    Registered User
    Join Date
    Jan 2002
    Posts
    18
    sound(150);//starts sound
    delay(3000);//waits 3 seconds
    nousound();//Stops sound

    that is the code you wrote, look at the last line. You have an extra 'u' in there. That will give you an error if that is actually in your code and not just a little typo.
    Be yourself for those who mind don't matter, and those who matter don't mind.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. questions....so many questions about random numbers....
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2009, 08:47 AM
  2. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 05:36 AM
  3. Several Questions, main one is about protected memory
    By Tron 9000 in forum C Programming
    Replies: 3
    Last Post: 06-02-2005, 07:42 AM
  4. Trivial questions - what to do?
    By Aerie in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 12-26-2004, 09:44 AM
  5. questions questions questions.....
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 08-14-2001, 07:22 AM