Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

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.
Comment

PREVIOUS NEXT
Code Example
Python :: python run command and read output 
Python :: how to reboot a python script 
Python :: how to combine two arrays in python 
Python :: python snakes 
Python :: conda env 
Python :: Python Tkinter Canvas Widget 
Python :: pytesseract.image_to_string save text file 
Python :: No package python37 available. 
Python :: python check if two sets intersect 
Python :: switching keys and values in a dictionary in python [duplicate] 
Python :: are tuples mutable 
Python :: construct contingency table from pandas 
Python :: 2 distinct numbers random number generator python 
Python :: get only first 10 columns pandas 
Python :: python get first n elements of dict 
Python :: anagram program in python 
Python :: convert string to integer in dictionary python 
Python :: python sort two key 
Python :: create a new dataframe from existing dataframe pandas 
Python :: pandas gropu by 
Python :: armstrong python 
Python :: change color of butto in thkinter 
Python :: how to delete role discord py rewrite 
Python :: python set and dictionary comprehensions 
Python :: excel get unique values from column formula 
Python :: short form of if statement in python 
Python :: find index of maximum value in list python 
Python :: sort a string in python 
Python :: list of numbers 
Python :: python open and read file with 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =