예제 #1
0
 def reset_game(self):
     L = []
     for planet in self.children:
         L.append(planet)
     if L:
         self.clear_widgets(L)
     sunmass = float(Utilitys.get_app_config('planetapp','defaultsunmass'))
     self.sunmass = sunmass
     self.gravity = float(Utilitys.get_app_config('planetapp','gravity'))
     self.planetmass = float(Utilitys.get_app_config('planetapp','planetmass'))
     self.resetmass = float(Utilitys.get_app_config('planetapp','resetmass'))
     self.add_planet(True, (100,100), (0,0), float(sunmass), 10, (1,1,1))
예제 #2
0
파일: planet.py 프로젝트: mamphis/PlanetApp
 def __init__(self, fixed, position, velocity, mass, density, colour,
              **kwargs):
     super(Planet, self).__init__(**kwargs)
     self.fixed = fixed
     self.mass = mass
     self.center = (position[0],position[1])
     self.velocity = velocity
     self.density = density
     self.colour = colour
     self.showforcelimit = float(Utilitys.get_app_config('planetapp',
                                                         'showforcelimit'))
     self.calc_size()
     self.hillbodies = []
예제 #3
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)
예제 #4
0
파일: planet.py 프로젝트: mamphis/PlanetApp
    def calc_hillbodies(self, force, planet):
        # typecasting problem while crosscompiling
        foo = Utilitys.get_app_config('planetapp','showforcemode')
        if foo == u'0':
            return
        if ((force / self.mass) > (self.showforcelimit * 0.0002)):
            if not planet.fixed:
                if not planet in self.hillbodies: 
                    self.hillbodies.append(planet)
        else:
            if planet in self.hillbodies:
                self.hillbodies.remove(planet)

        for dude in self.canvas.children:
            if 'InstructionGroup' in  type(dude).__name__:
                self.canvas.remove(dude)
        shit = InstructionGroup()
        for body in self.hillbodies:
            shit.add(Line(points=(self.center_x,self.center_y,
                                  body.center_x,body.center_y),
                          width=1,
                          group=str(self.uid)))
        if len(self.hillbodies) > 0:
            self.canvas.add(shit)