- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPyCraft_Code.py
More file actions
Latest commit
113 lines (97 loc) · 3.38 KB
/
Copy pathPyCraft_Code.py
File metadata and controls
113 lines (97 loc) · 3.38 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Imports
importursina
fromursinaimport*
fromursina.prefabs.first_person_controllerimportFirstPersonController
PyCraft=Ursina()
window.fps_counter.enabled=True
window.exit_button.visible=True
camera.fov=50
# Textures
grass_texture=load_texture('assets/grass_block.png')
stone_texture=load_texture('assets/stone_block.png')
brick_texture=load_texture('assets/brick_block.png')
dirt_texture=load_texture('assets/dirt_block.png')
sky_texture=load_texture('assets/skybox.png')
arm_texture=load_texture('assets/arm_texture.png')
snow_texture=load_texture('assets/snow_texture.png')
diamond_texture=load_texture('assets/item_diamond.png')
# Audio
panch_sund=Audio('C:/Users/Gabri/Desktop/assets/assets_punch_sound.wav', loop=False, autoplay=False)
#B locks pick
block_pick=1
defupdate():
globalblock_pick
ifheld_keys ['1']:
block_pick=1
ifheld_keys['2']:
block_pick=2
ifheld_keys['3']:
block_pick=3
ifheld_keys['4']:
block_pick=4
ifheld_keys ['5']:
block_pick=5
ifheld_keys['right mouse'] orheld_keys['left mouse']:
hand.active()
else:
hand.passive()
# The Block
classVoxel(Button):
def__init__(self, position= (0,0,0), texture=grass_texture):
super().__init__(
parent=scene,
position=position,
model='C:/Users/Gabri/Desktop/assets/block.obj',
origin_y=0.5,
texture=texture,
color=color.color(0,0,random.uniform(0.9,1)),
scale=0.5)
definput(self,key):
ifself.hovered:
ifkey=='right mouse down':
panch_sund.play()
ifblock_pick==1:
voxle=Voxel(position=self.position+mouse.normal, texture=grass_texture)
ifblock_pick==2:
voxle=Voxel(position=self.position+mouse.normal, texture=stone_texture)
ifblock_pick==3:
voxle=Voxel(position=self.position+mouse.normal, texture=dirt_texture)
ifblock_pick==4:
voxle=Voxel(position=self.position+mouse.normal, texture=brick_texture)
ifblock_pick==5:
voxle=Voxel(position=self.position+mouse.normal, texture=snow_texture)
ifkey=='left mouse down':
panch_sund.play()
destroy(self)
classMinecraftSky(Entity):
def__init__(self):
super().__init__(
parent=scene,
model='sphere',
texture=sky_texture,
scale=200,
double_sided=True)
# Hand
classHand(Entity):
def__init__(self):
super().__init__(
parent=camera.ui,
model='assets/arm.obj',
texture=arm_texture,
scale=0.2,
rotation=Vec3(150,-10,0),
position=Vec2(0.6,-0.6))
defactive(self):
self.position=Vec2(0.5,-0.5)
defpassive(self):
self.position=Vec2(0.6,-0.6)
forzinrange(50):
forxinrange(50):
voxle=Voxel(position= (x,0,z))
player=FirstPersonController(speed=10,
jump_height=0.7,
cursor=Entity(parent=camera.ui, model='Circle', color=color.white, scale=.008, rotation_z=45))
sky=MinecraftSky()
voxle=Voxel()
hand=Hand()
PyCraft.run()