def run(self): g.init() if not self.journal: utils.load() self.chess=chess.Chess() g.cells=self.chess.cells load_save.retrieve() self.chess.setup() # having retrieved layout if any self.buttons_setup() if self.canvas<>None: self.canvas.grab_focus() ctrl=False pygame.key.set_repeat(600,120); key_ms=pygame.time.get_ticks() going=True while going: if self.journal: # Pump GTK messages. while gtk.events_pending(): gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type==pygame.QUIT: if not self.journal: utils.save() going=False elif event.type == pygame.MOUSEMOTION: g.pos=event.pos g.redraw=True if self.canvas<>None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw=True if event.button==1: if self.do_click(): pass else: bu=buttons.check() if bu!='': self.do_button(bu); self.flush_queue() elif event.type == pygame.KEYDOWN: # throttle keyboard repeat if pygame.time.get_ticks()-key_ms>110: key_ms=pygame.time.get_ticks() if ctrl: if event.key==pygame.K_q: if not self.journal: utils.save() going=False; break else: ctrl=False if event.key in (pygame.K_LCTRL,pygame.K_RCTRL): ctrl=True; break self.do_key(event.key); g.redraw=True self.flush_queue() elif event.type == pygame.KEYUP: ctrl=False if not going: break if g.redraw: self.display() if g.version_display: utils.version_display() g.screen.blit(g.pointer,g.pos) pygame.display.flip() g.redraw=False self.update() g.clock.tick(40)
def run(self): g.init() if not self.journal: utils.load() self.board = sud.Board() self.board.setup() load_save.retrieve() self.board.check() self.buttons_setup() if self.journal: # Sugar only a, b, c, d = pygame.cursors.load_xbm('my_cursor.xbm', 'my_cursor_mask.xbm') pygame.mouse.set_cursor(a, b, c, d) going = True while going: # Pump GTK messages. while gtk.events_pending(): gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: # only in standalone version if not self.journal: utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.redraw = True if self.canvas <> None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True if event.button == 2: # centre button if not self.journal: g.version_display = not g.version_display if event.button == 1: bu = buttons.check() if bu != '': self.do_button(bu) elif not g.finished: if not self.help_check(): self.board.click() if g.finished: buttons.on('new') buttons.off('reset') if event.button == 3: if not g.finished: self.board.right_click() if not going: break if g.redraw: self.display() if g.version_display: utils.version_display() #g.screen.blit(g.pointer,(g.mx,g.my)) pygame.display.flip() g.redraw = False self.count = g.count tf = False if pygame.mouse.get_focused(): tf = True pygame.mouse.set_visible(tf) g.clock.tick(40)
def run(self): g.init() if not self.journal: utils.load() self.oms = [] for n in range(3, 8): omm = om.Om(n) omm.setup() self.oms.append(omm) load_save.retrieve() self.omm = self.oms[g.level - 1] self.buttons_setup() self.slider = slider.Slider(g.sx(10.5), g.sy(20), 5, utils.YELLOW) going = True while going: # Pump GTK messages. while gtk.events_pending(): gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: # only in standalone version if not self.journal: utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.pos = event.pos self.omm.mouse_move() g.redraw = True if self.canvas <> None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True if event.button == 2: # centre button if not self.journal: g.version_display = not g.version_display if event.button == 1: if self.do_click(): pass elif self.slider.mouse(): # level changed self.omm = self.oms[g.level - 1] else: bu = buttons.check() if bu != '': self.do_button(bu) if event.button == 3: # right button self.do_button('try') elif event.type == pygame.KEYDOWN: self.do_key(event.key) g.redraw = True if not going: break if g.redraw: self.display() if not self.journal: # not on XO if g.version_display: utils.version_display() g.screen.blit(g.pointer, g.pos) pygame.display.flip() g.redraw = False g.clock.tick(40)
def run(self): g.init() if not self.journal: utils.load() load_save.retrieve() g.puzzle_n=g.solved if g.puzzle_n==10: g.puzzle_n=0 iq1.init(); iq1.setup() if self.canvas<>None: self.canvas.grab_focus() ctrl=False pygame.key.set_repeat(600,120); key_ms=pygame.time.get_ticks() going=True while going: if self.journal: # Pump GTK messages. while Gtk.events_pending(): Gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type==pygame.QUIT: if not self.journal: utils.save() going=False elif event.type == pygame.MOUSEMOTION: g.pos=event.pos g.redraw=True if self.canvas<>None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw=True if event.button==1: self.do_click(); self.flush_queue() elif event.type == pygame.KEYDOWN: # throttle keyboard repeat if pygame.time.get_ticks()-key_ms>110: key_ms=pygame.time.get_ticks() if ctrl: if event.key==pygame.K_q: if not self.journal: utils.save() going=False; break else: ctrl=False if event.key in (pygame.K_LCTRL,pygame.K_RCTRL): ctrl=True; break self.do_key(event.key); g.redraw=True self.flush_queue() elif event.type == pygame.KEYUP: ctrl=False if not going: break if g.redraw: self.display() if g.version_display: utils.version_display() g.screen.blit(g.pointer,g.pos) pygame.display.flip() g.redraw=False iq1.complete() if g.finished and not g.redrawn: g.redraw=True; g.redrawn=True g.clock.tick(40)
def run(self): g.init() self.grid = grid.Grid(8, 8, g.sy(2.4), 2, (212, 212, 175), utils.CREAM, g.x0, g.y0) if not self.journal: utils.load() # setup before retrieve self.grid.setup() load_save.retrieve() self.buttons_setup() going = True while going: # Pump GTK messages. while gtk.events_pending(): gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: # only in standalone version if not self.journal: utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.pos = event.pos self.grid.check_mouse() g.redraw = True if self.canvas <> None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True if event.button == 2: # centre button if not self.journal: g.version_display = not g.version_display if event.button == 3: g.ms = None self.grid.right_click() if event.button == 1: g.ms = None if self.do_click(): pass else: bu = buttons.check() if bu != '': self.do_button(bu) elif event.type == pygame.KEYDOWN: g.ms = None self.do_key(event.key) g.redraw = True if not going: break self.glow() if g.redraw: self.display() if not self.journal: # not on XO if g.version_display: utils.version_display() g.screen.blit(g.pointer, g.pos) pygame.display.flip() g.redraw = False g.clock.tick(40)
def run(self): for event in pygame.event.get(): if event.type==pygame.QUIT: return elif event.type == pygame.VIDEORESIZE: pygame.display.set_mode(event.size, pygame.RESIZABLE) break g.init() if not self.journal: utils.load() self.acr=acr.Acr() load_save.retrieve() self.buttons_setup() if self.canvas<>None: self.canvas.grab_focus() ctrl=False pygame.key.set_repeat(600,120); key_ms=pygame.time.get_ticks() going=True while going: if self.journal: # Pump Gtk messages. while Gtk.events_pending(): Gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type==pygame.QUIT: if not self.journal: utils.save() going=False elif event.type == pygame.MOUSEMOTION: g.pos=event.pos g.redraw=True if self.canvas<>None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: self.acr.message=None g.redraw=True if event.button==1: if g.help_on: g.help_on=False elif self.do_click(): pass else: bu=buttons.check() if bu!='': self.do_button(bu); self.flush_queue() if event.button==3: g.help_on=not g.help_on elif event.type == pygame.KEYDOWN: if event.key not in g.CIRCLE: g.help_on=False self.acr.message=None # throttle keyboard repeat if pygame.time.get_ticks()-key_ms>110: key_ms=pygame.time.get_ticks() if ctrl: if event.key==pygame.K_q: if not self.journal: utils.save() going=False; break else: ctrl=False if event.key in (pygame.K_LCTRL,pygame.K_RCTRL): ctrl=True; break self.do_key(event.key); g.redraw=True self.flush_queue() elif event.type == pygame.KEYUP: ctrl=False if not going: break self.acr.update() if g.redraw: self.display() if g.version_display: utils.version_display() g.screen.blit(g.pointer,g.pos) pygame.display.flip() g.redraw=False g.clock.tick(40)
def run(self): g.init() if not self.journal: utils.load() g.grid.setup() load_save.retrieve() bx = g.sx(3.3) by = g.sy(9) buttons.Button("cyan", (bx, by), True) buttons.off("cyan") if self.canvas <> None: self.canvas.grab_focus() ctrl = False pygame.key.set_repeat(600, 120) key_ms = pygame.time.get_ticks() going = True while going: if self.journal: # Pump GTK messages. while gtk.events_pending(): gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: if not self.journal: utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.pos = event.pos g.redraw = True if self.canvas <> None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True if event.button == 1: if self.click(): self.flush_queue() break bu = buttons.check() if bu <> '': g.result = None g.state = 0 g.grid.setup() buttons.off("cyan") self.flush_queue() break elif event.type == pygame.KEYDOWN: # throttle keyboard repeat if pygame.time.get_ticks() - key_ms > 110: key_ms = pygame.time.get_ticks() if ctrl: if event.key == pygame.K_q: if not self.journal: utils.save() going = False break else: ctrl = False if event.key in (pygame.K_LCTRL, pygame.K_RCTRL): ctrl = True break self.do_key(event.key) g.redraw = True self.flush_queue() elif event.type == pygame.KEYUP: ctrl = False if not going: break self.process() g.grid.update() if g.redraw: self.display() if g.version_display: utils.version_display() g.screen.blit(g.pointer, g.pos) pygame.display.flip() g.redraw = False g.clock.tick(40)
def run(self): g.init() if not self.journal: utils.load() my_turtle2.cls() load_save.retrieve() self.buttons_setup() if self.canvas <> None: self.canvas.grab_focus() ctrl = False pygame.key.set_repeat(600, 120) key_ms = pygame.time.get_ticks() going = True while going: if self.journal: # Pump GTK messages. while gtk.events_pending(): gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: # only in standalone version if not self.journal: utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.pos = event.pos g.redraw = True if self.canvas <> None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True if event.button == 1: if self.do_click(): my_turtle2.do_towards() else: bu = buttons.check() if bu != '': self.do_button(bu) if event.button == 3: # right click self.check_panelr(False) my_turtle2.do_towards() self.flush_queue() elif event.type == pygame.KEYDOWN: # throttle keyboard repeat if pygame.time.get_ticks() - key_ms > 110: key_ms = pygame.time.get_ticks() if ctrl: if event.key == pygame.K_q: if not self.journal: utils.save() going = False break else: ctrl = False if event.key in (pygame.K_LCTRL, pygame.K_RCTRL): ctrl = True break self.do_key(event.key) g.redraw = True self.flush_queue() elif event.type == pygame.KEYUP: ctrl = False if not going: break if g.running: my_turtle2.do() if g.redraw: self.display() if g.version_display: utils.version_display() if g.carry_ind != None: utils.centre_blit(g.screen, g.turtles[g.carry_ind].img, g.pos) g.screen.blit(g.pointer, g.pos) pygame.display.flip() g.redraw = False g.clock.tick(40)
def run(self): g.init() if not self.journal: utils.load() g.xo = False load_save.retrieve() self.toc = layout.toc() self.layout = layout.Layout(g.w - 2 * g.offset, int(g.h * 19 / 24)) self.render() self.jig = jig.Jig() self.buttons_setup() if self.canvas <> None: self.canvas.grab_focus() ctrl = False pygame.key.set_repeat(600, 120) key_ms = pygame.time.get_ticks() going = True while going: if self.journal: # Pump GTK messages. while gtk.events_pending(): gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: if not self.journal: utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.pos = event.pos g.redraw = True if self.canvas <> None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True if event.button == 1: bu = '' if self.bu == None: bu = buttons.check() if bu != '': self.do_button(bu) self.flush_queue() else: self.do_click() elif event.type == pygame.KEYDOWN: # throttle keyboard repeat if pygame.time.get_ticks() - key_ms > 110: key_ms = pygame.time.get_ticks() if ctrl: if event.key == pygame.K_q: if not self.journal: utils.save() going = False break else: ctrl = False if event.key in (pygame.K_LCTRL, pygame.K_RCTRL): ctrl = True break self.do_key(event.key) g.redraw = True self.flush_queue() elif event.type == pygame.KEYUP: ctrl = False if not going: break if self.layout.movie != None: self.layout.movie.update() self.update() if g.redraw: self.display() if g.version_display: utils.version_display() g.screen.blit(g.pointer, g.pos) pygame.display.flip() g.redraw = False g.clock.tick(40)
def run(self, restore=False): self.g_init() if not self.journal: utils.load() load_save.retrieve() if restore: self.restore_pattern() else: g.delay = (3 - g.level) * 400 self.tu = my_turtle.TurtleClass() self.tu.current = [1, 1, 1, 3, 2] self.get_goal() if g.pattern == 1: self.tu.current = utils.copy_list(g.goal) self.tu.setup(self.colors[0]) g.numbers = utils.copy_list(self.tu.current) #buttons x = g.sx(7.3) y = g.sy(16.5) dx = g.sy(2.6) if not self.sugar: buttons.Button("cyan", (x, y), True) x += dx buttons.off('cyan') buttons.Button("green", (x, y), True) x += dx buttons.Button("red", (x, y), True) x += dx buttons.Button("black", (x, y), True) x += dx self.slider = slider.Slider(g.sx(23.5), g.sy(21), 3, utils.YELLOW) self.mouse_1st_no() # to 1st number if self.canvas is not None: self.canvas.grab_focus() ctrl = False pygame.key.set_repeat(600, 120) key_ms = pygame.time.get_ticks() going = True while going: if self.journal: # Pump GTK messages. while gtk.events_pending(): gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: if not self.journal: utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.pos = event.pos g.redraw = True if self.canvas is not None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True if g.big: g.big = False else: bu = buttons.check() if bu != '': self.do_button(bu) self.flush_queue() elif not self.sugar: if utils.mouse_on_img1(g.magician, g.magician_c): self.help2() elif utils.mouse_in(g.x1, g.y0, g.x1 + g.bw, g.y0 + g.bw): self.big_pic() elif self.slider.mouse(): g.delay = (3 - g.level) * 400 else: g.show_help = False self.check_nos(event.button) else: g.show_help = False self.check_nos(event.button) elif event.type == pygame.KEYDOWN: # throttle keyboard repeat if pygame.time.get_ticks() - key_ms > 110: key_ms = pygame.time.get_ticks() if ctrl: if event.key == pygame.K_q: if not self.journal: utils.save() going = False break else: ctrl = False if event.key in (pygame.K_LCTRL, pygame.K_RCTRL): ctrl = True break self.do_key(event.key) g.redraw = True self.flush_queue() elif event.type == pygame.KEYUP: ctrl = False if not going: break if self.tu.running: self.tu.move() if not g.crash_drawn: g.crash_drawn = True g.redraw = True if g.redraw: self.display() if g.version_display: utils.version_display() g.screen.blit(g.pointer, g.pos) pygame.display.flip() g.redraw = False g.clock.tick(40)
def run(self, restore=False): self.black = False for event in pygame.event.get(): if event.type == pygame.QUIT: return elif event.type == pygame.VIDEORESIZE: pygame.display.set_mode(event.size, pygame.RESIZABLE) break g.init() if not self.journal: utils.load() load_save.retrieve() x = g.sx(26) y = g.sy(11.2) if not self.sugar: buttons.Button("new", (x, y)) x, y = g.cxy2 dx = g.sy(4) self.back_button = buttons.Button("back", (x, y)) x += dx buttons.Button("plus", (x, y)) x += dx buttons.Button("times", (x, y)) x += dx buttons.Button("equals", (x, y)) self.ops = ['back', 'plus', 'times', 'equals'] if not self.sugar: self.slider = slider.Slider(g.sx(22.4), g.sy(20.5), 10, utils.GREEN) self.mouse_auto = True self.anim_ms = None self.level1() # initial animation self.scored = False if restore: g.score = self.save_score ctrl = False pygame.key.set_repeat(600, 120) key_ms = pygame.time.get_ticks() going = True if self.canvas is not None: self.canvas.grab_focus() while going: if self.journal: # Pump GTK messages. while Gtk.events_pending(): Gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: if not self.journal: utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.pos = event.pos g.redraw = True if self.canvas is not None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True self.anim_end() if event.button == 1: bu = buttons.check() if bu == '': if not self.check_numbers(): if not self.sugar: if self.slider.mouse(): self.level1() else: self.do_button(bu) # eg do_button('plus') self.flush_queue() elif event.type == pygame.KEYDOWN: self.anim_end() # throttle keyboard repeat if pygame.time.get_ticks() - key_ms > 110: key_ms = pygame.time.get_ticks() if ctrl: if event.key == pygame.K_q: if not self.journal: utils.save() going = False break else: ctrl = False if event.key in (pygame.K_LCTRL, pygame.K_RCTRL): ctrl = True break self.do_key(event.key) g.redraw = True self.flush_queue() elif event.type == pygame.KEYUP: ctrl = False if not going: break self.animation() if g.redraw: self.display() if g.version_display: utils.version_display() if not self.black: g.screen.blit(g.pointer, g.pos) pygame.display.flip() g.redraw = False g.clock.tick(40)
def run(self): g.init() if not self.journal: utils.load() load_save.retrieve() g.level = g.best self.demo_setup() self.buttons_setup() if self.canvas <> None: self.canvas.grab_focus() ctrl = False pygame.key.set_repeat(600, 120) key_ms = pygame.time.get_ticks() going = True while going: if self.journal: # Pump GTK messages. while gtk.events_pending(): gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: if not self.journal: utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.pos = event.pos g.redraw = True if self.canvas <> None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True if event.button == 1: if self.left_click(): break if g.best > 1: if self.slider != None: if self.slider.mouse(): self.round_setup() # level changed break bu = buttons.check() if bu != '': self.do_button(bu) self.flush_queue() if event.button == 3: self.right_click() elif event.type == pygame.KEYDOWN: # throttle keyboard repeat if pygame.time.get_ticks() - key_ms > 110: key_ms = pygame.time.get_ticks() if ctrl: if event.key == pygame.K_q: if not self.journal: utils.save() going = False break else: ctrl = False if event.key in (pygame.K_LCTRL, pygame.K_RCTRL): ctrl = True break self.do_key(event.key) g.redraw = True self.flush_queue() elif event.type == pygame.KEYUP: ctrl = False if not going: break self.update() if g.redraw: self.display() if g.version_display: utils.version_display() g.screen.blit(g.pointer, g.pos) pygame.display.flip() g.redraw = False g.clock.tick(40)
def run(self, restore=False): for event in pygame.event.get(): if event.type==pygame.QUIT: return elif event.type == pygame.VIDEORESIZE: pygame.display.set_mode(event.size, pygame.RESIZABLE) break self.g_init() if not self.journal: utils.load() load_save.retrieve() if restore: self.restore_pattern() else: g.delay = (3 - g.level) * 400 self.tu = my_turtle.TurtleClass() self.tu.current = [1, 1, 1, 3, 2] self.get_goal() if g.pattern == 1: self.tu.current = utils.copy_list(g.goals[0]) self.tu.setup(self.colors[0]) g.numbers = utils.copy_list(self.tu.current) # buttons x = g.sx(7.3) y = g.sy(16.5) dx = g.sy(2.6) if not self.sugar: buttons.Button("cyan", (x, y), True) x += dx buttons.off('cyan') buttons.Button("green", (x, y), True) x += dx buttons.Button("red", (x, y), True) x += dx buttons.Button("black", (x, y), True) x += dx self.slider = slider.Slider(g.sx(23.5), g.sy(21), 3, utils.YELLOW) self.mouse_1st_no() # to 1st number if self.canvas is not None: self.canvas.grab_focus() ctrl = False pygame.key.set_repeat(600, 120) key_ms = pygame.time.get_ticks() going = True while going: if self.journal: # Pump Gtk messages. while Gtk.events_pending(): Gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: if not self.journal: utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.pos = event.pos g.redraw = True if self.canvas is not None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True if g.big: g.big = False else: bu = buttons.check() if bu != '': self.do_button(bu) self.flush_queue() elif not self.sugar: if utils.mouse_on_img1(g.magician, g.magician_c): self.help2() elif utils.mouse_in(g.x1, g.y0, g.x1 + g.bw, g.y0 + g.bw): self.big_pic() elif self.slider.mouse(): g.delay = (3 - g.level) * 400 else: g.show_help = False self.check_nos(event.button) else: g.show_help = False self.check_nos(event.button) elif event.type == pygame.KEYDOWN: # throttle keyboard repeat if pygame.time.get_ticks() - key_ms > 110: key_ms = pygame.time.get_ticks() if ctrl: if event.key == pygame.K_q: if not self.journal: utils.save() going = False break else: ctrl = False if event.key in (pygame.K_LCTRL, pygame.K_RCTRL): ctrl = True break self.do_key(event.key) g.redraw = True self.flush_queue() elif event.type == pygame.KEYUP: ctrl = False if not going: break if self.tu.running: self.tu.move() if not g.crash_drawn: g.crash_drawn = True g.redraw = True if g.redraw: self.display() if g.version_display: utils.version_display() g.screen.blit(g.pointer, g.pos) pygame.display.flip() g.redraw = False g.clock.tick(40)
def run(self): # g.init and self.manc require that we know the display size first for event in pygame.event.get(): if event.type == pygame.QUIT: return elif event.type == pygame.VIDEORESIZE: pygame.display.set_mode(event.size, pygame.RESIZABLE) break g.init() if not self.journal: utils.load() self.manc = manc.Manc() self.manc.setup() load_save.retrieve() self.buttons_setup() if self.canvas <> None: self.canvas.grab_focus() ctrl = False pygame.key.set_repeat(600, 120) key_ms = pygame.time.get_ticks() going = True while going: if self.journal: # Pump GTK messages. while Gtk.events_pending(): Gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: if not self.journal: utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.pos = event.pos self.manc.check_mouse() g.redraw = True if self.canvas <> None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True if event.button == 1: bu = buttons.check() if bu != '': self.do_button(bu) else: self.do_click() self.flush_queue() elif event.type == pygame.KEYDOWN: # throttle keyboard repeat if pygame.time.get_ticks() - key_ms > 110: key_ms = pygame.time.get_ticks() if ctrl: if event.key == pygame.K_q: if not self.journal: utils.save() going = False break else: ctrl = False if event.key in (pygame.K_LCTRL, pygame.K_RCTRL): ctrl = True break self.do_key(event.key) g.redraw = True self.flush_queue() elif event.type == pygame.KEYUP: ctrl = False if not going: break self.update() if g.redraw: self.display() if g.version_display: utils.version_display() g.screen.blit(g.pointer, g.pos) pygame.display.flip() g.redraw = False g.clock.tick(40)
def run(self): for event in pygame.event.get(): if event.type == pygame.QUIT: return elif event.type == pygame.VIDEORESIZE: pygame.display.set_mode(event.size, pygame.RESIZABLE) break g.init() if not self.journal: utils.load() self.pages = pages.Pages() self.map1 = map1.Map1() self.ctry = ctry.Ctry() load_save.retrieve() self.buttons_setup() if self.canvas is not None: self.canvas.grab_focus() ctrl = False going = True while going: if self.journal: # Pump Gtk messages. while Gtk.events_pending(): Gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: if not self.journal: utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.pos = event.pos g.redraw = True if self.canvas is not None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True self.ctry.message = None g.pic = g.globe if event.button == 1: if self.do_click(): pass else: bu = buttons.check() if bu != '': self.do_button(bu) self.flush_queue() if event.button == 3: self.ctry.clear() elif event.type == pygame.KEYDOWN: # throttle keyboard repeat self.ctry.message = None g.pic = g.globe if ctrl: if event.key == pygame.K_q: if not self.journal: utils.save() going = False break else: ctrl = False if event.key in (pygame.K_LCTRL, pygame.K_RCTRL): ctrl = True break self.do_key(event.key) g.redraw = True self.flush_queue() elif event.type == pygame.KEYUP: ctrl = False if not going: break if g.redraw: self.display() if g.version_display: utils.version_display() g.screen.blit(g.pointer, g.pos) pygame.display.flip() g.redraw = False g.clock.tick(40)
def run(self, restore=False): g.init() if not self.journal: utils.load() self.let = let.Let() # setup before retrieve load_save.retrieve() self.buttons_setup() if self.canvas is not None: self.canvas.grab_focus() ctrl = False pygame.key.set_repeat(600, 120) key_ms = pygame.time.get_ticks() going = True while going: if self.journal: # Pump GTK messages. while Gtk.events_pending(): Gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: if not self.journal: utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.pos = event.pos g.redraw = True if self.canvas is not None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True if event.button == 1: if not self.sugar and g.help_on: g.help_on = False buttons.on('help') elif self.do_click(): pass else: bu = buttons.check() if bu != '': self.do_button(bu) self.flush_queue() if not self.sugar and event.button == 3: g.help_on = True buttons.off('help') elif event.type == pygame.KEYDOWN: if not self.sugar and event.key not in g.CIRCLE: g.help_on = False buttons.on('help') # throttle keyboard repeat if pygame.time.get_ticks() - key_ms > 110: key_ms = pygame.time.get_ticks() if ctrl: if event.key == pygame.K_q: if not self.journal: utils.save() going = False break else: ctrl = False if event.key in (pygame.K_LCTRL, pygame.K_RCTRL): ctrl = True break self.do_key(event.key) g.redraw = True self.flush_queue() elif event.type == pygame.KEYUP: ctrl = False if not going: break if g.state == 1: self.let.choose() if g.redraw: self.display() if g.version_display: utils.version_display() if g.state != 1: g.screen.blit(g.pointer, g.pos) pygame.display.flip() g.redraw = False g.clock.tick(40)
def run(self): g.init() if not self.journal: utils.load() self.sim=sim.Sim() load_save.retrieve() self.buttons_setup() if g.saved_n==0: buttons.off('cyan') self.slider=slider.Slider(g.sx(23.4),g.sy(20.2),5,utils.GREEN) if self.canvas<>None: self.canvas.grab_focus() ctrl=False pygame.key.set_repeat(600,120); key_ms=pygame.time.get_ticks() going=True while going: if self.journal: # Pump GTK messages. while gtk.events_pending(): gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type==pygame.QUIT: if not self.journal: utils.save() going=False elif event.type == pygame.MOUSEMOTION: g.pos=event.pos g.redraw=True if self.canvas<>None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw=True if g.help_on: g.help_on=False elif event.button==1: if self.do_click(): pass elif self.slider.mouse(): pass # level changed else: bu=buttons.check() if bu!='': self.do_button(bu); self.flush_queue() elif event.button==3: self.right_click() elif event.type == pygame.KEYDOWN: # throttle keyboard repeat if pygame.time.get_ticks()-key_ms>110: key_ms=pygame.time.get_ticks() if ctrl: if event.key==pygame.K_q: if not self.journal: utils.save() going=False; break else: ctrl=False if event.key in (pygame.K_LCTRL,pygame.K_RCTRL): ctrl=True; break self.do_key(event.key); g.redraw=True self.flush_queue() elif event.type == pygame.KEYUP: ctrl=False if not going: break self.update() if g.redraw: self.display() if g.version_display: utils.version_display() g.screen.blit(g.pointer,g.pos) pygame.display.flip() g.redraw=False g.clock.tick(40)
def run(self): for event in pygame.event.get(): if event.type == pygame.QUIT: return elif event.type == pygame.VIDEORESIZE: pygame.display.set_mode(event.size, pygame.RESIZABLE) break g.init() if not self.journal: utils.load() self.pages = pages.Pages() self.map1 = map1.Map1() self.ctry = ctry.Ctry() load_save.retrieve() self.buttons_setup() if self.canvas is not None: self.canvas.grab_focus() ctrl = False going = True answer_input = False down_event = None while going: if self.journal: # Pump Gtk messages. while Gtk.events_pending(): Gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: if not self.journal: utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.pos = event.pos g.redraw = True if self.canvas is not None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: # Store the latest MOUSEBUTTONDOWN event if event.button == 1: down_event = event elif event.type == pygame.MOUSEBUTTONUP: g.redraw = True self.ctry.message = None g.pic = g.globe if event.button == 1: if self.proximity( event, down_event) and answer_input is False: if self.do_click(): pass else: bu = buttons.check() if bu != '': value = self.do_button(bu) if value == 0: answer_input = True elif self.proximity( event, down_event) and answer_input is True: res = self.ctry.which_oval() if res == 'y': self.check_response() else: self.ctry.message = "Sorry, " + self.ctry.answer +\ " is not on my list" self.ctry.answer = '' answer_input = False self.flush_queue() if event.button == 3: self.ctry.clear() elif event.type == pygame.KEYDOWN: # throttle keyboard repeat self.ctry.message = None g.pic = g.globe if ctrl: if event.key == pygame.K_q: if not self.journal: utils.save() going = False break else: ctrl = False if answer_input is False: if event.key in (pygame.K_LCTRL, pygame.K_RCTRL): ctrl = True break value = self.do_key(event.key) if value == 0: answer_input = True else: if event.key == g.YES: # Value of 'y' self.check_response() else: self.ctry.message = "Sorry, " + self.ctry.answer +\ " is not on my list" self.ctry.answer = '' answer_input = False g.redraw = True self.flush_queue() elif event.type == pygame.KEYUP: ctrl = False if not going: break if g.redraw: self.display() if g.version_display: utils.version_display() g.screen.blit(g.pointer, g.pos) pygame.display.flip() g.redraw = False g.clock.tick(40)
def run(self): g.init() if not self.journal: utils.load() self.tr = [None, None, None, None] self.menu = menu.Menu(4, 4, g.sy(.2), g.sy(1.3), g.sy(.2)) load_save.retrieve() self.buttons_setup() self.slider = [None, None] self.slider[0] = slider.Slider(g.sx(16), g.sy(20.8), 2, utils.GREEN) self.slider[1] = slider.Slider(g.sx(16), g.sy(20.8), 3, utils.GREEN) self.levels = [1] * 16 if self.canvas <> None: self.canvas.grab_focus() ctrl = False pygame.key.set_repeat(600, 120) key_ms = pygame.time.get_ticks() going = True while going: if self.journal: # Pump GTK messages. while gtk.events_pending(): gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: if not self.journal: utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.pos = event.pos g.redraw = True if self.canvas <> None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True if event.button == 1: if self.do_click(): pass else: if g.state == 'jigsaw': bu = buttons.check() if bu != '': self.do_button(bu) self.flush_queue() elif event.type == pygame.KEYDOWN: # throttle keyboard repeat if pygame.time.get_ticks() - key_ms > 110: key_ms = pygame.time.get_ticks() if ctrl: if event.key == pygame.K_q: if not self.journal: utils.save() going = False break else: ctrl = False if event.key in (pygame.K_LCTRL, pygame.K_RCTRL): ctrl = True break self.do_key(event.key) g.redraw = True self.flush_queue() elif event.type == pygame.KEYUP: ctrl = False if not going: break if g.redraw: self.display() if g.version_display: utils.version_display() g.screen.blit(g.pointer, g.pos) pygame.display.flip() g.redraw = False g.clock.tick(40)
def run(self, restore=False): g.init() if not self.journal: utils.load() self.let = let.Let() # setup before retrieve load_save.retrieve() self.buttons_setup() if self.canvas is not None: self.canvas.grab_focus() pygame.key.set_repeat(600, 120) going = True while going: if self.journal: # Pump GTK messages. while Gtk.events_pending(): Gtk.main_iteration() if not going: break # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: if not self.journal: utils.save() return elif event.type == pygame.VIDEORESIZE: pygame.display.set_mode(event.size, pygame.RESIZABLE) g.redraw = True elif event.type == pygame.MOUSEMOTION: g.pos = event.pos g.redraw = True if self.canvas is not None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True if event.button == 1: if not self.sugar and g.help_on: g.help_on = False buttons.on('help') elif self.do_click(): pass else: bu = buttons.check() if bu != '': self.do_button(bu) if not self.sugar and event.button == 3: g.help_on = True buttons.off('help') elif event.type == pygame.KEYDOWN: if not self.sugar and event.key not in g.CIRCLE: g.help_on = False buttons.on('help') self.do_key(event.key) g.redraw = True elif event.type == pygame.KEYUP: pass if not going: break if g.state == g.STATE_SETUP: self.let.choose() if g.redraw: self.display() if g.version_display: utils.version_display() if g.state != g.STATE_SETUP: g.screen.blit(g.pointer, g.pos) pygame.display.flip() g.redraw = False g.clock.tick(40)
def run(self): g.init() if not self.journal: utils.load() load_save.retrieve() self.buttons_setup() self.slider=slider.Slider(g.sx(16),g.sy(20.5),9,utils.GREEN) self.grid=ah.Grid() self.grid.new1(); self.grid.setup() if self.canvas!=None: self.canvas.grab_focus() ctrl=False pygame.key.set_repeat(600,120); key_ms=pygame.time.get_ticks() going=True while going: if self.journal: # Pump GTK messages. while Gtk.events_pending(): Gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type==pygame.QUIT: if not self.journal: utils.save() going=False elif event.type == pygame.MOUSEMOTION: g.pos=event.pos g.redraw=True if self.canvas!=None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw=True if event.button==1: if self.grid.click(): pass elif self.slider.mouse(): self.grid.new1(); self.grid.setup(); buttons.clear() # level changed else: bu=buttons.check() if bu!='': self.do_button(bu) else: self.grid.colour_ind=0 self.flush_queue() elif event.button==3: self.do_button('reset') elif event.type == pygame.KEYDOWN: # throttle keyboard repeat if pygame.time.get_ticks()-key_ms>110: key_ms=pygame.time.get_ticks() if ctrl: if event.key==pygame.K_q: if not self.journal: utils.save() going=False; break else: ctrl=False if event.key in (pygame.K_LCTRL,pygame.K_RCTRL): ctrl=True; break self.do_key(event.key); g.redraw=True self.flush_queue() elif event.type == pygame.KEYUP: ctrl=False if not going: break if self.grid.complete(): buttons.clear() if g.redraw: self.display() if g.version_display: utils.version_display() g.screen.blit(g.pointer,g.pos) pygame.display.flip() g.redraw=False self.score=g.score; self.level=g.level g.clock.tick(40)
def run(self, restore=False): self.g_init() if not self.journal: utils.load() load_save.retrieve() self.aim = simon.Simon(1200) # arg is glow time if self.sugar: self.set_delay(800) else: self.set_delay() self.player = simon.Simon(200) if restore: self.restore_pattern() self.aim.started = True if self.sugar: self.green_button.set_sensitive(True) self.back_button.set_sensitive(False) else: bx = g.sx(22.42) by = g.sy(20.8) buttons.Button('green', (bx, by), True) buttons.Button('back', (bx, by), True) buttons.off('back') self.slider = slider.Slider(g.sx(9), g.sy(20.8), 3, utils.BLUE) self.rc = rc_skip_last.RC(3, 5) if self.canvas is not None: self.canvas.grab_focus() ctrl = False pygame.key.set_repeat(600, 120) key_ms = pygame.time.get_ticks() going = True while going: if self.journal: # Pump GTK messages. while Gtk.events_pending(): Gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: if not self.journal: utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.pos = event.pos g.redraw = True if self.canvas is not None: self.canvas.grab_focus() self.mouse_set() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True if event.button == 1: self.do_click() self.flush_queue() elif event.type == pygame.KEYDOWN: # throttle keyboard repeat if pygame.time.get_ticks() - key_ms > 110: key_ms = pygame.time.get_ticks() if ctrl: if event.key == pygame.K_q: if not self.journal: utils.save() going = False break else: ctrl = False if event.key in (pygame.K_LCTRL, pygame.K_RCTRL): ctrl = True break self.do_key(event.key) g.redraw = True self.flush_queue() elif event.type == pygame.KEYUP: ctrl = False if not going: break if self.sugar: if g.player_n == 0 and not self.green_button.get_sensitive(): self.back_button.set_sensitive(True) else: if g.player_n == 0 and not buttons.active('green'): buttons.on('back') self.player.do() self.aim.do() if g.redraw: self.display() if g.version_display: utils.version_display() if self.aim.running or self.aim.glow_active: pass else: g.screen.blit(g.pointer, g.pos) pygame.display.flip() g.redraw = False g.clock.tick(40)
def run(self, restore=False): g.init() for event in pygame.event.get(): if event.type == pygame.QUIT: return elif event.type == pygame.VIDEORESIZE: pygame.display.set_mode(event.size, pygame.RESIZABLE) break if not self.journal: utils.load() self.trip = trip.Trip(self.sugar, self.label, self.colors[0]) self.trip.setup() load_save.retrieve() self.buttons_setup() if self.canvas is not None: self.canvas.grab_focus() ctrl = False pygame.key.set_repeat(600, 120) key_ms = pygame.time.get_ticks() going = True while going: if self.journal: # Pump GTK messages. while Gtk.events_pending(): Gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: # only in standalone version if not self.journal: utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.pos = event.pos self.trip.check_mouse() g.redraw = True if self.canvas is not None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True if event.button == 1: bu = buttons.check() if bu != '': self.do_button(bu) else: if self.trip.check_mouse(): self.do_click() self.flush_queue() elif event.type == pygame.KEYDOWN: # throttle keyboard repeat if pygame.time.get_ticks() - key_ms > 110: key_ms = pygame.time.get_ticks() if ctrl: if event.key == pygame.K_q: if not self.journal: utils.save() going = False break else: ctrl = False if event.key in (pygame.K_LCTRL, pygame.K_RCTRL): ctrl = True break self.do_key(event.key) g.redraw = True self.flush_queue() elif event.type == pygame.KEYUP: ctrl = False if not going: break if g.redraw: self.display() if g.version_display: utils.version_display() g.screen.blit(g.pointer, g.pos) pygame.display.flip() g.redraw = False if self.trip.delay: pygame.time.delay(1000) self.trip.delay = False self.trip.gone() g.redraw = True self.trip.complete() g.clock.tick(40)
def run(self): g.init() if not self.journal: utils.load() self.jigsaw = jigsaw.Jigsaw() self.menu = menu.Menu(3, 4, g.sy(1), g.sy(1.5), g.sy(.32)) load_save.retrieve() self.buttons_setup() self.slider = slider.Slider(g.sx(16), g.sy(20.5), len(jigsaw.rc), utils.GREEN) if self.canvas <> None: self.canvas.grab_focus() ctrl = False pygame.key.set_repeat(600, 120) key_ms = pygame.time.get_ticks() going = True while going: if self.journal: # Pump GTK messages. while gtk.events_pending(): gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: # only in standalone version if not self.journal: utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.pos = event.pos if g.state == 2: self.menu.check_mouse() if g.state == 3: self.jigsaw.check_mouse() g.redraw = True if self.canvas <> None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True if event.button == 1: bu = buttons.check() if bu != '': self.do_button(bu) else: self.do_click() if event.button == 3: self.jigsaw.moving = not self.jigsaw.moving self.flush_queue() elif event.type == pygame.KEYDOWN: # throttle keyboard repeat if pygame.time.get_ticks() - key_ms > 110: key_ms = pygame.time.get_ticks() if ctrl: if event.key == pygame.K_q: if not self.journal: utils.save() going = False break else: ctrl = False if event.key in (pygame.K_LCTRL, pygame.K_RCTRL): ctrl = True break self.do_key(event.key) g.redraw = True self.flush_queue() elif event.type == pygame.KEYUP: ctrl = False if not going: break if g.state == 3: self.jigsaw.update() if g.redraw: self.display() if g.version_display: utils.version_display() if g.state == 3: g.screen.blit(g.negative, g.pos) else: g.screen.blit(g.pointer, g.pos) pygame.display.flip() g.redraw = False g.clock.tick(40)
def run(self, restore=False): self.g_init() if not self.journal: utils.load() load_save.retrieve() self.aim = simon.Simon(1200) # arg is glow time if self.sugar: self.set_delay(800) else: self.set_delay() self.player = simon.Simon(200) if restore: self.restore_pattern() self.aim.started = True if self.sugar: self.green_button.set_sensitive(True) self.back_button.set_sensitive(False) else: bx = g.sx(22.42) by = g.sy(20.8) buttons.Button('green', (bx, by), True) buttons.Button('back', (bx, by), True) buttons.off('back') self.slider = slider.Slider(g.sx(9), g.sy(20.8), 3, utils.BLUE) self.rc = rc_skip_last.RC(3, 5) if self.canvas is not None: self.canvas.grab_focus() ctrl = False pygame.key.set_repeat(600, 120) key_ms = pygame.time.get_ticks() going = True while going: if self.journal: # Pump GTK messages. while gtk.events_pending(): gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: if not self.journal: utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.pos = event.pos g.redraw = True if self.canvas is not None: self.canvas.grab_focus() self.mouse_set() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True if event.button == 1: self.do_click() self.flush_queue() elif event.type == pygame.KEYDOWN: # throttle keyboard repeat if pygame.time.get_ticks() - key_ms > 110: key_ms = pygame.time.get_ticks() if ctrl: if event.key == pygame.K_q: if not self.journal: utils.save() going = False break else: ctrl = False if event.key in (pygame.K_LCTRL, pygame.K_RCTRL): ctrl = True break self.do_key(event.key) g.redraw = True self.flush_queue() elif event.type == pygame.KEYUP: ctrl = False if not going: break if self.sugar: if g.player_n == 0 and not self.green_button.get_sensitive(): self.back_button.set_sensitive(True) else: if g.player_n == 0 and not buttons.active('green'): buttons.on('back') self.player.do() self.aim.do() if g.redraw: self.display() if g.version_display: utils.version_display() if self.aim.running or self.aim.glow_active: pass else: g.screen.blit(g.pointer, g.pos) pygame.display.flip() g.redraw = False g.clock.tick(40)
def run(self, restore=False): self.black = False g.init() if not self.journal: utils.load() load_save.retrieve() x = g.sx(26) y = g.sy(11.2) if not self.sugar: buttons.Button("new", (x, y)) x, y = g.cxy2 dx = g.sy(4) self.back_button = buttons.Button("back", (x, y)) x += dx buttons.Button("plus", (x, y)) x += dx buttons.Button("times", (x, y)) x += dx buttons.Button("equals", (x, y)) self.ops = ['back', 'plus', 'times', 'equals'] if not self.sugar: self.slider = slider.Slider(g.sx(22.4), g.sy(20.5), 10, utils.GREEN) self.mouse_auto = True self.anim_ms = None self.level1() # initial animation self.scored = False if restore: g.score = self.save_score ctrl = False pygame.key.set_repeat(600, 120) key_ms = pygame.time.get_ticks() going = True if self.canvas is not None: self.canvas.grab_focus() while going: if self.journal: # Pump GTK messages. while gtk.events_pending(): gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: if not self.journal: utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.pos = event.pos g.redraw = True if self.canvas is not None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True self.anim_end() if event.button == 1: bu = buttons.check() if bu == '': if not self.check_numbers(): if not self.sugar: if self.slider.mouse(): self.level1() else: self.do_button(bu) # eg do_button('plus') self.flush_queue() elif event.type == pygame.KEYDOWN: self.anim_end() # throttle keyboard repeat if pygame.time.get_ticks() - key_ms > 110: key_ms = pygame.time.get_ticks() if ctrl: if event.key == pygame.K_q: if not self.journal: utils.save() going = False break else: ctrl = False if event.key in (pygame.K_LCTRL, pygame.K_RCTRL): ctrl = True break self.do_key(event.key) g.redraw = True self.flush_queue() elif event.type == pygame.KEYUP: ctrl = False if not going: break self.animation() if g.redraw: self.display() if g.version_display: utils.version_display() if not self.black: g.screen.blit(g.pointer, g.pos) pygame.display.flip() g.redraw = False g.clock.tick(40)
def run(self, restore=False): g.init() pygame.init() pygame.display.init() if not self.journal: utils.load() self.trip = trip.Trip(self.sugar, self.label, self.colors[0]) self.trip.setup() load_save.retrieve() self.buttons_setup() if self.canvas is not None: self.canvas.grab_focus() ctrl = False pygame.key.set_repeat(600, 120) key_ms = pygame.time.get_ticks() going = True while going: if self.journal: # Pump GTK messages. while Gtk.events_pending(): Gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: # only in standalone version if not self.journal: utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.pos = event.pos self.trip.check_mouse() g.redraw = True if self.canvas is not None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True if event.button == 1: bu = buttons.check() if bu != '': self.do_button(bu) else: if self.trip.check_mouse(): self.do_click() self.flush_queue() elif event.type == pygame.KEYDOWN: # throttle keyboard repeat if pygame.time.get_ticks() - key_ms > 110: key_ms = pygame.time.get_ticks() if ctrl: if event.key == pygame.K_q: if not self.journal: utils.save() going = False break else: ctrl = False if event.key in (pygame.K_LCTRL, pygame.K_RCTRL): ctrl = True break self.do_key(event.key) g.redraw = True self.flush_queue() elif event.type == pygame.KEYUP: ctrl = False if not going: break if g.redraw: self.display() if g.version_display: utils.version_display() g.screen.blit(g.pointer, g.pos) pygame.display.flip() g.redraw = False if self.trip.delay: pygame.time.delay(1000) self.trip.delay = False self.trip.gone() g.redraw = True self.trip.complete() g.clock.tick(40)
def run(self): g.init() if not self.journal: utils.load() load_save.retrieve() self.buttons_setup() self.objects = jum.Objects() self.objects.setup() self.setup() if self.canvas <> None: self.canvas.grab_focus() ctrl = False pygame.key.set_repeat(600, 120) key_ms = pygame.time.get_ticks() going = True while going: if self.journal: # Pump GTK messages. while gtk.events_pending(): gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: if not self.journal: utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.pos = event.pos g.redraw = True self.objects.update() if self.canvas <> None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True if event.button == 1: if self.objects.click(): if self.objects.complete: buttons.off('next') else: self.display() bu = buttons.check() if bu != '': self.do_button(bu) if event.button == 3: if buttons.active('next'): self.do_button('next') self.flush_queue() elif event.type == pygame.KEYDOWN: # throttle keyboard repeat if pygame.time.get_ticks() - key_ms > 110: key_ms = pygame.time.get_ticks() if ctrl: if event.key == pygame.K_q: if not self.journal: utils.save() going = False break else: ctrl = False if event.key in (pygame.K_LCTRL, pygame.K_RCTRL): ctrl = True break self.do_key(event.key) g.redraw = True self.flush_queue() elif event.type == pygame.KEYUP: ctrl = False if not going: break if g.setup_on: self.objects.setup() g.redraw = True if (pygame.time.get_ticks() - self.setup_ms) > 2000: g.setup_on = False buttons.on('next') if g.redraw: self.display() if g.version_display: utils.version_display() g.screen.blit(g.pointer, g.pos) pygame.display.flip() g.redraw = False g.clock.tick(40)
def run(self): g.init() if not self.journal: utils.load() self.didg = didg.Didg() g.carry_shape = didg.shapes[0] self.didg.make_carry() load_save.retrieve() self.buttons_setup() if self.canvas <> None: self.canvas.grab_focus() ctrl = False pygame.key.set_repeat(600, 120) key_ms = pygame.time.get_ticks() need_carry = False going = True while going: if self.journal: # Pump GTK messages. while gtk.events_pending(): gtk.main_iteration() # Pump PyGame messages. for event in pygame.event.get(): if event.type == pygame.QUIT: if not self.journal: utils.save() going = False elif event.type == pygame.MOUSEMOTION: g.pos = event.pos need_carry = True if self.canvas <> None: self.canvas.grab_focus() elif event.type == pygame.MOUSEBUTTONDOWN: g.redraw = True if event.button == 1: if self.do_click(1): pass else: bu = buttons.check() if bu != '': self.do_button(bu) self.flush_queue() if event.button == 3: self.do_click(3) elif event.type == pygame.KEYDOWN: # throttle keyboard repeat if pygame.time.get_ticks() - key_ms > 110: key_ms = pygame.time.get_ticks() if ctrl: if event.key == pygame.K_q: if not self.journal: utils.save() going = False break else: ctrl = False if event.key in (pygame.K_LCTRL, pygame.K_RCTRL): ctrl = True break self.do_key(event.key) g.redraw = True self.flush_queue() elif event.type == pygame.KEYUP: ctrl = False if not going: break if g.redraw: g.carry_save = False self.display() if g.version_display: utils.version_display() self.carry() need_carry = False pygame.display.flip() g.redraw = False elif need_carry: self.carry() pygame.display.flip() need_carry = False g.clock.tick(40)