Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) Handles MyBase.KeyDown I don't see the need for the timer in your example since you just need to invalidate whenever the user is pressing the keyboard.įor object collision, you would need a list of objects that have their rectangle coordinates, and then just test for an intersection: Public Class Form1ĭim listOfThings As New List(Of Rectangle) Oh yes - the player must use the arrow keys to change the X and Y, and when it redraws, it will move. Private Sub Form1_Paint(ByVal sender As Object, ByVal e As ) Handles Me.PaintĮ.Graphics.FillRectangle(Brushes.Blue, X, Y, W, H)ĭim WinSqX As Integer = ĭim WinSqY As Integer = Private Sub TmrRedraw_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TmrRedraw.Tick Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As ) Handles Me.KeyDown How would I create a handler, or something as such to detect if the square that the form draws is touching these objects? Now my question is, that there are various squares and rectangles dotted around the form. There's a timer which basically invalidates the whole form for a redraw. The game relies on two variables, X and Y which are integers. I'm building a maze application in visual basic.
0 Comments
Leave a Reply. |