Week 4

Deliverables

Lab 4

Build and run the following sample projects. Study the documentation inside each sample project, which is in the form of an html file.

Assignment 4

(1) Modify the Picking sample project so that the cursor selects the nearest object in the case that selectable objects can cover each other.

(2) Use Gimp or other image manipulation tool to create a new obsticle that is pure magenta (red=255, green=0, blue=255) and add it to the 2D Per-Pixel Collision example. Because the image is pure magenta, you need to chose another color for a background. Make sure that you set the image's color key to this new background color. The color key is set in the properties window in Visual Studio for the image.

(extra credit) Create a new obsticle image that uses an alpha channel for background, and make this work in the 2D Per-Pixel Collision example.

Demonstrate your solution to an instructor in a lab session. (Due end of week 5)

Classroom Discussion

Transform versus TransformNormal

Vector2.Transform(Vector2, Matrix) is used to transform a point location to another point location using the scaling, rotation and translation encoded into the matrix. What this means is that the method multiplies (x, y, 0, 1) by the matrix to get a new Vector2.

In contrast, Vector2.TransformNormal(Vector2, matrix) is used to transform a direction to another direction using the scaling and rotation encoded into the matrix; it ignores any translation encoded into the matrix. This is done by multiplying (x, y, 0, 0) by the matrix to get a new Vector2.