NSA
sudo apt-get thefuckout.tar.gz
- Dec 9, 2011
- 715
- 86
Hello all,
We've been creating a game.
When the spacebar is pressed, a present is shot up to kill the falling gremlins.
At the minute, we only have one present which is annoying because when you press the space bar twice, the present returns to the bottom of the screen, instead of a new one being fired.
I asked my tutor how to do this and he said we'd look into something like this "later on".
And by later on he meant sometime 2014.
Is there anyway I can get the program to create new clones of the single picturebox and do the exact same things?
Here is my current code:
We've been creating a game.
When the spacebar is pressed, a present is shot up to kill the falling gremlins.
At the minute, we only have one present which is annoying because when you press the space bar twice, the present returns to the bottom of the screen, instead of a new one being fired.
I asked my tutor how to do this and he said we'd look into something like this "later on".
And by later on he meant sometime 2014.
Is there anyway I can get the program to create new clones of the single picturebox and do the exact same things?
Here is my current code:
Code:
Public Class Form1
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If picSanta.Left + picSanta.Width < Me.Width Then
If e.KeyCode = Keys.Right Then
picSanta.Left = picSanta.Left + 10
End If
End If
If picSanta.Left > Me.Left Then
If e.KeyCode = Keys.Left Then
picSanta.Left = picSanta.Left + -10
End If
End If
If e.KeyCode = Keys.Space Then
picPressie.Visible = True
tmrPressie.Enabled = True
Dim picNewNew As New PictureBox
picNewNew = picPressie
Controls.Add(picNewNew)
picPressie.Top = picSanta.Top
picPressie.Left = picSanta.Left
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
picGoblin.Top = picGoblin.Top - 100
picGoblin1.Top = picGoblin1.Top - 124
picGoblin2.Top = picGoblin2.Top - 156
picGoblin3.Top = picGoblin3.Top - 20
End Sub
Private Sub tmrGoblin_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrGoblin.Tick
picGoblin.Top = picGoblin.Top + 5
If picGoblin.Top > Me.Height Then
picGoblin.Top = Me.Top
picGoblin.Left = Int(Rnd() * Me.Width)
picGoblin.Image = My.Resources.desktopgoblin1
End If
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picGoblin.Click
End Sub
Private Sub tmrGoblin1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrGoblin1.Tick
picGoblin1.Top = picGoblin1.Top + 5
If picGoblin1.Top > Me.Height Then
picGoblin1.Top = Me.Top
picGoblin1.Left = Int(Rnd() * Me.Width)
picGoblin1.Image = My.Resources.desktopgoblin1
End If
End Sub
Private Sub tmrGoblin2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrGoblin2.Tick
picGoblin2.Top = picGoblin2.Top + 5
If picGoblin2.Top > Me.Height Then
picGoblin2.Top = Me.Top
picGoblin2.Left = Int(Rnd() * Me.Width)
picGoblin2.Image = My.Resources.desktopgoblin1
End If
End Sub
Private Sub tmrGoblin3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrGoblin3.Tick
picGoblin3.Top = picGoblin3.Top + 5
If picGoblin3.Top > Me.Height Then
picGoblin3.Top = Me.Top
picGoblin3.Left = Int(Rnd() * Me.Width)
picGoblin3.Image = My.Resources.desktopgoblin1
End If
If picSanta.Bounds.IntersectsWith(picGoblin3.Bounds) Then
End If
End Sub
Private Sub tmrPressie_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrPressie.Tick
picPressie.Top = picPressie.Top - 5
If picPressie.Bounds.IntersectsWith(picGoblin.Bounds) Then
picGoblin.Image = My.Resources.splat
End If
If picPressie.Bounds.IntersectsWith(picGoblin1.Bounds) Then
picGoblin1.Image = My.Resources.splat
End If
If picPressie.Bounds.IntersectsWith(picGoblin2.Bounds) Then
picGoblin2.Image = My.Resources.splat
End If
If picPressie.Bounds.IntersectsWith(picGoblin3.Bounds) Then
picGoblin3.Image = My.Resources.splat
End If
End Sub
End Class