Imports System
Imports System.IO
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 btnRocket As System.Windows.Forms.Button
Friend WithEvents mnuFile As System.Windows.Forms.MenuItem
Friend WithEvents mnuitemNew As System.Windows.Forms.MenuItem
Friend WithEvents mnuitemExit As System.Windows.Forms.MenuItem
Friend WithEvents mainmnu As System.Windows.Forms.MainMenu
Friend WithEvents mnuHelp As System.Windows.Forms.MenuItem
Friend WithEvents mnuAbout As System.Windows.Forms.MenuItem
Friend WithEvents grpboxGame As System.Windows.Forms.GroupBox
Friend WithEvents picboxShell As System.Windows.Forms.PictureBox
Friend WithEvents tmrShell1 As System.Windows.Forms.Timer
Friend WithEvents picboxBomb As System.Windows.Forms.PictureBox
Friend WithEvents tmrMove As System.Windows.Forms.Timer
Friend WithEvents lblHealth As System.Windows.Forms.Label
Friend WithEvents tmrJump As System.Windows.Forms.Timer
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents picboxCloud As System.Windows.Forms.PictureBox
Friend WithEvents lblScore As System.Windows.Forms.Label
Friend WithEvents tmrScore As System.Windows.Forms.Timer
Friend WithEvents mnuitSave As System.Windows.Forms.MenuItem
Friend WithEvents SaveFlDlg As System.Windows.Forms.SaveFileDialog
<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.grpboxGame = New System.Windows.Forms.GroupBox
Me.lblScore = New System.Windows.Forms.Label
Me.picboxCloud = New System.Windows.Forms.PictureBox
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.lblHealth = New System.Windows.Forms.Label
Me.picboxShell = New System.Windows.Forms.PictureBox
Me.btnRocket = New System.Windows.Forms.Button
Me.picboxBomb = New System.Windows.Forms.PictureBox
Me.mainmnu = New System.Windows.Forms.MainMenu
Me.mnuFile = New System.Windows.Forms.MenuItem
Me.mnuitemNew = New System.Windows.Forms.MenuItem
Me.mnuitemExit = New System.Windows.Forms.MenuItem
Me.mnuHelp = New System.Windows.Forms.MenuItem
Me.mnuAbout = New System.Windows.Forms.MenuItem
Me.tmrShell1 = New System.Windows.Forms.Timer(Me.components)
Me.tmrMove = New System.Windows.Forms.Timer(Me.components)
Me.tmrJump = New System.Windows.Forms.Timer(Me.components)
Me.tmrScore = New System.Windows.Forms.Timer(Me.components)
Me.mnuitSave = New System.Windows.Forms.MenuItem
Me.SaveFlDlg = New System.Windows.Forms.SaveFileDialog
Me.grpboxGame.SuspendLayout()
Me.SuspendLayout()
'
'grpboxGame
'
Me.grpboxGame.BackColor = System.Drawing.Color.Transparent
Me.grpboxGame.Controls.Add(Me.lblScore)
Me.grpboxGame.Controls.Add(Me.picboxCloud)
Me.grpboxGame.Controls.Add(Me.PictureBox1)
Me.grpboxGame.Controls.Add(Me.lblHealth)
Me.grpboxGame.Controls.Add(Me.picboxShell)
Me.grpboxGame.Controls.Add(Me.btnRocket)
Me.grpboxGame.Controls.Add(Me.picboxBomb)
Me.grpboxGame.Location = New System.Drawing.Point(16, 16)
Me.grpboxGame.Name = "grpboxGame"
Me.grpboxGame.Size = New System.Drawing.Size(344, 336)
Me.grpboxGame.TabIndex = 1
Me.grpboxGame.TabStop = False
'
'lblScore
'
Me.lblScore.ForeColor = System.Drawing.SystemColors.ActiveCaptionText
Me.lblScore.Location = New System.Drawing.Point(240, 40)
Me.lblScore.Name = "lblScore"
Me.lblScore.Size = New System.Drawing.Size(80, 16)
Me.lblScore.TabIndex = 6
Me.lblScore.Text = "[ Score: 0 ]"
'
'picboxCloud
'
Me.picboxCloud.Image = CType(resources.GetObject("picboxCloud.Image"), System.Drawing.Image)
Me.picboxCloud.Location = New System.Drawing.Point(24, 24)
Me.picboxCloud.Name = "picboxCloud"
Me.picboxCloud.Size = New System.Drawing.Size(64, 48)
Me.picboxCloud.TabIndex = 5
Me.picboxCloud.TabStop = False
'
'PictureBox1
'
Me.PictureBox1.BackgroundImage = CType(resources.GetObject("PictureBox1.BackgroundImage"), System.Drawing.Image)
Me.PictureBox1.Location = New System.Drawing.Point(8, 288)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(328, 40)
Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage
Me.PictureBox1.TabIndex = 4
Me.PictureBox1.TabStop = False
'
'lblHealth
'
Me.lblHealth.ForeColor = System.Drawing.SystemColors.ControlLight
Me.lblHealth.Location = New System.Drawing.Point(240, 16)
Me.lblHealth.Name = "lblHealth"
Me.lblHealth.Size = New System.Drawing.Size(88, 16)
Me.lblHealth.TabIndex = 3
Me.lblHealth.Text = "[ Health: | | | | | ]"
'
'picboxShell
'
Me.picboxShell.Image = CType(resources.GetObject("picboxShell.Image"), System.Drawing.Image)
Me.picboxShell.Location = New System.Drawing.Point(280, 272)
Me.picboxShell.Name = "picboxShell"
Me.picboxShell.Size = New System.Drawing.Size(16, 16)
Me.picboxShell.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.picboxShell.TabIndex = 1
Me.picboxShell.TabStop = False
'
'btnRocket
'
Me.btnRocket.BackColor = System.Drawing.Color.Transparent
Me.btnRocket.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.btnRocket.ForeColor = System.Drawing.Color.Transparent
Me.btnRocket.Image = CType(resources.GetObject("btnRocket.Image"), System.Drawing.Image)
Me.btnRocket.Location = New System.Drawing.Point(32, 248)
Me.btnRocket.Name = "btnRocket"
Me.btnRocket.Size = New System.Drawing.Size(32, 40)
Me.btnRocket.TabIndex = 0
'
'picboxBomb
'
Me.picboxBomb.Image = CType(resources.GetObject("picboxBomb.Image"), System.Drawing.Image)
Me.picboxBomb.Location = New System.Drawing.Point(344, 272)
Me.picboxBomb.Name = "picboxBomb"
Me.picboxBomb.Size = New System.Drawing.Size(16, 16)
Me.picboxBomb.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.picboxBomb.TabIndex = 2
Me.picboxBomb.TabStop = False
'
'mainmnu
'
Me.mainmnu.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuFile, Me.mnuHelp})
'
'mnuFile
'
Me.mnuFile.Index = 0
Me.mnuFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuitemNew, Me.mnuitSave, Me.mnuitemExit})
Me.mnuFile.Text = "File"
'
'mnuitemNew
'
Me.mnuitemNew.Index = 0
Me.mnuitemNew.Text = "New"
'
'mnuitemExit
'
Me.mnuitemExit.Index = 2
Me.mnuitemExit.Text = "Exit"
'
'mnuHelp
'
Me.mnuHelp.Index = 1
Me.mnuHelp.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuAbout})
Me.mnuHelp.Text = "Help"
'
'mnuAbout
'
Me.mnuAbout.Index = 0
Me.mnuAbout.Text = "About"
'
'tmrShell1
'
'
'tmrMove
'
Me.tmrMove.Interval = 1
'
'tmrJump
'
Me.tmrJump.Interval = 1
'
'tmrScore
'
'
'mnuitSave
'
Me.mnuitSave.Index = 1
Me.mnuitSave.Text = "Save"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.Color.FromArgb(CType(84, Byte), CType(165, Byte), CType(231, Byte))
Me.ClientSize = New System.Drawing.Size(376, 361)
Me.Controls.Add(Me.grpboxGame)
Me.Menu = Me.mainmnu
Me.Name = "Form1"
Me.Text = "Pilot Training"
Me.grpboxGame.ResumeLayout(False)
Me.ResumeLayout(False)
End Sub
#End Region
Dim Score
Private Sub btnRocket_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles btnRocket.KeyDown
If e.KeyCode = Keys.NumPad6 Then 'moves right
btnRocket.Left = btnRocket.Left + 10
End If
If e.KeyCode = Keys.NumPad8 Then 'moves up
tmrJump.Start()
End If
If e.KeyCode = Keys.NumPad2 Then 'moves down
'btnRocket.Top = btnRocket.Top + 10
End If
If e.KeyCode = Keys.NumPad4 Then
btnRocket.Left = btnRocket.Left - 10 'moves left
End If
End Sub
Private Sub mnuitemExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuitemExit.Click
Me.Close()
End Sub
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuAbout.Click
MessageBox.Show("Made in 4th Period Programming; 2008 (c); made by Neb Z and David M", "About")
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub tmrShell1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrShell1.Tick, mnuitemNew.Click
Dim Enemy = picboxShell
Static Health As Integer = 5
Enemy.Left = Enemy.Left - 5
If Enemy.Left <= 0 Then
picboxBomb.Left = picboxBomb.Left - 5
Enemy = picboxBomb
Score = Score + 1
End If
If Enemy.Left < btnRocket.Left + btnRocket.Width And Enemy.Left + _
Enemy.Width > btnRocket.Left And Enemy.Top < btnRocket.Top + _
btnRocket.Height And Enemy.Top + Enemy.Height > btnRocket.Top Then
If Health > 0 Then
Health = Health - 1
Me.lblHealth.Text = "[ Health: "
Dim I As Integer = 0
While I < Health
Me.lblHealth.Text = Me.lblHealth.Text & "| "
I = I + 1
End While
Me.lblHealth.Text = Me.lblHealth.Text & "]"
End If
ElseIf Health <= 0 Then
Static Reset
If Reset > 0 Then
Health = Health + 5
Score = Score - Score
Else
tmrShell1.Stop()
tmrScore.Stop()
MessageBox.Show("You are Dead!", ":(")
Reset = Reset + 1
GoTo endhere
End If
End If
If Enemy.Left <= -20 Then
Enemy = picboxShell
picboxShell.Location = New Point(344, 272)
picboxBomb.Location = New Point(344, 272)
End If
tmrScore.Start()
Endhere:
End Sub
Private Sub tmrMove_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrMove.Tick
Static Switch As Integer = 0
If Switch = 0 Then
Switch = Switch + 1
Me.btnRocket.Image.FromFile("C:\Documents and Settings\1231152\My Documents\Visual Studio Projects\Pilot Training Program\bin\mario_move.GIF")
ElseIf Switch = 1 Then
Me.btnRocket.Image.FromFile("C:\Documents and Settings\1231152\My Documents\Visual Studio Projects\Pilot Training Program\bin\mario_stand.GIF")
Switch = Switch + 1
ElseIf Switch = 2 Then
'tmrMove.Stop()
Switch = Switch - 2
End If
If Me.btnRocket.Location.X <= 0 Then
Dim X = Me.btnRocket.Location.X
Dim Y = Me.btnRocket.Location.Y
Me.btnRocket.Location = New Point(X + 1, Y)
ElseIf Me.btnRocket.Location.X >= 328 Then
Dim X = Me.btnRocket.Location.X
Dim Y = Me.btnRocket.Location.Y
Me.btnRocket.Location = New Point(X - 1, Y)
End If
End Sub
Private Sub tmrJump_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrJump.Tick
Static Switch As Integer = 0
If Switch = 0 Then
Switch = Switch + 1
btnRocket.Top = btnRocket.Top - 20
ElseIf Switch = 1 Then
btnRocket.Top = btnRocket.Top + 20
Switch = Switch + 1
ElseIf Switch = 2 Then
tmrJump.Stop()
Switch = Switch - 2
End If
tmrJump.Interval = 500
End Sub
Private Sub mnuitemNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuitemNew.Click
Me.lblHealth.Text = "[ Health: | | | | | ]"
Me.btnRocket.Location = New Point(32, 248)
Me.picboxShell.Location = New Point(280, 272)
Me.picboxBomb.Location = New Point(344, 272)
tmrShell1.Stop()
tmrShell1.Start()
End Sub
Private Sub tmrScore_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrScore.Tick
Score = Score + 1
Me.lblScore.Text = "[ Score: " & Score & " ]"
End Sub
Private Sub mnuitSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuitSave.Click
SaveFlDlg.FileName = ("Text Documents (*.txt)|.txt")
Dim fn As String = SaveFlDlg.ShowDialog.ToString()
Dim fs As New FileStream(fn, FileMode.Append)
Dim SaveFile As New StreamWriter(fs, System.Text.Encoding.UTF8, 1000)
SaveFile.Write(Me.lblScore.Text)
End Sub
End Class