Skip to content

Commit 4512544

Browse files
committed
파일 이름 수정 및 마인크래프트 터틀 기능 추가
1 parent 087a707 commit 4512544

File tree

6 files changed

+638
-38
lines changed

6 files changed

+638
-38
lines changed
File renamed without changes.
1.68 KB
Binary file not shown.
12 KB
Binary file not shown.

src/mcCmd.py

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
import mcpi.minecraft as minecraft
2+
import mcpi.block as block
3+
import Convert
4+
import mcTurtle
5+
import cmd
6+
7+
class Commands(cmd.Cmd):
8+
mc = minecraft.Minecraft.create()
9+
10+
def __init__(self):
11+
cmd.Cmd.__init__(self)
12+
self.prompt = ">> "
13+
self.intro = ""
14+
15+
def do_exit(self, args):
16+
# exit
17+
return -1
18+
19+
def do_EOF(self, line):
20+
return True
21+
22+
# convert mcMaps to turtlecraft(snu) Commands
23+
24+
def do_convert(self, args):
25+
Convert.Convert(self.startPos.x, self.startPos.y, self.startPos.z,
26+
self.endPos.x, self.endPos.y, self.endPos.z)
27+
28+
def do_setPos1(self, args):
29+
self.startPos = self.mc.player.getTilePos()
30+
print(str(self.startPos))
31+
32+
def do_setPos2(self, args):
33+
self.endPos = self.mc.player.getTilePos()
34+
print(str(self.endPos))
35+
36+
# mcTurtle Commands
37+
38+
def do_start(self, args):
39+
self.peter = mcTurtle.MinecraftTurtle(self.mc, self.mc.player.getPos())
40+
self.do_setTPos("setTPos")
41+
print(self.mc.player.getPos())
42+
43+
def do_setTPos(self, args):
44+
"set the turtle's position"
45+
temp = self.mc.player.getPos()
46+
self.peter.setposition(temp.x, temp.y, temp.z)
47+
48+
# Moves------------------------------------------
49+
50+
def do_up(self, num):
51+
"pitch up by a number(int) of degrees"
52+
try:
53+
self.peter.up(int(num))
54+
except Exception as ex:
55+
print("Error", ex)
56+
57+
58+
def do_down(self, num):
59+
"pitch down by a number(int) of degrees"
60+
try:
61+
self.peter.down(int(num))
62+
except Exception as ex:
63+
print("Error", ex)
64+
65+
def do_right(self, num):
66+
"rotate right by a number(int) of degrees"
67+
try:
68+
self.peter.right(int(num))
69+
except Exception as ex:
70+
print("Error", ex)
71+
72+
def do_left(self, num):
73+
"rotate left by a number(int) of degrees"
74+
try:
75+
self.peter.left(int(num))
76+
except Exception as ex:
77+
print("Error", ex)
78+
79+
def do_forward(self, num):
80+
"go forward by a number of blocks"
81+
try:
82+
self.peter.forward(int(num))
83+
except Exception as ex:
84+
print("Error", ex)
85+
86+
def do_backward(self, num):
87+
"go backward by a number of blocks"
88+
try:
89+
self.peter.backward(int(num))
90+
except Exception as ex:
91+
print("Error", ex)
92+
93+
def do_setSpeed(self, speed):
94+
"set Turtle's speed"
95+
try:
96+
self.peter.speed(int(speed))
97+
except Exception as ex:
98+
print("Error", ex)
99+
100+
def do_home(self, args):
101+
try:
102+
self.peter.home()
103+
except Exception as ex:
104+
print("Error", ex)
105+
106+
# Pens-----------------------------------------
107+
108+
def do_penUp(self, args):
109+
try:
110+
self.peter.penup()
111+
except Exception as ex:
112+
print("Error", ex)
113+
114+
def do_penDown(self, args):
115+
try:
116+
self.peter.pendown()
117+
except Exception as ex:
118+
print("Error", ex)
119+
120+
def do_isDown(self, args):
121+
try:
122+
print(self.peter.isdown())
123+
except Exception as ex:
124+
print("Error", ex)
125+
126+
def do_penBlock(self, num):
127+
try:
128+
self.peter.penblock(block.Block(int(num)))
129+
except Exception as ex:
130+
print("Error", ex)
131+
132+
if __name__ == "__main__":
133+
Commands().cmdloop()

src/mcCommand.py

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)