Moving a drawing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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_Paint1(ByVal sender As System.Object, ByVal
Block1 As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
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.
 
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

Usually draw the figure, erase it, draw it somewhere else!
 
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.fillrectangle (10,10,10,10)
^ ^
I I
(those two number)
 
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.fillrectangle (10,10,10,10)
^ ^
I I
(those two number)

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?
 
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.
 
Back
Top