Ejemplo n.º 1
0
 def __init__(self, planet, **kwargs):
     kwargs['thrust'] = self.GetThrust
     kwargs['mass'] = self.GetMass
     self.LastTime = 0
     self.ElapsedTime = 1
     self.FuelLeft = mdescfuel
     self.ThrustPct = 0
     self.LastAltitude = 0
     self.DeltaAltitude = 0
     # Clue for the thrust slider
     self.lab1 = Label((10, 340),
                       "Thrust: up/down key",
                       positioning="physical",
                       size=15)
     # Define a thrust slider
     self.ThrustSlider = Slider((10, 360),
                                0,
                                MaxThrottle,
                                0,
                                positioning="physical",
                                steps=20,
                                leftkey="down arrow",
                                rightkey="up arrow")
     # Fuel Gauge
     self.FuelGage = Label((10, 390),
                           self.FuelPct,
                           positioning="physical",
                           size=15)
     # Vertical Speedometer
     self.VSpeed = Label((10, 420),
                         self.VertVel,
                         positioning="physical",
                         size=15)
     super().__init__(planet, **kwargs)
     self.LastTime = self.shiptime
Ejemplo n.º 2
0
from ggrocket import Rocket, Planet
from math import radians, sqrt
from ggmath import Slider


earth = Planet()

# Constants relating to Earth and physics
Re = 6.371E6  # Earth radius: 6371000 meters in scientific notation
Me = 5.972E24 # Earth mass in kg (5.972 x 10^24)
G = 6.674E-11 # Gravitational constant
# Add a slider for controlling the timezoom
tz = Slider((10,400), 0, 5, 0, positioning="physical")
# Calculate the escape velocity from Earth's surface radius
Ve=sqrt(2*Me*G/Re)
print("Predicted escape velocity is ", Ve, " m/s")
rocket = Rocket(earth, heading=radians(90), directiond=90, velocity=Ve, timezoom=tz)

earth.run(rocket)
Ejemplo n.º 3
0
        return "STAGE 2 FIRING"
    elif PayloadLaunched:
        return "PAYLOAD DELIVERED"
    else:
        return "WAITING FOR LAUNCH"


# Create a button for starting the simulation
# Physical positioning at 10,400 pixels, calls the StartRocket function
start = InputButton((10, 400),
                    "START",
                    StartRocket,
                    positioning="physical",
                    size=15)

# Create a label for showing the current rocket status
status = Label((10, 420), GetStatus, positioning="physical", size=15)

# Add a slider for conrolling the timezoom
tz = Slider((10, 360),
            0,
            5,
            0,
            positioning="physical",
            leftkey="a",
            rightkey="d")

#Create and "run" the rocket
rocket = Rocket(earth, thrust=GetThrust, mass=GetMass, timezoom=tz)
earth.run(rocket)
Ejemplo n.º 4
0
        return "STAGE 2 FIRING"
    elif PayloadLaunched:
        return "PAYLOAD DELIVERED"
    else:
        return "WAITING FOR LAUNCH"


# Create a button for starting the simulation
# Physical positioning at 10,400 pixels, calls the StartRocket function
start = InputButton((10, 400),
                    "START",
                    StartRocket,
                    positioning="physical",
                    size=15)

stage2start = InputButton((10, 450),
                          "BEGIN STAGE 2",
                          Start2Stage,
                          positioning="physical",
                          size=15)

# Create a label for showing the current rocket status
status = Label((10, 420), GetStatus, positioning="physical", size=15)

# Add a slider for conrolling the timezoom
tz = Slider((10, 360), 0, 3, 0, positioning="physical")

#Create and "run" the rocket
rocket = Rocket(earth, thrust=GetThrust, mass=GetMass, timezoom=tz)
earth.run(rocket)