IS660Z – Programming Games Using Visual Basic

advertisement
IS660Z – Programming Games
Using Visual Basic
Required session 3
June 16, 2004
Agenda




Last minute corrections and fixes to
Cannonball and posting of assignment
Discussion questions from Blackboard
Overview of Minesweeper, Tic Tac Toe
Suggestions for other games
Lecture begins soon …


Students can finish up Cannonball and
post to digital drop box
Students missing project 2 presentation
will present
Discussion questions


Managing enhancements
Keeping cannon length constant


Finding the formulas to solve this problem
Angles vs. radians
Structures in code



Functions – return a value that answers
a question or solves a problem
Sub-routines – carry out a task but do
not return a value
Event handler – responds to an event
captured by OS
Final project


Final project presentation next
Wednesday
Your choice:




Enhanced Cannonball
Minesweeper
Tic Tac Toe
Your own game?
Final week wrap up

Second exam last hour of class





Conducted online
Same kinds of questions as midterm
Open books, open notes, but no electronic
resources (Internet)
Week 4 discussion postings due by 9 am
Saturday, June 26th
Post-course anonymous survey due by 9 am
Saturday, June 26th
Enhancements to Cannonball




Scoring
Move the target as well as the cannon
(requires multiple timers)
More realistic rendering of cannon,
target, scene
Other ideas?
Minesweeper



Control array of label objects represents
the minefield
Mines are randomly scattered
throughout the minefield and hidden
from player
Sophisticated mouse actions determine
player’s move
Minesweeper Design Issues

3 parallel data structures



Actual minefield visible to player
Hidden location of mines
Location (state) of player’s markings, i.e.
what cells have been uncovered or flagged
Minesweeper cont.


Visible minefield – control array of label
objects
Two internal arrays



Two dimensional array of Boolean values
(True, False)
One array records hidden location of
mines, other status of each cell
Similar to spreadsheet
2 dimensional arrays



Declaration:
Dim blnMinesOn (1 to conSize, _
1 to conSize) As Boolean
Access individual element with 2 subscripts:
blnMinesOn(i,j) = True
Processing requires nested loops:
For i = 1 to conSize
For j = 1 to conSize
blnMinesOn(i,j) = False
Next j
Next i
Tic Tac Toe




Simple child’s game is last chapter in
the book!
Requires two dimensional array to
represent board
Implement strategies for computer’s
choice of move (AI)
The Cat wins in case of a tie
Tic Tac Toe Design Issues




How to recognize a win? (p. 183)
Drawing a winning line
Cascading events (p. 182)
Implementing levels of play for the
computer (p. 185)
VB Exercise

Pre-minesweeper – introduces
algorithm for recognizing mouse
combination clicks



Left click
Right click
Left click with right button down
Last week!

See you online
Download