Hack Forums
Flight Simulation system - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Coders Lounge (https://hackforums.net/forumdisplay.php?fid=5)
+---- Thread: Flight Simulation system (/showthread.php?tid=23277)



Flight Simulation system - closed_my_HF_account - Jul 13, 2008

Me and my friend are working on a flight Simulation system that can/may be used in Games, and will actually be used on a hardware remote plane after all the project is done, I am doing the programming/maths/some physics and my friend is an aerospace engineer who will be advising me through the programming in what need's doing and will be putting the hardware version of the plane together.

All the programming will be done a a huge array of classes that hold some superior complexity, but I was going over a rough drafts and ideas with him today and thought I'd post it on here - feel free to comment, if you like I could post the finished source on here in a couple of months time (thousands of lines of code, lib, *.h, *.cpp, etc) if you'd like:

Obviously don't take this code literally, it was just some ideas, I'm just coding a timer at the moments and some drivers etc.


Code
//Flight simulation program by System error [email protected]


#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
//relevant headers 'n' libs

void main(void) //avoid return val with void func
{
    //main int vars
    int FCC = 0, Fuel = 100, Health_detection = 0, Lwing = 0, Rwing = 0, body = 0,
    x = 0, y = 0, accel = 0, V = 0, Collision = 0, xv = 0, yv = 0, time = 0;

    //menu
    cout<<"                           ||FLIGHT SIMULATOR||\n\n";
    cout<<"FCC status entire machine not operated\n";

  
   //infinate loop for repetatice query
    cout<<"Now imagine you're controlling the aircrart\nwhat would you like to do?:\n";
    cout<<"--------------------------------------------------------------------\n";
    cout<<"a1 = accelleration (Stage 1)\na2 = lift-off (Stage 2)\na3 = down (optional)\na3 = Left turn(optional)\n";
    cout<<"a4 = Right Turn (optional)\na5 = Fuel status (Check fuel status)\na6 = Health (Check health)\na7 = Flight_time (View air time spent)\n\n";


       //input vars for menu
       string a1 = "a1", a2 = "a2", a3 = "a3", a4 = "a4", a5 = "a5", a6 = "a6", a7 = "a7";

        string input;
        cin>>input;

      

                if(input == a1)
                {
                    cout<<"How many times would you loop this?:\n";
                    int inputloop;
                    cin>>inputloop;
                    for(int count = 0; count < inputloop; count++)
                    {
                
                    cout<<"Increasing Accelleration, auto lifting off\n\n";
        
                accel++;
                time++;
                V = accel*time;
                Fuel += -1;

                cout<<"accel is now : "<<accel<<"\n"<<"time is now :"<<time<<"\n"<<"Velocity is now :"<<V<<"\n"<<"Fuel decreased from 100% to "<<Fuel<<endl;


              
                //nice fuel warning system
                if(Fuel == 50)
                {
                cout<<"\n--Alert to FCC: you have half of your fuel left";
                }
                else if(Fuel == 15)
                {
                    cout<<"\n--Alert** you only have a quarter of your fuel left!\nGet the parahute ready";
                }
                else if(Fuel == 0)
                {
                cout<<"\n---WARNING!! fuel empty---";
                }



                   }
                }














                else
                {
                    cout<<"This function is not implemented yet, only function a1 is working\n";
              
                }



}



- bubbaphatz123 - Jul 13, 2008

Very nice, what language?


- Jimmie - Jul 13, 2008

C++ lol
and nice coding


- closed_my_HF_account - Jul 14, 2008

Yes it's C++, and thanks for that ultimate best comment one can give as far as I'm concerned Ikeo :)


- closed_my_HF_account - Jul 14, 2008

EDITED WORKING ON GUI VERSION FOR CLARITY:

Sneaky peak at some code I'm working on to discus our ideas


[img]http://img377.imageshack.us/img377/3496/93247038lz2.png[/img]


Code
private: System::Void Auto_pilot_test_Click(System::Object^  sender, System::EventArgs^  e)
         {
        
             System::Int32 accel = 0, FCC = 0, Fuel = 10000, Health_detection = 10000, Lwing = 0, Rwing = 0, body = 0,
              x = 0, y = 0,  V = 0, Collision = 0, xv = 0, yv = 0, time = 0, zero = 0;

             double speed = 0;
            
            
            
             for(int i = 0; i < 15000; i++)
             {
                accel++;
                time++;
                V = accel*time;
                Fuel += -1;
                speed+= accel-20;
                


               this->accel_number_label->Text=(accel).ToString();
               this->accel_number_label->Update();
                
               this->Fuel_num_label->Text=(Fuel).ToString();
               this->Fuel_num_label->Update();

               this->velocity_num_label->Text=(V).ToString();
               this->velocity_num_label->Update();
            
               this->time_num_label->Text=(time).ToString();
               this->time_num_label->Update();

               if(speed <= 5000)
               {
               this->speed_num_label->Text=(speed).ToString();
               this->speed_num_label->Update();
               }
          
             if(speed >= 1500)
             {
                 this->speed_num_label->Text->ToString();
                 this->speed_num_label->Text=("Max speed reached");
                 this->speed_num_label->Update();
                
             }
              
          
                if(Fuel == 5000)
                {
                  this->FCC_Process->Text=("WARNING! Half or fuel used");
                  this->FCC_Process->Update();
                }
              
                else if(Fuel == 2500)
                {
                  this->FCC_Process->Text=("WARNING! three quarters of fuel used");
                  this->FCC_Process->Update();
                }

                else if(Fuel <= 0)
                {
                    this->velocity_num_label->Text=(V).ToString();
                    this->velocity_num_label->Update();
                    V += -15;
                    this->Fuel_num_label->Text->ToString();
                    this->Fuel_num_label->Text=("Fuel empty");
                    this->Fuel_num_label->Update();
                }
                

                 else if(V == -1)
                {
                    
                    this->FCC_Process->Text=("Plane crashed");
                    this->FCC_Process->Update();
                    this->collision_num_label->Text=("1 collision detected!");
                    break;
                }
            
      
         }
                    
    }