Creating a Minecraft style menu in Python [Ursina]
A tutorial about creating a Minecraft style menu in Python with Ursina. The project somewhat follows from my previous tutorial on how to create a basic Minecraft setup in Python.
Original Minecraft in Python tutorial: • Creating Minecraft in ...
About 20 more videos until I get to all of Minecraft :D
Timestamps:
0:00:00 Intro
0:01:03 The Logic of the project
0:02:25 Creating the screen and menu background
0:06:30 Creating a basic draggable Item
0:11:27 Creating the grid
0:15:47 Connecting the Draggable to the grid
0:22:06 Snapping the Draggable into the cell
0:36:27 Adding Item textures
0:40:47 Adding items by pressing a button
0:52:10 Swapping overlapping items
Пікірлер: 83
No wayyyyyy you made this 😁 I was watching your videos yesterday, needed some pong collision logic 😜 Definitely the best Python content on the internet man!
best python content creator. full stop end of discussion. you can't even compete. So clear and simple, dosen't waste my time.
31:10 self.x+self.scale_x/2 is the center position of the Entity, in the round operation you are just removing the remainder on an integer division, it could also work similarly with the mod % operator def center(entity): return entity.position + Vec2(entity.scale.x,-entity.scale.y)/2 def snap(pos, tile_size): xsnap = pos.x - pos.x % tile_size[0] ysnap = pos.y - pos.y % -tile_size[1] return (xsnap, ysnap) Then you call it with the center of your item: newposition=snap(center(item), item.scale) Awesome tutorials by the way, I enjoy watching them
A smile appeard in my face when I saw the video
@coooolamro7283
Жыл бұрын
Noooooooooooo!!!
this is the best, i really hope that you keep making ursina tutorials, that would be nice, greetings from Chile!
@B3CTOR
2 жыл бұрын
Un capo 👍
Keep Up the Good Work Brother, We always support you, Come up with all good tutorials and projects, People really need it, & none explains better than you!!❣
Thank you for all the Tutorial, really enjoyed all of it, hope you can make more video on Ursina
Let's goooooooo your the most underrated youtuber
Awsome video, I am a big fan of Python & Blender addons. One of the best videos so far.
I liked it really so much..this engine and pyhton combination is superb..really helpful ...
Niceeee! Hope you dont give up on ursina!
Please upload more tutorials on ursina engine regularly.
You are back I was waiting for it 😀😀
I think your Community is world wide(i Hope i spelled ist right😜), greeting from germany
In the Item class constructor, if you add a z=-0.01, make item slightly above the grid, you can avoid the bug. I think the bug is related to the display order of background, grid and items.
Thanks man, nice video
Waiting for the next one :)
thanks God he remember his youtube channel password
@ClearCode
3 жыл бұрын
made me laugh :D
Sou brasileiro, amo seus vídeos
NO WAYYYYY THE LEGEND IS BACKKK
Python is the present!
So Cool
Just made Minecraft with Ursina, I think I’m gonna add some GUI to it now!
Clear at the begining: Hello there:))
How do I make the inventory interact with the game itself
Pls continue
Please make a tutorial on tiled map editor and pytmx
very good.
can you make more tutorials like this maybe like a save game and settings when you hit ESC on your keyboard
Where can I get the textures you used for this project?
I just hope you would make more tutorials on Ursina ...... I want to face majorly on it and build games with it....plus there documentation for now isnt helping me 😅😅😅
Where do you get the assets? Great job on the videos by the way
@ClearCode
3 жыл бұрын
There is an artist called Kenney who makes a huge amount of public domain art, I use his stuff most of the time (I did in this video as well) and sometimes I make my own (like in the snake game)
More please
Wow
Need more Ursina... You can have my kidney :(
Вау го 3 часть ;)
Please can you make a video how to make a random generation of terrain in python??
@ClearCode
3 жыл бұрын
working on it!
@stepancze1892
3 жыл бұрын
@@ClearCode ok thanks I love this videos About programming.
@manuelgranadoscollazos5910
2 жыл бұрын
@@ClearCode How did it go? Lol
can you show us how to put the minecraft menu into the minecraft that you created
Can we have a video on OOPS and more on pygame and GUI please?
Please suggest a laptop for high level coding and editing vids under 1k usd
Dude where can i find the assets file u use??? ive search on Artwork from Kenney but i dont know the file name or something,.. please help me
@AndreLuckytaFirdaus
2 жыл бұрын
i mean like the box and grid
umm hey, clear code I really appreciate the hard work on the videos but I need a code for my Minecraft game that u made. so basically suppose there are 30 blocks in x and z dimensions, so if we reach the 30th block in x or z dimension the blocks behind us will come to our front
Here Before 1k Views👀
Could you make some javascript, HTML, CSS tutorials?
Can you please make a tutorial about making this menu in pygame
Which green screen software are you using?
@ClearCode
2 жыл бұрын
It is called Open Broadcaster Software or obs. I have made a whole video on how I make tutorials: kzread.info/dash/bejne/h3mX0NZwotfVqNo.html
I haven't seen anyone successfully create an inventory system of differently shaped items. Like a 4x4 block or a 1x3 block all existing in the same inventory sort of like Diablo or Path of Exile.
More Please Please Please Please Please Please Please
25:03 when his fps went to 1060
I don't find the textures anywhere. Where can I find them?
what compiler do you use help mee
What about make with... C++?
Source CODE!???
What's IDE you used for this?
@spectronimo7964
3 жыл бұрын
sublime text i think
next video: how to make a Minecraft client.
Could you continue this series and make a tutorial on how to proceduraly generate a big world with biomes and stuff like in minecraft?
me trying game developmet in unity, watch one video of this guy, pip install ursina
can u share about Sokuban game
Next: UrsinaNetworking
I get an error: TypeError: __init__() missing 1 required positional argument: 'container' can someone help pls?
Sir please make a minecraft multiplayer using the ursina game engine
Can you upload your code for this project? Thanks
Hello, May you kindly share the source code please ?
no more facecam please it is the worst jumpscare I never had. nice tuto.
"making minecraft in python" = I made 2048 with minecraft textures
Plz give us source code too
0:02 Obi Wan Kenobi
34:22
Where's The Texture's?
pleeeeeeeeeeeeeaaaaaaaaaaaaase
TypeError: 'NoneType' object is not subscriptable the code *from ursina import * from random import choice class BG(Entity): def __init__(self): super().__init__( parent=camera.ui, model='quad', scale=(0.56, 0.86), texture=load_texture('bg.png') ) class Item(Draggable): def __init__(self, container, type, pos): super().__init__( parent=container, model='quad', color=color.white, texture = type, scale_x=1 / container.texture_scale[0] * 0.84, scale_y=1 / container.texture_scale[1] * 0.84, origin=(-0.6, 0.6), x=pos[0] * 1 / container.texture_scale[0], y=pos[1] * 1 / container.texture_scale[1] ) def drag(self): self.xy_pos = (self.x, self.y) def drop(self): self.x = int((self.x + self.scale_x / 2) * 5) / 5 self.y = int((self.y - self.scale_y / 2) * 8) / 8 self.menu_constraint() def menu_constraint(self): if self.x 1 or self.y > 0 or self.y self.x = self.xy_pos[0] self.y = self.xy_pos[1] def get_cell_pos(self): x = int(self.x * self.parent.texture_scale[0]) y = int(self.y * self.parent.texture_scale[1]) return Vec2(x, y) class Grid(Entity): def __init__(self): super().__init__( parent=camera.ui, model='quad', texture=load_texture('box.png'), texture_scale=(5, 8), scale=(0.5, 0.8), origin=(-0.5, 0.5), position=(-0.25, 0.4)) self.import_textures() self.add_new_item() def add_new_item(self): pos = self.find_free_cell() Item(self, choice(self.Textures[2]), pos) def find_free_cell(self): all_cells = [Vec2(x, y) for y in range(0, -8) for x in range(0, 5)] taken_cells = [child.get_cell_pos for child in self.children] for cell in all_cells: if cell not in taken_cells: return cell def import_textures(self): Dirt = load_texture('dirt2d.png'), Grass = load_texture('grass2d.png'), Brick = load_texture('brick2d.png'), Rock = load_texture('stone2d.png'), self.Textures = [Grass, Brick, Dirt, Rock] def input(key): if key == 'a': menu_grid.add_new_item() app = Ursina() bg = BG() menu_grid = Grid() app.run()*
How are you Christian?
Neat but useless, because it glitches and isn't easy to understand. Plus it's outside the box at the bottom and right sides. What was your BG, Grid and items pixel sizes? Didn't see that part in the tutorial. from ursina import * from ursina.prefabs.first_person_controller import FirstPersonController from random import choice app = Ursina() global windowFullscreen global inventoryOpen global inventory_BG global inventory_Grid global inventory_Item inventory_BG = () inventory_Grid = () inventory_Item = () windowFullscreen = 0 inventoryOpen = 0 fullscreenKey = 'f' inventoryKey = 'i' # Load Object Textures sky_texture = load_texture('textures/backgrounds/sky2_image.png') cursor_texture = load_texture('textures/cursors/cursor_image.png') grass1_texture = load_texture('textures/blocks/grass1_block.png') grass2_texture = load_texture('textures/blocks/grass2_block.png') dirt1_texture = load_texture('textures/blocks/dirt1_block.png') weapon_texture = load_texture('textures/weapons/sword_image.png') # Player 1 Attributes player1 = FirstPersonController() player1.cursor.texture = texture=cursor3_texture player1.cursor.visible = True player1Cursor = Entity(parent=camera.ui, model='quad', scale=.3, rotation_x=0, rotation_z=0, texture=cursor_texture) player1.gravity = 0.5 player1.speed = 6 player1.x = 5 player1.y = 3 player1.z = 5 # Application's Title window.title = 'Inventory Menu' # Window Settings window.color = color.rgb(0,100,200) window.fullscreen = True window.borderless = True window.exit_button.visible = False window.fps_counter.enabled = False window.vsync = False Sky(texture=sky_texture,shader="None") pause_handler = Entity(ignore_paused=True) class BG(Entity): # Inventory Background def __init__(self): super().__init__( parent = camera.ui, model = 'quad', scale = (0.56,0.86), texture = load_texture('textures/menus/bg.png')) class Grid(Entity): # Inventory Grid def __init__(self): super().__init__( parent = camera.ui, model = 'quad', texture = load_texture('textures/menus/inventoryGrid.png'), texture_scale = (5,8), # Number Of Cells In Grid x * y scale = (0.5,0.8), origin = (-5.0,0.5), position = (-0.25,0.4)) self.import_textures() self.add_new_item() def add_new_item(self): pos = self.find_free_cell() if pos: Item(self,choice(self.textures),pos) def find_free_cell(self): all_cells = [Vec2(x,y) for y in range(0,-8,-1) for x in range(0,5)] taken_cells = [child.get_cell_pos() for child in self.children] if (len(taken_cells)) >= len(all_cells): return False for cell in all_cells: if cell not in taken_cells: return cell def import_textures(self): grass1 = load_texture('textures/blocks/grass1_block.png') grass2 = load_texture('textures/blocks/grass2_block.png') dirt1 = load_texture('textures/blocks/dirt1_block.png') weapon = load_texture('textures/weapons/sword_image.png') self.textures = [grass1,grass2,dirt1,weapon] class Item(Draggable): # Inventory Items def __init__(self,container,type,pos): super().__init__( parent = container, model = 'quad', color = color.white, texture = type, scale_x = 1 / (container.texture_scale[0] * 1.2), # Item Size For x scale_y = 1 / (container.texture_scale[1] * 1.2), # Item Size For y origin = (-0.6,0.6), x = pos[0] * 1 / container.texture_scale[0], y = pos[1] * 1 / container.texture_scale[1]) def drag(self): self.xy_pos = (self.x,self.y) def drop(self): self.x = int((self.x + self.scale_x/2) * 5) / 5 # Item Placement On Grid For x self.y = int((self.y - self.scale_y/2) * 8) / 8 # Item Placement On Grid For y self.menu_constraint() self.overlap_check() def overlap_check(self): for child in self.parent.children: if child.x == self.x and child.y == self.y: if child == self: continue else: child.x = self.xy_pos[0] child.y = self.xy_pos[1] def menu_constraint(self): if self.x 1 or self.y > 0 or self.y self.x = self.xy_pos[0] self.y = self.xy_pos[1] def get_cell_pos(self): x = int(self.x * self.parent.texture_scale[0]) y = int(self.y * self.parent.texture_scale[1]) return Vec2(x,y) def input(key): global windowFullscreen global inventoryOpen global inventory_BG global inventory_Grid global inventory_Item if key == 'a': # Test Add Item To Inventory 'a' inventory_Grid.add_new_item() if (key == inventoryKey): # Inventory Menu Key 'i' if inventoryOpen == 0: inventoryOpen = 1 player1.disable = True mouse.visible = True mouse.locked = False inventory_BG = BG() inventory_Grid = Grid() else: if inventoryOpen == 1: inventoryOpen = 0 player1.disable = False mouse.visible = False mouse.locked = True destroy(inventory_BG) destroy(inventory_Grid) if (key == fullscreenKey): # Fullscreen Key 'f' if (windowFullscreen == 1): windowBoarderless = 0 window.borderless = True windowFullscreen = 0 window.fullscreen = True else: if (windowFullscreen == 0): windowBoarderless = 1 window.borderless = False windowFullscreen = 1 window.fullscreen = False class Voxel(Button): def __init__(self,position = (0,0,0), texture = grass1_texture): super().__init__( parent = scene, position = position, model = Entity(model='cube',texture=texture), origin_y = 0.5, texture = texture, color = color.color(0,0,random.uniform(0.9,1)), scale = 1) def input(self,key): if self.hovered: if key == 'left mouse down': if block_picked == 1: voxel = Voxel(position = self.position + mouse.normal, texture = grass1_texture) if block_picked == 2: voxel = Voxel(position = self.position + mouse.normal, texture = dirt1_texture) if block_picked == 3: voxel = Voxel(position = self.position + mouse.normal, texture = grass2_texture) if key == 'right mouse down': destroy(self) class Sky(Entity): def __init__(self,position = (0,1,0), texture = sky_texture): super().__init__( parent = scene, position = position, model = Entity(model='sphere',texture=sky_texture), texture = texture, origin_y = 0.5, scale = 0, double_sided = True) pause_handler.input = pause_handler_input for z in range(20): for x in range(20): voxel = Voxel(position = (x,0,z)) sky = Sky() app.run()