CMPS-4490 Game Design Lab-6

Overview:

Part 1:
Start by downloading the files for this week's work.

Files are located at:

/home/fac/gordon/p/4490/code/collision

Save your work at your Odin 4490/6/ folder.

Start by building the programs with make.

Run lineline and see the lines moving around.
Run bump to see the air-hockey elements collide and react.
Run collision and see the circle settling on the rectangle.


For audio:
cd 4490/6
cp -R /home/fac/gordon/p/4490/code/frameworks/openalTest


Part 2
Using the lineline.cpp program, indicate where the lines intersect.



Goal: Draw a circle or box around the intersection point.

We will code a solution together in class.

   1. write a function to determine if lines intersect.
   2. bisect one line turning it into 2 lines.
   3. choose the line that still intersects.
   4. go to step 2
   5. continue bisecting line until segment is very small.
   6. you are at the intersection point.
   

Exercise:

Define a key to start a game.
Show the user some instructions.
When the game starts:

1. Clear the screen.

2. At time intervals, create a line segment on the screen.
   The line segment will be made from 2 randomly generated end points.
   
3. Now move your mouse.

4. If your mouse cursor crosses the line, show the intersection point.
   Add a point to the player's score.

5. Show the score.

6. When the player reaches 10-points, game is over.

7. The elapsed time is the player's score.


Part 3
Use the bump.cpp program to do the following...



1. Play with the program to see how it works.

2. Setup the program window to look like a top-down view of a pool table.

3. Look around on-line to find a pool trick shot that you like.
   Setup your program to duplicate the trick shot.

How to go about this...

Start with the two balls shown. Setup a key-press or some other way
to start a ball moving in the direction you need.
Currently, a ball can be set in motion with the arrow keys.

Define each corner of the window to be a pocket in which the balls will
fall into and disappear. Choose two sides of the window in which two more
pockets will be defined. Six pockets in all.

Keep this as simple as you can while defining a scenario that you
have control over.

Tips:
  Start simple.
  Start with two balls and one pocket.
  Just get one ball moving and colliding with another ball.
  When a ball collides with a pocket area, it should maybe disappear.

You may add features such as:
  Slightly random collision reactions.
  Velocity drag caused by table felt friction.
  Colors of a pool table and balls.
  The cheer of specatators when your shot is made successfully.


Your trick shot scenario might look something like this...

I know to press A to play the shot animation.


Step 4
We will discuss the collision.cpp program during the week.



We will change the shape and resolution of the rectangle.
You should run and look at the program code when you have time.

You should accomplish something similar to this...



Step 5
We will discuss the orbit.cpp program during the week.



The satellite has some velocity in relation to the planet.
Write program code in the physics() function to cause the satellite to
go into orbit around the planet.

Change the velocity vector of the satellite due to the gravitational
pull of the planet.

The satellite is constantly pulled directly toward the planet.
Construct a vector toward the planet center.

You should run and look at the program code when you have time.


What to turn in...
Gordon will find your work out on Odin.