forked from juedwards/MinecraftEducationPythonExamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpixel_art.py
More file actions
54 lines (47 loc) · 1.59 KB
/
pixel_art.py
File metadata and controls
54 lines (47 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Agent Pixel Art with Array
# 26 Feb 2023
# @JustinEducation
def on_on_chat():
# teleport to player
agent.teleport_to_player()
# 2d array which contains pixel drawing 10x10.
art_stack = [[3,3,8,3,3,3,8,3,8,3],
[8,3,3,8,3,3,3,8,3,3],
[3,8,3,4,3,3,4,3,3,8],
[8,3,3,4,4,4,4,3,8,3],
[3,8,3,4,4,4,4,8,3,8],
[8,3,3,8,4,4,8,8,3,3],
[8,3,4,4,3,8,4,4,8,3],
[3,8,4,4,8,3,4,4,3,8],
[8,3,3,8,3,3,3,8,3,3],
[3,3,8,3,3,3,8,3,8,3]]
# loads color blocks with Agent
agent.set_item(RED_CONCRETE,64,1)
agent.set_item(BLUE_CONCRETE,64,2)
agent.set_item(GREEN_CONCRETE,64,3)
agent.set_item(BLACK_CONCRETE,64,4)
agent.set_item(ORANGE_CONCRETE,64,5)
agent.set_item(PURPLE_CONCRETE,64,6)
agent.set_item(CYAN_CONCRETE,64,7)
agent.set_item(LIME_CONCRETE,64,8)
agent.set_item(PINK_CONCRETE,64,9)
player.say("Running code.")
#loop through rows in array
for row in art_stack:
# for each item in a row
for item in row:
#move forward
agent.move(FORWARD,1)
#select the right resourcee in hot bar
agent.set_slot(item)
# place behind
agent.place(BACK)
#when row is built, move up
agent.move(UP,1)
# turn around
agent.turn_left()
agent.turn_left()
# move forward to be ready to build the newt line
agent.move(FORWARD,1)
# 'run' in chat runs code
player.on_chat("run", on_on_chat)