예제 #1
0
파일: main.py 프로젝트: mamphis/PlanetApp
class PlanetApp(App):
    def build(self):

        self.settings_cls = SettingsWithSidebar

        game = PlanetGame(do_rotation=False,do_translation=False)
        # Settings come in as unicode!
        sunmass = float(Utilitys.get_app_config('planetapp','defaultsunmass'))
        game.sunmass = sunmass
        game.gravity = float(Utilitys.get_app_config('planetapp','gravity'))
        game.planetmass = float(Utilitys.get_app_config('planetapp','planetmass'))
        game.resetmass = float(Utilitys.get_app_config('planetapp','resetmass'))
        game.add_planet(True, (100,100), (0,0), sunmass, 10, (1,1,1))
        
        Clock.schedule_interval(game.update, 1.0 / 120.0)

        self.root = PlanetGameLayout()
        self.root.add_widget(game)

        b = Button(text="Reset",size_hint=(.1,.1))
        b.bind(on_press=self.root.clear_planets)
        self.root.add_widget(b)
        b2 = SettingsButton(text="Settings",size_hint=(.1,.1))
        self.root.add_widget(b2)


    def build_config(self, config):
        config.setdefaults('planetapp', {
            'defaultsunmass': 1000,
            'gravity' : 2,
            'resetmass' : 50,
            'showforcemode' : False,
            'showforcelimit' : 5,
            'planetmass' : 10}),
        '''
            'boolexample': True,
            'optionsexample': 'option2',
            'stringexample': 'some_string',
            'pathexample': '/some/path'})
        '''

    def build_settings(self, settings):
        settings.add_json_panel('PlanetApp',
                                self.config,
                                data=settings_json)

    def on_config_change(self, config, section,
                         key, value):
        print config, section, key, value
        self.root.reset_game()
예제 #2
0
파일: main.py 프로젝트: mamphis/PlanetApp
    def build(self):

        self.settings_cls = SettingsWithSidebar

        game = PlanetGame(do_rotation=False,do_translation=False)
        # Settings come in as unicode!
        sunmass = float(Utilitys.get_app_config('planetapp','defaultsunmass'))
        game.sunmass = sunmass
        game.gravity = float(Utilitys.get_app_config('planetapp','gravity'))
        game.planetmass = float(Utilitys.get_app_config('planetapp','planetmass'))
        game.resetmass = float(Utilitys.get_app_config('planetapp','resetmass'))
        game.add_planet(True, (100,100), (0,0), sunmass, 10, (1,1,1))
        
        Clock.schedule_interval(game.update, 1.0 / 120.0)

        self.root = PlanetGameLayout()
        self.root.add_widget(game)

        b = Button(text="Reset",size_hint=(.1,.1))
        b.bind(on_press=self.root.clear_planets)
        self.root.add_widget(b)
        b2 = SettingsButton(text="Settings",size_hint=(.1,.1))
        self.root.add_widget(b2)