五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊

隨機(jī)地形只要3行代碼?背后是大名鼎鼎的柏林噪聲!論游戲中數(shù)學(xué)的重要性 | Pyt

2023-03-18 12:09 作者:xiaotiaotiao2011  | 我要投稿
from ursina import *  # 導(dǎo)入ursina
from ursina.prefabs.first_person_controller import FirstPersonController
import random
from perlin_noise import PerlinNoise

seed = int(input("請輸入4位地圖種子(1000-9999):"))
if len(str(seed)) != 4:
    print("種子長度沒有4位")
try:
    oct = int(input("請輸入畫質(zhì)質(zhì)量(2-5):"))
    if oct >= 5:
        print("畫質(zhì)過高,可能會(huì)太卡")
except:
    print("畫質(zhì)錯(cuò)誤")
try:
    big_or_small = int(input("請輸入地圖大小(6-50):"))
    if big_or_small < 5:
        print("地圖可能太小")
except:
    print("地圖錯(cuò)誤")




app = Ursina()  # 創(chuàng)建一個(gè)窗口

grass_texture = load_texture('assets/grass_block.png')
stone_texture = load_texture('assets/stone_block.png')
brick_texture = load_texture('assets/brick_block.png')
dirt_texture = load_texture('assets/dirt_block.png')
sky_texture = load_texture('assets/skybox.png')
arm_texture = load_texture('assets/arm_texture.png')
punch_sound = Audio('assets/punch_sound.wav', loop=False, autoplay=False)
block_pick = 1

window.exit_button.visible = False

scene.fog_color = color.white
scene.fog_density = 0.04


def input(key):
    if key == 'q':
        quit()


def update():
    global block_pick
    if held_keys['1']:
        block_pick = 1
    if held_keys['2']:
        block_pick = 2
    if held_keys['3']:
        block_pick = 3
    if held_keys['4']:
        block_pick = 4

    if held_keys['left mouse'] or held_keys['right mouse']:
        hand.active()
    else:
        hand.passive()


class Block(Button):
    def __init__(self, position=(0, 0, 0), texture=grass_texture):
        super().__init__(
            parent=scene,
            position=position,
            model='assets/block',
            origin_y=0.5,
            texture=texture,
            color=color.color(0, 0, random.uniform(0.9, 1)),
            # highlight_color=color.red,
            scale=0.5
        )

    def input(self, key):
        if self.hovered:
            if key == 'left mouse down':
                punch_sound.play()
                if block_pick == 1:
                    block = Block(position=self.position + mouse.normal, texture=grass_texture)
                if block_pick == 2:
                    for i in range(3):
                        block = Block(position=self.position + mouse.normal, texture=stone_texture)
                if block_pick == 3:
                    for i in range(5):
                        block = Block(position=self.position + mouse.normal, texture=brick_texture)
                if block_pick == 4:
                    for i in range(2):
                        block = Block(position=self.position + mouse.normal, texture=dirt_texture)

            if key == 'right mouse down':
                punch_sound.play()
                destroy(self)


class Sky(Entity):
    def __init__(self):
        super().__init__(
            parent=scene,
            model='sphere',
            texture=sky_texture,
            scale=random.randrange(100, 300),
            double_sided=True
        )


class Hand(Entity):
    def __init__(self):
        super().__init__(
            parent=camera.ui,
            model='assets/arm',
            texture=arm_texture,
            scale=0.2,
            rotation=Vec3(150, -big_or_small, 0),
            position=Vec2(0.7, -0.58)
        )

    def active(self):
        self.position = Vec2(0.5, -0.53)

    def passive(self):
        self.position = Vec2(0.7, -0.58)


noise = PerlinNoise(octaves=oct, seed=seed)
for z in range(big_or_small):
    for x in range(big_or_small):
        for y in range(1):
            block = Block(position=(x, 0, z))
            block.y = floor(noise([x / 24, z / 24]) * 8) + y

for z in range(big_or_small):
    for x in range(big_or_small):
        for y in range(4):
            for i in range(2):
                block = Block(position=(x, 0, z), texture=dirt_texture)
                block.y = floor(noise([x / 24, z / 24]) * 8) + y - 4

for z in range(big_or_small):
    for x in range(big_or_small):
        for y in range(4):
            for i in range(3):
                block = Block(position=(x, 0, z), texture=stone_texture)
                block.y = floor(noise([x / 24, z / 24]) * 8) + y - 8

for z in range(big_or_small):
    for x in range(big_or_small):
        for y in range(1):
            for i in range(5):
                block = Block(position=(x, 0, z), texture=brick_texture)
                block.y = floor(noise([x / 24, z / 24]) * 8) + y - 9

player = FirstPersonController(x=big_or_small/2-1, y=big_or_small+50, z=big_or_small/2-1)

sky = Sky()
hand = Hand()

app.run()


隨機(jī)地形只要3行代碼?背后是大名鼎鼎的柏林噪聲!論游戲中數(shù)學(xué)的重要性 | Pyt的評論 (共 條)

分享到微博請遵守國家法律
灌云县| 买车| 永平县| 巴楚县| 磐石市| 宜黄县| 东丽区| 托克托县| 大同县| 新巴尔虎左旗| 平南县| 满城县| 收藏| 平顶山市| 休宁县| 内黄县| 尖扎县| 资源县| 横峰县| 韩城市| 历史| 万载县| 日土县| 南澳县| 福安市| 宁波市| 法库县| 嘉黎县| 六安市| 松江区| 乐亭县| 湘潭县| 抚宁县| 固阳县| 博白县| 旺苍县| 房山区| 安陆市| 碌曲县| 多伦县| 塘沽区|