Announcement

Collapse
No announcement yet.

GET screen in colors

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • GET screen in colors

    I want to be able to grab the instructions to a game I am writing, and put it temporarily on the screen when the user presses the 'I' key. I am able to grab the screen,
    but when I PUT it on the screen, the colors I started with are not what is used. How can I create a color box, and use it as created? Below is the code for am using. Am I doing something wrong?
    Thanks for any suggestions...
    screen 12
    cls
    dim box(15300)

    Boxit:
    for x = 2 to 20: locate x,2: color 0,9 rint " ": next x
    color 5,7:LOCATE 1, 1: PRINT CHR$(201) + STRING$(40, 205) + CHR$(187)
    FOR x = 2 TO 20: LOCATE x, 1: PRINT CHR$(186): LOCATE x, 42: PRINT CHR$(186);chr$(176): NEXT x
    LOCATE 21, 1: PRINT CHR$(200) + STRING$(40, 205) + CHR$(188);chr$(176)
    print tab(2);string$(42,176)
    Instructions:
    locate 2,15: print "Instructions"
    locate 3,14: print "--------------"
    locate 4,3: print "You, as the wolf, must land on a goat"
    locate 5,3: print "by exact count. You move in any direc-"
    locate 6,3: print "tion, up to your total moves allotted."
    locate 7,3: print "The goats move in a straight line in"
    locate 8,3: print "any one direction. They move in the"
    locate 9,3: print "amount shown as their number. That is,"
    locate 10,3: print "a G4 will move 4 straight spaces and"
    locate 11,3: print "will try to land on your wolf. If one"
    locate 12,3: print "does, the game is over. YOU LOSE !!!"
    locate 14,11: print "The game is over when :"
    locate 15,12: print "A) You eat 3 goats."
    locate 16,12: print "B) A goat eats YOU!"
    locate 18,12: print "Press Space To End"
    locate 20,5: print "Press 'i' to re-read instructions"
    get(1,1)-(343,355),box
    delay 4
    color 7,2
    cls

    put(150,65),box,XOR

    end

    ------------------

  • #2
    Stafford,

    the matter is the odd way SCREEN 12 uses colors to print text. As in text mode (SCREEN 0) you can choose both the foreground and the background color, while in SCREEN 12 you can only choose the foreground. In SCREEN 12, PRINTs always use color 0 as background, and the second value of the COLOR statement defines the color to be associated to the color 0 used as background. Try to modify the last lines as foloows:
    Code:
    ....
    get ...
    delay 4
    color 5, 4
    delay 4
    ....
    You'll see the whole background change its color without even do a single PRINT.

    In your code, the GET statement gets a 0 for each background pixel, and the PUT puts the same 0, which will be showed as the current COLOR statement.

    Aldo

    ps - Change the XOR into a PSET in the PUT statement.


    ------------------
    Rgds, Aldo

    Comment


    • #3
      An alternative way that does save the colors would be to
      save the screen to disk, & then reload it. The needed code has
      been posted in these forums before; I myself once posted code
      that would save/load any valid DOS screen.

      A possible catch is that most if not all posted programs save
      the entire screen. Another is that I tried just now, for perhaps
      five minutes, to find out the web address of some of these
      programs, using PB search, & had no luck. The code is there,
      however, believe me.



      ------------------

      Comment


      • #4
        Thanks to both of you, Aldo and Emil. I will try some of your suggestions. The instructions that come with PowerBASIC aren't to explicit about the use of a lot of the commands. My thanks again...

        Stafford White

        ------------------

        Comment


        • #5
          You could always save the screen "before" and restore "after" using one of the "orginal" ways to save and restore screens: BSAVE and BLOAD.
          Michael Mattias
          Tal Systems Inc. (retired)
          Racine WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            Michael..
            I hadn't thought about 'BSAVE' and 'BLOAD' commands. That sounds like it may work. I was going to try overwiting the play-field with instructions, then put the play-field back over them, to make them disappear. But, your way, I can create a more elaborate screen. Thanks a lot. That was a big help.

            Stafford White

            ------------------

            Comment


            • #7
              may be my explanation was too complicated. What's enough is to restore the original color you used to create the help screen: you created it with "color 5, 7": well, just before the "get", perform another "color 5, 7" (the important part of the statement is the ",7". Nothing else is required to make your program run correctly.

              ------------------
              Rgds, Aldo

              Comment

              Working...
              X