CMPS-4490 Game Design Lab-5

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/5/ 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.

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



Draw a circle or box around the intersection point.

Use any method you can think of to get this done.

Code your own solution to gain some extra credit.

You may search for a solution on-line.
If you find a solution on-line, then please document the source and a few
details about how it works in some code comments.


Extra credit for completing this solution: An interesting solution would be to reduce the length on one of the line segments using sub-division, while still maintaining intersection. When the reduced line segment becomes very short, use its midpoint as the intersection point. When an intersection is detected... 1. Subdivide the line. 2. Discard one half. 3. If it no longer intersects, use the other half. 4. Keep doing this until the line length is less than 1.0. 5. Use the midpoint of the line segment as the intersection.

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.