Announcement

Collapse
No announcement yet.

DiscoLights does not the correct results

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

  • DiscoLights does not the correct results

    Hi all

    Can someone help me because my program is not the correct result as the original program?
    This is the code:

    QB45/QB64
    ==========
    Code:
    'DO
    '    _LIMIT 40
    '    d = INT(RND * 10)
    '    SELECT CASE d
    '        CASE 2
    '            GOSUB red
    '        CASE 3
    '            GOSUB green
    '        CASE 4
    '            GOSUB blue
    '    END SELECT
    'LOOP
    'red:
    'r = RND * 240
    'CIRCLE (130, 125), 100, _RGB32(r, 0, 0)
    'PAINT (130, 125), _RGB32(r, 0, 0)
    'RETURN
    'green:
    'g = RND * 240
    'CIRCLE (360, 125), 100, _RGB32(0, g, 0)
    'PAINT (360, 125), _RGB32(0, g, 0)
    'RETURN
    'blue:
    'b = RND * 240
    'CIRCLE (590, 125), 100, _RGB32(0, 0, b)
    'PAINT (590, 125), _RGB32(0, 0, b)
    'RETURN
    Try-out in PBCC60
    Code:
    #COMPILE EXE "cc60_DiscoLight.exe"
    #DIM ALL
    FUNCTION PBMAIN () AS LONG
        '===================================================================='
        'Declarations                                                        '
        '===================================================================='
        DIM a       AS SINGLE
        DIM x       AS SINGLE
        DIM y       AS SINGLE
        DIM hGW     AS DWORD
        DIM d       AS LONG
        DIM r       AS LONG
        DIM g       AS LONG
        DIM b       AS LONG
    
        '===================================================================='
        'Init Graphic Device and Canvas                                      '
        '===================================================================='
    
        GRAPHIC WINDOW "Horizontal Disco Lights", 0, 0, 800, 640 TO hGW
        GRAPHIC ATTACH hGW, 0&', REDRAW
        'GRAPHIC COLOR %WHITE, %BLACK
        ' graphic color %black,%white
        GRAPHIC COLOR RGB(0,0,0) ', RGB(255,255,255)
        GRAPHIC CLEAR
    
        DO
            d = INT(RND * 10)
            SELECT CASE d
                CASE 2
                    GOSUB red
                CASE 3
                    GOSUB green
                CASE 4
                    GOSUB blue
            END SELECT
        LOOP
        EXIT FUNCTION
    
    red:
        r = RND * 240
        GRAPHIC ELLIPSE (130, 125) - (100, 100), RGB(r, 0, 0)
        GRAPHIC PAINT BORDER (130, 125), RGB(r, 0, 0)
    RETURN
    
    green:
        g = RND * 240
        GRAPHIC ELLIPSE (360, 125) - (100, 100), RGB(0, g, 0)
        GRAPHIC PAINT BORDER (360, 125), RGB(0, g, 0)
    RETURN
    
    blue:
        b = RND * 240
        GRAPHIC ELLIPSE (590, 125) - (100, 100), RGB(0, 0, b)
        GRAPHIC PAINT BORDER (590, 125), RGB(0, 0, b)
    RETURN
    
        GRAPHIC WAITKEY$
    END FUNCTION
    Kind regards
    Stephane

  • #2
    Stephane -

    Assuming you have not figured this out by yourself by now:

    1) Read the documentation on GRAPHIC ELLIPSE. Note that each ellipse must be specified by location, so for instance GRAPHIC ELLIPSE (360, 125) - (100, 100) should be GRAPHIC ELLIPSE (360, 125) - (330, 100). A similar change is required for blue.

    2) Since it is possible to specify a fill color in GRAPHIC ELLIPSE, there is no need for a GRAPHIC PAINT BORDER. Again, read the help on GRAPHIC ELLIPSE.

    Comment


    • #3
      3, 2, 1...
      "Not my circus, not my monkeys."

      Comment


      • #4
        Jim,
        WHY, why, why are you resurrecting something more than a year old?

        Eric.
        Was the count-down refering to how long before someone jumped on this? (like I just did?)

        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        It's pretty good having silence from original poster too! Please let that sleeping dog lay.
        Dale

        Comment


        • #5
          I was anticipating the return of the OP, who has a long history in these forums.
          "Not my circus, not my monkeys."

          Comment


          • #6
            Eric, what is OP ?

            Anyway, when I execute the compiled program in #1, it blinks like disco
            but when i click close button, the program does not shutdown properly.
            i have to use Task Manager to kill the process

            Can someone show be how to place a close button on this program so that
            it can be shutdown normally ? I'm new to PB graphics

            Comment


            • #7
              Original Poster, aka the person who did post #1 in the thread; or depending on context, Original Post, meaning the first post itself.

              The code in the OP is known broken. The person who posted it had (has?) a bad habit of "borrowing" code from other versions of BASIC, or even other languages, trying literal line-to-line translation to PB, then coming here for help when it didn't work because he didn't even attempt to understand what the code was doing and then write PB code to acheive the result.

              Someone with extra time on their hands may fix it for you.

              Cheers,
              Dale

              Comment


              • #8
                ok thanxx Dale

                Comment


                • #9
                  Can someone show be how to place a close button on this program so that
                  it can be shutdown normally ? I'm new to PB graphics
                  The following code shuts the program down normally, I also slowed the flashing down a tad.
                  Code:
                  #COMPILE EXE "cc60_DiscoLight.exe"
                  #DIM ALL
                  FUNCTION PBMAIN () AS LONG
                      '===================================================================='
                      'Declarations                                                        '
                      '===================================================================='
                      DIM a       AS SINGLE
                      DIM x       AS SINGLE
                      DIM y       AS SINGLE
                      DIM hGW     AS DWORD
                      DIM d       AS LONG
                      DIM r       AS LONG
                      DIM g       AS LONG
                      DIM b       AS LONG
                      LOCAL hDC AS DWORD
                      '===================================================================='
                      'Init Graphic Device and Canvas                                      '
                      '===================================================================='
                  
                      GRAPHIC WINDOW "Horizontal Disco Lights", 0, 0, 800, 640 TO hGW
                      GRAPHIC ATTACH hGW, 0&', REDRAW
                      'GRAPHIC COLOR %WHITE, %BLACK
                      ' graphic color %black,%white
                      GRAPHIC COLOR RGB(0,0,0) ', RGB(255,255,255)
                      GRAPHIC CLEAR
                  
                      DO
                          d = INT(RND * 10)
                          SELECT CASE d
                              CASE 2
                                   red
                              CASE 3
                                   green
                              CASE 4
                                   blue
                          END SELECT
                          GRAPHIC WAITKEY$(30)
                          GRAPHIC GET DC TO hDC  'if hDC becomes 0, program is closing
                  
                      LOOP UNTIL hDC = 0
                      GRAPHIC WINDOW END
                  END FUNCTION
                  SUB red
                      LOCAL r AS LONG
                      r = RND * 240
                      GRAPHIC ELLIPSE (130, 125) - (100, 100), RGB(r, 0, 0)
                      GRAPHIC PAINT BORDER (130, 125), RGB(r, 0, 0)
                  END SUB
                  
                  SUB green
                      LOCAL g AS LONG
                      g = RND * 240
                      GRAPHIC ELLIPSE (360, 125) - (100, 100), RGB(0, g, 0)
                      GRAPHIC PAINT BORDER (360, 125), RGB(0, g, 0)
                  END SUB
                  
                  SUB blue
                      LOCAL b AS LONG
                      b = RND * 240
                      GRAPHIC ELLIPSE (590, 125) - (100, 100), RGB(0, 0, b)
                      GRAPHIC PAINT BORDER (590, 125), RGB(0, 0, b)
                  END SUB
                  Rod
                  "To every unsung hero in the universe
                  To those who roam the skies and those who roam the earth
                  To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

                  Comment


                  • #10
                    Originally posted by Chris Chancellor View Post
                    I'm new to PB graphics
                    Looks like you are fairly new here in general. A belated welcome to the community.
                    Will code for food.

                    Comment


                    • #11
                      Thanxx Rodney , that's very good

                      Thanxx Brice, i w'd need all your help as being a beginner programmer there are many road blocks

                      Comment


                      • #12
                        Originally posted by Chris Chancellor View Post
                        Thanxx Brice, i w'd need all your help as being a beginner programmer there are many road blocks
                        One thing to keep in mind, there is no such thing as an expert when it comes to programming. There is always somebody who is going to know more than somebody else. The industry changes too rapidly for anybody to be an expert. So, never be intimidated. Most can remember what it was like being a beginner. Lots of helpful people here who will generally go out of their way to help somebody else.

                        I had a few years hiatus from programming, suffered a TBI in 2014 and I have dealt with memory issues since then. I consider myself a beginner in many ways, as I am having to relearn many things. Unfortunately, now it takes several times before something "sinks in".


                        Will code for food.

                        Comment


                        • #13
                          as being a beginner programmer there are many road blocks
                          Sheesh, I hate negative thinking.

                          They are not "road blocks" they are "opportunity hurdles."
                          Michael Mattias
                          Tal Systems Inc.
                          Racine WI USA
                          mmattias@talsystems.com
                          http://www.talsystems.com

                          Comment


                          • #14
                            Originally posted by Michael Mattias View Post
                            They are not "road blocks" they are "opportunity hurdles."
                            Launch ramps.
                            The world is strange and wonderful.*
                            I reserve the right to be horrifically wrong.
                            Please maintain a safe following distance.
                            *wonderful sold separately.

                            Comment


                            • #15
                              If you watch the original Magnificent Seven movie, Steve McQueen says, "I once knew a guy who one day took off all his clothes and started rolling around in a bed of cactus. When I asked him why he did it, he said it seemed like a good idea at the time."

                              So, I just HAD to get Stephane into the mix one more time.

                              Or, to take another literary tack, you should read Edgar Allen Poe's "The Imp of Perversity". It was an impulse I could not resist.

                              And Chris, just to show how masochistic that is, you should be aware that Stephane joined the forum in 2002. Consider that he has been "programming" for 15 years at least, and look at his question with this in mind.

                              Comment


                              • #16
                                Or like the scorpion who promised not to string while geting a ride across the river. Half way across he stung. When asked why he'd killed both he said he couldn't help himself, stinging is what scorpions do. Couldn't help yourself Jim?

                                Stephane was also always harping that PB was no good unless the lastest buzz word thing was added. It got so bad about OOP, the the good hearted and tolerent Mr. Z had to ban him from the forum. Eventually he was allowed back, and behaved (mostly). Also eventually PB got OOP. Guess who only visited the OOP section once or twice? Then he started harping about adding this or that to PB again. Then he disappeared again. Maybe Mr. Z. was gone by then and the site admin at the time baned him again.

                                It may amuse Jim, I'd still rather that dog not be kicked.
                                Dale

                                Comment

                                Working...
                                X