Moving a drawing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • easily confused

    #1

    Moving a drawing

    Ok so im going intomaking a tetris type program and was wondering how i would
    move the drawing after i have crated the shape for the shape i have this code
    ....

    Public Class Form1

    Public Sub PictureBox1_Pai nt1(ByVal sender As System.Object, ByVal
    Block1 As System.Windows. Forms.PaintEven tArgs) Handles PictureBox1.Pai nt
    Block1.Graphics .FillRectangle( Brushes.Blue, 0, 0, 25, 30)
    Block1.Graphics .FillRectangle( Brushes.Blue, 25, 0, 25, 30)
    Block1.Graphics .FillRectangle( Brushes.Blue, 25, 25, 25, 30)
    Block1.Graphics .FillRectangle( Brushes.Blue, 50, 25, 25, 30)

    End Sub

    End Class

    This makes a block that looks like two retangles overlapped.. now how would
    i go about putting movement to this whole shape. Im assuming that i went
    ahead and mde each of the blocks within the shape its own block so when you
    have to dealeate a line of blocks it will be easier. But for now all i have
    to know is how to put a downward movement to the blocks.

  • Homer J Simpson

    #2
    Re: Moving a drawing


    "easily confused" <easilyconfused @discussions.mi crosoft.com> wrote in
    message news:AC6429E2-1C62-4764-92E1-99C9A9780CBD@mi crosoft.com...
    [color=blue]
    > Ok so im going intomaking a tetris type program and was wondering how i
    > would
    > move the drawing after i have crated the shape for the shape i have this
    > code[/color]

    Usually draw the figure, erase it, draw it somewhere else!


    Comment

    • easily confused

      #3
      Re: Moving a drawing

      well im clueless on how you would erase it but could i make some kind of loop
      some how ... then how would i refrence the x and y coordinates to change
      within the sub class

      block1.fillrect angle (10,10,10,10)
      ^ ^
      I I
      (those two number)

      Comment

      • Homer J Simpson

        #4
        Re: Moving a drawing


        "easily confused" <easilyconfused @discussions.mi crosoft.com> wrote in
        message news:8032ADF8-5BC9-447C-835E-AC1C6C5D64D8@mi crosoft.com...
        [color=blue]
        > well im clueless on how you would erase it but could i make some kind of
        > loop
        > some how ... then how would i refrence the x and y coordinates to change
        > within the sub class
        >
        > block1.fillrect angle (10,10,10,10)
        > ^ ^
        > I I
        > (those two number)[/color]

        I'm not sure VB.Net uses this now - but the older Windows OS USED to use
        functions like BitBlit to move objects.

        Search for (PPT2000: Sample Visual Basic Code for Moving Objects On Screen
        During a Slide Show)

        and (PSS ID Number: Q222764) for possible hints.

        Did you download the Blackjack demo solution?



        Comment

        • Dennis

          #5
          Re: Moving a drawing

          If you have a shape that you want to move around, suggest you might use a
          bitmap to draw it to. Use BitBlt to copy to the screen's or a control's
          graphic's object. Before you copy it to one place, you can save the
          background area to a bitmap then when moving the image, replace the screen
          area from the saved bitmap then copy your bitmap to the new position.

          Also, it might work if you just had a timer and called the .invalidate or
          refresh method. This will restore your screen to what it was before you
          added the shape and you can then change the shape's postion in the paint
          event each time it's called. Might work but never tried it.
          --
          Dennis in Houston


          "easily confused" wrote:
          [color=blue]
          > well im clueless on how you would erase it but could i make some kind of loop
          > some how ... then how would i refrence the x and y coordinates to change
          > within the sub class
          >
          > block1.fillrect angle (10,10,10,10)
          > ^ ^
          > I I
          > (those two number)[/color]

          Comment

          Working...