def run(self): global player global running global laser_list global green pfio.init() tick = 0 while running: try: x = pfio.read_input() if x >= 8 : x=0 if tick + 0.8 < time.time(): #FIRE!!!!!! if x - 4 >= 0: x = x-4 newlaser = laser_sprite(4,10,1, green) newlaser.rect.x = 28 + player.rect.x # laser is 4 wide player is 60; 60 /2 + 4 /2 = 28 newlaser.rect.y = player.rect.y laser_list.add(newlaser) tick = time.time() # go right if x - 2 >= 0: x = x-2 player.rect.x += 2 #go left if x - 1 >= 0: player.rect.x -= 2 except: pass pfio.deinit()
def main(): if len(sys.argv) <= 1: print("A phrase/word was not informed!!") else: pfio.init() j = 0 for argument in sys.argv: print(argument.lower()) if j != 0: print(translator(argument.lower())) ledBlinker(list(translator(argument.lower()))) j += 1 pfio.deinit()
def main(): if len(sys.argv) <= 1: print("A phrase/word was not informed!!") else: pfio.init() j = 0 for argument in sys.argv: print (argument.lower()) if j != 0: print (translator(argument.lower())) ledBlinker(list(translator(argument.lower()))) j += 1 pfio.deinit()
def run(self): """The main game stuff goes here""" while True: # set up the questions if self.question_file_name: question_file = open(question_file_name, "r") else: question_file = open(DEFAULT_QUESTION_FILE, "r") self.questions = list() for line in question_file.readlines(): q_parts = line.split(",") # this can be moved into db later... self.questions.append(Question(q_parts[0], q_parts[1], q_parts[2])) random.shuffle(self.questions) self.ask_questions() if self.stopped(): break self.stop() pfio.deinit()
def run(self): """The main game stuff goes here""" while True: # set up the questions if self.question_file_name: question_file = open(question_file_name, "r") else: question_file = open(DEFAULT_QUESTION_FILE, "r") self.questions = list() for line in question_file.readlines(): q_parts = line.split(",") # this can be moved into db later... self.questions.append( Question(q_parts[0], q_parts[1], q_parts[2])) random.shuffle(self.questions) self.ask_questions() if self.stopped(): break self.stop() pfio.deinit()
f = open('high_scores.txt','r+') high_scores = f.readlines() high_score = 0 index = 0 for indx, line in enumerate(high_scores): if "simon" in line: line = line.split(",") high_score = int(line[1]) index = indx break f.close() print "The high score was %d" %high_score if score > high_score: print "Congratulations! You have the new high score" f = open('high_scores.txt','r+') f.write(replace(str(high_score),str(score))) f.close() else: print "You haven't beaten the high score, keep trying!" """ pfio.deinit() # close the pfio
def cleanup(*args): pfio.deinit()
def __del__(self): self.mos.disconnect() pfio.deinit()