TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
craig j
NA
1
0
help with my pinball game.
Dec 11 2009 5:06 PM
hi im trying to get my speed of my Ball to be the HScrollBar1.Value but i cant seem to do it.
this is my code at the moment
i have Highlighted the code that im trying to work with.
Public Class Form1
Dim xplus As Integer = 3
Dim yplus As Integer = 3
Dim points As Integer = 0
Dim lives As Integer = 5
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vbkey As Long) As Integer
Dim filename As String = "HighestScore.Txt"
Dim ydown
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim xz As Integer
Dim zx As Integer
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ydown = OvalShape4.Bottom
' If PictureBox10.Location.X < 919 Then
'PictureBox10.Left = PictureBox10.Location.X + 11
' End If
' If PictureBox10.Left <= PictureBox11.Right Then
' x = -x
' End If
' If PictureBox10.Bounds.IntersectsWith(PictureBox11.Bounds) Then
' xplus = -yplus
'End If
'If OvalShape4.Bounds.Intersectwith Then
'End If
If OvalShape4.Bounds.IntersectsWith(OvalShape1.Bounds) Then
lives -= 1
Label2.Text = lives
End If
If OvalShape4.Bounds.IntersectsWith(OvalShape2.Bounds) Then
lives -= 1
Label2.Text = lives
End If
If OvalShape4.Bounds.IntersectsWith(OvalShape3.Bounds) Then
lives -= 1
Label2.Text = lives
End If
If OvalShape4.Bounds.IntersectsWith(PictureBox9.Bounds) Then
yplus = -yplus * 1
xplus = +xplus
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
End If
' If OvalShape4.Bounds.IntersectsWith(PictureBox11.Bounds) Then
' xplus = -xplus + 5
' yplus = +yplus
' End If
If OvalShape4.Bounds.IntersectsWith(PictureBox10.Bounds) Then
xplus = +xplus
yplus = -yplus
''''''''''''''''''''''''''''''''''''''''''''''''''''
yplus = -yplus - 1
'Console.Beep(3000, 20)
End If
If OvalShape4.Bounds.IntersectsWith(PictureBox15.Bounds) Then
xplus = +xplus + 5
yplus = -yplus
'''''''''''''''''''''''''''''''''''''''''''''''
End If
If OvalShape4.Bounds.IntersectsWith(PictureBox8.Bounds) Then
xplus = -xplus * 1
yplus = +yplus
''''''''''''''''''''''''''''''''''''''''''''
End If
If OvalShape4.Bounds.IntersectsWith(PictureBox7.Bounds) Then
xplus = -xplus * 1
yplus = +yplus
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End If
If OvalShape4.Bounds.IntersectsWith(PictureBox4.Bounds) Then
yplus = +yplus * -1
points += 50
End If
If OvalShape4.Bounds.IntersectsWith(PictureBox1.Bounds) Then
xplus = -xplus * +1
points += 50
End If
If OvalShape4.Bounds.IntersectsWith(PictureBox2.Bounds) Then
xplus = +xplus * -1
points += 50
End If
If OvalShape4.Bounds.IntersectsWith(PictureBox3.Bounds) Then
yplus = +yplus * -1
points += 50
End If
If OvalShape4.Bounds.IntersectsWith(PictureBox11.Bounds) Then
xplus = +xplus * -1
points += 50
End If
If OvalShape4.Bounds.IntersectsWith(PictureBox17.Bounds) Then
xplus = -xplus * +1
points += 50
End If
If OvalShape4.Bounds.IntersectsWith(PictureBox21.Bounds) Then
yplus = +yplus * -1
points += 50
End If
If OvalShape4.Bounds.IntersectsWith(PictureBox20.Bounds) Then
xplus = +xplus * -1
points += 50
End If
If OvalShape4.Bounds.IntersectsWith(PictureBox19.Bounds) Then
xplus = -xplus * +1
points += 50
End If
If OvalShape4.Bounds.IntersectsWith(PictureBox18.Bounds) Then
yplus = +yplus * -1
points += 50
End If
If OvalShape4.Bounds.IntersectsWith(PictureBox6.Bounds) Then
xplus = +xplus * -1
points += 50
End If
If OvalShape4.Bounds.IntersectsWith(PictureBox5.Bounds) Then
xplus = -xplus * +1
points += 50
End If
If OvalShape4.Right >= Me.Right Then
xplus = +xplus
yplus = -yplus
End If
'check ball position relative to left boundary
If OvalShape4.Left < Me.Left Then
xplus = +xplus
yplus = -yplus
End If
'check ball position relative to bottom boundary
If yplus > 0 Then
If OvalShape4.Bottom >= Me.Bottom Then
xplus = +xplus
yplus = -yplus
End If
End If
'check ball position relative to top boundary
If yplus < 0 Then
If OvalShape4.Top <= Me.Top Then
xplus = +xplus
yplus = -yplus
End If
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Timer1.Enabled = False
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Timer1.Enabled = True
End Sub
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.Left Then
PictureBox10.Left -= 40
End If
If e.KeyCode = Keys.Right Then
PictureBox10.Left += 40
End If
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
If e.X >= 0 Then
PictureBox10.Left = e.X - 10
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
points = 0
lives = 10
NumericUpDown1.Text = 0
Label2.Text = 10
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' My.Computer.Audio.Play(My.Resources.Dumped, AudioPlayMode.BackgroundLoop)
'FileOpen(1, "test.txt", OpenMode.Output)
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
' AxWindowsMediaPlayer1.playState =
Button1.PerformClick()
PictureBox23.SendToBack()
PictureBox24.SendToBack()
PictureBox25.SendToBack()
LineShape8.BringToFront()
LineShape8.BringToFront()
LineShape8.BringToFront()
LineShape9.BringToFront()
LineShape4.BringToFront()
lives = 5
PictureBox9.SendToBack()
OvalShape1.BringToFront()
OvalShape2.BringToFront()
OvalShape3.BringToFront()
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
Timer2.Enabled = True
Timer3.Enabled = True
Timer1.Enabled = True
End Sub
Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click
Timer1.Enabled = False
Timer2.Enabled = False
Timer3.Enabled = False
End Sub
Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
'move the ball
NumericUpDown1.Text = points
OvalShape4.Left = OvalShape4.Left + xplus
OvalShape4.Top = OvalShape4.Top + yplus
' OvalShape4.Location = New Point(OvalShape4.Location.X + xVel, OvalShape4.Location.Y + yVel)
'check ball position relative to right boundary
'check for pic 2/ object
If lives = 0 Then Timer1.Enabled = False
If lives = 0 Then Form2.Show()
Form2.BringToFront()
'
' If xplus >= 4 Then
' xplus = 3
' '
' '
' If yplus >= 4 Then
' yplus = 3
'
'
' If xplus <= 3 Then
' xplus = 3
'
'
' If yplus <= 3 Then
' yplus = 3
' End If
' End If
' End If
' End If
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If Form2.Visible = True Then
Timer1.Enabled = False
Timer3.Enabled = False
End If
If xplus >= 20 Then
xplus = 5
End If
If yplus >= 20 Then
yplus = 5
End If
End Sub
Private Sub Button1_Click_2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
xplus = 3
yplus = 3
OvalShape4.Location = PictureBox22.Location
'OvalShape4.Location = New Point(OvalShape4.Location.X, _
' OvalShape4.Location.Y + 1)
' OvalShape4.Location = New Point(OvalShape4.Location.Y = 23)
' OvalShape4.Location = New Point(OvalShape4.Location.X = 22)
lives = 10
NumericUpDown1.Text = 0
Label2.Text = 5
points = 0
End Sub
Private Sub tmrLine_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrLine.Tick
OvalShape1.Refresh()
OvalShape2.Refresh()
OvalShape3.Refresh()
PictureBox23.Refresh()
PictureBox24.Refresh()
PictureBox25.Refresh()
End Sub
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form2.Show()
End Sub
Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
PictureBox26.Left = PictureBox26.Left + xplus
PictureBox26.Top = PictureBox26.Top + yplus
Label6.Text = HScrollBar1.Value
yplus & xplus = HScrollBar1.Value
End Sub
End Class
Reply
Answers (
0
)
Immutability drawbacks
How Do I save a wpf rich text box with text in it?