Thread: simple background color question.

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    465

    simple background color question.

    i began learning C++ a while back but have kind of forgotten about it for one reason or another. recently i have been re-inspired and, more specifially, have decided to translate a card game i made up a few years back into the digital world.

    i have always had problems with the background color function. since i need it to work now (because what is a computer card game without the traditional green background) i have finally decided to ask someone what it is i am doing wrong.

    so far (because i havent started on the game yet, and am merely trying to get my background green) this is all the code i have:

    Code:
    #include <stdio.h>
    #include <winbgim.h>
    
    int main()
    {
    
      initwindow(800,600);
      setbkcolor(GREEN);   //also tried "setbkcolor(2);" 
    
        while ( !kbhit() ){}
    
      return 0;
    }
    ive tried moving the function before the initwindow(), after it, in the while loop, but still all i get is a 800x600 black window.

    any help?

    (and, as you may have gathered from my code, i am using Dev C++ with the winbgim graphics library, which is almost identical to borland's graphics.h)

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    465
    c'mon! you mean to tell me that bit of code is flawless? i must be doing something wrong.....
    I came up with a cool phrase to put down here, but i forgot it...

  3. #3
    I have never seen the fuinctions you are unsing before. Maybe the don't exist. Or maybe i live a sheltered life. What compiler are you using, and what are the errors?
    Compilers:
    GCC on Red Hat 8.1 (Primary)
    GCC on Mac OS X 10.2.4 (Secondary)

    Others:
    MinGW on XP

  4. #4
    Registered User
    Join Date
    Feb 2002
    Posts
    465
    im using Bloodshed Dev C++ with the winbgim.h graphics library.

    a list of all of the functions contained within both the borland and winbgim librarys can be found here:

    http://www.cs.colorado.edu/~main/bgi/doc/

    which is where i am getting the functions from. all of them seem to work except setbkcolor().
    I came up with a cool phrase to put down here, but i forgot it...

  5. #5
    The top line of the setbkcolor page:
    #include <graphics.h>
    Compilers:
    GCC on Red Hat 8.1 (Primary)
    GCC on Mac OS X 10.2.4 (Secondary)

    Others:
    MinGW on XP

  6. #6
    Bios Raider biosninja's Avatar
    Join Date
    Jul 2002
    Location
    South Africa
    Posts
    765
    Here, try this :

    Code:
    #include <stdio.h>
    #include <graphics.h>
    #include <conio.h>
    
    int main()
    {
    
      window(1,1,800,600);
      setbkcolor(GREEN);   //also tried "setbkcolor(2);"
    
        while ( !kbhit() ){}
    
      return 0;
    }

  7. #7
    Registered User
    Join Date
    Feb 2002
    Posts
    465
    "<winbgim.h>" and "<graphics.h> are identical librarys. graphics.h works for borland and winbgim.h works for dev c++ (after you download the library from their website).

    i tried adding <conio.h> and it gave me a bunch of errors, such as:

    "conflicting types for 'enum COLORS BLUE' "
    "previous declaration as 'enum colors BLUE' "

    for all of the colors.

    now what?
    I came up with a cool phrase to put down here, but i forgot it...

  8. #8
    Bios Raider biosninja's Avatar
    Join Date
    Jul 2002
    Location
    South Africa
    Posts
    765
    I use borland so, use the the header that works for you.
    and for "window" to work, I need conio.h

  9. #9
    Registered User
    Join Date
    Feb 2002
    Posts
    465
    hum...

    anyone use winbgim.h that can help me?
    I came up with a cool phrase to put down here, but i forgot it...

  10. #10
    If i am not mistaken, a lot of people here use allegro.

    ~Inquirer
    Compilers:
    GCC on Red Hat 8.1 (Primary)
    GCC on Mac OS X 10.2.4 (Secondary)

    Others:
    MinGW on XP

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple Socialising Chat Bots
    By bengreenwood in forum C++ Programming
    Replies: 10
    Last Post: 11-28-2007, 08:42 AM
  2. Detect Close of a background process
    By Schwarzhelm in forum C Programming
    Replies: 1
    Last Post: 11-05-2003, 01:46 AM
  3. Simple Compile Time Problem - HELP!
    By kamikazeecows in forum Windows Programming
    Replies: 2
    Last Post: 12-02-2001, 01:30 PM
  4. Help me with these simple programs
    By Help me in forum C Programming
    Replies: 4
    Last Post: 11-08-2001, 10:38 AM
  5. Need help with simple data types
    By partnole in forum C++ Programming
    Replies: 1
    Last Post: 10-03-2001, 08:36 AM