john-formby
asked on
VB.NET Image Control Array
Hi,
I have been sitting in front of my PC for about 12 hours trying to figure out this problem so I think it is time for some help.
I am trying to design a simple game that moves a series of images across the screen using a control array. The direction of the moving images is dependant on whether the user clicks the right or left command button.
The program starts with a static image on the left hand side of the screen and when the user clicks the 'Right' button it should start moving in that direction, cycling through 6 images until it reaches the other side of the screen.
I have got it so it displays the starting image on the left side of the screen, but when I click the 'Right' button it comes up with an error:
Object variable With block variable not set
I haven't got a clue what this means and once it has given me the error message it starts to move the static image across the screen, but it does not cycle through them.
I am very confused and frustrated with this whole thing and don't think I have explained it very well but please help.
Thanks in advance,
John
I have been sitting in front of my PC for about 12 hours trying to figure out this problem so I think it is time for some help.
I am trying to design a simple game that moves a series of images across the screen using a control array. The direction of the moving images is dependant on whether the user clicks the right or left command button.
The program starts with a static image on the left hand side of the screen and when the user clicks the 'Right' button it should start moving in that direction, cycling through 6 images until it reaches the other side of the screen.
I have got it so it displays the starting image on the left side of the screen, but when I click the 'Right' button it comes up with an error:
Object variable With block variable not set
I haven't got a clue what this means and once it has given me the error message it starts to move the static image across the screen, but it does not cycle through them.
I am very confused and frustrated with this whole thing and don't think I have explained it very well but please help.
Thanks in advance,
John
The error means that you are trying to reference some variable with setting it... i.e. dim var as vartype = new vartype
ASKER
Thanks for the reply but I am still confused. I have only been using VB for about three weeks so I don't know a lot :-)
Here is the code for what I have done so far. If you could have a look at it I would be very grateful.
Option Strict Off
Option Explicit On
Public Class Form1
Inherits System.Windows.Forms.Form
Public imgLeft()
Public imgRight()
#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.ICon tainer
'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 cmdStop As System.Windows.Forms.Butto n
Friend WithEvents cmdRight As System.Windows.Forms.Butto n
Friend WithEvents cmdJump As System.Windows.Forms.Butto n
Friend WithEvents cmdReset As System.Windows.Forms.Butto n
Friend WithEvents cmdExit As System.Windows.Forms.Butto n
Friend WithEvents cmdLeft As System.Windows.Forms.Butto n
Friend WithEvents hsbSpeed As System.Windows.Forms.HScro llBar
Friend WithEvents lblSpeed As System.Windows.Forms.Label
Friend WithEvents lblFast As System.Windows.Forms.Label
Friend WithEvents lblSlow As System.Windows.Forms.Label
Friend WithEvents Timer1 As System.Windows.Forms.Timer
Friend WithEvents imgPath As System.Windows.Forms.Pictu reBox
Friend WithEvents imgWall As System.Windows.Forms.Pictu reBox
Friend WithEvents imgStandLeft As System.Windows.Forms.Pictu reBox
Friend WithEvents imgFlatLeft As System.Windows.Forms.Pictu reBox
Friend WithEvents imgFlatRight As System.Windows.Forms.Pictu reBox
Friend WithEvents imgStandRight As System.Windows.Forms.Pictu reBox
Friend WithEvents imgPerson As System.Windows.Forms.Pictu reBox
Friend WithEvents imgOuch As System.Windows.Forms.Pictu reBox
Friend WithEvents _imgRight_0 As System.Windows.Forms.Pictu reBox
Friend WithEvents _imgRight_1 As System.Windows.Forms.Pictu reBox
Friend WithEvents _imgRight_3 As System.Windows.Forms.Pictu reBox
Friend WithEvents _imgLeft_0 As System.Windows.Forms.Pictu reBox
Friend WithEvents _imgLeft_3 As System.Windows.Forms.Pictu reBox
Friend WithEvents _imgLeft_1 As System.Windows.Forms.Pictu reBox
Friend WithEvents _imgLeft_2 As System.Windows.Forms.Pictu reBox
Friend WithEvents _imgRight_5 As System.Windows.Forms.Pictu reBox
Friend WithEvents _imgRight_4 As System.Windows.Forms.Pictu reBox
Friend WithEvents _imgRight_2 As System.Windows.Forms.Pictu reBox
Friend WithEvents _imgLeft_5 As System.Windows.Forms.Pictu reBox
Friend WithEvents _imgLeft_4 As System.Windows.Forms.Pictu reBox
<System.Diagnostics.Debugg erStepThro ugh()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Cont ainer
Dim resources As System.Resources.ResourceM anager = New System.Resources.ResourceM anager(Get Type(Form1 ))
Me.cmdStop = New System.Windows.Forms.Butto n
Me.cmdRight = New System.Windows.Forms.Butto n
Me.cmdJump = New System.Windows.Forms.Butto n
Me.cmdReset = New System.Windows.Forms.Butto n
Me.cmdExit = New System.Windows.Forms.Butto n
Me.cmdLeft = New System.Windows.Forms.Butto n
Me.hsbSpeed = New System.Windows.Forms.HScro llBar
Me.imgPath = New System.Windows.Forms.Pictu reBox
Me.imgWall = New System.Windows.Forms.Pictu reBox
Me.lblSpeed = New System.Windows.Forms.Label
Me.lblFast = New System.Windows.Forms.Label
Me.lblSlow = New System.Windows.Forms.Label
Me._imgRight_0 = New System.Windows.Forms.Pictu reBox
Me._imgRight_1 = New System.Windows.Forms.Pictu reBox
Me._imgRight_3 = New System.Windows.Forms.Pictu reBox
Me._imgLeft_0 = New System.Windows.Forms.Pictu reBox
Me.imgStandLeft = New System.Windows.Forms.Pictu reBox
Me._imgLeft_3 = New System.Windows.Forms.Pictu reBox
Me._imgLeft_5 = New System.Windows.Forms.Pictu reBox
Me.imgFlatLeft = New System.Windows.Forms.Pictu reBox
Me._imgLeft_1 = New System.Windows.Forms.Pictu reBox
Me._imgLeft_4 = New System.Windows.Forms.Pictu reBox
Me._imgLeft_2 = New System.Windows.Forms.Pictu reBox
Me.imgFlatRight = New System.Windows.Forms.Pictu reBox
Me._imgRight_5 = New System.Windows.Forms.Pictu reBox
Me.imgStandRight = New System.Windows.Forms.Pictu reBox
Me._imgRight_4 = New System.Windows.Forms.Pictu reBox
Me._imgRight_2 = New System.Windows.Forms.Pictu reBox
Me.Timer1 = New System.Windows.Forms.Timer (Me.compon ents)
Me.imgPerson = New System.Windows.Forms.Pictu reBox
Me.imgOuch = New System.Windows.Forms.Pictu reBox
Me.SuspendLayout()
'
'cmdStop
'
Me.cmdStop.BackColor = System.Drawing.Color.Cornf lowerBlue
Me.cmdStop.Cursor = System.Windows.Forms.Curso rs.Hand
Me.cmdStop.Font = New System.Drawing.Font("Arial ", 12.0!, System.Drawing.FontStyle.B old, System.Drawing.GraphicsUni t.Point, CType(0, Byte))
Me.cmdStop.Location = New System.Drawing.Point(96, 400)
Me.cmdStop.Name = "cmdStop"
Me.cmdStop.Size = New System.Drawing.Size(64, 32)
Me.cmdStop.TabIndex = 1
Me.cmdStop.Text = "Stop"
'
'cmdRight
'
Me.cmdRight.BackColor = System.Drawing.Color.Cornf lowerBlue
Me.cmdRight.Cursor = System.Windows.Forms.Curso rs.Hand
Me.cmdRight.Font = New System.Drawing.Font("Arial ", 12.0!, System.Drawing.FontStyle.B old, System.Drawing.GraphicsUni t.Point, CType(0, Byte))
Me.cmdRight.Location = New System.Drawing.Point(160, 400)
Me.cmdRight.Name = "cmdRight"
Me.cmdRight.Size = New System.Drawing.Size(64, 32)
Me.cmdRight.TabIndex = 2
Me.cmdRight.Text = "Right"
'
'cmdJump
'
Me.cmdJump.BackColor = System.Drawing.Color.Cornf lowerBlue
Me.cmdJump.Cursor = System.Windows.Forms.Curso rs.Hand
Me.cmdJump.Font = New System.Drawing.Font("Arial ", 12.0!, System.Drawing.FontStyle.B old, System.Drawing.GraphicsUni t.Point, CType(0, Byte))
Me.cmdJump.Location = New System.Drawing.Point(96, 368)
Me.cmdJump.Name = "cmdJump"
Me.cmdJump.Size = New System.Drawing.Size(64, 32)
Me.cmdJump.TabIndex = 3
Me.cmdJump.Text = "Jump"
'
'cmdReset
'
Me.cmdReset.BackColor = System.Drawing.Color.Cornf lowerBlue
Me.cmdReset.Cursor = System.Windows.Forms.Curso rs.Hand
Me.cmdReset.Font = New System.Drawing.Font("Arial ", 12.0!, System.Drawing.FontStyle.B old, System.Drawing.GraphicsUni t.Point, CType(0, Byte))
Me.cmdReset.Location = New System.Drawing.Point(96, 432)
Me.cmdReset.Name = "cmdReset"
Me.cmdReset.Size = New System.Drawing.Size(64, 32)
Me.cmdReset.TabIndex = 4
Me.cmdReset.Text = "Reset"
'
'cmdExit
'
Me.cmdExit.BackColor = System.Drawing.Color.Cornf lowerBlue
Me.cmdExit.Cursor = System.Windows.Forms.Curso rs.Hand
Me.cmdExit.Font = New System.Drawing.Font("Arial ", 12.0!, System.Drawing.FontStyle.B old, System.Drawing.GraphicsUni t.Point, CType(0, Byte))
Me.cmdExit.Location = New System.Drawing.Point(720, 448)
Me.cmdExit.Name = "cmdExit"
Me.cmdExit.Size = New System.Drawing.Size(64, 32)
Me.cmdExit.TabIndex = 5
Me.cmdExit.Text = "Exit"
'
'cmdLeft
'
Me.cmdLeft.BackColor = System.Drawing.Color.Cornf lowerBlue
Me.cmdLeft.Cursor = System.Windows.Forms.Curso rs.Hand
Me.cmdLeft.Font = New System.Drawing.Font("Arial ", 12.0!, System.Drawing.FontStyle.B old, System.Drawing.GraphicsUni t.Point, CType(0, Byte))
Me.cmdLeft.Location = New System.Drawing.Point(32, 400)
Me.cmdLeft.Name = "cmdLeft"
Me.cmdLeft.Size = New System.Drawing.Size(64, 32)
Me.cmdLeft.TabIndex = 6
Me.cmdLeft.Text = "Left"
'
'hsbSpeed
'
Me.hsbSpeed.Cursor = System.Windows.Forms.Curso rs.Hand
Me.hsbSpeed.Location = New System.Drawing.Point(368, 416)
Me.hsbSpeed.Maximum = 500
Me.hsbSpeed.Minimum = 4
Me.hsbSpeed.Name = "hsbSpeed"
Me.hsbSpeed.Size = New System.Drawing.Size(192, 32)
Me.hsbSpeed.TabIndex = 7
Me.hsbSpeed.Value = 250
'
'imgPath
'
Me.imgPath.Image = CType(resources.GetObject( "imgPath.I mage"), System.Drawing.Image)
Me.imgPath.Location = New System.Drawing.Point(0, 288)
Me.imgPath.Name = "imgPath"
Me.imgPath.Size = New System.Drawing.Size(800, 40)
Me.imgPath.TabIndex = 8
Me.imgPath.TabStop = False
'
'imgWall
'
Me.imgWall.Image = CType(resources.GetObject( "imgWall.I mage"), System.Drawing.Image)
Me.imgWall.Location = New System.Drawing.Point(332, 200)
Me.imgWall.Name = "imgWall"
Me.imgWall.Size = New System.Drawing.Size(121, 92)
Me.imgWall.TabIndex = 9
Me.imgWall.TabStop = False
'
'lblSpeed
'
Me.lblSpeed.BackColor = System.Drawing.Color.Cornf lowerBlue
Me.lblSpeed.Font = New System.Drawing.Font("Arial ", 12.0!, System.Drawing.FontStyle.B old, System.Drawing.GraphicsUni t.Point, CType(0, Byte))
Me.lblSpeed.Location = New System.Drawing.Point(432, 376)
Me.lblSpeed.Name = "lblSpeed"
Me.lblSpeed.Size = New System.Drawing.Size(64, 32)
Me.lblSpeed.TabIndex = 10
Me.lblSpeed.Text = "Speed"
Me.lblSpeed.TextAlign = System.Drawing.ContentAlig nment.Midd leCenter
'
'lblFast
'
Me.lblFast.BackColor = System.Drawing.Color.Cornf lowerBlue
Me.lblFast.Font = New System.Drawing.Font("Arial ", 12.0!, System.Drawing.FontStyle.B old, System.Drawing.GraphicsUni t.Point, CType(0, Byte))
Me.lblFast.Location = New System.Drawing.Point(304, 416)
Me.lblFast.Name = "lblFast"
Me.lblFast.Size = New System.Drawing.Size(56, 32)
Me.lblFast.TabIndex = 11
Me.lblFast.Text = "Fast"
Me.lblFast.TextAlign = System.Drawing.ContentAlig nment.Midd leCenter
'
'lblSlow
'
Me.lblSlow.BackColor = System.Drawing.Color.Cornf lowerBlue
Me.lblSlow.Font = New System.Drawing.Font("Arial ", 12.0!, System.Drawing.FontStyle.B old, System.Drawing.GraphicsUni t.Point, CType(0, Byte))
Me.lblSlow.Location = New System.Drawing.Point(568, 416)
Me.lblSlow.Name = "lblSlow"
Me.lblSlow.Size = New System.Drawing.Size(56, 32)
Me.lblSlow.TabIndex = 12
Me.lblSlow.Text = "Slow"
Me.lblSlow.TextAlign = System.Drawing.ContentAlig nment.Midd leCenter
'
'_imgRight_0
'
Me._imgRight_0.BackColor = System.Drawing.Color.Trans parent
Me._imgRight_0.Image = CType(resources.GetObject( "_imgRight _0.Image") , System.Drawing.Image)
Me._imgRight_0.Location = New System.Drawing.Point(8, 80)
Me._imgRight_0.Name = "_imgRight_0"
Me._imgRight_0.Size = New System.Drawing.Size(46, 63)
Me._imgRight_0.TabIndex = 13
Me._imgRight_0.TabStop = False
Me._imgRight_0.Visible = False
'
'_imgRight_1
'
Me._imgRight_1.BackColor = System.Drawing.Color.Trans parent
Me._imgRight_1.Image = CType(resources.GetObject( "_imgRight _1.Image") , System.Drawing.Image)
Me._imgRight_1.Location = New System.Drawing.Point(48, 80)
Me._imgRight_1.Name = "_imgRight_1"
Me._imgRight_1.Size = New System.Drawing.Size(56, 63)
Me._imgRight_1.TabIndex = 14
Me._imgRight_1.TabStop = False
Me._imgRight_1.Visible = False
'
'_imgRight_3
'
Me._imgRight_3.BackColor = System.Drawing.Color.Trans parent
Me._imgRight_3.Image = CType(resources.GetObject( "_imgRight _3.Image") , System.Drawing.Image)
Me._imgRight_3.Location = New System.Drawing.Point(160, 80)
Me._imgRight_3.Name = "_imgRight_3"
Me._imgRight_3.Size = New System.Drawing.Size(44, 63)
Me._imgRight_3.TabIndex = 15
Me._imgRight_3.TabStop = False
Me._imgRight_3.Visible = False
'
'_imgLeft_0
'
Me._imgLeft_0.BackColor = System.Drawing.Color.Trans parent
Me._imgLeft_0.Image = CType(resources.GetObject( "_imgLeft_ 0.Image"), System.Drawing.Image)
Me._imgLeft_0.Location = New System.Drawing.Point(744, 80)
Me._imgLeft_0.Name = "_imgLeft_0"
Me._imgLeft_0.Size = New System.Drawing.Size(46, 63)
Me._imgLeft_0.TabIndex = 16
Me._imgLeft_0.TabStop = False
Me._imgLeft_0.Visible = False
'
'imgStandLeft
'
Me.imgStandLeft.BackColor = System.Drawing.Color.Trans parent
Me.imgStandLeft.Image = CType(resources.GetObject( "imgStandL eft.Image" ), System.Drawing.Image)
Me.imgStandLeft.Location = New System.Drawing.Point(734, 8)
Me.imgStandLeft.Name = "imgStandLeft"
Me.imgStandLeft.Size = New System.Drawing.Size(56, 64)
Me.imgStandLeft.TabIndex = 17
Me.imgStandLeft.TabStop = False
Me.imgStandLeft.Visible = False
'
'_imgLeft_3
'
Me._imgLeft_3.BackColor = System.Drawing.Color.Trans parent
Me._imgLeft_3.Image = CType(resources.GetObject( "_imgLeft_ 3.Image"), System.Drawing.Image)
Me._imgLeft_3.Location = New System.Drawing.Point(584, 80)
Me._imgLeft_3.Name = "_imgLeft_3"
Me._imgLeft_3.Size = New System.Drawing.Size(48, 63)
Me._imgLeft_3.TabIndex = 18
Me._imgLeft_3.TabStop = False
Me._imgLeft_3.Visible = False
'
'_imgLeft_5
'
Me._imgLeft_5.BackColor = System.Drawing.Color.Trans parent
Me._imgLeft_5.Image = CType(resources.GetObject( "_imgLeft_ 5.Image"), System.Drawing.Image)
Me._imgLeft_5.Location = New System.Drawing.Point(472, 80)
Me._imgLeft_5.Name = "_imgLeft_5"
Me._imgLeft_5.Size = New System.Drawing.Size(56, 63)
Me._imgLeft_5.TabIndex = 19
Me._imgLeft_5.TabStop = False
Me._imgLeft_5.Visible = False
'
'imgFlatLeft
'
Me.imgFlatLeft.BackColor = System.Drawing.Color.Trans parent
Me.imgFlatLeft.Image = CType(resources.GetObject( "imgFlatLe ft.Image") , System.Drawing.Image)
Me.imgFlatLeft.Location = New System.Drawing.Point(448, 224)
Me.imgFlatLeft.Name = "imgFlatLeft"
Me.imgFlatLeft.Size = New System.Drawing.Size(81, 65)
Me.imgFlatLeft.TabIndex = 20
Me.imgFlatLeft.TabStop = False
Me.imgFlatLeft.Visible = False
'
'_imgLeft_1
'
Me._imgLeft_1.BackColor = System.Drawing.Color.Trans parent
Me._imgLeft_1.Image = CType(resources.GetObject( "_imgLeft_ 1.Image"), System.Drawing.Image)
Me._imgLeft_1.Location = New System.Drawing.Point(684, 80)
Me._imgLeft_1.Name = "_imgLeft_1"
Me._imgLeft_1.Size = New System.Drawing.Size(59, 63)
Me._imgLeft_1.TabIndex = 21
Me._imgLeft_1.TabStop = False
Me._imgLeft_1.Visible = False
'
'_imgLeft_4
'
Me._imgLeft_4.BackColor = System.Drawing.Color.Trans parent
Me._imgLeft_4.Image = CType(resources.GetObject( "_imgLeft_ 4.Image"), System.Drawing.Image)
Me._imgLeft_4.Location = New System.Drawing.Point(528, 80)
Me._imgLeft_4.Name = "_imgLeft_4"
Me._imgLeft_4.Size = New System.Drawing.Size(63, 63)
Me._imgLeft_4.TabIndex = 22
Me._imgLeft_4.TabStop = False
Me._imgLeft_4.Visible = False
'
'_imgLeft_2
'
Me._imgLeft_2.BackColor = System.Drawing.Color.Trans parent
Me._imgLeft_2.Image = CType(resources.GetObject( "_imgLeft_ 2.Image"), System.Drawing.Image)
Me._imgLeft_2.Location = New System.Drawing.Point(632, 80)
Me._imgLeft_2.Name = "_imgLeft_2"
Me._imgLeft_2.Size = New System.Drawing.Size(55, 63)
Me._imgLeft_2.TabIndex = 23
Me._imgLeft_2.TabStop = False
Me._imgLeft_2.Visible = False
'
'imgFlatRight
'
Me.imgFlatRight.BackColor = System.Drawing.Color.Trans parent
Me.imgFlatRight.Image = CType(resources.GetObject( "imgFlatRi ght.Image" ), System.Drawing.Image)
Me.imgFlatRight.Location = New System.Drawing.Point(256, 224)
Me.imgFlatRight.Name = "imgFlatRight"
Me.imgFlatRight.Size = New System.Drawing.Size(81, 65)
Me.imgFlatRight.TabIndex = 24
Me.imgFlatRight.TabStop = False
Me.imgFlatRight.Visible = False
'
'_imgRight_5
'
Me._imgRight_5.BackColor = System.Drawing.Color.Trans parent
Me._imgRight_5.Image = CType(resources.GetObject( "_imgRight _5.Image") , System.Drawing.Image)
Me._imgRight_5.Location = New System.Drawing.Point(264, 80)
Me._imgRight_5.Name = "_imgRight_5"
Me._imgRight_5.Size = New System.Drawing.Size(56, 63)
Me._imgRight_5.TabIndex = 25
Me._imgRight_5.TabStop = False
Me._imgRight_5.Visible = False
'
'imgStandRight
'
Me.imgStandRight.BackColor = System.Drawing.Color.Trans parent
Me.imgStandRight.Image = CType(resources.GetObject( "imgStandR ight.Image "), System.Drawing.Image)
Me.imgStandRight.Location = New System.Drawing.Point(8, 8)
Me.imgStandRight.Name = "imgStandRight"
Me.imgStandRight.Size = New System.Drawing.Size(56, 64)
Me.imgStandRight.TabIndex = 26
Me.imgStandRight.TabStop = False
Me.imgStandRight.Visible = False
'
'_imgRight_4
'
Me._imgRight_4.BackColor = System.Drawing.Color.Trans parent
Me._imgRight_4.Image = CType(resources.GetObject( "_imgRight _4.Image") , System.Drawing.Image)
Me._imgRight_4.Location = New System.Drawing.Point(200, 80)
Me._imgRight_4.Name = "_imgRight_4"
Me._imgRight_4.Size = New System.Drawing.Size(63, 63)
Me._imgRight_4.TabIndex = 27
Me._imgRight_4.TabStop = False
Me._imgRight_4.Visible = False
'
'_imgRight_2
'
Me._imgRight_2.BackColor = System.Drawing.Color.Trans parent
Me._imgRight_2.Image = CType(resources.GetObject( "_imgRight _2.Image") , System.Drawing.Image)
Me._imgRight_2.Location = New System.Drawing.Point(104, 80)
Me._imgRight_2.Name = "_imgRight_2"
Me._imgRight_2.Size = New System.Drawing.Size(55, 63)
Me._imgRight_2.TabIndex = 28
Me._imgRight_2.TabStop = False
Me._imgRight_2.Visible = False
'
'Timer1
'
Me.Timer1.Enabled = True
Me.Timer1.Interval = 10
'
'imgPerson
'
Me.imgPerson.BackColor = System.Drawing.Color.Trans parent
Me.imgPerson.Location = New System.Drawing.Point(0, 232)
Me.imgPerson.Name = "imgPerson"
Me.imgPerson.Size = New System.Drawing.Size(81, 72)
Me.imgPerson.TabIndex = 29
Me.imgPerson.TabStop = False
'
'imgOuch
'
Me.imgOuch.BackColor = System.Drawing.Color.Trans parent
Me.imgOuch.Image = CType(resources.GetObject( "imgOuch.I mage"), System.Drawing.Image)
Me.imgOuch.Location = New System.Drawing.Point(336, 56)
Me.imgOuch.Name = "imgOuch"
Me.imgOuch.Size = New System.Drawing.Size(100, 100)
Me.imgOuch.TabIndex = 30
Me.imgOuch.TabStop = False
Me.imgOuch.Visible = False
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackgroundImage = CType(resources.GetObject( "$this.Bac kgroundIma ge"), System.Drawing.Image)
Me.ClientSize = New System.Drawing.Size(800, 494)
Me.ControlBox = False
Me.Controls.Add(Me.imgOuch )
Me.Controls.Add(Me.imgPers on)
Me.Controls.Add(Me._imgRig ht_2)
Me.Controls.Add(Me._imgRig ht_4)
Me.Controls.Add(Me.imgStan dRight)
Me.Controls.Add(Me._imgRig ht_5)
Me.Controls.Add(Me.imgFlat Right)
Me.Controls.Add(Me._imgLef t_2)
Me.Controls.Add(Me._imgLef t_4)
Me.Controls.Add(Me._imgLef t_1)
Me.Controls.Add(Me.imgFlat Left)
Me.Controls.Add(Me._imgLef t_5)
Me.Controls.Add(Me._imgLef t_3)
Me.Controls.Add(Me.imgStan dLeft)
Me.Controls.Add(Me._imgLef t_0)
Me.Controls.Add(Me._imgRig ht_3)
Me.Controls.Add(Me._imgRig ht_1)
Me.Controls.Add(Me._imgRig ht_0)
Me.Controls.Add(Me.lblSlow )
Me.Controls.Add(Me.lblFast )
Me.Controls.Add(Me.lblSpee d)
Me.Controls.Add(Me.imgWall )
Me.Controls.Add(Me.imgPath )
Me.Controls.Add(Me.hsbSpee d)
Me.Controls.Add(Me.cmdLeft )
Me.Controls.Add(Me.cmdExit )
Me.Controls.Add(Me.cmdRese t)
Me.Controls.Add(Me.cmdJump )
Me.Controls.Add(Me.cmdRigh t)
Me.Controls.Add(Me.cmdStop )
Me.FormBorderStyle = System.Windows.Forms.FormB orderStyle .FixedSing le
Me.Name = "Form1"
Me.Text = "Sonic Jump - Designed & Written by John Crick"
Me.ResumeLayout(False)
End Sub
#End Region
Public direction As String
Public steps As Integer
Public Jumping As Boolean
Public JumpCounts As Integer
Public JumpAmount As Integer
Dim quit As Object
Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
quit = MsgBox("Do you really want to exit?", vbQuestion + vbYesNo, "Sonic Jump") 'Message box and message
If quit = vbYes Then 'If quit equals yes Then
Me.Close() ' Close the form window
Else
If quit = vbNo Then 'If quit equals no Then
cmdStop.Focus() 'Set focus to Price Excluding VAT textbox
End If
End If
End Sub
Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Messa ge, ByVal keyData As System.Windows.Forms.Keys) As Boolean
If msg.WParam.ToInt32() = CInt(Keys.Escape) Then ' If escape key pressed Then
quit = MsgBox("Do you really want to exit?", vbQuestion + vbYesNo, "Sonic Jump") 'Message box and message
If quit = vbYes Then 'If quit equals yes Then
Me.Close() ' Close the form window
Else
If quit = vbNo Then 'If quit equals no Then
cmdStop.Focus() 'Set focus to Price Excluding VAT textbox
End If
End If
End If
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
steps = 0
direction = "none"
Timer1.Enabled = False
imgPerson.Image = imgStandRight.Image
End Sub
Private Sub cmdLeft_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLeft.Click
direction = "left"
Timer1.Enabled = True
End Sub
Private Sub cmdRight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRight.Click
direction = "right"
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If steps = 0 Then
steps = 1
ElseIf steps = 1 Then
steps = 2
ElseIf steps = 2 Then
steps = 3
ElseIf steps = 3 Then
steps = 4
ElseIf steps = 4 Then
steps = 5
ElseIf steps = 5 Then
steps = 0
End If
If direction = "left" Then
imgPerson.Left = imgPerson.Left - 1
imgPerson.Image = imgLeft(steps).Image
ElseIf direction = "right" Then
imgPerson.Left = imgPerson.Left + 1
imgPerson.Image = imgRight(steps).Image
End If
End Sub
End Class
Here is the code for what I have done so far. If you could have a look at it I would be very grateful.
Option Strict Off
Option Explicit On
Public Class Form1
Inherits System.Windows.Forms.Form
Public imgLeft()
Public imgRight()
#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.ICon
'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 cmdStop As System.Windows.Forms.Butto
Friend WithEvents cmdRight As System.Windows.Forms.Butto
Friend WithEvents cmdJump As System.Windows.Forms.Butto
Friend WithEvents cmdReset As System.Windows.Forms.Butto
Friend WithEvents cmdExit As System.Windows.Forms.Butto
Friend WithEvents cmdLeft As System.Windows.Forms.Butto
Friend WithEvents hsbSpeed As System.Windows.Forms.HScro
Friend WithEvents lblSpeed As System.Windows.Forms.Label
Friend WithEvents lblFast As System.Windows.Forms.Label
Friend WithEvents lblSlow As System.Windows.Forms.Label
Friend WithEvents Timer1 As System.Windows.Forms.Timer
Friend WithEvents imgPath As System.Windows.Forms.Pictu
Friend WithEvents imgWall As System.Windows.Forms.Pictu
Friend WithEvents imgStandLeft As System.Windows.Forms.Pictu
Friend WithEvents imgFlatLeft As System.Windows.Forms.Pictu
Friend WithEvents imgFlatRight As System.Windows.Forms.Pictu
Friend WithEvents imgStandRight As System.Windows.Forms.Pictu
Friend WithEvents imgPerson As System.Windows.Forms.Pictu
Friend WithEvents imgOuch As System.Windows.Forms.Pictu
Friend WithEvents _imgRight_0 As System.Windows.Forms.Pictu
Friend WithEvents _imgRight_1 As System.Windows.Forms.Pictu
Friend WithEvents _imgRight_3 As System.Windows.Forms.Pictu
Friend WithEvents _imgLeft_0 As System.Windows.Forms.Pictu
Friend WithEvents _imgLeft_3 As System.Windows.Forms.Pictu
Friend WithEvents _imgLeft_1 As System.Windows.Forms.Pictu
Friend WithEvents _imgLeft_2 As System.Windows.Forms.Pictu
Friend WithEvents _imgRight_5 As System.Windows.Forms.Pictu
Friend WithEvents _imgRight_4 As System.Windows.Forms.Pictu
Friend WithEvents _imgRight_2 As System.Windows.Forms.Pictu
Friend WithEvents _imgLeft_5 As System.Windows.Forms.Pictu
Friend WithEvents _imgLeft_4 As System.Windows.Forms.Pictu
<System.Diagnostics.Debugg
Me.components = New System.ComponentModel.Cont
Dim resources As System.Resources.ResourceM
Me.cmdStop = New System.Windows.Forms.Butto
Me.cmdRight = New System.Windows.Forms.Butto
Me.cmdJump = New System.Windows.Forms.Butto
Me.cmdReset = New System.Windows.Forms.Butto
Me.cmdExit = New System.Windows.Forms.Butto
Me.cmdLeft = New System.Windows.Forms.Butto
Me.hsbSpeed = New System.Windows.Forms.HScro
Me.imgPath = New System.Windows.Forms.Pictu
Me.imgWall = New System.Windows.Forms.Pictu
Me.lblSpeed = New System.Windows.Forms.Label
Me.lblFast = New System.Windows.Forms.Label
Me.lblSlow = New System.Windows.Forms.Label
Me._imgRight_0 = New System.Windows.Forms.Pictu
Me._imgRight_1 = New System.Windows.Forms.Pictu
Me._imgRight_3 = New System.Windows.Forms.Pictu
Me._imgLeft_0 = New System.Windows.Forms.Pictu
Me.imgStandLeft = New System.Windows.Forms.Pictu
Me._imgLeft_3 = New System.Windows.Forms.Pictu
Me._imgLeft_5 = New System.Windows.Forms.Pictu
Me.imgFlatLeft = New System.Windows.Forms.Pictu
Me._imgLeft_1 = New System.Windows.Forms.Pictu
Me._imgLeft_4 = New System.Windows.Forms.Pictu
Me._imgLeft_2 = New System.Windows.Forms.Pictu
Me.imgFlatRight = New System.Windows.Forms.Pictu
Me._imgRight_5 = New System.Windows.Forms.Pictu
Me.imgStandRight = New System.Windows.Forms.Pictu
Me._imgRight_4 = New System.Windows.Forms.Pictu
Me._imgRight_2 = New System.Windows.Forms.Pictu
Me.Timer1 = New System.Windows.Forms.Timer
Me.imgPerson = New System.Windows.Forms.Pictu
Me.imgOuch = New System.Windows.Forms.Pictu
Me.SuspendLayout()
'
'cmdStop
'
Me.cmdStop.BackColor = System.Drawing.Color.Cornf
Me.cmdStop.Cursor = System.Windows.Forms.Curso
Me.cmdStop.Font = New System.Drawing.Font("Arial
Me.cmdStop.Location = New System.Drawing.Point(96, 400)
Me.cmdStop.Name = "cmdStop"
Me.cmdStop.Size = New System.Drawing.Size(64, 32)
Me.cmdStop.TabIndex = 1
Me.cmdStop.Text = "Stop"
'
'cmdRight
'
Me.cmdRight.BackColor = System.Drawing.Color.Cornf
Me.cmdRight.Cursor = System.Windows.Forms.Curso
Me.cmdRight.Font = New System.Drawing.Font("Arial
Me.cmdRight.Location = New System.Drawing.Point(160, 400)
Me.cmdRight.Name = "cmdRight"
Me.cmdRight.Size = New System.Drawing.Size(64, 32)
Me.cmdRight.TabIndex = 2
Me.cmdRight.Text = "Right"
'
'cmdJump
'
Me.cmdJump.BackColor = System.Drawing.Color.Cornf
Me.cmdJump.Cursor = System.Windows.Forms.Curso
Me.cmdJump.Font = New System.Drawing.Font("Arial
Me.cmdJump.Location = New System.Drawing.Point(96, 368)
Me.cmdJump.Name = "cmdJump"
Me.cmdJump.Size = New System.Drawing.Size(64, 32)
Me.cmdJump.TabIndex = 3
Me.cmdJump.Text = "Jump"
'
'cmdReset
'
Me.cmdReset.BackColor = System.Drawing.Color.Cornf
Me.cmdReset.Cursor = System.Windows.Forms.Curso
Me.cmdReset.Font = New System.Drawing.Font("Arial
Me.cmdReset.Location = New System.Drawing.Point(96, 432)
Me.cmdReset.Name = "cmdReset"
Me.cmdReset.Size = New System.Drawing.Size(64, 32)
Me.cmdReset.TabIndex = 4
Me.cmdReset.Text = "Reset"
'
'cmdExit
'
Me.cmdExit.BackColor = System.Drawing.Color.Cornf
Me.cmdExit.Cursor = System.Windows.Forms.Curso
Me.cmdExit.Font = New System.Drawing.Font("Arial
Me.cmdExit.Location = New System.Drawing.Point(720, 448)
Me.cmdExit.Name = "cmdExit"
Me.cmdExit.Size = New System.Drawing.Size(64, 32)
Me.cmdExit.TabIndex = 5
Me.cmdExit.Text = "Exit"
'
'cmdLeft
'
Me.cmdLeft.BackColor = System.Drawing.Color.Cornf
Me.cmdLeft.Cursor = System.Windows.Forms.Curso
Me.cmdLeft.Font = New System.Drawing.Font("Arial
Me.cmdLeft.Location = New System.Drawing.Point(32, 400)
Me.cmdLeft.Name = "cmdLeft"
Me.cmdLeft.Size = New System.Drawing.Size(64, 32)
Me.cmdLeft.TabIndex = 6
Me.cmdLeft.Text = "Left"
'
'hsbSpeed
'
Me.hsbSpeed.Cursor = System.Windows.Forms.Curso
Me.hsbSpeed.Location = New System.Drawing.Point(368, 416)
Me.hsbSpeed.Maximum = 500
Me.hsbSpeed.Minimum = 4
Me.hsbSpeed.Name = "hsbSpeed"
Me.hsbSpeed.Size = New System.Drawing.Size(192, 32)
Me.hsbSpeed.TabIndex = 7
Me.hsbSpeed.Value = 250
'
'imgPath
'
Me.imgPath.Image = CType(resources.GetObject(
Me.imgPath.Location = New System.Drawing.Point(0, 288)
Me.imgPath.Name = "imgPath"
Me.imgPath.Size = New System.Drawing.Size(800, 40)
Me.imgPath.TabIndex = 8
Me.imgPath.TabStop = False
'
'imgWall
'
Me.imgWall.Image = CType(resources.GetObject(
Me.imgWall.Location = New System.Drawing.Point(332, 200)
Me.imgWall.Name = "imgWall"
Me.imgWall.Size = New System.Drawing.Size(121, 92)
Me.imgWall.TabIndex = 9
Me.imgWall.TabStop = False
'
'lblSpeed
'
Me.lblSpeed.BackColor = System.Drawing.Color.Cornf
Me.lblSpeed.Font = New System.Drawing.Font("Arial
Me.lblSpeed.Location = New System.Drawing.Point(432, 376)
Me.lblSpeed.Name = "lblSpeed"
Me.lblSpeed.Size = New System.Drawing.Size(64, 32)
Me.lblSpeed.TabIndex = 10
Me.lblSpeed.Text = "Speed"
Me.lblSpeed.TextAlign = System.Drawing.ContentAlig
'
'lblFast
'
Me.lblFast.BackColor = System.Drawing.Color.Cornf
Me.lblFast.Font = New System.Drawing.Font("Arial
Me.lblFast.Location = New System.Drawing.Point(304, 416)
Me.lblFast.Name = "lblFast"
Me.lblFast.Size = New System.Drawing.Size(56, 32)
Me.lblFast.TabIndex = 11
Me.lblFast.Text = "Fast"
Me.lblFast.TextAlign = System.Drawing.ContentAlig
'
'lblSlow
'
Me.lblSlow.BackColor = System.Drawing.Color.Cornf
Me.lblSlow.Font = New System.Drawing.Font("Arial
Me.lblSlow.Location = New System.Drawing.Point(568, 416)
Me.lblSlow.Name = "lblSlow"
Me.lblSlow.Size = New System.Drawing.Size(56, 32)
Me.lblSlow.TabIndex = 12
Me.lblSlow.Text = "Slow"
Me.lblSlow.TextAlign = System.Drawing.ContentAlig
'
'_imgRight_0
'
Me._imgRight_0.BackColor = System.Drawing.Color.Trans
Me._imgRight_0.Image = CType(resources.GetObject(
Me._imgRight_0.Location = New System.Drawing.Point(8, 80)
Me._imgRight_0.Name = "_imgRight_0"
Me._imgRight_0.Size = New System.Drawing.Size(46, 63)
Me._imgRight_0.TabIndex = 13
Me._imgRight_0.TabStop = False
Me._imgRight_0.Visible = False
'
'_imgRight_1
'
Me._imgRight_1.BackColor = System.Drawing.Color.Trans
Me._imgRight_1.Image = CType(resources.GetObject(
Me._imgRight_1.Location = New System.Drawing.Point(48, 80)
Me._imgRight_1.Name = "_imgRight_1"
Me._imgRight_1.Size = New System.Drawing.Size(56, 63)
Me._imgRight_1.TabIndex = 14
Me._imgRight_1.TabStop = False
Me._imgRight_1.Visible = False
'
'_imgRight_3
'
Me._imgRight_3.BackColor = System.Drawing.Color.Trans
Me._imgRight_3.Image = CType(resources.GetObject(
Me._imgRight_3.Location = New System.Drawing.Point(160, 80)
Me._imgRight_3.Name = "_imgRight_3"
Me._imgRight_3.Size = New System.Drawing.Size(44, 63)
Me._imgRight_3.TabIndex = 15
Me._imgRight_3.TabStop = False
Me._imgRight_3.Visible = False
'
'_imgLeft_0
'
Me._imgLeft_0.BackColor = System.Drawing.Color.Trans
Me._imgLeft_0.Image = CType(resources.GetObject(
Me._imgLeft_0.Location = New System.Drawing.Point(744, 80)
Me._imgLeft_0.Name = "_imgLeft_0"
Me._imgLeft_0.Size = New System.Drawing.Size(46, 63)
Me._imgLeft_0.TabIndex = 16
Me._imgLeft_0.TabStop = False
Me._imgLeft_0.Visible = False
'
'imgStandLeft
'
Me.imgStandLeft.BackColor = System.Drawing.Color.Trans
Me.imgStandLeft.Image = CType(resources.GetObject(
Me.imgStandLeft.Location = New System.Drawing.Point(734, 8)
Me.imgStandLeft.Name = "imgStandLeft"
Me.imgStandLeft.Size = New System.Drawing.Size(56, 64)
Me.imgStandLeft.TabIndex = 17
Me.imgStandLeft.TabStop = False
Me.imgStandLeft.Visible = False
'
'_imgLeft_3
'
Me._imgLeft_3.BackColor = System.Drawing.Color.Trans
Me._imgLeft_3.Image = CType(resources.GetObject(
Me._imgLeft_3.Location = New System.Drawing.Point(584, 80)
Me._imgLeft_3.Name = "_imgLeft_3"
Me._imgLeft_3.Size = New System.Drawing.Size(48, 63)
Me._imgLeft_3.TabIndex = 18
Me._imgLeft_3.TabStop = False
Me._imgLeft_3.Visible = False
'
'_imgLeft_5
'
Me._imgLeft_5.BackColor = System.Drawing.Color.Trans
Me._imgLeft_5.Image = CType(resources.GetObject(
Me._imgLeft_5.Location = New System.Drawing.Point(472, 80)
Me._imgLeft_5.Name = "_imgLeft_5"
Me._imgLeft_5.Size = New System.Drawing.Size(56, 63)
Me._imgLeft_5.TabIndex = 19
Me._imgLeft_5.TabStop = False
Me._imgLeft_5.Visible = False
'
'imgFlatLeft
'
Me.imgFlatLeft.BackColor = System.Drawing.Color.Trans
Me.imgFlatLeft.Image = CType(resources.GetObject(
Me.imgFlatLeft.Location = New System.Drawing.Point(448, 224)
Me.imgFlatLeft.Name = "imgFlatLeft"
Me.imgFlatLeft.Size = New System.Drawing.Size(81, 65)
Me.imgFlatLeft.TabIndex = 20
Me.imgFlatLeft.TabStop = False
Me.imgFlatLeft.Visible = False
'
'_imgLeft_1
'
Me._imgLeft_1.BackColor = System.Drawing.Color.Trans
Me._imgLeft_1.Image = CType(resources.GetObject(
Me._imgLeft_1.Location = New System.Drawing.Point(684, 80)
Me._imgLeft_1.Name = "_imgLeft_1"
Me._imgLeft_1.Size = New System.Drawing.Size(59, 63)
Me._imgLeft_1.TabIndex = 21
Me._imgLeft_1.TabStop = False
Me._imgLeft_1.Visible = False
'
'_imgLeft_4
'
Me._imgLeft_4.BackColor = System.Drawing.Color.Trans
Me._imgLeft_4.Image = CType(resources.GetObject(
Me._imgLeft_4.Location = New System.Drawing.Point(528, 80)
Me._imgLeft_4.Name = "_imgLeft_4"
Me._imgLeft_4.Size = New System.Drawing.Size(63, 63)
Me._imgLeft_4.TabIndex = 22
Me._imgLeft_4.TabStop = False
Me._imgLeft_4.Visible = False
'
'_imgLeft_2
'
Me._imgLeft_2.BackColor = System.Drawing.Color.Trans
Me._imgLeft_2.Image = CType(resources.GetObject(
Me._imgLeft_2.Location = New System.Drawing.Point(632, 80)
Me._imgLeft_2.Name = "_imgLeft_2"
Me._imgLeft_2.Size = New System.Drawing.Size(55, 63)
Me._imgLeft_2.TabIndex = 23
Me._imgLeft_2.TabStop = False
Me._imgLeft_2.Visible = False
'
'imgFlatRight
'
Me.imgFlatRight.BackColor = System.Drawing.Color.Trans
Me.imgFlatRight.Image = CType(resources.GetObject(
Me.imgFlatRight.Location = New System.Drawing.Point(256, 224)
Me.imgFlatRight.Name = "imgFlatRight"
Me.imgFlatRight.Size = New System.Drawing.Size(81, 65)
Me.imgFlatRight.TabIndex = 24
Me.imgFlatRight.TabStop = False
Me.imgFlatRight.Visible = False
'
'_imgRight_5
'
Me._imgRight_5.BackColor = System.Drawing.Color.Trans
Me._imgRight_5.Image = CType(resources.GetObject(
Me._imgRight_5.Location = New System.Drawing.Point(264, 80)
Me._imgRight_5.Name = "_imgRight_5"
Me._imgRight_5.Size = New System.Drawing.Size(56, 63)
Me._imgRight_5.TabIndex = 25
Me._imgRight_5.TabStop = False
Me._imgRight_5.Visible = False
'
'imgStandRight
'
Me.imgStandRight.BackColor
Me.imgStandRight.Image = CType(resources.GetObject(
Me.imgStandRight.Location = New System.Drawing.Point(8, 8)
Me.imgStandRight.Name = "imgStandRight"
Me.imgStandRight.Size = New System.Drawing.Size(56, 64)
Me.imgStandRight.TabIndex = 26
Me.imgStandRight.TabStop = False
Me.imgStandRight.Visible = False
'
'_imgRight_4
'
Me._imgRight_4.BackColor = System.Drawing.Color.Trans
Me._imgRight_4.Image = CType(resources.GetObject(
Me._imgRight_4.Location = New System.Drawing.Point(200, 80)
Me._imgRight_4.Name = "_imgRight_4"
Me._imgRight_4.Size = New System.Drawing.Size(63, 63)
Me._imgRight_4.TabIndex = 27
Me._imgRight_4.TabStop = False
Me._imgRight_4.Visible = False
'
'_imgRight_2
'
Me._imgRight_2.BackColor = System.Drawing.Color.Trans
Me._imgRight_2.Image = CType(resources.GetObject(
Me._imgRight_2.Location = New System.Drawing.Point(104, 80)
Me._imgRight_2.Name = "_imgRight_2"
Me._imgRight_2.Size = New System.Drawing.Size(55, 63)
Me._imgRight_2.TabIndex = 28
Me._imgRight_2.TabStop = False
Me._imgRight_2.Visible = False
'
'Timer1
'
Me.Timer1.Enabled = True
Me.Timer1.Interval = 10
'
'imgPerson
'
Me.imgPerson.BackColor = System.Drawing.Color.Trans
Me.imgPerson.Location = New System.Drawing.Point(0, 232)
Me.imgPerson.Name = "imgPerson"
Me.imgPerson.Size = New System.Drawing.Size(81, 72)
Me.imgPerson.TabIndex = 29
Me.imgPerson.TabStop = False
'
'imgOuch
'
Me.imgOuch.BackColor = System.Drawing.Color.Trans
Me.imgOuch.Image = CType(resources.GetObject(
Me.imgOuch.Location = New System.Drawing.Point(336, 56)
Me.imgOuch.Name = "imgOuch"
Me.imgOuch.Size = New System.Drawing.Size(100, 100)
Me.imgOuch.TabIndex = 30
Me.imgOuch.TabStop = False
Me.imgOuch.Visible = False
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackgroundImage = CType(resources.GetObject(
Me.ClientSize = New System.Drawing.Size(800, 494)
Me.ControlBox = False
Me.Controls.Add(Me.imgOuch
Me.Controls.Add(Me.imgPers
Me.Controls.Add(Me._imgRig
Me.Controls.Add(Me._imgRig
Me.Controls.Add(Me.imgStan
Me.Controls.Add(Me._imgRig
Me.Controls.Add(Me.imgFlat
Me.Controls.Add(Me._imgLef
Me.Controls.Add(Me._imgLef
Me.Controls.Add(Me._imgLef
Me.Controls.Add(Me.imgFlat
Me.Controls.Add(Me._imgLef
Me.Controls.Add(Me._imgLef
Me.Controls.Add(Me.imgStan
Me.Controls.Add(Me._imgLef
Me.Controls.Add(Me._imgRig
Me.Controls.Add(Me._imgRig
Me.Controls.Add(Me._imgRig
Me.Controls.Add(Me.lblSlow
Me.Controls.Add(Me.lblFast
Me.Controls.Add(Me.lblSpee
Me.Controls.Add(Me.imgWall
Me.Controls.Add(Me.imgPath
Me.Controls.Add(Me.hsbSpee
Me.Controls.Add(Me.cmdLeft
Me.Controls.Add(Me.cmdExit
Me.Controls.Add(Me.cmdRese
Me.Controls.Add(Me.cmdJump
Me.Controls.Add(Me.cmdRigh
Me.Controls.Add(Me.cmdStop
Me.FormBorderStyle = System.Windows.Forms.FormB
Me.Name = "Form1"
Me.Text = "Sonic Jump - Designed & Written by John Crick"
Me.ResumeLayout(False)
End Sub
#End Region
Public direction As String
Public steps As Integer
Public Jumping As Boolean
Public JumpCounts As Integer
Public JumpAmount As Integer
Dim quit As Object
Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
quit = MsgBox("Do you really want to exit?", vbQuestion + vbYesNo, "Sonic Jump") 'Message box and message
If quit = vbYes Then 'If quit equals yes Then
Me.Close() ' Close the form window
Else
If quit = vbNo Then 'If quit equals no Then
cmdStop.Focus() 'Set focus to Price Excluding VAT textbox
End If
End If
End Sub
Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Messa
If msg.WParam.ToInt32() = CInt(Keys.Escape) Then ' If escape key pressed Then
quit = MsgBox("Do you really want to exit?", vbQuestion + vbYesNo, "Sonic Jump") 'Message box and message
If quit = vbYes Then 'If quit equals yes Then
Me.Close() ' Close the form window
Else
If quit = vbNo Then 'If quit equals no Then
cmdStop.Focus() 'Set focus to Price Excluding VAT textbox
End If
End If
End If
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
steps = 0
direction = "none"
Timer1.Enabled = False
imgPerson.Image = imgStandRight.Image
End Sub
Private Sub cmdLeft_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLeft.Click
direction = "left"
Timer1.Enabled = True
End Sub
Private Sub cmdRight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRight.Click
direction = "right"
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If steps = 0 Then
steps = 1
ElseIf steps = 1 Then
steps = 2
ElseIf steps = 2 Then
steps = 3
ElseIf steps = 3 Then
steps = 4
ElseIf steps = 4 Then
steps = 5
ElseIf steps = 5 Then
steps = 0
End If
If direction = "left" Then
imgPerson.Left = imgPerson.Left - 1
imgPerson.Image = imgLeft(steps).Image
ElseIf direction = "right" Then
imgPerson.Left = imgPerson.Left + 1
imgPerson.Image = imgRight(steps).Image
End If
End Sub
End Class
Your code needs to be:
Public imgRight as vartype
Public imgLeft as vartype
It looks like these are meant to be arrays of images, but I don't see where they're ever initialized.
Public imgRight as vartype
Public imgLeft as vartype
It looks like these are meant to be arrays of images, but I don't see where they're ever initialized.
ASKER
Changed them to vartype but it is not recognised. Tried varianttype but it comes up with build errors.
Just to get around the error for now....
Try
If direction = "left" Then
imgPerson.Left = imgPerson.Left - 1
imgPerson.Image = imgLeft(steps)
ElseIf direction = "right" Then
imgPerson.Left = imgPerson.Left + 1
imgPerson.Image = imgRight(steps)
End If
Catch ex As Exception
'Skip error
End Try
Try
If direction = "left" Then
imgPerson.Left = imgPerson.Left - 1
imgPerson.Image = imgLeft(steps)
ElseIf direction = "right" Then
imgPerson.Left = imgPerson.Left + 1
imgPerson.Image = imgRight(steps)
End If
Catch ex As Exception
'Skip error
End Try
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The images I am using are not bitmaps, but transparent Gifs. Does that make a difference? I have uploaded a .zip file so you can download and see what I have done. I am not very good at explaining whats wrong cause I don't fully understand myself. Also what you have just written for me has gone way over my head :-( This is only the second program I have ever written, sorry.
You can download the file at: http://www.3doubleu.co.uk/game.zip
It is quite a large file, 1,211KB
You can download the file at: http://www.3doubleu.co.uk/game.zip
It is quite a large file, 1,211KB
Chaosian has the right idea, but for a smoother image flow try the try and catch code with
Private imgRight() As Bitmap
Private imgLeft() As Bitmap
Private imgRight() As Bitmap
Private imgLeft() As Bitmap
Thats it for me today check back with you tomorrow.
Do you have an e-mail I can send the working project to?
ASKER
Yes, its: admin@3doubleu.co.uk Thanks
There is a neat concept in VB.NET where you can easily create run-time controls, and add event handlers, that would be more dynamic than the static method that you have chosen.
Bob
Bob