Exemple #1
0
 def __init__(self):
     self.Clock = pygame.time.Clock()  # Used to keep a constant frame-rate
     self.Time = pygame.time.Clock()  # Used to keep time of the simulation
     self.framerate = 10000  # Frame-rate
     '''
     Creating objects from my modules
     Calculations: calculates the physics which affect the sphere
     PyObject:     handles buttons, check boxes, what to draw and drawing it
     Features:     includes many different feature, some are essential
     '''
     self.Calculations = Calculations.Formulas()
     self.PyObject = Pygame_handling.Window()
     self.Features = Features.Methods()
     # Simulator settings
     self.pos, self.speed = 0, 0
     # Trying to load saved settings...
     try:
         settings = self.Features.get_settings()
         self.Features.monitor_changes(settings, True)
     except:
         self.mass, self.volume, self.density = 0, 0, 0
     self.verify_settings()
     # Save the settings
     # self.Features.save_settings(self.scale, self.radius, self.mass,
     #                            self.pos, self.user_densityAir, 
     #                            self.user_densityFluid)
     # Start the program
     # Width & height, Window name
     self.PyObject.set_display((500, 600), "Density Simulator - Simon Larsen")
     self.PyObject.prepare_sphere(self.radius, self.density, self.scale)
     self.dictionary = ["mass", "radius", "volume", "density", "fluid density",
                        "air density", "scale", "time"]
     # Reset timer for the arrow animation on startup
     self.PyObject.Draw.AnimationClock.tick()
     # Reset timer - nullifying time spend while initializing
     print
     "Initiate time:", self.Time.tick(), "ms"
    def __init__(self):
        self.Draw = Draw_options()  # Draw_options object
        self.Features = Features.Methods()  # Features object
        self.work_dir = os.getcwd()
        self.data_dir = os.path.join(self.work_dir, 'data')
        self.image_dir = os.path.join(self.data_dir, 'images')
        self.arrowUp = pygame.image.load(
            os.path.join(self.image_dir, 'menu_up.png'))
        self.arrowDown = pygame.image.load(
            os.path.join(self.image_dir, 'menu_down.png'))

        text = ["Show details"]
        pos = [(420, 565)]
        self.cbs = []
        self.cbs_state = []
        self.create_cb(text, pos)
        # zModule buttons
        images = [
            os.path.join(self.image_dir, 'rewind.png'),
            os.path.join(self.image_dir, 'rewind.png'),
            os.path.join(self.image_dir, 'stop.png'),
            os.path.join(self.image_dir, 'stop.png'),
            os.path.join(self.image_dir, 'play.png'),
            os.path.join(self.image_dir, 'play.png'),
            os.path.join(self.image_dir, 'forward.png'),
            os.path.join(self.image_dir, 'forward.png'),
            os.path.join(self.image_dir, 'up.png'),
            os.path.join(self.image_dir, 'up.png'),
            os.path.join(self.image_dir, 'down.png'),
            os.path.join(self.image_dir, 'down.png'),
            os.path.join(self.image_dir, 'up.png'),
            os.path.join(self.image_dir, 'up.png'),
            os.path.join(self.image_dir, 'down.png'),
            os.path.join(self.image_dir, 'down.png'),
            os.path.join(self.image_dir, 'up.png'),
            os.path.join(self.image_dir, 'up.png'),
            os.path.join(self.image_dir, 'down.png'),
            os.path.join(self.image_dir, 'down.png'),
            os.path.join(self.image_dir, 'up.png'),
            os.path.join(self.image_dir, 'up.png'),
            os.path.join(self.image_dir, 'down.png'),
            os.path.join(self.image_dir, 'down.png'),
            os.path.join(self.image_dir, 'up.png'),
            os.path.join(self.image_dir, 'up.png'),
            os.path.join(self.image_dir, 'down.png'),
            os.path.join(self.image_dir, 'down.png'),
            os.path.join(self.image_dir, 'up.png'),
            os.path.join(self.image_dir, 'up.png'),
            os.path.join(self.image_dir, 'down.png'),
            os.path.join(self.image_dir, 'down.png'),
        ]
        functions = [
            nothing,
            nothing,
            nothing,
            nothing,
            nothing,
            nothing,
            nothing,
            nothing,
            nothing,
            nothing,
            nothing,
            nothing,
            nothing,
            nothing,
            nothing,
            nothing,
        ]
        pos = [
            (18, 564),
            (71, 564),
            (124, 564),
            (157, 564),
            (116, 462),
            (116, 475),
            (116, 498),
            (116, 511),
            (116, 532),
            (116, 545),
            (408, 462),
            (408, 475),
            (408, 498),
            (408, 511),
            (408, 532),
            (408, 545),
        ]
        self.btns = []
        self.btns_state = []
        self.create_btn(pos, images, functions)

        # Buttons
        self.menuArrow = Buttons.Button()
        self.show_menu = False
        self.arrowAnimation = True
        print
        "Finished initiating Pygame_handling module..."