1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
|
//Parachutist
//Taylor Sanchez
//This should be a class that you input speed of a plane and how many seconds to wait until pulling
// a parachute, from there it will simulate from there.
//Upon closer inspection of the directions, I think I need to change what type of inputs come from the main program.
#include "ccc_win.h"
using namespace std;
class Parachutist
{
public:
Parachutist();
Parachutist(int, int, int);
void pull();
void move(int dx, int dy);
void display();
private:
Point man;
int seconds;
int y;
int x;
int dy;
int dx;
int r;
void move_closed(int, int);
void display_closed();
void move_open(int,int);
void display_open();
};
Parachutist::Parachutist()
{
int pull = 6; //seconds until parachute pulled
int speed = 150; //speed of plane jumped from
int seconds = 0; //constant //seconds falling in program
int dy = 0; //constant //change in y (acceleration/deceleration to ground)
int dx = 0; //constant //change in x (drag factor)
int x = 100;
int y = 950;
man= Point (x,y);
int r=10;
}
Parachutist::Parachutist(int s, int p, int height)
{
speed = s; //refer to main() currently is 150 ft/sec
pull = p; //refer to main() currently is after 8 sec
y = height;
}
void Parachutist::move_closed(int dx, int dy)
{
//p.move(dx,dy);
dy = 32 * seconds;
dx = speed;
//line for if slowing down after jump, we assume he isnt //dx = dx - 5*seconds;
if(dy > 174) {dy = 174;}
y = y - dy;
Message xy(Point (x,y), dx);
cwin<<xy;
x = x + dx;
seconds = seconds + 1;
}
void Parachutist::move_open(int dx, int dy)
{
dy = dy - (100 * seconds);
dx = dx - 20;
if(dx <= 0) {dx = 0;}
if(dy <= 17) {dy = 17;}
y = y - dy;
Message xy(Point (x,y), dx);
cwin<<xy;
x = x + dx;
seconds = seconds + 1;
}
void Parachutist::display()
{
if (seconds<pull)
void move_closed(int,int);
display_closed();
if (seconds>=pull)
void move_open(int,int);
display_open();
}
void Parachutist::display_closed()
{
Point h(x,y); //Center Point //h for head
Circle c(h,r); //circle p
cwin << c;
//body
Point b1(x,y-r); //neck connection
Point b2(x,y-(4*r)); //end of body Body and head will be same size?
cwin << Line(b1,b2);
//Legs
Point l1(x+((0.5)*r),y-(5.5*r)); //trying to make proportional, again may need to do math seperately
Point l2(x-((0.5)*r),y-(5.5*r)); //
cwin << Line(b2,l1) << Line(b2,l2);
//Arms
Point c1(x,y-(3*r)); // midpoint to connect arms
Point a1(x+(r),y-(1.5*r)); //arm
Point a2(x-(r),y-(1.5*r)); //arm
cwin << Line (c1,a1) << Line (c1,a2);
if (y>0){Parachutist::display();}
}
void Parachutist::display_open()
{
Point h(x,y); //Center Point //h for head
Circle c(h,r); //circle p
cwin << c;
//body
Point b1(x,y-r); //neck connection
Point b2(x,y-(4*r)); //end of body Body and head will be same size?
cwin << Line(b1,b2);
//Legs
Point l1(x+((0.5)*r),y-(5.5*r)); //trying to make proportional, again may need to do math seperately
Point l2(x-((0.5)*r),y-(5.5*r)); //
cwin << Line(b2,l1) << Line(b2,l2);
//Arms
Point c1(x,y-(3*r)); // midpoint to connect arms
Point a1(x+(r),y-(1.5*r)); //arm
Point a2(x-(r),y-(1.5*r)); //arm
cwin << Line (c1,a1) << Line (c1,a2);
//parachute
Point c2(x,y-(2*r)); //connection point for parachute
Point s1(x-(3*r),y+(3*r)); //string
Point s2(x+(3*r),y+(3*r)); //string
Point p3(x+(2*r),y+(4*r));
Point p2(x,y+(5*r));
Point p1(x-(2*r),y+(4*r));
//connect the dots
cwin << Line(c2,s1) << Line (c2,s2) << Line(s1,s2) << Line(s1,p1) << Line(s2,p3) <<Line(p1,p2) <<Line (p3,p2);
if (y>0){Parachutist::display();}
}
int ccc_win_main(){
cwin.coord(0,1000,1000,0);
Parachutist person1(150, 8,1000); //speed of plane, seconds to pull chute, height of plane
person1.display();
return 1;
}
|