Skip to content

Commit 051736d

Browse files
added minor improvements
1 parent 799d8c4 commit 051736d

File tree

4 files changed

+79
-15
lines changed

4 files changed

+79
-15
lines changed

configuration.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"fps_counter_enabled": true,
77
"treesCount": 5,
88
"parkour_mode": false,
9-
"land_size": 15
9+
"land_size": 15,
10+
"world_type": "default"
1011
}

main.py

Lines changed: 77 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
player.height = 2
1616
player.cursor = Entity(parent=camera.ui, model='quad',color=color.light_gray, scale=.008, rotation_z=45)
1717
player.gravity = 1
18-
player.jump_up_duration = .3
18+
player.jump_height = 1
19+
player.fall_after = .30
1920
# player.model = "assets/player.obj"
2021
# player.texture = "textures/"
2122

@@ -75,6 +76,7 @@
7576
fps_counter_enabled = data["fps_counter_enabled"]
7677
parkour = data["parkour_mode"]
7778
landsize = data["land_size"]
79+
world_type = data["world_type"]
7880

7981
if fps_counter_enabled == False:
8082
window.fps_counter = False
@@ -137,6 +139,7 @@ def whichblockami(block):
137139
except:
138140
print(f"No texture on index")
139141

142+
140143
# Sneaking
141144
def sneak():
142145
player.scale_y = 0.90
@@ -162,13 +165,13 @@ def default():
162165

163166
# Task Update
164167
def update():
165-
global inventorytrue, pressed
168+
global inventorytrue, pressed, items
166169
if held_keys['left mouse down'] or held_keys['right mouse down']:
167170
# punch_sound.play()
168171
hand.active()
169172
else:
170173
hand.passive()
171-
174+
172175
if held_keys["shift"]:
173176
sneak()
174177

@@ -205,13 +208,27 @@ def update():
205208
memoryUse = python_process.memory_info()[0]/2.**30
206209

207210
cpu_panel.text = f'CPU: {cpu}% / RAM: {ram}% / Memory use: {round(memoryUse,2)} GB'
208-
211+
209212
if player.y < -100:
210213
Audio("assets/sounds/sh/die.ogg")
211214
player.y = 15
212215
player.x = 0
213216
player.z = 0
214217
Audio("assets/sounds/sh/spawn.ogg")
218+
219+
# if player.y < -100:
220+
# Audio("assets/sounds/sh/die.ogg")
221+
# application.pause()
222+
# o.visible = True
223+
# dietext.visible = True
224+
# items = False
225+
# hotbar.destroyItems()
226+
# hotbar.visible = False
227+
# hand.visible = False
228+
# selected.visible = False
229+
# respawn_button = RespawnButton()
230+
# respawn_button.text_entity.font = button_font
231+
# mouse.locked = False
215232

216233
# Defining Voxel
217234
class Voxel(Button):
@@ -251,6 +268,36 @@ def input(key):
251268
block_id = len(blocks) - 1
252269
hand.texture = blocks[block_id][2]
253270

271+
# Death Screen
272+
o = Panel(scale=4, color=color.rgba(255, 0, 0, 200))
273+
o.visible = False
274+
items = True
275+
dietext = Text(font=button_font, text="You Died!",
276+
position=Vec2(-0.1, 0.2), color=color.white, scale=2)
277+
dietext.visible = False
278+
class RespawnButton(Button):
279+
def __init__(self):
280+
super().__init__(
281+
text="Respawn",
282+
parent=camera.ui,
283+
model="quad",
284+
texture="textures/widgets/button.png",
285+
color=color.color(0, 0, random.uniform(0.9, 1)),
286+
scale=(0.5, 0.1)
287+
)
288+
289+
def input(self, key):
290+
if self.hovered:
291+
self.texture = "textures/widgets/button_selected.png"
292+
if key == "left mouse down":
293+
dietext.visible = False
294+
application.resume()
295+
player.y = 15
296+
player.x = 0
297+
player.z = 0
298+
Audio("assets/sounds/sh/spawn.ogg")
299+
destroy(self)
300+
254301
# Defining Hand
255302
class Hand(Entity):
256303
def __init__(self):
@@ -330,16 +377,27 @@ def __init__(self):
330377
)
331378

332379
def appendItems(self):
333-
grass = Item(blocks[1][2],(-0.35,-0.42))
334-
dirt = Item(blocks[2][2],(-0.26,-0.42))
335-
stone = Item(blocks[3][2],(-0.17, -0.42))
336-
cobblestone = Item(blocks[4][2],(-0.08,-0.42))
337-
sand = Item(blocks[5][2],(0,-0.42))
338-
oak = Item(blocks[6][2],(0.08,-0.42))
339-
planks = Item(blocks[7][2],(0.17,-0.42))
340-
obsidian = Item(blocks[8][2], (0.26, -0.42))
341-
ice = Item(blocks[9][2], (0.35, -0.42))
380+
self.grass = Item(blocks[1][2],(-0.35,-0.42))
381+
self.dirt = Item(blocks[2][2],(-0.26,-0.42))
382+
self.stone = Item(blocks[3][2],(-0.17, -0.42))
383+
self.cobblestone = Item(blocks[4][2],(-0.08,-0.42))
384+
self.sand = Item(blocks[5][2],(0,-0.42))
385+
self.oak = Item(blocks[6][2],(0.08,-0.42))
386+
self.planks = Item(blocks[7][2],(0.17,-0.42))
387+
self.obsidian = Item(blocks[8][2], (0.26, -0.42))
388+
self.ice = Item(blocks[9][2], (0.35, -0.42))
342389

390+
def destroyItems(self):
391+
if items == False:
392+
self.grass.visible = False
393+
self.dirt.visible = False
394+
self.stone.visible = False
395+
self.cobblestone.visible = False
396+
self.sand.visible = False
397+
self.oak.visible = False
398+
self.planks.visible = False
399+
self.obsidian.visible = False
400+
self.ice.visible = False
343401
#-------------------------------------End of Inventory Zone-------------------------------------------
344402

345403
# Terrain Generation
@@ -348,7 +406,12 @@ def appendItems(self):
348406
if parkour == True:
349407
amp = 100
350408
else:
351-
amp = 6
409+
amp = 5
410+
411+
if world_type == "super_flat":
412+
amp = 0
413+
else:
414+
amp = 5
352415
for i in range(terrainWidth*terrainWidth):
353416
voxel = Voxel(texture=blocks[1][2])
354417
voxel.x = floor(i/terrainWidth)

textures/widgets/button.png

3.25 KB
Loading

textures/widgets/button_selected.png

3.26 KB
Loading

0 commit comments

Comments
 (0)