EASY Random Map Generation - Python ASCII Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 พ.ย. 2024

ความคิดเห็น • 36

  • @bandedecodeurs
    @bandedecodeurs 10 หลายเดือนก่อน +7

    Just falling in love with your channel. So inspiring. Thank you very much 🙏🏻

    • @orkslayergamedev
      @orkslayergamedev  10 หลายเดือนก่อน

      My pleasure! Thank you for the kind words, they mean a lot! 🙌🏻

  • @HelicopterHoneymoon
    @HelicopterHoneymoon 4 หลายเดือนก่อน +1

    Fun tutorial! Perfect for making little random maps for my pen and paper rpg!

    • @orkslayergamedev
      @orkslayergamedev  4 วันที่ผ่านมา

      That sounds awesome! I remember playing similar games on paper, too - it was so much fun! Thanks for the feedback 😊

  • @feellikedying-xy7wo
    @feellikedying-xy7wo หลายเดือนก่อน +1

    Thx man im trying to learn python and this is so good

    • @orkslayergamedev
      @orkslayergamedev  4 วันที่ผ่านมา

      Hey there, my pleasure! I'm glad to hear you're enjoying the content! Happy coding to you 🐍

  • @knut-olaihelgesen3608
    @knut-olaihelgesen3608 5 หลายเดือนก่อน +2

    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  4 วันที่ผ่านมา

      Totally right, thanks for pointing that out! I appreciate the suggestion! 🐍

  • @GamingGuruImMortaL
    @GamingGuruImMortaL 11 หลายเดือนก่อน +1

    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 หลายเดือนก่อน +1

      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 🙌🏻

  • @sirknumbskull3418
    @sirknumbskull3418 10 หลายเดือนก่อน +2

    Hey, I love that one! Thanks!

    • @orkslayergamedev
      @orkslayergamedev  10 หลายเดือนก่อน

      I'm happy to hear this, thank you for the feedback! 🙏🏻

  • @noahvb9835
    @noahvb9835 8 หลายเดือนก่อน

    Hey, I am loving these videos. Quick question! Why do you put " -> None" when defining things within a class?

    • @orkslayergamedev
      @orkslayergamedev  8 หลายเดือนก่อน +2

      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 :)

  • @Poulet39
    @Poulet39 11 หลายเดือนก่อน +1

    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 👌🏻

  • @denisgokalp9951
    @denisgokalp9951 3 หลายเดือนก่อน +1

    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  4 วันที่ผ่านมา

      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! 😊

  • @superbautumn969
    @superbautumn969 10 หลายเดือนก่อน +1

    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 หลายเดือนก่อน +1

      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 หลายเดือนก่อน +1

      Thank you very much 🙏

  • @Balance080
    @Balance080 6 หลายเดือนก่อน +1

    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  6 หลายเดือนก่อน

      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 หลายเดือนก่อน +1

    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

  • @philtoa334
    @philtoa334 11 หลายเดือนก่อน

    Nice.

  • @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 หลายเดือนก่อน +1

      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 หลายเดือนก่อน +2

      ​@@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 หลายเดือนก่อน +1

      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 หลายเดือนก่อน +2

      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! 🙌🏻