Game Enviornment using Python and ursina library.

from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
app = Ursina()
grass_texture = load_texture("assets/grass.png")
sky_texture = load_texture("assets/sky.png")
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,
            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 )
            if key == "right mouse down":
                destroy(self)
for z in range(50):
    for x in range(50):
        voxel = Voxel((x,0,z))
player = FirstPersonController()
sky = Sky()
app.run()
using Pycharm IDE to create game environment
basic platform and sky environment

By Pankaj

Leave a Reply

Your email address will not be published. Required fields are marked *