Skip to content

Commit 8d393f0

Browse files
first commit
0 parents  commit 8d393f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+236
-0
lines changed

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.vscode
2+
/__pycache__

Diff for: assets/block.mtl

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Made in Blockbench 4.5.2
2+
newmtl m_1478cec5-1946-7eb6-b84d-50a1f55591bd
3+
map_Kd texture
4+
newmtl none

Diff for: assets/block.obj

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Made in Blockbench 4.5.2
2+
mtllib block.mtl
3+
4+
o cube
5+
v 0.5 1 0.5
6+
v 0.5 1 -0.5
7+
v 0.5 0 0.5
8+
v 0.5 0 -0.5
9+
v -0.5 1 -0.5
10+
v -0.5 1 0.5
11+
v -0.5 0 -0.5
12+
v -0.5 0 0.5
13+
vt 0 1
14+
vt 0.25 1
15+
vt 0.25 0.75
16+
vt 0 0.75
17+
vt 0 0.75
18+
vt 0.25 0.75
19+
vt 0.25 0.5
20+
vt 0 0.5
21+
vt 0.25 1
22+
vt 0.5 1
23+
vt 0.5 0.75
24+
vt 0.25 0.75
25+
vt 0.25 0.75
26+
vt 0.5 0.75
27+
vt 0.5 0.5
28+
vt 0.25 0.5
29+
vt 0.25 0.25
30+
vt 0 0.25
31+
vt 0 0.5
32+
vt 0.25 0.5
33+
vt 0.75 1
34+
vt 0.5 1
35+
vt 0.5 0.75
36+
vt 0.75 0.75
37+
vn 0 0 -1
38+
vn 1 0 0
39+
vn 0 0 1
40+
vn -1 0 0
41+
vn 0 1 0
42+
vn 0 -1 0
43+
usemtl m_1478cec5-1946-7eb6-b84d-50a1f55591bd
44+
f 4/4/1 7/3/1 5/2/1 2/1/1
45+
f 3/8/2 4/7/2 2/6/2 1/5/2
46+
f 8/12/3 3/11/3 1/10/3 6/9/3
47+
f 7/16/4 8/15/4 6/14/4 5/13/4
48+
f 6/20/5 1/19/5 2/18/5 5/17/5
49+
f 7/24/6 4/23/6 3/22/6 8/21/6

Diff for: assets/cobblestone_block_tex.png

616 Bytes

Diff for: assets/dirt_block_tex.png

601 Bytes

Diff for: assets/grass_block_tex.png

1.77 KB

Diff for: assets/ice_block_tex.png

846 Bytes

Diff for: assets/music/calm1.ogg

2.41 MB
Binary file not shown.

Diff for: assets/music/calm2.ogg

1.89 MB
Binary file not shown.

Diff for: assets/music/calm3.ogg

2.13 MB
Binary file not shown.

Diff for: assets/music/hal1.ogg

1.88 MB
Binary file not shown.

Diff for: assets/music/hal3.ogg

1.83 MB
Binary file not shown.

Diff for: assets/music/hal4.ogg

2.44 MB
Binary file not shown.

Diff for: assets/oak_block_tex.png

725 Bytes

Diff for: assets/obsidian_block_tex.png

581 Bytes

Diff for: assets/planks_block_tex.png

587 Bytes

Diff for: assets/sand_block_tex.png

556 Bytes

Diff for: assets/sounds/cobblestone/cobblestone1.ogg

6.54 KB
Binary file not shown.

Diff for: assets/sounds/cobblestone/cobblestone2.ogg

6.57 KB
Binary file not shown.

Diff for: assets/sounds/cobblestone/cobblestone3.ogg

6.47 KB
Binary file not shown.

Diff for: assets/sounds/cobblestone/cobblestone4.ogg

6.36 KB
Binary file not shown.

Diff for: assets/sounds/dirt/dirt1.ogg

7.29 KB
Binary file not shown.

Diff for: assets/sounds/dirt/dirt2.ogg

7.51 KB
Binary file not shown.

Diff for: assets/sounds/dirt/dirt3.ogg

7.03 KB
Binary file not shown.

Diff for: assets/sounds/dirt/dirt4.ogg

7 KB
Binary file not shown.

Diff for: assets/sounds/grass/grass1.ogg

7.29 KB
Binary file not shown.

Diff for: assets/sounds/grass/grass2.ogg

7.51 KB
Binary file not shown.

Diff for: assets/sounds/grass/grass3.ogg

7.03 KB
Binary file not shown.

Diff for: assets/sounds/grass/grass4.ogg

7 KB
Binary file not shown.

Diff for: assets/sounds/ice/ice1.ogg

6.54 KB
Binary file not shown.

Diff for: assets/sounds/ice/ice2.ogg

6.57 KB
Binary file not shown.

Diff for: assets/sounds/ice/ice3.ogg

6.47 KB
Binary file not shown.

Diff for: assets/sounds/ice/ice4.ogg

6.36 KB
Binary file not shown.

Diff for: assets/sounds/oak/oak1.ogg

6.39 KB
Binary file not shown.

Diff for: assets/sounds/oak/oak2.ogg

6.15 KB
Binary file not shown.

Diff for: assets/sounds/oak/oak3.ogg

6.45 KB
Binary file not shown.

Diff for: assets/sounds/oak/oak4.ogg

6.66 KB
Binary file not shown.

Diff for: assets/sounds/obsidian/obsidian1.ogg

6.54 KB
Binary file not shown.

Diff for: assets/sounds/obsidian/obsidian2.ogg

6.57 KB
Binary file not shown.

Diff for: assets/sounds/obsidian/obsidian3.ogg

6.47 KB
Binary file not shown.

Diff for: assets/sounds/obsidian/obsidian4.ogg

6.36 KB
Binary file not shown.

Diff for: assets/sounds/planks/planks1.ogg

6.39 KB
Binary file not shown.

Diff for: assets/sounds/planks/planks2.ogg

6.15 KB
Binary file not shown.

Diff for: assets/sounds/planks/planks3.ogg

6.45 KB
Binary file not shown.

Diff for: assets/sounds/planks/planks4.ogg

6.66 KB
Binary file not shown.

Diff for: assets/sounds/sand/sand1.ogg

5.41 KB
Binary file not shown.

Diff for: assets/sounds/sand/sand2.ogg

5.42 KB
Binary file not shown.

Diff for: assets/sounds/sand/sand3.ogg

5.42 KB
Binary file not shown.

Diff for: assets/sounds/sand/sand4.ogg

5.36 KB
Binary file not shown.

Diff for: assets/sounds/sh/die.ogg

6.39 KB
Binary file not shown.

Diff for: assets/sounds/sh/spawn.ogg

38.2 KB
Binary file not shown.

Diff for: assets/sounds/stone/stone1.ogg

6.54 KB
Binary file not shown.

Diff for: assets/sounds/stone/stone2.ogg

6.57 KB
Binary file not shown.

Diff for: assets/sounds/stone/stone3.ogg

6.47 KB
Binary file not shown.

Diff for: assets/sounds/stone/stone4.ogg

6.36 KB
Binary file not shown.

Diff for: assets/stone_block_tex.png

620 Bytes

Diff for: assets/texture.png

375 Bytes

Diff for: main.py

+181
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
from ursina import *
2+
from ursina.prefabs.first_person_controller import FirstPersonController
3+
from perlin_noise import PerlinNoise
4+
from ursina.shaders import basic_lighting_shader
5+
import random
6+
import sys
7+
import math
8+
9+
10+
11+
app = Ursina()
12+
13+
player = FirstPersonController()
14+
15+
window.exit_button.visible = False
16+
window.fullscreen = True
17+
window.borderless = False
18+
window.color = color.rgb(0,181,226)
19+
window.show_ursina_splash = True
20+
window.title = "Minecraft Python Edition"
21+
player.height = 2
22+
player.gravity = 0.5
23+
player.y = 50
24+
block_id = 1
25+
bgmusic = [Audio("assets/music/calm1.ogg", loop=True, autoplay=False),
26+
Audio("assets/music/calm2.ogg", loop=True, autoplay=False),
27+
Audio("assets/music/calm3.ogg", loop=True, autoplay=False),
28+
Audio("assets/music/hal1.ogg", loop=True, autoplay=False),
29+
Audio("assets/music/hal3.ogg", loop=True, autoplay=False),
30+
Audio("assets/music/hal4.ogg", loop=True, autoplay=False),
31+
]
32+
bgumusic = random.choice(bgmusic)
33+
# bgmusic.autoplay = True
34+
voxels = []
35+
noise = PerlinNoise(octaves=3,seed=random.randint(1,1000000))
36+
37+
blocks = [
38+
['hello', "hello", "hello"],
39+
["grass", "assets/grass_block_tex.png", load_texture("assets/grass_block_tex.png")],
40+
["dirt", "assets/dirt_block_tex.png", load_texture("assets/dirt_block_tex.png")],
41+
["stone", "assets/stone_block_tex.png", load_texture("assets/stone_block_tex.png")],
42+
["cobblestone", "assets/cobblestone_block_tex.png", load_texture("assets/cobblestone_block_tex.png")],
43+
["sand", "assets/sand_block_tex.png", load_texture("assets/sand_block_tex.png")],
44+
["oak", "assets/oak_block_tex.png", load_texture("assets/oak_block_tex.png")],
45+
["planks", "assets/planks_block_tex.png", load_texture("assets/planks_block_tex.png")],
46+
["obsidian", "assets/obsidian_block_tex.png", load_texture("assets/obsidian_block_tex.png")],
47+
["ice", "assets/ice_block_tex.png", load_texture("assets/ice_block_tex.png")]
48+
]
49+
50+
def findsoundbasedontexture(blockid,blocklist=blocks):
51+
if blocklist[blockid][0] in blocklist[blockid][1]:
52+
sound = Audio(f"assets/sounds/{blocklist[blockid][0]}/{blocklist[blockid][0]}{random.randint(1, 4)}", loop=False, autoplay=False)
53+
return sound
54+
55+
# def whichblockami(block):
56+
# for eachBlock in blocks:
57+
# if block.texture in eachBlock[1]:
58+
# print(eachBlock[0])
59+
60+
61+
62+
def update():
63+
if held_keys['left mouse down'] or held_keys['right mouse down']:
64+
# punch_sound.play()
65+
hand.active()
66+
else:
67+
hand.passive()
68+
69+
if held_keys['escape']:
70+
sys.exit()
71+
72+
if player.y < -110:
73+
Audio("assets/sounds/sh/die.ogg")
74+
player.y = 15
75+
player.x = 0
76+
player.z = 0
77+
Audio("assets/sounds/sh/spawn.ogg")
78+
79+
80+
class Side(Entity):
81+
def __init__(self, x, y, z):
82+
super().__init__(
83+
parent=scene,
84+
position=(x, y, z),
85+
model="quad",
86+
scale=(16, 1, 16),
87+
texture=None,
88+
89+
)
90+
91+
92+
class Voxel(Button):
93+
def __init__(self, position=(0, 0, 0), texture="assets/grass_block_tex.png"):
94+
super().__init__(
95+
parent=scene,
96+
position=position,
97+
model="assets/block",
98+
origin_y=0.5,
99+
texture=texture,
100+
color=color.color(0, 0, random.uniform(0.9, 1)),
101+
scale=1,
102+
shader=basic_lighting_shader,
103+
# block=whichblockami(self)
104+
)
105+
106+
def input(self, key):
107+
if self.hovered:
108+
if key == 'right mouse down':
109+
findsoundbasedontexture(blockid=block_id).play()
110+
Voxel(position=self.position + mouse.normal,
111+
texture=blocks[block_id][2])
112+
if key == 'left mouse down':
113+
findsoundbasedontexture(blockid=block_id).play()
114+
destroy(self)
115+
116+
def create_sides(self, direction, x, y, z):
117+
if direction == "north":
118+
plane = Side(x=x+15, y=y, z=z)
119+
plane.texture = "textures/grass_block_side.png"
120+
if direction == "south":
121+
plane = Side(x=x-15, y=y, z=z)
122+
plane.texture = "textures/grass_block_side.png"
123+
if direction == "west":
124+
plane = Side(x=x, y=y, z=z+15)
125+
plane.texture = "textures/grass_block_side.png"
126+
if direction == "east":
127+
plane = Side(x=x, y=y, z=z-15)
128+
plane.texture = "textures/grass_block_side.png"
129+
if direction == "up":
130+
plane = Side(x=x, y=y+15, z=z)
131+
plane.texture = "textures/grass_block_top.png"
132+
if direction == "down":
133+
plane = Side(x=x, y=y-15, z=z)
134+
plane.texture = "textures/dirt.png"
135+
136+
137+
138+
139+
140+
141+
def input(key):
142+
global block_id, hand
143+
if key.isdigit():
144+
block_id = int(key)
145+
if block_id >= len(blocks):
146+
block_id = len(blocks) - 1
147+
hand.texture = blocks[block_id][2]
148+
149+
150+
class Hand(Entity):
151+
def __init__(self):
152+
super().__init__(
153+
parent=camera.ui,
154+
model='assets/block',
155+
texture=blocks[block_id][2],
156+
scale=0.4,
157+
shader=basic_lighting_shader,
158+
rotation=Vec3(-10, -10, 10),
159+
position=Vec2(-0.6, -0.6)
160+
)
161+
162+
@staticmethod
163+
def active():
164+
hand.position = Vec2(0.4, -0.5)
165+
166+
@staticmethod
167+
def passive():
168+
hand.position = Vec2(0.6, -0.6)
169+
170+
for z in range(-10,10):
171+
for x in range(-10,10):
172+
y = noise([x * .02, z * .02])
173+
y = math.floor(y * 7.5)
174+
voxel = Voxel(position=(x,y,z))
175+
# voxels.append(voxel)
176+
177+
hand = Hand()
178+
179+
app.run()
180+
181+

Diff for: textures/Grassblock.png

1.09 KB

Diff for: textures/block_images/cobblestone.png

265 Bytes

Diff for: textures/block_images/dirt.png

266 Bytes

Diff for: textures/block_images/grass_block_side.png

332 Bytes

Diff for: textures/block_images/grass_block_side_overlay.png

295 Bytes

Diff for: textures/block_images/grass_block_top (1).png

560 Bytes

Diff for: textures/block_images/grass_block_top.png

808 Bytes

Diff for: textures/block_images/ice.png

249 Bytes

Diff for: textures/block_images/oak_log.png

263 Bytes

Diff for: textures/block_images/oak_log_top.png

273 Bytes

Diff for: textures/block_images/oak_planks.png

268 Bytes

Diff for: textures/block_images/obsidian.png

263 Bytes

Diff for: textures/block_images/sand.png

262 Bytes

Diff for: textures/block_images/stone.png

215 Bytes

Diff for: trees.py

Whitespace-only changes.

0 commit comments

Comments
 (0)