omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    3D Level help

    Pythonista
    3d level 3d game
    2
    3
    2415
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ELECTRO8888
      ELECTRO8888 last edited by ELECTRO8888

      Hey, so I did a post like this before, but does anybody know how to make an expandable list with 3 numbers: 0 1 and 2, create a 3D game level? And if so, please explain how so people like me can understand it

      Edit: and how to make 0 an empty space 1 a block and 2 A coin or something that opens the next file which is the next game when walked into?

      Ex:# 1 = wall, 0 = empty 2=finish
      level = [[1,1,1,1,1,1,1,1],
      [1,1,1,2,0,0,1,1],
      [1,1,1,1,1,0,0,1],
      [1,1,1,0,0,1,0,1],
      [1,1,1,0,0,1,0,1],
      [1,1,1,0,1,1,0,1],
      [1,1,1,0,0,0,0,1],
      [1,1,1,1,1,1,1,1]]

      1 Reply Last reply Reply Quote 0
      • ccc
        ccc last edited by ccc

        A naive first attempt...

        Also see https://forum.omz-software.com/topic/3261/instead-of-a-question-i-d-like-to-share-my-accomplishments

        from random import choice
        
        level = [[1,1,1,1,1,1,1,1],
                 [1,1,1,2,0,0,1,1],
                 [1,1,1,1,1,0,0,1],
                 [1,1,1,0,0,1,0,1],
                 [1,1,1,0,0,1,0,1],
                 [1,1,1,0,1,1,0,1],
                 [1,1,1,0,0,0,0,1],
                 [1,1,1,1,1,1,1,1]]
        
        
        def new_level(maze_size=8):
            level = [[choice((0, 1)) for x in range(maze_size)] for y in range(maze_size)]
            level[choice(range(maze_size))][choice(range(maze_size))] = 2  # add the goal
            return level
        
        
        def print_level(level):
            print('\n'.join(str(row) for row in level) + '\n')
        
        
        print_level(level)
        print_level(new_level())
        
        1 Reply Last reply Reply Quote 1
        • ELECTRO8888
          ELECTRO8888 last edited by

          Thank you that is very helpful, I will try to use it now 😄

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors