Visual Basic Pong Project      

Feature Required Concept Examples
Paddle and Ball
  • Objects (picture box, radio button, panel)
  • Properties
 
Move Paddle
  • Points
  • Location property
  • mousemove event and the e argument
  • Global versus local variables
  • Declaring objects
  • Dim p as New Point(1,2)
  • object.location = p
  • p.x = e.x
  • Globals declared outside of functions; local variables declared in functions
Move Ball
  • Timer
  • Increment variables
  • Timer properties interval and enabled
  • Timer tick event
  • p.x = p.x + d*m
Bounce Ball
  • Collision detection
  • Coordinate System
  • if statements
  • if (p.X + img.width > me.width) then
        dirX = -dirX
    end if
Track Score and Time
  • Global variables
  • Static variables
  • Date variables
  • Status strip
  • Static variables retain values even after leaving function
  • Static x As Int16
  • Dim d As Date = #09/15/2005#
  • d = Today
  • d = Now
  • Status strip text property
  • Status strip items collection
Use keys to control paddle
  • keypress event
  • e.keyChar
  • form keypreview property
  • msgbox(e.keyChar.toString) in keypress event for form
  • Set the form's keypreview property to true

Add menu with start, new, exit and option to set speed.

Should confirm exit

  • Menu bar
  • Hot keys
  • Messagebox with yes/no buttons
  •   Use "&" to make HotKeys

If MessageBox.Show("Are you sure?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
   End
End If

Save High Score
  • StreamReader
  • StreamWriter

Dim srF As StreamReader
srF = New StreamReader("filepath ")
Dim sText As String
While (srF.Peek > -1) 
   sText =  srF.ReadLine
End While
srf.close()

Dim swWriter As New StreamWriter("filepath ", True)
swWriter.WriteLine("HI")
swWriter.Close()