Comments (4)
from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
#from ursina.prefabs.exit_button import *
t = -1
app = Ursina()
a = Audio('assets/song_Forest.mp3', pitch=1, loop=True, autoplay=True)
a.volume=5
window.title = 'Minecraft_clone' # The window title
window.borderless = False # Show a border
window.fullscreen = False # Do not go Fullscreen
#window.exit_button.visible = False # Do not show the in-game red X that loses the window
window.fps_counter.enabled = True
window.cursor_hidden = False
#window.icon = "/assets/tree.jpg"
grass_texture = load_texture("assets/download.jpg")
sky_texture = load_texture("assets/sky.jpg")
soil_texture = load_texture("assets/soil.jpg")
tree_texture = load_texture("assets/tree.jpg")
plank_texture = load_texture("assets/planks.jpg")
leaf_texture = load_texture("assets/leaf.jpg")
wall_texture = load_texture("assets/wall.jpg")
stone_texture = load_texture("assets/stone.png")
iron_texture = load_texture("assets/images.png")
gold_texture = load_texture("assets/gold.png")
wall_2_texture = load_texture("assets/1.png")
current_texture = soil_texture
def update():
global current_texture
if held_keys['q']: exit()
if held_keys['Q']: exit()
if held_keys['1']: current_texture = grass_texture
if held_keys['2']: current_texture = soil_texture
if held_keys['3']: current_texture = tree_texture
if held_keys['4']: current_texture = plank_texture
if held_keys['5']: current_texture = leaf_texture
if held_keys['6']: current_texture = wall_texture
if held_keys['7']: current_texture = stone_texture
if held_keys['8']: current_texture = gold_texture
if held_keys['9']: current_texture = iron_texture
if held_keys['0']: current_texture = wall_2_texture
class Sky(Entity):
def init(self):
super().init(
parent=scene,
model='sphere',
scale=150,
texture=sky_texture,
double_sided=True
)
class Voxel(Button):
def init(self, position=(0, 0, 0), texture=grass_texture):
super().init(
parent=scene,
model='cube',
color=color.white,
texture=texture,
highlight_color=color.white,
position=position,
origin__y=0.5
)
def input(self, key):
if self.hovered:
if key == "left mouse down":
voxel = Voxel(position=self.position + mouse.normal, texture= current_texture)
if key == "right mouse down":
destroy(self)
for z in range(6):
for x in range(6):
voxel = Voxel((x, 0, z), texture= grass_texture)
while t >= -10:
for z in range(6):
for x in range(6):
voxel = Voxel((x, t, z) , texture= soil_texture)
t-=1
player = FirstPersonController()
sky = Sky()
app.run()
this is the code to which i am trying to add the code of the inventory, so please help me.
from ursina.
Can i have more details pls ?
from ursina.
ya, sure. so, i was trying to add inventory to a small game of mine but everytime i tryed to run the code, i got the same error (or similar error). i tryed many different iterations but non of them seemed to work properly. if you like, i can provide you with those codes that i tryed so you can look into it.
from ursina.
Related Issues (20)
- How to animate 3D character using shape keys HOT 1
- Conversation is broken HOT 2
- Cant apply different textures for each face of the cube using ursina engine HOT 3
- May bad terrain generation... HOT 1
- How to increase the performance with this python script?: HOT 1
- i dont have a rotation_gizmo_model.ursinamesh HOT 1
- Render distance performance-oriented HOT 1
- ValueError when running `particle_system.py` HOT 1
- I tried to merge all cubes in Mesh() function, but it didnt worked for me... HOT 1
- The discord link on reddit is down. HOT 1
- ERROR: Cannot install ursina==0.2, ursina==0.3..........ursina==6.1.1 and ursina==6.1.2 because these package versions have conflicting dependencies. HOT 2
- macOS missing dependency: ModuleNotFoundError: No module named 'screeninfo' HOT 3
- I used 'parent=terrain' and it didnt still worked for me for increase the performance: HOT 1
- Typo on documentation Entity Basics - Other Magic Functions HOT 2
- InputField should have a "wrap text" option
- Ursina cannot open monitor under Docker
- Graphics issues when converting to .exe HOT 2
- Ursina Build too little info HOT 1
- Loading issue for settings.py HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ursina.