def update(): global player, gameState, wav_bomb, wav_item if gameState != GAMESTATE_INPLAY: delay(0.01) return ui.update() game_world.update() global wall, ball wall.didBounce(ball) player.didBounce(ball) global stage, stage_number for b in game_world.objects_at_layer(game_world.layer_obstacle): if b.didBounce(ball): if stage != None and 'scores' in stage: score = stage['scores'][b.type] # print(b.type, score) else: score = b.score if b.life == 0: player.score += score update_score() count = game_world.count_at_layer(game_world.layer_obstacle) if count == 0: goto_next_stage() break delay(0.01)
def update(self): self.lbl = [\ ui.Label('가진 : %d'%player_info['coin'] + '$', 250, 400, 30, ui.FONT_3),\ ui.Label('이름: ' + car_info[str(self.slot[self.select])]['name'], 250, 370, 30, ui.FONT_3),\ ui.Label('최고속력: %d'%(car_info[str(self.slot[self.select])]['speed']*5) + 'km/s', 250, 340, 30, ui.FONT_2),\ ui.Label('가격: %d'%car_info[str(self.slot[self.select])]['cost'] + '$', 250, 310, 30, ui.FONT_2),\ ui.Label(self.msg, 250, 280, 30, ui.FONT_2),\ ui.Label('통행량', 575, 300, 30, ui.FONT_2),\ ui.Label(difficulty_str[self.difficulty], 575, 250, 20, ui.FONT_2),\ ui.Label('코인획득량: X %.1f'%(self.difficulty+1), 575, 200, 20, ui.FONT_2),\ ] if self.slot[self.select] in player_info['have']: self.btn[0] = self.btn_start self.msg = '탑승가능' else: self.btn[0] = self.btn_buy have = player_info['coin'] cost = car_info[str(garage.slot[garage.select])]['cost'] if have < cost: self.msg = '돈이 부족합니다!!' else: self.msg = '차량이 잠겨있습니다!!' ui.buttons = self.btn ui.labels = self.lbl ui.update() self.coin.update()
def update(self): global player self.current_game_time = time.time() - self.gamestart_time self.ed = time.time() self.elapsed = self.ed - self.st self.st = self.ed self.lbl = [\ ui.Label('가진 돈: %d $' % player.coin, self.x + 20, self.y, 30, ui.FONT_2),\ ui.Label('속도: %.3f km/h'%(player.car.y_speed*5), self.x + 20, self.y - 30, 30, ui.FONT_2),\ ui.Label('얻은 돈: %d $' % (player.coin - self.gamestart_coin), self.x + 20, self.y - 60, 30, ui.FONT_2),\ ui.Label('시간: %.3f 초' % self.current_game_time, self.x + 20, self.y - 90, 30, ui.FONT_2),\ ] if self.waving: self.temp_label_timer = 3 self.waving = False if self.temp_label_timer > 0: warning = ui.Label('통행량이 급증하고있습니다!!', 200, 500, 30, ui.FONT_3) warning.color = (255, 0, 0) self.lbl = [*self.lbl, warning] self.temp_label_timer -= self.elapsed ui.labels = self.lbl ui.buttons = self.btn ui.update() self.coin.update() self.coin.x, self.coin.y = self.x, self.y
def reduce_sudoku(sudoku, strategies=[eliminate, only_choice, naked_twins]): """ Recursively apply the provied strategies (by default eliminate, only_choice and naked_twins). If at some point, there is a box with no available values, terminate. If the sudoku is solved, return the sudoku. If after an iteration of both functions, the sudoku remains the same, return the sudoku. Input: the sudoku in dictonary form, mapping boxs to the possible values. Keys: The boxes, e.g., 'A1' Values: choices for the values in the box, e.g., '238'. Output: The sudoku in dictionary form after constraint propagation or None if the sudoku is not solvable. """ result = sudoku.copy() stalled = False while not stalled: solved_boxes_before = len( [box for box in result.keys() if len(result[box]) == 1]) for strategy in strategies: result = strategy(result) if result else None if not result or len( [box for box in result.keys() if len(result[box]) == 0]): return None ui.update(result) solved_boxes_after = len( [box for box in result.keys() if len(result[box]) == 1]) stalled = solved_boxes_before == solved_boxes_after return result
def game_loop(game): while True: if blt.has_input(): code = blt.read() if code in codes_close: break ui.update(game, code) draw.update(game) blt.delay(1)
def loop(): '''Main loop.''' lastUpdate = -1 # initialise at -1 to update immediately lastBrewfatherPush = -1 # initialise at -1 to update immediately oldState = None spinner = '|/-\\' spinindex = 0 while keepRunning: #ui.ticks() if (time.time() - lastUpdate >= 1.0): # update settings every second # round to nearest 1 second boundary to keep in sync with real time lastUpdate = round(time.time()) tempControl.updateTemperatures() tempControl.detectPeaks() tempControl.updatePID() oldState = tempControl.getState() tempControl.updateState() if (oldState != tempControl.getState()): print("State changed from %s to %s" % (oldState, tempControl.getState())) piLink.printTemperatures( ) # add a data point at every state transition tempControl.updateOutputs() ui.update() # We have two lines free at the bottom of the display. # Show local time YYYY-MM-DD hh:mm (16 characters.) display.printStationaryText() display.printMode() display.printState() display.printAllTemperatures() # Last character is a spinner to show we haven't crashed #LCD.print("%s" % spinner[spinindex]) #spinindex = (spinindex + 1) % 4 # listen for incoming serial connections while waiting to update piLink.receive() if (time.time() - lastBrewfatherPush > 900): brewfather.push() lastBrewfatherPush = round(time.time()) time.sleep(0.05) # Don't hog the processor piLink.cleanup() LCD.printat(0, 5, "Shutting down. ") ui.update()
def start(): pygame.init() pygame.display.set_caption(GAME_NAME) screen = pygame.display.set_mode(SCREEN_SIZE) world.init(GAME_SIZE) clock = pygame.time.Clock() game_exit = False while not game_exit: for event in pygame.event.get(): if event.type == QUIT: game_exit = True world.update(event, screen) ui.update(event, screen) pygame.display.update() clock.tick(FPS) pygame.quit()
def update(): global player, gameState, wav_bomb, wav_item ui.update() game_world.update() if gameState == GAMESTATE_INPLAY: if random.random() < 0.01: if (random.random() < 0.5): item = Item(*gen_random()) else: item = CoinItem(*gen_random()) game_world.add_object(item, game_world.layer_item) print("Items:", game_world.count_at_layer(game_world.layer_item)) for m in game_world.objects_at_layer(game_world.layer_obstacle): collides = collides_distance(player, m) if collides: wav_bomb.play() player.life -= 1 print("Player Life = ", player.life) if player.life > 0: game_world.remove_object(m) else: end_game() break for m in game_world.objects_at_layer(game_world.layer_item): collides = collides_distance(player, m) if collides: wav_item.play() game_world.remove_object(m) if player.life < Life.LIFE_AT_START: player.life += 1 else: player.score += m.score break player.score += game_framework.frame_time update_score() obstacle_count = game_world.count_at_layer(game_world.layer_obstacle) # print(obstacle_count) if obstacle_count < BULLETS_AT_START + player.score // 10: # print("Missiles:", (obstacle_count + 1)) createMissle() delay(0.03)
def main(): print(sm64net.VERSION_STR + "\n" "Copyright (C) 2019 - 2022 devwizard\n" "This project is licensed under the terms of the GNU General Public " "License\n" "version 2. See LICENSE for more information.") server.init() ui.init() try: while ui.update(): server.update() time.sleep(1.0 / 60) finally: ui.exit() server.exit() return 0
import controlhandler import ui from subprocess import Popen import sys import os patch = "rhythmic_chords_tcp" fullPath = "/home/alarm/QB_Nebulae_V2/Code/pd/" + patch + ".pd" cmd = "pd -nogui -verbose -rt -audiobuf 5".split() cmd.append(fullPath) pt = Popen(cmd) request = False ch = controlhandler.ControlHandler(None, 0, None) ch.enterPureDataMode() ui = ui.UserInterface(ch) while (request != True): ch.updateAll() ui.update()
def update(self): ui.buttons = self.btn ui.update()
def update(): ui.update() delay(0.03)
def update(self): ui.buttons = self.btn ui.labels = self.lbl ui.update()