def __init__(self): QWidget.__init__(self) self.setFixedSize(640,480) top = QWidget() topLayout = QHBoxLayout() top.setLayout(topLayout) title = QLabel("尋寶遊戲"); title.setFont(QFont("verdana",25,QFont.Bold)) topLayout.addWidget(title) lcd = QLCDNumber() lcd.setSegmentStyle(QLCDNumber.Flat) lcd.setFrameStyle(QFrame.StyledPanel|QFrame.Plain) topLayout.addWidget(lcd) self.myScene = scene.Scene() self.connect(self.myScene, SIGNAL("steroidTaken(int)"), lcd, SLOT("display(int)")) view = QGraphicsView() view.setAutoFillBackground(True) view.setScene(self.myScene) layout = QVBoxLayout() layout.addWidget(top) layout.addWidget(view) self.setLayout(layout)
def test_imaka(psf_grid_raw): time_start = time.time() if psf_grid_raw is None: psf_grid_raw = prepare_test() h4rg = instrument.Instrument((6000,6000), 4.0, 10., 4.) h4rg.scale = 0.1 sources = scene.Scene(stars_x, stars_y, stars_f) psfgrid = psf.PSF_grid(psf_grid_raw) print('Making Image: {0} sec'.format(time.time() - time_start)) obs = observation.Observation(h4rg, sources, psfgrid, 4, 3.0) print('Saving Image: {0} sec'.format(time.time() - time_start)) obs.save_to_fits('tmp.fits', clobber=True) # print 'Displaying Image' # py.clf() # py.imshow(obs.img, cmap='gist_heat') # # Zoom in # py.axis([2000, 3000, 2000, 3000]) # Print out some runtime information. time_end = time.time() run_time = time_end - time_start print('Total Time: {0} seconds'.format(run_time)) print('Time Per Star: {0} seconds'.format(run_time / Nstars)) return obs
def __init__(self, category): guirender.RenderTaskView.__init__(self, category, 'Scene') self.scene = scene.Scene() sceneDir = mh.getPath('scenes') if not os.path.exists(sceneDir): os.makedirs(sceneDir) self.currentScene = os.path.join(sceneDir, "Default.mhscene") if os.path.exists(self.currentScene): loaded = self.scene.load(self.currentScene) if loaded is False: self.scene.save(self.currentScene) else: self.scene.save(self.currentScene) if not os.path.exists(os.path.join(sceneDir, "notfound.thumb")): shutil.copy( os.path.normpath(mh.getSysDataPath("uvs/notfound.thumb")), sceneDir) self.filechooser = self.addRightWidget( \ fc.IconListFileChooser(sceneDir , 'mhscene', ['thumb', 'png'], 'notfound.thumb', 'Scene')) #self.addLeftWidget(self.filechooser.createSortBox()) self.filechooser.enableAutoRefresh(False) glmodule.setSceneLighting(self.scene) @self.filechooser.mhEvent def onFileSelected(filename): self.loadScene(filename)
def newSceneButtonCb(event, button): if self.sceneDirty: ynd = gui.Dialog.createYesNoDialog( "Save existing scene first?") ynd.run() if ynd.result: saveScene(self) wid = gui.InputDialog("Enter new scene width") wid.run() w = int(wid.textInput.text) if wid.textInput.text.isdigit( ) else configuration.default_width_in_tiles hid = gui.InputDialog("Enter new scene height") hid.run() h = int(hid.textInput.text) if hid.textInput.text.isdigit( ) else configuration.default_height_in_tiles bid = gui.Dialog.createYesNoDialog("Choose different base tile?") bid.run() bt = None if bid.result: ts = TileSelector(self.scene) ts.show() bt = ts.selectedTile self.engine.scene = scene.Scene(self.engine, widthInTiles=w, heightInTiles=h, players=[self.scene.player]) if bt: self.engine.scene.baseTile = bt self.engine.scene.initScene() button.ancestor.exit()
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()
def __init__(self, *args, **kwargs): if kwargs: self.camera = kwargs.get('camera', camera.Camera()) self.scene = kwargs.get('scene', scene.Scene()) self.background_color = kwargs.get('background_color', glm.vec3(.0, .0, .0)) self.samples = kwargs.get('samples', 1) self.buffer = kwargs.get('buffer', buffer.Buffer()) elif args: self.camera, self.scene, self.background_color, self.samples, self.buffer = args else: self.camera = camera.Camera() self.scene = scene.Scene() self.background_color = glm.vec3(.0, .0, .0) self.samples = 1 self.buffer = buffer.Buffer()
def __init__(self, first_scene="title_screen", name="Adventure", reset_save=False): self.ui = ui.UI() self.name = name self.game_variables = {} self.dj = music.DJ(self, 0.8) self.background_dj = music.DJ(self, 0.1) self.save_path = pyglet.resource.get_settings_path(self.name) util.mkdir_if_absent(self.save_path) if reset_save: try: shutil.rmtree(os.path.join(self.save_path, "autosave")) except OSError: pass # Directory didn't exist but we don't care self.scene_handler = scenehandler.SceneHandler(self) scn = self.load() or scene.Scene(first_scene, self.scene_handler, self.ui) self.scene_handler.set_first_scene(scn) self.update = self.scene_handler.update
def __init__(self, input): self.has_errors = False self.scene = scene.Scene() self.input = input self.lexer = Lexer(input) self.parser = yacc.yacc(module=self) self.parser.parse(input, lexer=self.lexer.lexer)
def getScene(): """Return the global %scene instance.""" global _scene if _scene is None: import scene _scene = scene.Scene() return _scene
def init(self): self.moving = True self.s = scene.Scene(self.width, self.height, self.moving,"start", False) self.scores = [0,0] self.p1 = player.Player(0,0) self.goals = pygame.sprite.Group() self.goalsDrawn = False self.balls = pygame.sprite.Group()
def sanvenirtin(): # #convert_resource() app = QApplication(sys.argv) load_resources() game_scene = scene.Scene() window = interface.GameSceneInterface(game_scene) window.show() app.exec_()
def get_map_by_name(self, name): name = urllib.quote(name) req = urllib2.urlopen(self.base_url + "/maps/name/" + name) res_str = req.read() res_dict = json.loads(res_str) sc = scene.Scene(**res_dict) return sc
def getScene(): mhscene = None try: mhscene = G.app.getCategory('Rendering').getTaskByName( 'Scene').scene except: import scene mhscene = scene.Scene() return mhscene
def make_image(): numz = numerics.Numerics() my_scene = scene.Scene(WIDTH, HEIGHT, numerics=numz) pixels = my_scene.render_scene() img = PIL.Image.new(mode='RGB', size=(WIDTH, HEIGHT)) img.putdata(list(chain(*pixels))) img.save('scene.png')
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.setWindowTitle('OpenCMISS Control Centre') self.graphicsWindow = scene.Scene() self.setCentralWidget(self.graphicsWindow) self.createDocks() self.createActions() self.createMenus()
def init_singletons(): """ Initialize singleton classes and attach them direclty to our module""" global Scene global Mel import scene Scene = scene.Scene() import util Mel = util.Mel()
def get_maps_by_author(self, name): name = urllib.quote(name) req = urllib2.urlopen(self.base_url + "/maps/authorName/" + name) res_str = req.read() res_list = json.loads(res_str) scene_list = list() for scene_json in res_list: scene_list.append(scene.Scene(**scene_json)) return scene_list
def open(self): yaml_file = tkinter.filedialog.askopenfilename( title='Select OSD YAML FIle', filetypes=(("YAML files", "*.yaml"), ("all files", "*.*"))) if len(yaml_file) == 0: return s = scene.Scene(yaml_file) self._scenes = [s] self._root.geometry('%dx%d' % (s.width, s.height)) self._scene_index = 0 self._paint()
def build_test_case(self, name): """ Constructs the objects needed for a test and sets their global data, if any :param name: test case name """ self._curr_test = SimTestCase(name) self._curr_vhcl = vehicle.Vehicle() self._curr_scene = scene.Scene() self._curr_objs = [] self._set_globals()
def __init__(self): self.settings_marshaller = settings.SettingsMarshaller() self.settings = self.settings_marshaller.settings self.face_recognizer = face_recognizer.FaceRecognizer(self.settings) self.gtk_window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.gtk_window.connect("destroy", gtk.main_quit) self.gtk_window.connect("key_press_event", self.on_key_press_event) self.gtk_window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0, 0, 0)) self.gtk_fixed = gtk.Fixed() self.gtk_window.add(self.gtk_fixed) if self.settings.default_height is not None and self.settings.default_width is not None: self.gtk_window.set_default_size(self.settings.default_width, self.settings.default_height) self.gtk_window.fullscreen() self.gtk_fixed.show() self.gtk_window.show() self.screen_width, self.screen_height = self.gtk_window.get_size() self.gtk_drawing_area = gtk.DrawingArea() self.gtk_drawing_area.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0, 0, 0)) self.gtk_drawing_area.connect("expose_event", self.expose_event) self.gtk_drawing_area.connect("configure_event", self.configure_event) self.gtk_drawing_area.set_size_request(self.screen_width, self.screen_height) self.gtk_pixmap = None self.gtk_fixed.add(self.gtk_drawing_area) self.gtk_drawing_area.show() #self.pixbuf_animation_blue_bird_iter = gtk.gdk.PixbufAnimation('images/bluebird.gif').get_iter() self.scene = scene.Scene() self.settings_marshaller.default_if_none('background_image_width', self.screen_width) self.settings_marshaller.default_if_none('background_image_height', self.screen_height) self.settings_marshaller.default_if_none('left_pad', 0) self.settings_marshaller.default_if_none('top_pad', 0) self.settings_marshaller.default_if_none('showing_background_image', False) self.settings_marshaller.default_if_none('showing_face_rectangles', False) self.settings_marshaller.default_if_none('recognition_threshold', 80) self.settings_marshaller.save() self.camera = self.get_camera() self.background_thread = threading.Thread(target=self.background_work) self.background_thread.daemon = True self.kill_background = False self.recognizing_face = False self.pending_delete_training = False self.temporary_notice_timer = None self.temporary_notice = None
def __init__(self): self._running = True self._display_surf = None self.size = self.weight, self.height = 720, 720 self.background = pygame.Surface(self.size) self.scenes = ["some_path", "some_other_path", "etc_you_get_the_idea"] self.current_scene = scene.Scene(self.scenes[0], player.Player(), [ collectiblegameobject.CollectibleGameObject( "key.png", 50, 50, "Chujka", "Klucz do kurwy"), gameobject.GameObject("bed.png", 150, 150, "Luszko"), gameobject.GameObject("desk.png", 350, 300, "Dzwi") ]) self.font = pygame.font.Font("assets/BebasNeue.otf", 15)
def load(self, folder_name="autosave"): """Returns a scene if save existed and was loaded successfully""" base_path = os.path.join(self.save_path, folder_name) scn = self.scene_handler.scene if not os.path.exists(base_path): return None else: my_info = util.load_json(os.path.join(base_path, 'game')) self.game_variables = my_info['game_variables'] return scene.Scene(my_info['first_scene'], self.scene_handler, self.ui, load_path=os.path.join(base_path, my_info['first_scene']))
def start(): global platformscene, player disp = pygame.Surface((320, 240)) player = PlatformPlayer() platformscene = scene.Scene(disp) platformscene.add(player) del enemies[:] for i in range(20): angst(450 + 300 * i) for i in range(20): fear(300 + 300 * i) platformscene.bg_color = (200, 200, 200)
def main(): """Main loop""" # Inicia bibliotecas necessárias para o pygame pygame.init() # Cria uma tela de tamanho 800x600 game_display = pygame.display.set_mode((600, 500)) # Preenche o fundo da tela com a cor branca game_display.fill(pygbutton.WHITE) backgroundimage = pygame.image.load('matemática-1.jpg') music_win = pygame.mixer.music.load('gamewining.mp3') # backgroundimage = pygame.transform.scale(backgroundimage,(600, 500)) # Define o nome da janela pygame.display.set_caption("Arithmetic Game") cena1 = scene.Scene(game_display, 15, 7, ['2', '3', '4', '+', 'x']) # Solução = 2 * 4 +4 +3 cena2 = scene.Scene(game_display, 26, 9, ['2', '5', '4', '+', 'x', '(', ')']) cena3 = scene.Scene(game_display, 59, 9, ['2', '4', '6', '7', 'x', '+', '/']) cena4 = scene.Scene(game_display, 156, 6, ['7', '8', '6', '3', 'x', '/']) cena5 = scene.Scene(game_display, 63, 12, ['1', '2', '5', '3', 'x', '-', '/', '+', 'x', '(', ')']) cena6 = scene.Scene(game_display, 257, 19, ["(", ")", "8", "3", "1", "+", "-", "x"]) cenas = [] cenas.append(cena1) cenas.append(cena2) cenas.append(cena3) cenas.append(cena4) cenas.append(cena5) cenas.append(cena6) gamewin = endgame.GameWin(game_display, music_win) # loop principal do game fase = 0 proxima_fase = 0 while True: # percorre os eventos (clique do mouse, tecla pressionada, movimentar o mouse, etc.) for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() quit() if event.type in (pygame.MOUSEBUTTONDOWN, pygame.MOUSEBUTTONUP): proxima_fase += cenas[fase].handle_events(event) if proxima_fase > fase: fase = proxima_fase # Preenche a tela de branco try: game_display.fill(pygbutton.WHITE) game_display.blit(backgroundimage, [0, 0]) cenas[fase].build_scene() cenas[fase].write_calculator() except: gamewin.gamewin() time.sleep(5) fase = 0 proxima_fase = 0 # Atualiza a tela pygame.display.flip()
def loop(): sc = scene.Scene(game_state.WIDTH * 2, game_state.HEIGHT * 1.5) set_min_zoom(sc) scene.setup(sc) while game_state.RUNNING: clock.tick(game_state.FPS) dt = clock.get_time() / 100 sc.clear(game_state.surface) process_input() sc.update(dt) sc.render(game_state.surface) pygame.quit()
def __init__(self): """Конструктор. Инициализируем необходимые параметры""" self.root = tk.Tk() self.width = 800 self.height = 600 self.floor_height = 100 self.root.geometry(str(self.width) + 'x' + str(self.height)) self.canvas = tk.Canvas(self.root, bg='white') self.canvas.pack(fill=tk.BOTH, expand=1) self.scene = scene.Scene(self.canvas, self.width, self.height, self.floor_height) self.targets = targets.Targets(self.scene, target.Target(self.scene), target.Target(self.scene)) self.win_screen = self.canvas.create_text(self.width / 2, self.height / 2, text='', font='28') self.gun = gun_class.Gun(self.scene)
def spawn_scenes(self, rois, overlapping=0, sampling_rate=3): """ Creates the scenes by setting the ROIS (extrinsic parameter for the external reference system) Params: * rois: list([[x0, x1],[y0, y1]]) * overlapping: pixels of overlapping * sampling_rate: how many times the detector is deployed Return: None """ for roi in rois: self._scenes.append( Scene.Scene( ROI=roi, overlap=overlapping, detection_sampling=sampling_rate, settings=self._settings ) )
def __init__(self): glutInit(len(sys.argv), sys.argv) glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE) glutInitWindowSize(800, 600) glutCreateWindow('Dynamic Skybox') glutFullScreen() glutDisplayFunc(self.draw) glutMotionFunc(self.mouse_drag) glutKeyboardFunc(self.keyboard) glutMouseFunc(self.mouse_press) glutReshapeFunc(self.reshape) glutIdleFunc(self.idle) glClearColor(0.1, 0.2, 0.5, 1.0) glEnable(GL_DEPTH_TEST) glEnable(GL_BLEND) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) glShadeModel(GL_SMOOTH) glEnable(GL_NORMALIZE) glEnable(GL_LIGHTING) glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE) glEnable(GL_COLOR_MATERIAL) self.time = time.clock() self.screen_width = 1.0 self.shader = shader.Shader("./shaders/plain.vert", "./shaders/plain.frag") self.seed = random.uniform(0, 5000) self.last_mouse_pos = 0, 0 self.x_rotation = 0 self.y_rotation = 0 self.scene = scene.Scene() self.zoom = 0 self.fps = 60 self.idle_tick = 1.0 / self.fps self.scr_width = glutGet(GLUT_WINDOW_WIDTH) self.scr_height = glutGet(GLUT_WINDOW_HEIGHT) self.first_pass = postprocessing.PostProcessor( 1, 1, self.scr_width, self.scr_height, "./shaders/god_rays.vert", "./shaders/god_rays.frag") self.using_pp = False self.paused = False
def make_animation(): numz = numerics.Numerics() my_scene = scene.Scene(WIDTH, HEIGHT, numerics=numz) imgs = [] for (frame, pixels) in enumerate(my_scene.render_anim(FRAME_COUNT)): img = PIL.Image.new(mode='RGB', size=(WIDTH, HEIGHT)) img.putdata(list(chain(*pixels))) if frame == 0: seq = img else: imgs.append(img) print('Frame {}'.format(frame)) seq.save('scene.gif', include_color_table=True, save_all=True, append_images=imgs, duration=20, loop=100)
def run(largura, altura, cores_randomizadas, fator_de_randomizacao, entrada_camera, entrada_objeto, entrada_iluminacao): cam = Camera(entrada_camera) cena = scene.Scene(entrada_objeto, entrada_iluminacao) posicao_ilumi = cam.ver_coordenadas_sistema(cena.pl) cena.pl = posicao_ilumi for p in cena.pontos: cena.ver_coordenadas.append(cam.ver_coordenadas_sistema(p)) for t in cena.triangulos: p1, p2, p3 = cena.ver_coordenadas[t[0] - 1], cena.ver_coordenadas[ t[1] - 1], cena.ver_coordenadas[t[2] - 1] tr_normal = cam.get_normal_triangulo(p1, p2, p3) tr_normal = opVetores.normalizar(tr_normal) cena.triangulos_v_obj.append(Triangulo(p1, p2, p3, norm=tr_normal)) cena.pontos_normal[t[0] - 1] += tr_normal cena.pontos_normal[t[1] - 1] += tr_normal cena.pontos_normal[t[2] - 1] += tr_normal for i in range(len(cena.pontos_normal)): cena.pontos_normal[i] = opVetores.normalizar(cena.pontos_normal[i]) for vp in cena.ver_coordenadas: cena.coordenadas_tela.append(cam.converter_coordenadas(vp)) cena.zbuffer(largura, altura) cena.criar_triangulos_objeto() cena.rast_tela_triangulos(cores_randomizadas, fator_de_randomizacao) return cena