Giter Site home page Giter Site logo

Comments (3)

a2cy avatar a2cy commented on July 18, 2024

the error youre getting is because youre trying to parent te cube to itself. if you want to use multiple textures on one Entity you have to create a texture atlas or use a texture array

from ursina.

DrFHMNBU avatar DrFHMNBU commented on July 18, 2024

This is the atlas:
atlas_grass_cube
But I have this code:

from ursina import *
import math

app = Ursina()

window.borderless = False
window.exit_button.visible = False
window.fps_counter.enabled = False
window.entity_counter.enabled = False
window.collider_counter.enabled = False

def g(x,y,z):
    cube = Entity(model='cube', texture='dirt', position=(x, y, z), scale=(1,3,1))
    cube = Entity(parent='cube', model='cube', texture='grass_side', position=(x, y + 1, z), scale=(1.01,1,1.01))
    cube = Entity(parent='cube', model='cube', texture='grass', position=(x, y + 1, z), scale=(1,1.01,1))

def getSurface(i,k):
    return int((sin(i/5)+cos(k/5))*5)+int((sin(i/25)+cos(k/25))*25)-50

for i in range(20):
    for k in range(20):
        surface=getSurface(i,k)
        g(i,surface,k)

walkspeed=4
rotspeed=90
mouse_sensitivity = Vec2(20, 20)

window.color = color.rgb(0,127,255)

def update():
    if held_keys['space'] and mouse.locked == True and mouse.visible == False:
        camera.position += (0, time.dt*walkspeed, 0)
    if held_keys['x'] and mouse.locked == True and mouse.visible == False:
        camera.position += (0,-time.dt*walkspeed, 0) 
    if held_keys['w'] and mouse.locked == True and mouse.visible == False:
        camera.position += (math.sin(math.radians(camera.rotation_y)) * time.dt * walkspeed, 0, math.cos(math.radians(camera.rotation_y)) * time.dt * walkspeed)
    if held_keys['s'] and mouse.locked == True and mouse.visible == False:
        camera.position -= (math.sin(math.radians(camera.rotation_y)) * time.dt * walkspeed, 0, math.cos(math.radians(camera.rotation_y)) * time.dt * walkspeed)
    if held_keys['a'] and mouse.locked == True and mouse.visible == False:
        camera.position -= (math.cos(math.radians(camera.rotation_y)) * time.dt * walkspeed, 0, -math.sin(math.radians(camera.rotation_y)) * time.dt * walkspeed)
    if held_keys['d'] and mouse.locked == True and mouse.visible == False:
        camera.position += (math.cos(math.radians(camera.rotation_y)) * time.dt * walkspeed, 0, -math.sin(math.radians(camera.rotation_y)) * time.dt * walkspeed)
    if mouse.left:
        mouse.locked = True
        mouse.visible = False
    if held_keys['escape']:
        mouse.locked = False
        mouse.visible = True
    if mouse.locked == True and mouse.visible == False:
        camera.rotation_y += mouse.velocity[0] * mouse_sensitivity[1]
        camera.rotation_x -= mouse.velocity[1] * mouse_sensitivity[0]
        camera.rotation_x = clamp(camera.rotation_x, -90, 90)

app.run()

How to use it? With texture.load("atlas_grass_cube") ?:
image

from ursina.

a2cy avatar a2cy commented on July 18, 2024

you need to make your own cube model

from ursina.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.