All pastes #924884 Raw Edit

ray help meeeee

public text v1 · immutable
·published 2008-03-01 20:14 UTC
rendered paste body
#include<ccc_win.h>

using namespace std;

double position(double init_pos, double velocity, double accel, int t)
{
   double pos;
   pos = init_pos + (velocity * t) + (0.5 * accel * t * t);
   return pos;
}

double velocity(double init_vel, double accel, int t)
{
   double vel;
   vel = init_vel + (accel * t);
   return vel;
} 

void accelaration(double & x_accelaration, double & y_accelaration)
{
   string input;
   double left_thruster;
   double right_thruster;

   // Get Y Accelaration
   input = cwin.get_string("Vertical Thruster Value, (h)igh, (m)edium, (l)ow, (n)one: ");
   if(input == "h")
      y_accelaration = 2.0;
   if(input == "m")
      y_accelaration = 1.0;
   if(input == "l")
      y_accelaration = 0.0;
   else
      y_accelaration = -1.6;

   // Get Right Thruster
   input = cwin.get_string("Right Thruster Value, (h)igh, (m)edium, (l)ow, (n)one: ");
   if(input == "h")
      right_thruster = -2.0;
   if(input == "m")
      right_thruster = -1.0;
   if(input == "l")
      right_thruster = -0.5;
   else
      right_thruster = 0.0;

   // Get Left Thruster
   input = cwin.get_string("Left Thruster Value, (h)igh, (m)edium, (l)ow, (n)one: ");
   if(input == "h")
      left_thruster = 2.0;
   if(input == "m")
      left_thruster = 1.0;
   if(input == "l")
      left_thruster = 0.5;
   else
      left_thruster = 0.0;

   // Calculate X Accelaration
   x_accelaration = left_thruster + right_thruster;

}

void drawship(Point one)
{
   Point two = one;
   one.move(0,1000);
   Line l(one,two);
   two.move(500,0);
   Line ll(one,two);
   two.move(-1000,0);
   Line lll(one,two);
   one.move(500,-1000);
   Line llll(one,two);
   cwin << l << ll << lll << llll;
}


int ccc_win_main()
{
   cwin.coord(0,10000,10000,0);
   const int drawnum = 100;
   int n = 1;

   double x_velocity = 0.0;
   double y_velocity = 0.0;
   double x_accelaration = 0.0;
   double y_accelaration = -1.6;
   double x_initial_pos = 5000.0;
   double y_initial_pos = 7000.0;
   double x_position;
   double y_position;
   int time = 1;

   while(time>-1)
   {
      while(time <= 30)
      {
         x_position = position(x_initial_pos,x_velocity,x_accelaration,time);
         y_position = position(y_initial_pos,y_velocity,y_accelaration,time);
         cwin.clear();

         for(n=1;n<=drawnum;n++)
         {
            Point p(x_position,y_position);
            drawship(p);
         }
        
         time++;
      }
             

      x_initial_pos = x_position;
      y_initial_pos = y_position;
      x_velocity = velocity(x_velocity,x_accelaration,30);
      y_velocity = velocity(y_velocity,y_accelaration,30);
      accelaration(x_accelaration,y_accelaration);
      time = 1;
   }
   return 0;

}