Esempio n. 1
0
    x = min(7, max(0, x))
    z = round(pos.z / 10 + 3.5)
    if not 0 <= z <= 7:
        flashing = True
    z = min(7, max(0, z))

    fb.erase()
    flash_count += 1
    if flash_count > FLASH_COUNT:
        flash_lit = not flash_lit
        flash_count = 0
    if not flashing or flashing and flash_lit:
        fb.point(z, x)
    fb.show()

    for button, action in keymap.items():
        action(release=(not button.is_pressed()))

    x, y, z = accel.forces()
    prev_table = table
    table += -1 if abs(x) < EPSILON and abs(y) < EPSILON else +1
    table = max(0, min(100, table))
    if prev_table >= TABLE_THRESH and table < TABLE_THRESH:
        pos = mc.player.getTilePos()
        mc.player.setTilePos(0, 100, 0)

    y -= 0.3
    control.look(up=150 * y * abs(y), left=150 * x * abs(x))

    time.sleep(0.01)
Esempio n. 2
0
def vector_angle(start, end):
    return degrees(atan2(end.x - start.x, end.z - start.z))


compass = Button(24)
fb = FrameBuffer()
while block.Block(mc.getBlock(gold_pos)) == block.GOLD_BLOCK:
    if compass.presses():
        heading = control.get_heading(mc)
        angle_to_gold = vector_angle(mc.player.getPos(), gold_pos)
        compass_angle = 90 + (angle_to_gold - heading)
        fb.erase()
        arrow_index = round(compass_angle / 15) % 24
        fb.draw(arrows[arrow_index])
        fb.show()

    for button, action in keymap.items():
        if button.is_pressed():
            action()
        else:
            action(release=True)

    x, y, z = accel.forces()
    control.look(up=20 * y, left=20 * x)

    time.sleep(0.01)

mc.postToChat("You found the gold!")
time.sleep(3)
from rstem.accel import Accel
from rstem.button import Button
from rstem.mcpi import control
import time

control.show()

keymap = {
    Button(18) : control.left,
    Button(14) : control.right,
    Button(15) : control.forward,
    Button(23) : control.backward,
    Button(7)  : control.smash,
    Button(24) : control.jump,
    }

accel = Accel()

while True:
    for button, action in keymap.items():
        action(release=(not button.is_pressed()))

    x, y, z = accel.forces()
    y -= 0.3
    control.look(up=150*y*abs(y), left=150*x*abs(x))
    
    time.sleep(0.01)
left = Button(23)
right = Button(14)
up = Button(18)
down = Button(15)

accel = Accel()

while True:
    if left.is_pressed():
        control.left()
    else:
        control.left(release=True)
    if right.is_pressed():
        control.right()
    else:
        control.right(release=True)
    if up.is_pressed():
        control.forward()
    else:
        control.forward(release=True)
    if down.is_pressed():
        control.backward()
    else:
        control.backward(release=True)

    x, y, z = accel.forces()
    control.look(up=20*y, left=20*x)
    
    time.sleep(0.01)

Esempio n. 5
0
def slow_look(delay=0.1, **kwargs):
    control.look(**kwargs)
    time.sleep(delay)