Example #1
0
    def init(self):
        ##	load some textures
        # 	bakground texture
        stars_t = self.res.load_tex("stars.jpg")
        # 	sun texture
        sun_t = self.res.load_tex("sun.png")

        ##	set up the background
        self.background = sf.Sprite(stars_t)
        scale = self.scn.get_window_size().x / stars_t.size.x
        self.background.scale((scale, scale))
        self.background.move((0, 0))
        # 	make it a little fainter
        self.background.color = sf.Color(255, 255, 255, 150)

        ##	parse the solar system data
        self.system_data = resource.parse_json("system.json")

        ##	populate a dictionary of bodies
        for body_data in self.system_data["bodies"]:
            self.bodies[body_data["name"]] = body.Body()
            self.bodies[body_data["name"]].populate(body_data)

        self.sun = sf.Sprite(sun_t)
        self.sun.origin = (sun_t.size.x / 2.0, sun_t.size.y / 2.0)
        self.sun.scale((0.001, 0.001))

        ##	initialize the views
        self.bgview = self.scn.default_view()
        self.bodyview = self.scn.default_view()

        # 	TODO setup so that initial view shows orbit of earth
        self.bodyview.move(-self.scn.size().x / 2.0, -self.scn.size().y / 2.0)
        self.bodyview.zoom(0.005)
Example #2
0
    def init(self):
        ##	load some textures
        #	bakground texture
        stars_t = self.res.load_tex("stars.jpg")
        #	sun texture
        sun_t = self.res.load_tex("sun.png")

        ##	set up the background
        self.background = sf.Sprite(stars_t)
        scale = self.scn.get_window_size().x / stars_t.size.x
        self.background.scale((scale, scale))
        self.background.move((0, 0))
        #	make it a little fainter
        self.background.color = sf.Color(255, 255, 255, 150)

        ##	parse the solar system data
        self.system_data = resource.parse_json("system.json")

        ##	populate a dictionary of bodies
        for body_data in self.system_data["bodies"]:
            self.bodies[body_data["name"]] = body.Body()
            self.bodies[body_data["name"]].populate(body_data)

        self.sun = sf.Sprite(sun_t)
        self.sun.origin = (sun_t.size.x / 2., sun_t.size.y / 2.)
        self.sun.scale((0.001, 0.001))

        ##	initialize the views
        self.bgview = self.scn.default_view()
        self.bodyview = self.scn.default_view()

        #	TODO setup so that initial view shows orbit of earth
        self.bodyview.move(-self.scn.size().x / 2., -self.scn.size().y / 2.)
        self.bodyview.zoom(0.005)
Example #3
0
def main():
    ##	read settings from settings.json and store them
    settings = resource.parse_json("settings.json")

    ##	initialize resource manager
    res_man = resource.Manager()

    ##	open window
    scn = scene.Scene()
    scn.open_window(
        sf.VideoMode(settings["window"]["width"],
                     settings["window"]["height"]), settings["window"]["name"],
        sf.Style.CLOSE,
        sf.ContextSettings(0, 0, settings["window"]["antialias"], 2, 0))
    scn.set_window_icon(sf.Image.from_file("sun.png"))

    ##	send all that to the app
    app = solar.Solar(res_man, scn)
    app.init()

    while scn.running():
        scn.handle_events()

        app.update()
        app.render()
Example #4
0
def main():
	##	read settings from settings.json and store them
	settings = resource.parse_json("settings.json")

	##	initialize resource manager
	res_man = resource.Manager()

	##	open window
	scn = scene.Scene()
	scn.open_window(sf.VideoMode(settings["window"]["width"], settings["window"]["height"]), settings["window"]["name"], sf.window.Style.CLOSE, sf.ContextSettings(0, 0, settings["window"]["antialias"], 2, 0))
	scn.set_window_icon(sf.Image.from_file("sun.png"))

	##	send all that to the app
	app = solar.Solar(res_man, scn)
	app.init()

	while scn.running():
		scn.handle_events()

		app.update()
		app.render()