Minecraft
First All import are I will write here ok and you know how to import file is here
first you create folder name assets
and python file
and all code is here and if you want write step by step watch this :- here
from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
app = Ursina()
grass_texture = load_texture("assets/grass.jpg")
gold_texture = load_texture("assets/gold.jpg")
glass_texture = load_texture("assets/glass.png")
wood_texture = load_texture("assets/wood.jpg")
diamond_texture = load_texture("assets/diamond.jpg")
plank_texture = load_texture("assets/plank.jpg")
neterite_texture = load_texture("assets/neterite.jpg")
stone_texture = load_texture("assets/stone.png")
stoneb_texture = load_texture("assets/stone b.jpg")
coblestone_texture = load_texture("assets/coblestone.png")
white_texture = load_texture("assets/white wool.png")
sky_texture = load_texture("assets/sky.jpg")
current_texture = wood_texture
current_texture = plank_texture
current_texture = glass_texture
current_texture = stone_texture
current_texture = stoneb_texture
current_texture = coblestone_texture
current_texture = white_texture
current_texture = gold_texture
current_texture = diamond_texture
current_texture = neterite_texture
current_texture = grass_texture
def update():
global current_texture
if held_keys['1']: current_texture = wood_texture
if held_keys['2']: current_texture = plank_texture
if held_keys['3']: current_texture = glass_texture
if held_keys['4']: current_texture = stone_texture
if held_keys['5']: current_texture = stoneb_texture
if held_keys['6']: current_texture = coblestone_texture
if held_keys['7']: current_texture = white_texture
if held_keys['8']: current_texture = gold_texture
if held_keys['9']: current_texture = diamond_texture
if held_keys['0']: current_texture = neterite_texture
if held_keys['`']: current_texture = grass_texture
class Sky(Entity):
def __init__(self):
super().__init__(
parent = scene,
model = 'sphere',
scale = 300,
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,
highlight_color = color.lime,
texture = texture,
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(30):
for x in range(30):
voxel = Voxel((x,0,z))
for z in range(30):
for x in range(30):
voxel = Voxel((x,1,z))
for z in range(30):
for x in range(30):
voxel = Voxel((x,2,z))
player = FirstPersonController()
sky = Sky()
app.run()
From: Zeetoc
Author: Pratham
Thanks for reading
1 Comments
This programme is nice
ReplyDelete