def __init__(self): self.scenes = [scn for scn in find_scenes()] assert self.scenes, "No Scene files found!" print("{} scenes imported: {}".format(len(self.scenes), self.scenes)) self.scene_index = -1 self.switch_scenes() scene.run(self, orientation=scene.LANDSCAPE)
def __init__(self): self.img2 = photos.pick_image() self.img = self.img2.convert('RGBA') #fix for current scene.load_pil_image() if self.img: self.picsize = scene.Size(*self.img.size) scene.run(self) else: print('Good bye!')
def __init__(self): self.text = raw_input('Text to insert in the picture [Hello]: ') or 'Hello' self.position = None self.fontnr = 0 # Helvetica self.colornr = 3 # red self.fontsize = 48.0 # 48 point self.img2 = photos.pick_image() self.img = self.img2.convert('RGBA') #fix for current scene.load_pil_image() self.picsize = scene.Size(*self.img.size) self.btn_height = 0 if self.img: scene.run(self, frame_interval=3) # save battery with less frame rates -> 3 = 20fps else: print('Good bye!')
def __init__(self): self.distance_old = 0.0 self.distance_new = 0.0 self.distance_abs = 0.0 self.reset = True self.zoom = 1.0 #no zoom self.zoom_min = 0.5 self.zoom_max = 5 self.zoom_speed = 3 self.img2 = photos.pick_image() self.img = self.img2.convert('RGBA') #fix for current scene.load_pil_image() if self.img: self.picsize = scene.Size(*self.img.size) scene.run(self) else: print('Good bye!')
def __init__(self): self.text = raw_input('Text to insert in the picture [Hello]: ') or 'Hello' self.position = None self.fontnr = 0 # Helvetica self.colornr = 3 # red self.fontsize = 48.0 # 48 point self.img = photos.pick_image() self.picsize = scene.Size(*self.img.size) if self.picsize.h > self.picsize.w: print('Sorry at the moment only landscape or square pictures are supported!') self.img = None self.picborder = None self.btn_height = 0 if self.img: scene.run(self) else: print('Good bye!')
def run(game, frame_delay=1): game.conf() if not gamepie.isPieSupported(game.gamepie): game = gamepie.ErrorPie( "Target GamePie version is not supported: %s" % game.gamepie) for module in __required__: setattr(gamepie, module, importlib.import_module("gamepie." + module)) if not "graphics" in __required__: # We need this module any way setattr(gamepie, "graphics", importlib.import_module("gamepie.graphics")) gamepie.graphics.setSetting("width", game.size[0]) gamepie.graphics.setSetting("height", game.size[1]) scene.run(PieScene(game), frame_interval=frame_delay)
def gui(self): """Spawn a GUI for the game. **Only works in Pythonista, on other platforms does nothing.""" from Phantom.constants import in_pythonista if in_pythonista: from Phantom.gui_pythonista.main_scene import MultiScene from Phantom.gui_pythonista.screen_main import ChessMainScreen from Phantom.gui_pythonista.screen_loading import ChessLoadingScreen from Phantom.gui_pythonista.screen_options import ChessOptionsScreen from Phantom.gui_pythonista.screen_promote import ChessPromoteScreen self.data['screen_main'] = ChessMainScreen(self) self.data['screen_load'] = ChessLoadingScreen() self.data['screen_options'] = ChessOptionsScreen(self) self.data['screen_promote'] = ChessPromoteScreen(self) self.data['main_scene'] = MultiScene(self.data['screen_load']) self.data['screen_main'].set_parent(self.data['main_scene']) self.data['screen_load'].set_parent(self.data['main_scene']) self.data['screen_options'].set_parent(self.data['main_scene']) self.data['screen_promote'].set_parent(self.data['main_scene']) self.data['main_scene'].switch_scene(self.data['screen_load']) import scene scene.run(self.data['main_scene'])
def run(self): scene.run(self.scene)
self.tmp_t = 0 def setup(self): pass def set_parent(self, p): self.parent = p self.parent.set_load_scene(self) def touch_began(self, touch): self.parent.did_begin() def draw(self): scene.background(0, 0, 0) scene.fill(1, 1, 1) x = screen_width / 2 s_y = screen_height / 2 + 100 d_y = s_y - 30 l_y = d_y - 75 scene.tint(0.32645,0.28306,0.93492) scene.text('PhantomChess version {}'.format(version), x=x, y=s_y, font_size=20.0) scene.tint(1, 1, 1) if debug: scene.text('Debugger set to level {}'.format(debug), x=x, y=d_y) for i, line in enumerate(short().splitlines()): scene.text(line, x=x, y=l_y - (i*20)) if __name__ == '__main__': scene.run(ChessLoadingScreen())
self.touch = touch self.t0 = self.t loc = touch.location self.spot_color = (loc.x / self.bounds.width, loc.y / self.bounds.height, .5) def touch_moved(self, touch): '''Record points and relative timing ''' self.touch = touch self.points.append(touch) self.timing.append(self.t - self.t0) def touch_ended(self, touch): '''instantiate a shapenode, and animate it''' self.touch = None self.spot = scene.ShapeNode(path=ui.Path.oval(0, 0, 100, 100), parent=self) self.spot.fill_color = self.spot_color self.spot.position = self.points[0].location actions = [] for i in range(len(self.points) - 1): duration = self.timing[i + 1] - self.timing[i] loc = self.points[i].location actions.append(scene.Action.move_to(*loc, duration)) self.spot.run_action( scene.Action.repeat_forever(scene.Action.sequence(actions))) s = MyScene() scene.run(s, show_fps=True)
elif title == "Resume Game": self.load_save() elif title == "Continue": if self.game.started: self.player.start_clock() # Override def update(self) -> None: try: if self.player == self.info_white.player: self.info_white.update_clock() else: self.info_black.update_clock() except AttributeError: # The info boxes were not created yet. pass # Override def pause(self) -> None: self.player.stop_clock() self.show_continue_menu() self.save_game() # Override def stop(self) -> None: self.pause() if __name__ == "__main__": scene.run(Main(), scene.PORTRAIT)
] def flatmap(fn, sequence): '''Map a list producing function over a collection and flatten the result into a single list''' return [ l for lists in [fn(item) for item in sequence] for l in lists ] def count_neighbors(cell, curr_gen): '''Given a position and a list of active positions, return count of active neighbors''' return sum((neigh in curr_gen) for neigh in map(wrap, get_neighbors(cell))) def wrap(position): '''Given any position, return a position that fits on the grid''' w, h = WIDTH, HEIGHT x, y = position return (x + w) % w, (y + h) % h def randomize(size): '''Given dimensions of screen, return list of random active positions''' w, h = size return [ (random.randint(0, w - 1), random.randint(0, h - 1)) for i in xrange(int((w * h) ** 0.5) * 2) ] if __name__ == '__main__': scene.run(MyScene())
def __init__(self): scene.run(self)
self.frame.x += self.dx * 2 # with a little hop if self.frame.y <= sup.y or ( self.frame.y + self.frame.h >= sup.y + sup.h): self.dy = -self.dy # change y direction self.frame.y += self.dy * 2 # with a little hop class FontSampleView(scene.Scene): def setup(self): self.frameCount = -1 def draw(self): self.frameCount += 1 if self.frameCount % 80 == 0: try: fontName = getFontName.next() print(fontName) self.add_layer(FontSampleLayer(fontName)) except StopIteration: pass scene.background(0, 0, 0) self.root_layer.update(self.dt) self.root_layer.draw() for theLayer in self.root_layer.sublayers: if isinstance(theLayer, FontSampleLayer): theLayer.move() if __name__ == "__main__": print('=' * 20) scene.run(FontSampleView())
self.frontq.text = self.frontq.text[:-1] elif event_type == 'enters': self.washq.text += '🚗' elif event_type == 'leaves': self.washq.text = self.washq.text[:-1] self.leaveq.text = '🚗' + self.leaveq.text if len(self.leaveq.text) > 16: self.leaveq.text = '' def update(self): if self.time_count >= (self.time_count_checkpoint): self.update_event_list() if self.time_count in self.event_dict: for e in self.event_dict[self.time_count]: self.process(self.time_count, e) self.time_count += 1 # Setup and start the simulation print('Carwash') print('Check out http://youtu.be/fXXmeP9TvBg while simulating ... ;-)') random.seed(RANDOM_SEED) # This helps reproducing the results # Create an environment and start the setup process env = simpy.Environment() env.process(setup(env, NUM_MACHINES, WASHTIME, T_INTER)) # Execute! #env.run(until=SIM_TIME) scene.run(MyScene(), frame_interval=10, show_fps=True)
def __init__(self): self.save_velocity_x = g_speed self.enemies = [random_particle() for i in xrange(g_number_of_enemies)] scene.run(self, scene.LANDSCAPE)
def main(): scene = Scene() ui.run(scene)
print("Back here") #============================== import ui, scene class scTest(scene.Scene): def pause(self): print('pause') def resume(self): print('resume') if False: scene.run(scTest()) else: v = ui.View() sv = scene.SceneView() sv.scene = scTest() #sv.hidden = True v.add_subview(sv) v.present('panel') #============================== import ui, scene def AmIBack(): global gbGone
def __init__(self): scene.run(self) # a self running scene
autoreverse=True, repeat=3) # alpha animation self.add_layer(self.rect1_layer) # touch handling self.circle2_layer = scene.Layer(self.circle2) self.add_layer(self.circle2_layer) def draw(self): scene.background(0, 0, 1) # 0,0,1 = blue self.rect1_layer.update(self.dt) # alpha animation self.rect1_layer.draw() # alpha animation #scene.fill(0,1,0) # 0,1,0 = green #scene.ellipse(*self.rect1) # *self.rect1 = self.rect1[0], ..., self.rect1[3] scene.fill(1, 0, 0) # 1,0,0 = red scene.ellipse(*self.circle2) def touch_began(self, touch): if touch.layer == self.rect1_layer: if self.circle2.x < self.size.w - 150: self.circle2.x += 50 if touch.layer == self.circle2_layer: if self.circle2.w == 50: self.circle2.w, self.circle2.h = 100, 100 else: self.circle2.w, self.circle2.h = 50, 50 scene.run(MyClass()) # Please change rect1 to circle1, but don't change the alpha animation. # Please animate the x and y scaling from 50 to 100 and back.
def __init__(self, start_scene): self.active_scene = start_scene() scene.run(self)
f(now) def touch_began(self, touch): self.player.touch_began(touch) def touch_moved(self, touch): x, y = touch.location self.player.run_action(Action.move_to(x, self.player.position.y)) def touch_ended(self, touch): self.player.touch_ended(touch) def check_collision(self, obj, others): if not isinstance(obj, GameObject): return for other in others: if not isinstance(other, GameObject): continue if obj.invisible: return if other.invisible: continue if obj is other: continue if obj.frame.intersects(other.frame): obj.collided_with(other) if __name__ == '__main__': scene.run(Game(), scene.PORTRAIT, show_fps=True, frame_interval=2)
# Scene0 import scene, sound class Scene0(scene.Scene): def __init__(self, main_scene=None): self.main_scene = main_scene def draw(self): scene.background(1, 0, 0) def touch_began(self, touch): sound.play_effect('Coin_1') self.main_scene.switch_scenes() if __name__ == '__main__': scene.run(Scene0())
class pt(SpriteNode): def __init__(self, **kargs): SpriteNode.__init__(self, 'plf:HudX', **kargs) self.scale = 0.5 class plot(SpriteNode): def __init__(self, **kargs): SpriteNode.__init__(self, **kargs) self.anchor_point = (0, 0) self.color = '#8989ff' class test(Scene): def setup(self): clip = EffectNode(parent=self) clip.crop_rect = (0, 0, self.size.x / 2, self.size.y / 2) pane = plot(parent=clip) pane.size = (self.size.x / 2, self.size.y / 2) clip.position = (50, 50) for x in (50, 100, 150, 200, 250, 300, 350, 400): p = pt(parent=pane) p.position = (x, x) if __name__ == '__main__': tst = test() run(tst)
pos = Coord(896, turn_y) size = Coord(scale_factor / 2, scale_factor / 2) scene.tint(1, 1, 1, 1) scene.image(self.turn_indicator_img, pos.x, pos.y, size.x, size.y) scene.tint(1, 1, 1, 1) if self.won: pos = Coord(self.size.w/2, self.size.h/2) scene.tint(0.32645,0.28306,0.93492) # commented out until the bug in ChessGame.is_won() is fixed to be # less annoying scene.text('{} wins'.format(self.won), x=pos.x, y=pos.y, font_size=40.0) scene.tint(1, 1, 1, 1) # Buttons scene.text('AI Easy', x=scale_factor/2, y=scale_factor*6 - scale_factor/2) scene.text('AI Hard', x=scale_factor/2, y=scale_factor*5 - scale_factor/2) scene.text('Get score', x=scale_factor/2, y=scale_factor*4 - scale_factor/2) if self.disp_score: scene.text(str(self.pos_score), x=scale_factor/2, y=scale_factor*4 - scale_factor/1.5) scene.text('Undo', x=scale_factor/2, y=scale_factor*3 - scale_factor/2) scene.text('Deselect', x=scale_factor/2, y=scale_factor*2 - scale_factor/2) scene.text('Options', x=scale_factor/2, y=scale_factor*7 - scale_factor/2) if __name__ == '__main__': from Phantom.core.game_class import ChessGame, loadgame game = ChessGame() #loadgame('Long Endgame 1') game.board.cfg.disp_sqrs = True s = ChessMainScreen(game) scene.run(s)
self.reset_color(self.alive) SEED = randint(1, 9) self.game_setup() self.draw_stage() def time(self, dt): self.life_time += dt if self.life_time > self.life_speed: self.next_turn() self.draw_stage() self.life_time = 0.0 class MyScene(scene.Scene): def setup(self): self.life = Life(self) def update(self): self.life.time(self.dt) def touch_began(self, touch): self.life.reset_game() main = MyScene() scene.run( main, #orientation=1, frame_interval=0, #2, show_fps=True)
except: wx=wy=wz=sx=sy=sz=.5 ue=(-wx,-wy,-wz) un=(sx,sy,sz) uu=(-gx,-gy,-gz) physvert=[None for i in range(8)] for j in range(8): i=cvert[j] cx=i[0]*ue[0]+i[1]*un[0]+i[2]*uu[0] cy=i[0]*ue[1]+i[1]*un[1]+i[2]*uu[1] cz=i[0]*ue[2]+i[1]*un[2]+i[2]*uu[2] physvert[j]=[cx,cy,cz] faces=((2,3,6,7,'#ff6060'),(0,1,4,5,'#a00000'),(0,3,4,7,'#60ff60'),(1,2,5,6,'#00a000'),(0,1,3,2,'#6060ff'),(4,5,7,6,'#0000a0')) faceord=sorted([0,1,2,3,4,5],key=lambda t: sum([physvert[n][2] for n in faces[t][:4]])) visvert=[] D=4*self.size.width*.5/(.61*19.8) centx,centy=self.size/2 for i in physvert: x,y,z=i rad=D*20/(65-z) visvert.append((rad*x+centx,rad*y+centy)) for i in faceord: scene_drawing.fill(faces[i][4]) scene_drawing.triangle_strip([visvert[j] for j in faces[i][:4]]) def stop(self): stop_updates() if __name__=='__main__': scene.run(quubcam(),scene.PORTRAIT,show_fps=True)
import scene class MyClass(scene.Scene): def draw(self): # this method draws 60 times per second the blue background, if you don't change it scene.background(0,0,1) # 0,0,1 = blue scene.run(MyClass())
# Scene2 import scene, sound class Scene2(scene.Scene): def __init__(self, main_scene=None): self.main_scene = main_scene def draw(self): scene.background(0, 0, 1) def touch_began(self, touch): sound.play_effect('Clank') if self.main_scene: self.main_scene.switch_scenes() if __name__ == '__main__': scene.run(Scene2())
from functools import partial import random class TextAnimate(scene.Scene): def setup(self): #self.label_text = 'ABCDEFGHIJKLMNOPQR' self.label_text = 'abcdefghijklmnopqrstuvwxyz' length = len(self.label_text) center = self.bounds.center() self.font_size = 60 self.pixel_size = .6*self.font_size self.main_node = scene.Node(position=(center[0]-length/2.0*self.pixel_size, center[1]), parent=self) self.label_node = [None]*len(self.label_text) self.pos1 = [None]*len(self.label_text) self.pos2 = [None]*len(self.label_text) for i in range(len(self.label_text)): self.pos1[i] = (800*random.random()+100, 600*random.random()-300) self.pos2[i] = (self.pixel_size*i*1.0, 0.0) A = scene.Action for i in range(len(self.label_text)): self.label_node[i] = scene.LabelNode(self.label_text[i], font=('Courier', self.font_size), position=self.pos1[i], parent=self.main_node) animate_action = A.repeat(A.sequence( A.move_to(self.pos2[i][0], self.pos2[i][1], 8), A.move_to(self.pos1[i][0], self.pos1[i][1], 8)), 0) self.label_node[i].run_action(animate_action) scene.run(TextAnimate())
import scene class MyClass(scene.Scene): def draw(self): # this method draws now 20 times per second the blue background scene.background(0,0,1) # 0,0,1 = blue scene.run(MyClass(), frame_interval=3) # 60 / 3 = 20fps -> see scene.run(...) for more details
self.middle_x = self.size.x / 2 def check_collision(self): if self.cactuses.check_collision(self.dino.left_buttom_coord, self.dino.size): self.dino.is_dead = True self.dino.update() self.paused = True def update(self): self.dino.update() self.grounds.update() self.clouds.update() self.cactuses.update() self.score_boards.update() self.check_collision() def touch_began(self, touch): if touch.location.x < self.middle_x: self.dino.start_jump() else: self.dino.start_duck() def touch_ended(self, touch): self.dino.end_duck() scene.run(MyScene(), scene.PORTRAIT)
self.first_touch = touch def touch_moved(self, touch): pass def touch_ended(self, touch): old = self.first_touch.location new = touch.location if abs(old - new) < 30: if touch.location in self.score_board.frame: self.show_menu() else: if abs(old.x - new.x) > abs(old.y - new.y): if old.x - new.x > 0: self.move(WEST) else: self.move(EAST) else: if old.y - new.y > 0: self.move(NORTH) else: self.move(SOUTH) if not self.board.can_move() and touch.location in self.board.bbox: self.delay( 0.2, lambda: self.present_modal_scene( MenuScene('Game Over', 'Play again?', ['New Game']))) if __name__ == '__main__': scene.run(GameScene(), scene.PORTRAIT, show_fps=True)
# Scene1 import scene, sound class Scene1(scene.Scene): def __init__(self, main_scene=None): self.main_scene = main_scene def draw(self): scene.background(0, 1, 0) def touch_began(self, touch): sound.play_effect('Beep') if self.main_scene: self.main_scene.switch_scenes() if __name__ == '__main__': scene.run(Scene1())
print(fmt.format('Thread.__init__:', self.fgColor)) def run(self): print(fmt.format('Thread scene starts:', self.fgColor)) #scene.run(MyScene(self.fgColor)) for i in xrange(5): # interrupted sleep time.sleep(1) scene.run(MyScene(self.fgColor)) # Delayed 5 seconds print(fmt.format('Thread scene ends:', self.fgColor)) print('=' * 12) print('Main starts.') # Create three Scenes in Threads but delay calling run() theThreads = [ThreadClass(theColor) for theColor in theColors] for theThread in theThreads: theThread.start() for theColor in theGreys: print(fmt.format('Main scene start:', theColor)) theScene = MyScene(theColor) scene.run(theScene) print(fmt.format('Main scene end:', theColor)) print(threading.active_count()) for theThread in theThreads: print(threading.active_count()) theThread.join() print('Main ends.')
else : y=r[self.idx%Nr].data() # start idx, stop idx+1 r[self.idx%Nr].record() #stop recorder a few samples before im ready to read it lookaheadidx=self.idx+1+int(0.25//(T/(Nr-1))) r[lookaheadidx%Nr].stop() self.idx+=1 if len(y)==0: return for i,n in enumerate(self.v): iy=int(i/Np*len(y)) n.position=(i/Np*W,y[iy]*H+H/2) def did_stop(self): print 'stopping' #raise Error() self['n'][0].remove_all_actions() [rec.stop() for rec in r] ui.delay(cleanup,0.25) # the scene seems to crash when restarting, unless we raise an error here raise KeyboardInterrupt #sc=Vis(dofft=True) sc=Vis(dofft=False) sc.shows_fps=True sc.shows_node_count=True scene.run(sc)
# https://forum.omz-software.com/topic/4098/possible-to-resize-spritenode-image/2 # @ omz I'd recommend setting the scale attribute. Setting the size (as @ccc has shown) would also work, but you would need to set it again when you change the texture of a sprite. # It might actually be easier to set the scale of the entire scene instead of scaling each card individually. import scene class MyScene(scene.Scene): def setup(self): scene.SpriteNode('card:BackBlue2', parent=self, position=(100, 130)) scene.SpriteNode('card:BackRed2', parent=self, position=(300, 220), size=(240, 380)) if __name__ == '__main__': scene.run(MyScene())
p.line_to(0.08*6000,20) self.chart_clk.path=p p=scene.ui.Path() p.move_to(0,20) for a in [(t*6000,(1-y)*20) for t,y in rc_filter(gen_pwl(generate_pw((list(d3.items())[j*3+i][1]))))]: p.line_to(*a) p.line_to(0.08*6000,20) self.chart_dat.path=p for x in generate_signal((list(d3.items())[j*3+i][1])): # print(x) for IR,led in self.IR_Receivers: IR.clk,IR.rx=(x[0]^1,x[1]^1) for IR,led in self.IR_Receivers: led.fill_color=('darkgreen','lightgreen')[IR.D7] IR1=IrRemote() scene.run(IR1,scene.LANDSCAPE,show_fps=True) #runTests() #testStateMachine(codes= ( d2['KEY_NEXT'],d2['KEY_PLAYPAUSE'],d2['KEY_NEXT'],d2['KEY_PLAYPAUSE']) ) #testStateMachine(fbp=10,ba=0b100001<<7)#+ #testStateMachine(fbp=10,ba=0b010001<<7)#+ #testStateMachine(fbp=10,ba=0b000000<<7)#+ #testStateMachine(fbp= 7,ba=0b101000<<7)#+ #testStateMachine(fbp= 7,ba=0b011000<<7)#+ #testStateMachine(fbp= 7,ba=0b000000<<7)#+ #testStateMachine(fbp=11,ba=0b001001<<7)#+ #testStateMachine(fbp=11,ba=0b000000<<7)#+ #with open('IR_Remote_a.bin','wb') as f: f.write(bytes(g));f.close()
def __init__(self): scene.run(self, scene.LANDSCAPE)
im = scene.load_image_file('white_rectangle_512_512.png') self.sprite_node = scene.SpriteNode(im, position=(400,400), size=(96, 64), parent=self) self.sprite_node.shader = scene.Shader(fragment_shader_text) def key_down(self, key): if key.key_val == pyglet.window.key.RIGHT: self.sprite_node.position = ((self.sprite_node.position[0]+10)%self.size[0], self.sprite_node.position[1]) elif key.key_val == pyglet.window.key.LEFT: self.sprite_node.position = ((self.size[0]+self.sprite_node.position[0]-10)%self.size[0], self.sprite_node.position[1]) elif key.key_val == pyglet.window.key.UP: self.sprite_node.position = (self.sprite_node.position[0], (self.sprite_node.position[1]+10)%self.size[1]) elif key.key_val == pyglet.window.key.DOWN: self.sprite_node.position = (self.sprite_node.position[0], (self.size[0]+self.sprite_node.position[1]-10)%self.size[1]) #else: # self.label.text = "Key pressed %s" % chr(key.key_val) def touch_began(self, touch): self.sprite_node.position = touch.location def touch_moved(self, touch): self.sprite_node.position = touch.location scene.run(MyScene(screen_width=800, screen_height=800))
self.value = 'play' self.msg = 'Play ' self.label.text = self.msg class MyScene(scene.Scene): def initialize(self): self.state.initialize() self.gridofblocks.initialize() def setup(self): self.state = State(position=(self.size[0] / 2, 50), parent=self) self.gridofblocks = NQueenGridOfBlocks(8, 8, position=(self.size[0] / 2, self.size[1] / 2), size=(8 * 64, 8 * 64), parent=self, font_name='arialms', color=(0, 255, 0, 255)) self.initialize() def touch_began(self, touch): if self.state.value == 'win' or self.state.value == 'lose': self.initialize() return self.gridofblocks.touch_began(touch) scene.run(MyScene(), show_fps=True)
def __init__(self): self.text = '' scene.run(self)
def __init__(self): # This scene runs itself scene.run(self, frame_interval=15) # Lower the FPS
def __init__(self): self.current_animal = None self.score = 0 scene.run(self)
def run(self): scene.run(self)
def animate(wall, *args, **kwargs): anim = Scene() anim.do_setup(wall) scene.run(anim, *args, **kwargs)
# Dead check if player1['HP'] <= 0: # Signaliserer at et av spillerene er døde self.critHit.text = '' self.Game_Over = True self.wintext = scene.LabelNode( '{} (Player 2) wins'.format(player2['name']), font=('Avenir', 100), color='#000', position=(self.size.w / 2, (self.size.h / 2) - 25), parent=self) sys.exit() if player2['HP'] <= 0: self.critHit.text = '' self.Game_Over = True self.wintext = scene.LabelNode( '{} (Player 1) wins'.format(player1['name']), font=('Avenir', 100), color='#000', position=(self.size.w / 2, (self.size.h / 2) - 25), parent=self) sys.exit() #print(DMGcalc(playablecharacters[0], playablecharacters[0], 'Normal Attack')) #print(scene.get_screen_size()) #1080 810 scene.run(mainScene())
def __init__(self): scene.run(self, frame_interval=0)
# https://forum.omz-software.com/topic/3754/show-all-scene-child-nodes/4 import scene from math import pi ''' Trying to create a rotating earth in an eliptical orbit around the sun. ''' class SolorSystemScene(scene.Scene): def setup(self): center = self.bounds.center() sun = scene.SpriteNode('emj:Sun_1', position=center, parent=self) earth_anchor = scene.Node(position=center, parent=self) earth = scene.SpriteNode('emj:Moon_5', position=(0, 150)) earth_anchor.add_child(earth) A = scene.Action self_rotate_action = A.repeat( A.sequence(A.rotate_to(-20 * pi, 5), A.rotate_to(0, 0), 0), 0) earth.run_action(self_rotate_action) rotate_action = A.repeat( A.sequence(A.rotate_to(-20 * pi, 20), A.rotate_to(0, 0), 0), 0) earth_anchor.run_action(rotate_action) scene.run(SolorSystemScene())
def __init__(self, event_name, event_date): self.event_name = event_name self.event_date = event_date scene.run(self)
self.first_touch = touch def touch_moved(self, touch): pass def touch_ended(self, touch): old = self.first_touch.location new = touch.location if abs(old - new) < 30: if touch.location in self.score_board.frame: self.show_menu() else: if abs(old.x - new.x) > abs(old.y - new.y): if old.x - new.x > 0: self.move(WEST) else: self.move(EAST) else: if old.y - new.y > 0: self.move(NORTH) else: self.move(SOUTH) if not self.board.can_move() and touch.location in self.board.bbox: self.delay(0.2, lambda: self.present_modal_scene( MenuScene('Game Over', 'Play again?', ['New Game'])) ) if __name__ == '__main__': scene.run(GameScene(), scene.PORTRAIT, show_fps=True)
fall = False else: fall = True self.run_action(sc.Action.call(self.player_dead)) def player_dead(self): # If any of the conditions for the end of the game are satisfied, the player simply drops off the screen, and after 2 seconds, a new game is started. self.game_over = True sound.play_effect('arcade:Explosion_1') self.player.texture = dead_texture self.player.run_action(sc.Action.move_by(0, -self.size.h)) # Note: The duration of the `wait` action is multiplied by the current game speed, so that it always takes exactly 2 seconds, regardless of how fast the rest of the game is running. self.run_action( sc.Action.sequence(sc.Action.wait(2 * self.speed), sc.Action.call(self.new_game))) # When a touch is applied to the screen, a laser is shot from the player. def touch_began(self, touch): laser = sc.SpriteNode('spc:LaserBlue9', position=self.player.position, z_position=-1, parent=self) laser.run_action( sc.Action.sequence(sc.Action.move_by(0, 1000), sc.Action.remove())) self.lasers.append(laser) sound.play_effect('arcade:Laser_1') if __name__ == '__main__': sc.run(Game(), sc.PORTRAIT, show_fps=True)
from scene import Scene, run from map_loader import MapLoader class Main(Scene): def setup(self): MapLoader.store_maps(self) MapLoader.load_map(self, 'map0') self.player = MapLoader.get_player(self) def update(self): self.player.update() if __name__ == '__main__': run(Main(), show_fps=True)
for( int j=0; j<2; j++ ) for( int i=0; i<2; i++ ) { vec2 of = -0.5 + vec2( float(i), float(j) ) / 2.0; of = (of/iResolution.xy); scol += calc(uv+of, iGlobalTime ); } scol *= 0.25; #endif vec3 vcol = pow( vec3(scol), vec3(0.9,1.1,1.4) ); vcol *= 0.7 + 0.3*pow(16.0*uv.x*uv.y*(1.0-uv.x)*(1.0-uv.y),0.25); gl_FragColor = vec4( vcol, 1.0 ); } """ class MyScene (scene.Scene): def setup(self): im = scene.load_image_file('snake.png') self.sprite = scene.SpriteNode(im, size=(512, 512), parent=self) self.sprite.shader = scene.Shader(shader_text) self.sprite.position = (self.size[0]/2.0, self.size[1]/2.0) scene.run(MyScene(), show_fps=True)
def setup(self): pass def touch_began(self, touch): if self.parent: self.parent.did_begin() def draw(self): scene.background(0, 0, 0) scene.fill(1, 1, 1) x, y = self.bounds.center() #print(self.bounds) s_y = y + 100 d_y = s_y - 30 l_y = s_y - 75 scene.tint(0.32645, 0.28306, 0.93492) scene.text('PhantomChess version {}'.format(C.version), x=x, y=s_y, font_size=20.0) scene.tint(1, 1, 1) if C.debug: scene.text('Debugger set to level {}'.format(C.debug), x=x, y=d_y) for i, line in enumerate(short().splitlines()): scene.text(line, x=x, y=l_y - (i * 20)) if __name__ == '__main__': scene.run(ChessLoadingScreen(), orientation=scene.LANDSCAPE)