Game Development Reference
In-Depth Information
(a) Extend the game, so that there is a generic 'wind' parameter that varies
throughout playing the game. When there is more wind, the paint cans and
balloon rotate and move more heavily. If you define this 'wind' parameter
as a vector, it can also be used to indicate the direction of the wind. The di-
rection and strength of the wind then influences how the balloons move, but
also how fast the ball moves.
(b) Make a two-player version of the game, where each player controls his/her
own cannon (think of a good input mechanism for each player). You could
make it a symmetrical game in that the players collaborate to give the paint
cans the right color, and the player that colors the most paint can correctly
wins the game. You could also make it an asymmetrical game, where the
goal of one player is to correctly paint as many cans as possible, and the
other player's goal is to obstruct the first player as much as possible.
A.3 Exercises and Challenges for Part III
Exercises
1. Arrays
(a) Write a method CountZeros which has an array of integers as a parameter.
The result of the method is the number of zeros in the array.
(b) Write a method Add which has two integer arrays as parameters. You may
assume that the length of each array is the same. The method adds the values
in the two arrays and returns as a result another integer array. For example,
given is an array array1 = {0, 3, 8, 4} and an array array2 = {10, 2, 8, 8} .The
result of the method call add(array1, array2) will be another array {10, 5, 0, 4} .
(c) Write a method FirstPosition which has two parameters: a string and a char .
The method returns the first position of the character in the string. If the char-
acter doesn't occur in the string, the method should return
1. For example:
int result = this .FirstPosition("arjan", 'a'); // returns 0
result = this .FirstPosition("jeroen", 'a'); // return
1
result = this .FirstPosition("mark", 'a'); // returns 1
2. string methods
(a) The string class contains the method ToUpper that returns a version of the
string containing only capital letters. You can call this method as follows:
h = s.ToUpper();
If you had to write the class string yourself, how would you implement this
method (using other methods in the string class?
 
Search WWH ::




Custom Search