Eight thumbs up, said the octopus with human hands (somnambulist) wrote in visualbasic,
Eight thumbs up, said the octopus with human hands
somnambulist
visualbasic

newbie

HELP ME! I am stuck with this and my brain has turned to mush!

I want the start, pause and exit buttons to do as they are meant to. I also need the left and right buttons to be activated by keystrokes (eg pressing z = left, pressing x = right) I also want to be able to have a points system, where if the "ball" hits the top of the playing area then 1 is added to the score. i.e. a points system.



Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Timer1 As System.Windows.Forms.Timer
Friend WithEvents BTNLEFT As System.Windows.Forms.Button
Friend WithEvents BTNRIGHT As System.Windows.Forms.Button
Friend WithEvents LBLBAT As System.Windows.Forms.PictureBox
Friend WithEvents bouncemonkey As System.Windows.Forms.PictureBox
Friend WithEvents PauseBTN As System.Windows.Forms.Button
Friend WithEvents quitBTN As System.Windows.Forms.Button
Friend WithEvents StartBTN As System.Windows.Forms.Button
[Error: Irreparable invalid markup ('<system.diagnostics.debuggerstepthrough()>') in entry. Owner must fix manually. Raw contents below.]

HELP ME! I am stuck with this and my brain has turned to mush!

I want the start, pause and exit buttons to do as they are meant to. I also need the left and right buttons to be activated by keystrokes (eg pressing z = left, pressing x = right) I also want to be able to have a points system, where if the "ball" hits the top of the playing area then 1 is added to the score. i.e. a points system.

<lj-cut>

<code>Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Timer1 As System.Windows.Forms.Timer
Friend WithEvents BTNLEFT As System.Windows.Forms.Button
Friend WithEvents BTNRIGHT As System.Windows.Forms.Button
Friend WithEvents LBLBAT As System.Windows.Forms.PictureBox
Friend WithEvents bouncemonkey As System.Windows.Forms.PictureBox
Friend WithEvents PauseBTN As System.Windows.Forms.Button
Friend WithEvents quitBTN As System.Windows.Forms.Button
Friend WithEvents StartBTN As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.bouncemonkey = New System.Windows.Forms.PictureBox()
Me.PauseBTN = New System.Windows.Forms.Button()
Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
Me.BTNLEFT = New System.Windows.Forms.Button()
Me.BTNRIGHT = New System.Windows.Forms.Button()
Me.LBLBAT = New System.Windows.Forms.PictureBox()
Me.quitBTN = New System.Windows.Forms.Button()
Me.StartBTN = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'bouncemonkey
'
Me.bouncemonkey.Image = CType(resources.GetObject("bouncemonkey.Image"), System.Drawing.Bitmap)
Me.bouncemonkey.Location = New System.Drawing.Point(360, 64)
Me.bouncemonkey.Name = "bouncemonkey"
Me.bouncemonkey.Size = New System.Drawing.Size(32, 32)
Me.bouncemonkey.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.bouncemonkey.TabIndex = 0
Me.bouncemonkey.TabStop = False
'
'PauseBTN
'
Me.PauseBTN.BackColor = System.Drawing.Color.Transparent
Me.PauseBTN.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.PauseBTN.ForeColor = System.Drawing.Color.Gold
Me.PauseBTN.Location = New System.Drawing.Point(0, 24)
Me.PauseBTN.Name = "PauseBTN"
Me.PauseBTN.Size = New System.Drawing.Size(96, 23)
Me.PauseBTN.TabIndex = 1
Me.PauseBTN.Text = "pause"
'
'Timer1
'
Me.Timer1.Enabled = True
'
'BTNLEFT
'
Me.BTNLEFT.BackColor = System.Drawing.SystemColors.InfoText
Me.BTNLEFT.Font = New System.Drawing.Font("Rockwell Extra Bold", 12.0!, System.Drawing.FontStyle.Bold)
Me.BTNLEFT.ForeColor = System.Drawing.SystemColors.HotTrack
Me.BTNLEFT.Location = New System.Drawing.Point(328, 472)
Me.BTNLEFT.Name = "BTNLEFT"
Me.BTNLEFT.TabIndex = 2
Me.BTNLEFT.Text = "<<<<"
'
'BTNRIGHT
'
Me.BTNRIGHT.BackColor = System.Drawing.SystemColors.InfoText
Me.BTNRIGHT.Font = New System.Drawing.Font("Rockwell Extra Bold", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.BTNRIGHT.ForeColor = System.Drawing.SystemColors.HotTrack
Me.BTNRIGHT.Location = New System.Drawing.Point(400, 472)
Me.BTNRIGHT.Name = "BTNRIGHT"
Me.BTNRIGHT.TabIndex = 3
Me.BTNRIGHT.Text = ">>>>"
'
'LBLBAT
'
Me.LBLBAT.BackColor = System.Drawing.SystemColors.Desktop
Me.LBLBAT.Location = New System.Drawing.Point(352, 432)
Me.LBLBAT.Name = "LBLBAT"
Me.LBLBAT.Size = New System.Drawing.Size(96, 8)
Me.LBLBAT.TabIndex = 4
Me.LBLBAT.TabStop = False
'
'quitBTN
'
Me.quitBTN.BackColor = System.Drawing.Color.Transparent
Me.quitBTN.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.quitBTN.ForeColor = System.Drawing.Color.Gold
Me.quitBTN.Location = New System.Drawing.Point(0, 48)
Me.quitBTN.Name = "quitBTN"
Me.quitBTN.Size = New System.Drawing.Size(96, 23)
Me.quitBTN.TabIndex = 5
Me.quitBTN.Text = "Exit"
'
'StartBTN
'
Me.StartBTN.BackColor = System.Drawing.Color.Transparent
Me.StartBTN.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.StartBTN.ForeColor = System.Drawing.Color.Gold
Me.StartBTN.Name = "StartBTN"
Me.StartBTN.Size = New System.Drawing.Size(96, 23)
Me.StartBTN.TabIndex = 6
Me.StartBTN.Text = "Start"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.SystemColors.InactiveCaption
Me.ClientSize = New System.Drawing.Size(752, 517)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.StartBTN, Me.quitBTN, Me.LBLBAT, Me.BTNRIGHT, Me.BTNLEFT, Me.bouncemonkey, Me.PauseBTN})
Me.ForeColor = System.Drawing.SystemColors.ActiveBorder
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
Me.Name = "Form1"
Me.Text = "GAME"
Me.ResumeLayout(False)

End Sub

#End Region

Dim forward As Boolean = True
Dim downward As Boolean = True



Private Sub start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PauseBTN.Click
Timer1.Enabled = Not Timer1.Enabled
End Sub 'Button1_click

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim x As Integer
Dim y As Integer


x = bouncemonkey.Location.X()
y = bouncemonkey.Location.Y()

'changes direction of bouncmonkey if contacts right/left edge
If (x <= 0) Or (x >= (Me.Width - 2 * bouncemonkey.Width)) Then
forward = Not forward
End If

'changes direction of bouncmonkey if contacts top edge
If (y <= 0) Then
downward = Not downward
'Label.Text = Label.Text + 1
End If

'changes direction of bouncmonkey if contacts bottom edge
If (y >= (Me.Height - 2.5 * bouncemonkey.Height)) Then
bouncemonkey.Visible = False
Timer1.Enabled = False

End If

If bouncemonkey.Top >= (Height - bouncemonkey.Height) Then
Timer1.Enabled = False

End If


If forward Then
bouncemonkey.Location = New System.Drawing.Point(x + 30, y)
Else
bouncemonkey.Location = New System.Drawing.Point(x - 30, y)
End If

x = bouncemonkey.Location.X()
y = bouncemonkey.Location.Y()
If downward Then
bouncemonkey.Location = New System.Drawing.Point(x, y + 30)
Else
bouncemonkey.Location = New System.Drawing.Point(x, y - 30)
End If
x = bouncemonkey.Location.X()
y = bouncemonkey.Location.Y()
'changes direction if ball meets bat
If bouncemonkey.Location.Y >= LBLBAT.Top - bouncemonkey.Height _
And bouncemonkey.Location.X > LBLBAT.Left _
And bouncemonkey.Location.X < (LBLBAT.Left + LBLBAT.Width) Then
downward = Not downward
End If

End Sub

Private Sub BTNLEFT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNLEFT.Click
If LBLBAT.Left > 0 Then
LBLBAT.Left = LBLBAT.Left - 50
End If
End Sub


Private Sub BTNRIGHT_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNRIGHT.Click
If LBLBAT.Left < (Me.Width - LBLBAT.Width) Then
LBLBAT.Left = LBLBAT.Left + 50
End If
End Sub



End Class 'Form1

</code>
  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

  • 2 comments