Horje
how to make minecraft using python Code Example
how to make minecraft using python
from ursina import * 
from ursina.prefabs.first_person_controller import FirstPersonController

#we make this 'app' so that we can let the program run 
app = Ursina()

'''
each block in minecraft is a voxel, so we make a voxel class (the blocks)
and we give these voxels some attributes
'''
class Voxel(Button):
    def __init__(self, position = (0,0,0)):
        super().__init__(
            parent = scene,
            position = position,
            model = 'cube',
            origin_y = 0.5,
            texture = 'white_cube',
            color = color.color(0,0,random.uniform(0.9,1)),
            highlight_color = color.lime)
#this method below allows us to mine and place blocks on key command
    def input(self,key):
        if self.hovered:
            if key == 'left mouse down':
                voxel = Voxel(position = self.position + mouse.normal)

            if key == "right mouse down":
                destroy(self)
#the below tells us how big the field is going to be
for z in range(20):
    for x in range(20):
        voxel = Voxel(position = (x,0,z))

#this calls the first person controller
player = FirstPersonController()

#this makes ursina get called and runs the program
app.run()

#Run the program! Hopefully, it should work!!!!Good luck mining and crafting!

#This project is also on ClearCode's channel, so thanks to ClearCode.




Python

Related
numpy random for string Code Example numpy random for string Code Example
Identify Null and NAN python Code Example Identify Null and NAN python Code Example
bash install wheel Code Example bash install wheel Code Example
How to make a function repeat itself a specifc amount of times python Code Example How to make a function repeat itself a specifc amount of times python Code Example
title() in python Code Example title() in python Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
6