Midnightfoxkrissy

pong,i just need to know how to make the controls...i've got the pictures and everything...I also need to know how to make the AI...please help...


Re: Visual Basic Express Edition How do i make pong controls???

MJW

Make your you mark this as an answer if its correct please which im sure it is, because i made pong

Code Snippet

Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.Down Then
PictureBox.Top = PictureBox.Top + 5
ElseIf e.KeyCode = Keys.Up Then
PictureBox.Top = PictureBox.Top - 5
End If
End Sub



Make sure you put it in the forms: "KeyDown" sub.




Re: Visual Basic Express Edition How do i make pong controls???

js06

I couldn't get the code to work in the form event (not sure why exactly)

however i did get it to work by putting a richtextbox on the form and used the following code

set both it's height and width to 0

sloppy but it works

Private Sub RichTextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles RichTextBox1.KeyDown

If e.KeyCode = Keys.Down Then

Me.Button1.Top = Me.Button1.Top + 5

ElseIf e.KeyCode = Keys.Up Then

Me.Button1.Top = Me.Button1.Top - 5

End If

e.Handled = True

End Sub

the other thing

you might be able to make the movement smoother and faster by using a timer to handle the movement

just a thought