Loading ...
Sorry, an error occurred while loading the content.
 

Beginning Program

Expand Messages
  • William Roggow
    I am beginning to learn to program in the windows environment by looking at other peoples programs. I try to investigate line by line, try different things,
    Message 1 of 6 , Oct 30, 2008
      I am beginning to learn to program in the windows environment by looking at
      other peoples programs. I try to investigate line by line, try different
      things, and see what happens. However, I have run across the following
      problem. If I run the following code in the "debugger" , I get the
      background to show as expected. If I run the code in LB (Shift + F5), I get
      a "flash" and then a white screen. Can someone explain the reason for the
      difference?

      Thanks



      'Code beginns here

      nomainwin

      WindowWidth = 700
      WindowHeight = 550
      UpperLeftX = Int((DisplayWidth - WindowWidth)/2)
      UpperLeftY = Int((DisplayHeight - WindowHeight)/2)

      graphicbox #game.g 0, 20, 700, 470

      open "Balloon Shoot" for window as #game
      print #game, "trapclose [quit]"
      cursor crosshair

      loadbmp "background", "bliss.bmp"

      print #game.g, "background background";

      print #game.g, "drawsprites"

      wait

      [quit]
      unloadbmp "background"
      close #game
      end


      'Code end
    • E Mattison
      Hey,   Kinda new here myself, but from what I gather, here are a couple of possible troublespots:  
      Message 2 of 6 , Oct 30, 2008
        Hey,
         
        Kinda new here myself, but from what I gather, here are a couple of possible troublespots:
         

        << open "Balloon Shoot" for window as #game - probably should be 'for graphics as'
         
        << graphicbox #game.g 0, 20, 700, 470 should have a coma after the '#game.g,'

         As I state, I am very new as well, so I may be completely off base here, but hopefully I'm close enough to give you a place to start.
         
         
        E




        [Non-text portions of this message have been removed]
      • styskul
        before the line print #game.g, background background , put: print #game.g, down I think this was addressed recently, and if I remember correctly the
        Message 3 of 6 , Oct 30, 2008
          before the line 'print #game.g, "background background"', put:

          print #game.g, "down"

          I think this was addressed recently, and if I remember correctly the
          problem is that the debugger automatically issues the "down" command
          when drawing, but when running an executable you need to explicitly
          call the command.

          --- In libertybasic@yahoogroups.com, "William Roggow" <roggowb@...> wrote:
          >
          >
          >
          > I am beginning to learn to program in the windows environment by
          looking at
          > other peoples programs. I try to investigate line by line, try
          different
          > things, and see what happens. However, I have run across the following
          > problem. If I run the following code in the "debugger" , I get the
          > background to show as expected. If I run the code in LB (Shift +
          F5), I get
          > a "flash" and then a white screen. Can someone explain the reason
          for the
          > difference?
          >
          > Thanks
          >
          >
          >
          > 'Code beginns here
          >
          > nomainwin
          >
          > WindowWidth = 700
          > WindowHeight = 550
          > UpperLeftX = Int((DisplayWidth - WindowWidth)/2)
          > UpperLeftY = Int((DisplayHeight - WindowHeight)/2)
          >
          > graphicbox #game.g 0, 20, 700, 470
          >
          > open "Balloon Shoot" for window as #game
          > print #game, "trapclose [quit]"
          > cursor crosshair
          >
          > loadbmp "background", "bliss.bmp"
          >
          > print #game.g, "background background";
          >
          > print #game.g, "drawsprites"
          >
          > wait
          >
          > [quit]
          > unloadbmp "background"
          > close #game
          > end
          >
          >
          > 'Code end
          >
        • Stefan Pendl
          ... There are two ways to add a graphics area to a window: 1) open a graphics window 2) include a graphics box inside a normal window, as done in the example
          Message 4 of 6 , Oct 30, 2008
            >
            > << open "Balloon Shoot" for window as #game - probably should
            > be 'for graphics as'
            >  

            There are two ways to add a graphics area to a window:
            1) open a graphics window
            2) include a graphics box inside a normal window,
            as done in the example

            >  
            > << graphicbox #game.g 0, 20, 700, 470 should have a coma
            > after the '#game.g,'
            >

            The missing comma should raise a syntax error, but sometimes LB is very forgiving.

            ---
            Stefan Pendl
          • Stefan Pendl
            ... For any graphics area the DOWN command should be the first command issued to a graphics area. I think, Carl is going to change the default for any graphics
            Message 5 of 6 , Oct 30, 2008
              >
              > before the line 'print #game.g, "background background"', put:
              >
              > print #game.g, "down"
              >
              > I think this was addressed recently, and if I remember correctly the
              > problem is that the debugger automatically issues the "down" command
              > when drawing, but when running an executable you need to explicitly
              > call the command.
              >

              For any graphics area the DOWN command should be the first command issued to a graphics area.

              I think, Carl is going to change the default for any graphics area to be pen down, not pen up, as it is the default for RB now.
              This might break some programs, which use turtle commands to move the pen, but that is easy to fix by adding an UP command at the
              beginning.

              The majority of people are caught by the need to add a DOWN command as the first command before drawing.

              ---
              Stefan Pendl
            • William Roggow
              Thanks to all who answered. It was the down command.
              Message 6 of 6 , Oct 30, 2008
                Thanks to all who answered. It was the "down" command.


                >> before the line 'print #game.g, "background background"', put:
                >>
                >> print #game.g, "down"
              Your message has been successfully submitted and would be delivered to recipients shortly.