def on_start(): global a while True: if neurons.pir_sensor.is_activated(1): neurons.led_panel.show_image([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1 ], 0, 1) time.sleep(1) neurons.led_panel.clear() codey.set_variable('a', 2)
def runCmd(cmd): if len(cmd) < 1: return for i, j in enumerate(cmd): if j == 0: rocky.stop() codey.set_variable('cmd', "0_0_0") else: t = type(j) if t == str: codey.face(j) elif t == tuple: run(j[0], j[1])
def move_control(): global down_speed, current_script, move_lock_flag if current_script == None : time.sleep(0.2) return if codey.get_variable('cmd') == 1 and move_lock_flag == False: current_script.up() if game.background_collision_check(current_script): current_script.down() codey.set_variable('cmd', 0) elif codey.get_variable('cmd') == 2 and move_lock_flag == False: current_script.down() if game.background_collision_check(current_script): current_script.up() codey.set_variable('cmd', 0) elif codey.get_variable('cmd') == 3 and move_lock_flag == False: current_script.rotate() codey.set_variable('cmd', 0) elif codey.get_variable('cmd') == 4 and move_lock_flag == False: down_speed = 2 codey.set_variable('cmd', 0) temp = current_script.meet_border_check() if temp == UP_MEET: current_script.down() while current_script.meet_border_check() == UP_MEET: current_script.down() elif temp == DOWN_MEET: current_script.up() while current_script.meet_border_check() == DOWN_MEET: current_script.up()
def runCmd(cmd): if len(cmd) < 1: return for i, j in enumerate(cmd): print("index: %d" % i) if j == 0: # rocky.stop() codey.set_variable('cmd', "0_0_0") else: t = type(j) if t == str: if i == 0: if len(j) > 0: codey.say(j + '.wav') else: codey.face(j) elif t == tuple: run(j[0], j[1], j[2])
def move_control(): if codey.get_variable('cmd') == 1: p.up() codey.set_variable('cmd', 0) elif codey.get_variable('cmd') == 2: p.down() codey.set_variable('cmd', 0) elif codey.get_variable('cmd') == 3: p.left() codey.set_variable('cmd', 0) elif codey.get_variable('cmd') == 4: p.right() codey.set_variable('cmd', 0)
background = game.get_background() removed_flag = False i = 0 while i < 16: if screen[i] & 0xff == 0xff: score += 1 removed_flag = True del background[i] background.insert(0, 0x00) i += 1 if removed_flag: codey.say("start") game.set_background(background) down_speed = 10 codey.set_variable('cmd', 0) def move_control(): global down_speed, current_script, move_lock_flag if current_script == None : time.sleep(0.2) return if codey.get_variable('cmd') == 1 and move_lock_flag == False: current_script.up() if game.background_collision_check(current_script): current_script.down() codey.set_variable('cmd', 0) elif codey.get_variable('cmd') == 2 and move_lock_flag == False: current_script.down() if game.background_collision_check(current_script): current_script.up() codey.set_variable('cmd', 0)
import codey import rocky import time version = '1_1' codey.set_variable('cmd', "0") codey.set_variable('v', version) def run(dir, duration): if dir == 0: rocky.drive(200, 200) elif dir == 1: rocky.drive(0, 200) elif dir == 2: rocky.drive(-200, -200) elif dir == 3: rocky.drive(200, 0) elif dir == 4: rocky.drive(0, 0) time.sleep(duration) def runCmd(cmd): if len(cmd) < 1: return for i, j in enumerate(cmd): if j == 0: rocky.stop() codey.set_variable('cmd', "0_0_0") else: t = type(j) if t == str: codey.face(j)