I have been doing some simple programming for a year now with my boss on VB.NET. Then I had a great idea, to try to make small windows games at home for fun learning experience while at the same time learning more stuff at work.
I am essentially making a game where there is a timer, and a picture(The picture is a black blob). Essentially I have it jumping around on the screen every 3 seconds; however, I want to make it so that if someone click on the blob before 2 seconds that the blob goes away, otherwise the blob stays there and a new blob is generated.
I am right now making it put each random location of the picture be put in a picture array; however, I am unable to actually get the pictures to appear.
Private Sub StartGameTimer_Tick(sender As Object, e As System.EventArgs) Handles StartGameTimer.Tick 'Randomize() pbPicture.Visible = True Dim x1 As Integer = pnlPicture.Width * Rnd(0.3) Dim y1 As Integer = pnlPicture.Height * Rnd(0.3) If x1 < pnlPicture.Location.X Then x1 += 24 ElseIf x1 > (pnlPicture.Location.X + pnlPicture.Width) Then x1 -= 24 End If If y1 < pnlPicture.Location.Y Then y1 += 24 ElseIf y1 > (pnlPicture.Location.Y + pnlPicture.Height) Then y1 -= 24 End If X3 = x1 Y3 = y1 pbPicture.Location = New Point(x1, y1) picture1(count1) = New PictureBox picture1(count1).Equals(pbPicture) picture1(count1).ImageLocation = "C:\Users\Venom\Documents\Visual Studio 2010\Projects\RandomPictureGame\RandomPictureGame\Resources\Blob.jpg" picture1(count1).Location = New Point(X3, Y3) picture1(count1).Image = pbPicture.Image count1 += 1 'For pos = 1 To 100 ' Y = RandomClass.Next(300) ' pbPicture.Location = New Point(100, y) 'Next pos LoadImages() NextLevelCheck(tslScore.Text) TimeKeeper = Now End Sub Public Sub LoadImages() For i As Integer = 0 To picture1.Length - 1 If picture1(i) IsNot Nothing Then Using g As Graphics = Graphics.FromImage(picture1(i).Image) g.DrawImage(picture1(i).Image, New Point(picture1(i).Location.X, picture1(i).Location.Y)) Me.Refresh() End Using Dim pic As PictureBox = New PictureBox pic = GetImage(i) pic.Load("C:\Users\Venom\Documents\Visual Studio 2010\Projects\RandomPictureGame\RandomPictureGame\Resources\Blob.jpg") pnlPicture.Refresh() Me.Refresh() End If Next End Sub
I know the code looks primitive, but I am not sure how to get the pictures in the picturebox array to appear on the form.
attached is a screenshot of the programming running, however, that is the third time it changed locations, and there should be two other blobs that haven't gone away, yet they don't appear. What am I doing wrong?
Any help is appreciative.
Whoops, forgot to attach the file. Here it is.