Every 10 seconds, increase the speed of 2 of the blocks by some amount. (Hint: instead of changing the timer speed, change the amount that the blocks move each tick of the timer.) Increase the size of the other 2 blocks by some amount. (Hint: to keep the aspect ration, length:width, multiply both sides by the same amount).
Create a 5th rectangle of a different color. This rectangle should move with your mouse. Do not allow the user to move the rectangle off the window. For example, if the user drags the mouse to the right edge of the window, stop the rectangle so its right edge touches the right edge of the window.
Detect collisions between the user's rectangle and the 4 "enemy" rectangles. If there is a collision, the game is over. Stop the movement of the "enemies" and display a button to play again or quit.
If the play again button is pressed:
• Remove the button
• Reset the "enemy" speed to the initial speed
• Reset the "enemy" sizes to the initial size
• Start the movement again
• Create an initial splash screen for your game. Give the game any name you want.
How do I code for the collision to make the player stop and how do I code for the other 3 enemies?
Thank you for any help you can give me.
Public Class Form1
Private Enemy1dx As Integer = 1
Private Enemy1dy As Integer = 1
Private Counter As Integer = 0
Private Sub TimerMovement_Tick(sender As System.Object, e As System.EventArgs) Handles TimerMovement.Tick
Enemy1.Left += Enemy1dx
Enemy1.Top += Enemy1dy
If Enemy1.Bounds.IntersectsWith(WallBottom.Bounds) Then
End If
If Enemy1dy > 0 Then
Enemy1dy *= -1
End If
Counter += 1
If Counter > 100 Then
Me.Text = Enemy1.Left.ToString
Counter = 0
End If
End Sub
Private Sub Form1_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
Player.Location = e.Location
checkCollision()
End Sub
Private Sub Player_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Player.MouseMove
'Player.Location = e.Location
Player.Left = Player.Left + e.X - Convert.ToInt32(Player.Width / 2)
Player.Top = Player.Top + e.Y - Convert.ToInt32(Player.Height / 2)
checkCollision()
End Sub
Private Sub checkCollision()
If Player.Bounds.IntersectsWith(Enemy1.Bounds) Then
End If
Me.Text = "Ouch"
End Sub
End Class
This post has been edited by modi123_1: 19 October 2011 - 04:59 PM
Reason for edit:: fixed botched code tag

New Topic/Question
Reply



MultiQuote




|