Skip to content

Commit 99da7d0

Browse files
author
Mikey Sklar
committed
MC-Melons.py ported to CircuitPython, python3, linted and tested
1 parent 4615bf3 commit 99da7d0

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

Binary file not shown.
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
import RPi.GPIO as GPIO
21
import time
2+
import board
33
import mcpi.minecraft as minecraft
4-
mc = minecraft.Minecraft.create()
4+
from digitalio import DigitalInOut, Direction
55

6-
GPIO.setmode(GPIO.BCM)
6+
mc = minecraft.Minecraft.create()
77

8-
padPin = 23
8+
pad_pin = board.D23
99

10-
GPIO.setup(padPin, GPIO.IN)
10+
pad = DigitalInOut(pad_pin)
11+
pad.direction = Direction.INPUT
1112

1213
# melon block
13-
blockType = 103
14+
block_type = 103
1415

1516
while True:
16-
padPressed = GPIO.input(padPin)
1717

18-
if padPressed:
18+
if pad.value:
1919
pos = mc.player.getPos()
2020
x = pos.x
2121
y = pos.y
2222
z = pos.z
23-
mc.setBlock(x, y, z, blockType)
23+
mc.setBlock(x, y, z, block_type)
2424

2525
time.sleep(0.1)

0 commit comments

Comments
 (0)