Тёмный

Creating a Minecraft style menu in Python [Ursina] 

Clear Code
Подписаться 210 тыс.
Просмотров 32 тыс.
50% 1

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

Опубликовано:

 

2 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 83   
@mixlaproduction
@mixlaproduction 3 года назад
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!
@luvtv7433
@luvtv7433 Год назад
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
@sammple
@sammple 2 года назад
best python content creator. full stop end of discussion. you can't even compete. So clear and simple, dosen't waste my time.
@exoditore1929
@exoditore1929 3 года назад
this is the best, i really hope that you keep making ursina tutorials, that would be nice, greetings from Chile!
@B3CTOR
@B3CTOR 2 года назад
Un capo 👍
@calitts4708
@calitts4708 3 года назад
A smile appeard in my face when I saw the video
@coooolamro7283
@coooolamro7283 Год назад
Noooooooooooo!!!
@snowman_student
@snowman_student 3 года назад
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!!❣
@stephencurry3502
@stephencurry3502 3 года назад
Let's goooooooo your the most underrated youtuber
@obatmaagtv
@obatmaagtv 2 года назад
Thank you for all the Tutorial, really enjoyed all of it, hope you can make more video on Ursina
@nilesh3646
@nilesh3646 3 года назад
You are back I was waiting for it 😀😀
@shadofermusic
@shadofermusic 3 года назад
Niceeee! Hope you dont give up on ursina!
@simplegregg4664
@simplegregg4664 Год назад
Awsome video, I am a big fan of Python & Blender addons. One of the best videos so far.
@eshanbahuguna8088
@eshanbahuguna8088 3 года назад
Thanks man, nice video
@sandippankhaniya489
@sandippankhaniya489 2 года назад
I liked it really so much..this engine and pyhton combination is superb..really helpful ...
@davidli3849
@davidli3849 2 года назад
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.
@slappy_chimp
@slappy_chimp 3 года назад
Waiting for the next one :)
@muhammadaarizimam4890
@muhammadaarizimam4890 3 года назад
Please upload more tutorials on ursina engine regularly.
@thepaulcraft957
@thepaulcraft957 3 года назад
I think your Community is world wide(i Hope i spelled ist right😜), greeting from germany
@rafaeld.3852
@rafaeld.3852 3 года назад
Sou brasileiro, amo seus vídeos
@armcannon7902
@armcannon7902 2 года назад
How do I make the inventory interact with the game itself
@mohiuddinsyed1684
@mohiuddinsyed1684 3 года назад
Where can I get the textures you used for this project?
@SKSam-bq6zt
@SKSam-bq6zt 3 года назад
NO WAYYYYY THE LEGEND IS BACKKK
@goblinslayer6375
@goblinslayer6375 3 года назад
So Cool
@philtoa334
@philtoa334 3 года назад
very good.
@SanjayKumar-xn2xm
@SanjayKumar-xn2xm 3 года назад
thanks God he remember his youtube channel password
@ClearCode
@ClearCode 3 года назад
made me laugh :D
@matheusrodrigues-kf6pj
@matheusrodrigues-kf6pj 3 года назад
Python is the present!
@atharvapatil7474
@atharvapatil7474 3 года назад
Please make a tutorial on tiled map editor and pytmx
@xoxogamewolf7585
@xoxogamewolf7585 6 месяцев назад
Just made Minecraft with Ursina, I think I’m gonna add some GUI to it now!
@commpisto5948
@commpisto5948 3 года назад
Clear at the begining: Hello there:))
@nei6387
@nei6387 2 года назад
can you make more tutorials like this maybe like a save game and settings when you hit ESC on your keyboard
@creepikpedaass2133
@creepikpedaass2133 3 года назад
Here Before 1k Views👀
@hemantbisht5630
@hemantbisht5630 2 года назад
Pls continue
@sangeetaraisane2141
@sangeetaraisane2141 3 года назад
Please suggest a laptop for high level coding and editing vids under 1k usd
@solomonbestz
@solomonbestz 3 года назад
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 😅😅😅
@theimmaturegoat
@theimmaturegoat 2 года назад
Where do you get the assets? Great job on the videos by the way
@ClearCode
@ClearCode 2 года назад
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)
@avengersworld5487
@avengersworld5487 2 года назад
can you show us how to put the minecraft menu into the minecraft that you created
@anonymously_smh1010
@anonymously_smh1010 3 года назад
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
@rittwikde5145
@rittwikde5145 3 года назад
Can we have a video on OOPS and more on pygame and GUI please?
@AlejandroSanchez-gn9vg
@AlejandroSanchez-gn9vg Год назад
I don't find the textures anywhere. Where can I find them?
@AndreLuckytaFirdaus
@AndreLuckytaFirdaus 2 года назад
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
@AndreLuckytaFirdaus 2 года назад
i mean like the box and grid
@Ashersminicartoons
@Ashersminicartoons 3 года назад
Could you make some javascript, HTML, CSS tutorials?
@alltrabrawl3894
@alltrabrawl3894 2 года назад
More please
@randomized.person
@randomized.person 2 года назад
Can you please make a tutorial about making this menu in pygame
@stepancze1892
@stepancze1892 3 года назад
Please can you make a video how to make a random generation of terrain in python??
@ClearCode
@ClearCode 3 года назад
working on it!
@stepancze1892
@stepancze1892 3 года назад
@@ClearCode ok thanks I love this videos About programming.
@manuelgranadoscollazos5910
@manuelgranadoscollazos5910 2 года назад
@@ClearCode How did it go? Lol
@ravenovreaper
@ravenovreaper 3 года назад
what compiler do you use help mee
@m0ke0
@m0ke0 2 года назад
I get an error: TypeError: __init__() missing 1 required positional argument: 'container' can someone help pls?
@takky8879
@takky8879 3 года назад
Wow
@slappy_chimp
@slappy_chimp 3 года назад
Need more Ursina... You can have my kidney :(
@simex4274
@simex4274 2 года назад
Can you upload your code for this project? Thanks
@kahwigulum
@kahwigulum 2 года назад
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.
@AmanPatel-lo3ce
@AmanPatel-lo3ce 2 года назад
Which green screen software are you using?
@ClearCode
@ClearCode 2 года назад
It is called Open Broadcaster Software or obs. I have made a whole video on how I make tutorials: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-UEcnt7rtoxw.html
@zikodik946
@zikodik946 3 года назад
Вау го 3 часть ;)
@valencefootball9740
@valencefootball9740 3 года назад
Source CODE!???
@kenhriviu9130
@kenhriviu9130 3 года назад
can u share about Sokuban game
@sedatyilmaz6907
@sedatyilmaz6907 2 года назад
Hello, May you kindly share the source code please ?
@HeitorYT
@HeitorYT 3 года назад
What about make with... C++?
@javaSucks
@javaSucks 3 года назад
What's IDE you used for this?
@spectronimo7964
@spectronimo7964 3 года назад
sublime text i think
@alltrabrawl3894
@alltrabrawl3894 2 года назад
More Please Please Please Please Please Please Please
@onemeeliondollars
@onemeeliondollars 2 года назад
25:03 when his fps went to 1060
@cedricjacob6954
@cedricjacob6954 3 года назад
next video: how to make a Minecraft client.
@theanimeguy4556
@theanimeguy4556 2 года назад
Sir please make a minecraft multiplayer using the ursina game engine
@refactoringg
@refactoringg 2 года назад
Next: UrsinaNetworking
@PanKDev
@PanKDev 3 месяца назад
no more facecam please it is the worst jumpscare I never had. nice tuto.
@harshittechnology6955
@harshittechnology6955 3 года назад
Plz give us source code too
@johncanfield5250
@johncanfield5250 Год назад
"making minecraft in python" = I made 2048 with minecraft textures
@michaelnotfound2123
@michaelnotfound2123 2 года назад
Where's The Texture's?
@kotaiahchowdary5920
@kotaiahchowdary5920 2 года назад
me trying game developmet in unity, watch one video of this guy, pip install ursina
@rednibcoding3412
@rednibcoding3412 2 года назад
Could you continue this series and make a tutorial on how to proceduraly generate a big world with biomes and stuff like in minecraft?
@puravm9294
@puravm9294 3 года назад
0:02 Obi Wan Kenobi
@onemeeliondollars
@onemeeliondollars 2 года назад
34:22
@avengersworld5487
@avengersworld5487 2 года назад
pleeeeeeeeeeeeeaaaaaaaaaaaaase
@jkwiz1923
@jkwiz1923 2 года назад
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 < 0 or self.x > 1 or self.y > 0 or self.y < -1: 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()*
@Miquelete20
@Miquelete20 2 года назад
How are you Christian?
@michaeldavis6473
@michaeldavis6473 Год назад
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 < 0 or self.x > 1 or self.y > 0 or self.y < -1: 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()
Далее
25 Fake Minecraft "Facts" You Still Believe
9:46
Просмотров 4,5 млн
C++ Developer Learns Python
9:26
Просмотров 2,7 млн
Gonna tell my kids this was Spider-Man
00:27
Просмотров 11 млн
Making FPS Games in Python
8:52
Просмотров 234 тыс.
19 Ridiculous Ways to Use Map Art in Minecraft
11:28
What Happens To Deleted Minecraft Worlds?
13:36
Просмотров 4,6 млн
What Jumping Spiders Teach Us About Color
32:37
Просмотров 1,8 млн
I Made a Zero Player Game
12:30
Просмотров 10 млн
I Made Minecraft but with Realistic Physics
14:02
Просмотров 6 млн
2D water magic
10:21
Просмотров 534 тыс.