EASY Random Map Generation - Python ASCII Tutorial

  Рет қаралды 8,698

Ork Slayer Gamedev

Ork Slayer Gamedev

Күн бұрын

Пікірлер: 36
@bandedecodeurs
@bandedecodeurs 11 ай бұрын
Just falling in love with your channel. So inspiring. Thank you very much 🙏🏻
@orkslayergamedev
@orkslayergamedev 11 ай бұрын
My pleasure! Thank you for the kind words, they mean a lot! 🙌🏻
@HelicopterHoneymoon
@HelicopterHoneymoon 4 ай бұрын
Fun tutorial! Perfect for making little random maps for my pen and paper rpg!
@orkslayergamedev
@orkslayergamedev 12 күн бұрын
That sounds awesome! I remember playing similar games on paper, too - it was so much fun! Thanks for the feedback 😊
@feellikedying-xy7wo
@feellikedying-xy7wo Ай бұрын
Thx man im trying to learn python and this is so good
@orkslayergamedev
@orkslayergamedev 12 күн бұрын
Hey there, my pleasure! I'm glad to hear you're enjoying the content! Happy coding to you 🐍
@sirknumbskull3418
@sirknumbskull3418 11 ай бұрын
Hey, I love that one! Thanks!
@orkslayergamedev
@orkslayergamedev 11 ай бұрын
I'm happy to hear this, thank you for the feedback! 🙏🏻
@GamingGuruImMortaL
@GamingGuruImMortaL 11 ай бұрын
Great video, nice explanation as usual 🙌🏻, a future video idea: implement the feature to set a minimum number of each type of tile, because during some execution it is visible that some tiles are too small and some are great in number.
@orkslayergamedev
@orkslayergamedev 11 ай бұрын
I always appreciate some great feedback! 🙏🏻 The issue you mentioned is due to the patch generator overwriting any tile it's covering. So you might create a patch and it's possible that it won't be there at the end if another patch is spawned after it the same place (on top of that). This could be solved by overwriting the tile only if it's the default one. But I like your idea nevertheless! This tutorial is kinda basic, it could use some improvements like exception handling instead of numerical limits, this way the sides of the map could be covered as well :) Maybe in the next one! Anyways, thanks a lot, bro 🙌🏻
@noahvb9835
@noahvb9835 9 ай бұрын
Hey, I am loving these videos. Quick question! Why do you put " -> None" when defining things within a class?
@orkslayergamedev
@orkslayergamedev 9 ай бұрын
Thanks for the feedback! Sorry for the late reply, let me copy my previous answer, as I get this question quite regularly. When defining functions and methods, you can leave type hints for the arguments and the return value. Let me show examples: def sum_numbers(n1: int, n2: int) -> int: return n1 + n2 Here we say both arguments should be integers, just like the returned number. If you use an IDE (code editor) that has a built-in linter (code checker), it will automatically warn you if you A, define the function/method in a way that the actual returned value is not what you define in the first line (where the arrow points): def sum_numbers(n1: int, n2: int) -> int: return str(n1 + n2) B, you call the function/method with arguments not matching their annotated types: sum_numbers(n1="string", n2=True) So, whenever you create a method that returns nothing, you can also emphasize it by putting -> None at the end of the definition, like... def useless_printer() -> None: print("I don't return anything") ...and when you call it: result = useless_printer() >>> "I don't return anything" print(result) >>> None Whereas you call the other method that has a returned value... result = sum_numbers(3, 4) print(result) >>> 7 I hope this helps :)
@denisgokalp9951
@denisgokalp9951 3 ай бұрын
Hey! Thanks for your informative, great videos! I'm currently learning the Python basics on my iPhone with the app Pyto... maybe you know it. Do the color codes work there too, or is that only possible on a computer. Can I somehow add these functions to an iPhone? Thank you very much! Keep it up, I'm looking forward to your game! Kind regards 👋🏽💪🏼
@orkslayergamedev
@orkslayergamedev 12 күн бұрын
Oh hey! Thanks so much for the kind words, and apologies for the delayed reply - I had to take a huge break to rest. I can't say for sure how these color codes work in iOS environment, but I think a bit of research would answer that! I remember testing the early versions of this random map generator on my android phone, probably using the pydroid3 app, and I had no issues with the color codes. If you figured it out by now, I'd love to hear about your experiences! Thanks again! 😊
@knut-olaihelgesen3608
@knut-olaihelgesen3608 5 ай бұрын
You should declare annotations that don't have a value at class level scope (right under the class deceleration), as the structure is not spesific to that spesific instance, but rather every instance of the class
@orkslayergamedev
@orkslayergamedev 12 күн бұрын
Totally right, thanks for pointing that out! I appreciate the suggestion! 🐍
@Balance080
@Balance080 7 ай бұрын
Hi Ork great vid and very educational and helpful, however i got a issue at the very end: Traceback (most recent call last): File "d:\Desktop\Python\main.py", line 4, in hero = Hero(name="Hero", health=100) File "d:\Desktop\Python\character.py", line 24, in __init__ self.health_bar = HealthBar(self, color="blue") TypeError: HealthBar() takes no arguments Any ideas how or why this happened, any help would be appreciated, used Python 3.10.9, it worked until the hp bars were added and my code should be the same as the one in the vid, i compared it a couple of times and saw no significant differences.
@orkslayergamedev
@orkslayergamedev 7 ай бұрын
Hey, thanks a bunch for the feedback! I think I see the issue. Based on the line you showed (File "d:\Desktop\Python\character.py", line 24, in _init_), it seems there might be a typo in how you defined the constructor method. You should use double underscores on both sides (__init__) instead of _init_. Because it's written as _init_, Python doesn't recognize it as the constructor, and it defaults to a built-in __init__ method that accepts no arguments. Hence the TypeError. Try changing _init_ to __init__ in your HealthBar class, and that should fix the issue. Please let me know if this resolves the problem! Cheers! 🐍
@ElGreco15
@ElGreco15 6 ай бұрын
I'm trying to make a static map, and between the last video and this one there is a step I am missing. How do I display the map I created in the last video using gamemap = [[Tile(plains), Tile(mountains)...etc] I do not want the batches or procedural creation. I just want to see the map from the previous in this playlist.
@orkslayergamedev
@orkslayergamedev 6 ай бұрын
Hey! I hope I understand the issue correctly. Here's a simplified version of the modules you want to use: ## --------------- tile.py --------------- ## ANSI_RESET = "\033[0m" ANSI_YELLOW = "\033[33m" ANSI_GREEN = "\033[32m" ANSI_BLUE = "\033[34m" ANSI_RED = "\033[31m" ANSI_WHITE = "\033[97m" ANSI_MAGENTA = "\033[35m" ANSI_CYAN = "\033[36m" class Tile: def __init__(self, symbol: str, color: str | None = None): self.symbol = f"{color}{symbol}{ANSI_RESET}" if color else symbol plains = Tile(".", ANSI_YELLOW) forest = Tile("8", ANSI_GREEN) pines = Tile("Y", ANSI_GREEN) mountain = Tile("A", ANSI_WHITE) water = Tile("~", ANSI_CYAN) ## -------------------- ## -------------------- ## ## --------------- map.py --------------- ## from random import randint from tile import Tile, plains, forest, pines, mountain, water class Map: def __init__(self, width: int, height: int) -> None: self.width = width self.height = height self.map_data: list[list[Tile]] def display_map(self) -> None: frame = "x" + self.width * "=" + "x" print(frame) for row in self.map_data: row_tiles = [tile.symbol for tile in row] print("|" + "".join(row_tiles) + "|") print(frame) ## -------------------- ## -------------------- ## ## --------------- main.py --------------- ## from map import Map import os os.system("") def run() -> None: while True: game_map.display_map() input("> ") if __name__ == "__main__": # considering you have a complete map that you created manually map = Map(5, 5) map.map_data = [ [forest, forest, forest, mountain, mountain], [plains, forest, forest, pines, mountain], [plains, forest, forest, pines, pines], [plains, plains, forest, forest, forest], [plains, plains, plains, plains, plains], ] run() ## -------------------- ## -------------------- ## With these 3 simplified files, you can display your map if you run "python main.py" from the console in the directory where these modules are located. Let me know if this solved your problem!
@ElGreco15
@ElGreco15 6 ай бұрын
@@orkslayergamedev map.py in display_map row_tiles =[tile.symbol for tile in row] ^^^^^^^^^^^^ AttributeError: 'str ' object has no attribute 'symbol' I don't know if maybe there's a difference in the latest version of python and yours, but this is the exact line that's been stopping me
@superbautumn969
@superbautumn969 10 ай бұрын
This is great video i was able to put a health bar for the ascii game but making something move on the map is throwing me in loop i cant seem to figure out
@orkslayergamedev
@orkslayergamedev 10 ай бұрын
Thanks for the feedback! If it's player movement that you struggle with, I recommend my upcoming video where I will feature lots of cool game mechanics like that one. While the video is in production, feel free to send me code pieces so I can try to help you! 👋🏻
@superbautumn969
@superbautumn969 10 ай бұрын
Thank you very much 🙏
@Poulet39
@Poulet39 11 ай бұрын
Liked your video i do this on my games and i convert the ascii characters to png image to get also another graphic mod available. Would like to see a map editor.
@orkslayergamedev
@orkslayergamedev 11 ай бұрын
Thanks a lot for the feedback! I'll actually upload a video with the same technique implemented in Pygame. For map editing I can recommend Tiled, a free software for this purpose 👌🏻
@philtoa334
@philtoa334 11 ай бұрын
Nice.
@orkslayergamedev
@orkslayergamedev 11 ай бұрын
Thank you! 🙏🏻
@programmingchannel9739
@programmingchannel9739 11 ай бұрын
I like the idea, however, my script doesn't generate a new patch when hitting Enter. It always repeats the same patch in the same position until I rerun the script. As the video, It is supposed to generate a new patch in a new position after hitting Enter!
@orkslayergamedev
@orkslayergamedev 11 ай бұрын
Hi! Thanks for reaching out to me. There must be some difference that creates this issue. You can either show me your code so I can have a look, or feel free to use my files as an exact reference: github.com/orkslayergamedev/random-ascii-map-generation
@programmingchannel9739
@programmingchannel9739 11 ай бұрын
Thank you for your quick response. I compared my copy with yours several times, they look the same. However, I believe there is no problem, according to your script it should act the way I mentioned, unless instantiating the map class inside the loop in the the main function. By the way, I cloned your repo and ran it! It did exactly as my copy.@@orkslayergamedev
@orkslayergamedev
@orkslayergamedev 11 ай бұрын
​@@programmingchannel9739 You're totally right, there is no problem! Seems like I successfully confused myself too, haha. Turns out it's a bit misleading, because in the recording I don't actually press enter in the console, I rerun the interpreter instead. If you look at the green button at the top right corner of Pycharm, you can see it getting pressed multiple times. It's the same as if I ran "python main.py" again and again. Apologies for the headache!
@programmingchannel9739
@programmingchannel9739 11 ай бұрын
Hey, thanks a lot for your quick response! Really, no need to apologize - it's all part of the learning process for all of us. I actually wanted to say that it's been a real pleasure for me to discuss Python code with a programmer like you. I've been learning Python for about three years now, and this is the first time I've had the opportunity to have a conversation like this. It's been a great experience and definitely a highlight in my programming journey. Keep up the awesome work with your tutorials - they're a big help!@@orkslayergamedev
@orkslayergamedev
@orkslayergamedev 10 ай бұрын
Wow! I really appreciate your support and I'm delighted to hear that you enjoyed our conversation. I always love to connect with fellow Python enthusiasts and share the joy of programming. If you ever need some help, feel free to reach out, I'll be in touch :) Good luck with your journey! 🐍 (ps. I just found your answer, as youtube doesn't send notification of threads 😞)
@gustavoduarte3121
@gustavoduarte3121 11 ай бұрын
make ASCII games Greats Again!!!
@orkslayergamedev
@orkslayergamedev 11 ай бұрын
That's the spirit! 🙌🏻
Same Roguelike in Two Different Styles - Python ASCII vs Pygame
8:31
Ork Slayer Gamedev
Рет қаралды 7 М.
Coding Challenge 166: ASCII Text Images
22:42
The Coding Train
Рет қаралды 1,1 МЛН
Мама у нас строгая
00:20
VAVAN
Рет қаралды 12 МЛН
If people acted like cats 🙀😹 LeoNata family #shorts
00:22
LeoNata Family
Рет қаралды 35 МЛН
Муж внезапно вернулся домой @Oscar_elteacher
00:43
История одного вокалиста
Рет қаралды 8 МЛН
Python dataclasses will save you HOURS, also featuring attrs
8:50
Dynamic Battles With RNG - Python ASCII Tutorial #2
24:03
Ork Slayer Gamedev
Рет қаралды 2,9 М.
Much bigger simulation, AIs learn Phalanx
29:13
Pezzza's Work
Рет қаралды 2,8 МЛН
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 734 М.
EASY Health Bars for BEGINNERS - Python ASCII Tutorial
7:45
Ork Slayer Gamedev
Рет қаралды 5 М.
I made Games with Python for 10 Years...
28:52
DaFluffyPotato
Рет қаралды 371 М.
What is Mode 7? Let's code it!
8:03
Coder Space
Рет қаралды 51 М.
How to turn a few Numbers into Worlds (Fractal Perlin Noise)
15:24
The Taylor Series
Рет қаралды 196 М.
Мама у нас строгая
00:20
VAVAN
Рет қаралды 12 МЛН