Skip to content

Commit

Permalink
Version 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperZekes committed Jul 25, 2024
1 parent 2dee22f commit 7e7d5c4
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
Binary file added assets/break_sound.mp3
Binary file not shown.
Binary file added assets/place_sound.mp3
Binary file not shown.
Binary file modified output/sinacraft.exe
Binary file not shown.
48 changes: 45 additions & 3 deletions sinacraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,51 @@

app = Ursina()

colors = [
color.red, color.orange, color.yellow, color.green,
color.azure, color.blue, color.white, color.pink, color.brown
]

selected_color_index = 0

# Load sound effects
place_sound = Audio('assets/place_sound.mp3', autoplay=False)
break_sound = Audio('assets/break_sound.mp3', autoplay=False)

hotbar = Entity(parent=camera.ui, model='quad', texture='white_cube',
scale=(0.9, 0.1), color=color.black, position=(0, -0.45, 0))

hotbar_slots = []
for i, col in enumerate(colors):
slot = Entity(parent=hotbar, model='quad', texture='white_cube',
scale=(0.1, 0.1), position=(i * 0.11 - 0.44, 0, -0.1),
color=col)
hotbar_slots.append(slot)

highlight = Entity(parent=hotbar, model='quad', scale=(0.11, 0.11),
color=color.white.tint(-0.5), position=(selected_color_index * 0.11 - 0.44, 0, -0.2))

class Voxel(Button):
def __init__(self, position=(0, 0, 0)):
def __init__(self, position=(0, 0, 0), block_color=color.white):
super().__init__(
parent=scene,
position=position,
model='cube',
origin_y=0.5,
texture='white_cube',
color=color.hsv(0, 0, random.uniform(0.9, 1)),
color=block_color,
highlight_color=color.lime,
)

def input(self, key):
if self.hovered:
if key == 'right mouse down':
voxel = Voxel(position=self.position + mouse.normal)
# Play place sound
place_sound.play()
voxel = Voxel(position=self.position + mouse.normal, block_color=colors[selected_color_index])
if key == 'left mouse down':
# Play break sound
break_sound.play()
destroy(self)

for z in range(20):
Expand All @@ -33,10 +61,24 @@ def input(self, key):
mouse.locked = True

def update():
global selected_color_index

if held_keys['escape']:
application.quit()

if player.y < -30:
player.position = (10, 10, 10)

for i in range(9):
if held_keys[str(i+1)]:
selected_color_index = i
break

if held_keys['scroll up']:
selected_color_index = (selected_color_index + 1) % len(colors)
elif held_keys['scroll down']:
selected_color_index = (selected_color_index - 1) % len(colors)

highlight.x = selected_color_index * 0.11 - 0.44

app.run()

0 comments on commit 7e7d5c4

Please sign in to comment.