0
\$\begingroup\$

I decided to learn how to make games during this quarantine. I am reading Mission Python, a book that teaches how to make games using python and pygame. I'm halfway through it, but the game only has one map.

I'm trying to challenge myself by adding a basement and an upstairs room, but the book doesn't have anything on making multiple floors.

Current code for my map:

###############
##    MAP    ##
###############  

MAP_WIDTH = 5
MAP_HEIGHT = 10 
MAP_SIZE = MAP_WIDTH * MAP_HEIGHT

GAME_MAP = [ ["Room 0 - where unused objects are kept", 0, 0, False, False] ]

outdoor_rooms = range(1, 26)
for planetsectors in range(1, 26): #rooms 1 to 25 are generated here
    GAME_MAP.append( ["The dusty planet surface", 13, 13, True, True] )

GAME_MAP  += [
        #["Room name", height, width, Top exit?, Right exit?]
        ["The airlock", 13, 5, True, False], # room 26
        ["The engineering lab", 13, 13, False, False], # room 27
        ["Poodle Mission Control", 9, 13, False, True], # room 28
        ["The viewing gallery", 9, 15, False, False], # room 29
        ["The crew's bathroom", 5, 5, False, False], # room 30
        ["The airlock entry bay", 7, 11, True, True], # room 31
        ["Left elbow room", 9, 7, True, False], # room 32
        ["Right elbow room", 7, 13, True, True], # room 33
        ["The science lab", 13, 13, False, True], # room 34
        ["The greenhouse", 13, 13, True, False], # room 35
        [PLAYER_NAME + "'s sleeping quarters", 9, 11, False, False], # room 36
        ["West corridor", 15, 5, True, True], # room 37
        ["The briefing room", 7, 13, False, True], # room 38
        ["The crew's community room", 11, 13, True, False], # room 39
        ["Main Mission Control", 14, 14, False, False], # room 40
        ["The sick bay", 12, 7, True, False], # room 41
        ["West corridor", 9, 7, True, False], # room 42
        ["Utilities control room", 9, 9, False, True], # room 43
        ["Systems engineering bay", 9, 11, False, False], # room 44
        ["Security portal to Mission Control", 7, 7, True, False], # room 45
        [FRIEND1_NAME + "'s sleeping quarters", 9, 11, True, True], # room 46
        [FRIEND2_NAME + "'s sleeping quarters", 9, 11, True, True], # room 47
        ["The pipeworks", 13, 11, True, False], # room 48
        ["The chief scientist's office", 9, 7, True, True], # room 49
        ["The robot workshop", 9, 11, True, False] # room 50
        ]

#simple sanity check on map above to check data entry
assert len(GAME_MAP)-1 == MAP_SIZE, "Map size and GAME_MAP don't match"


\$\endgroup\$
1
  • 1
    \$\begingroup\$ Welcome to Game Development Stack Exchange. What exactly is your question? \$\endgroup\$ – Philipp Apr 15 '20 at 19:07
0
\$\begingroup\$

Not quite sure if you're asking to add a new room or a new floor but if you want to add a new room you can simply write in another entry to that large array you have there

...
["The pipeworks", 13, 11, True, False], # room 48
["The chief scientist's office", 9, 7, True, True], # room 49
["The robot workshop", 9, 11, True, False] # room 50

["basement", 9, 11, True, False] # your first new room
["upstairs", 15, 8, True, False] # your second new room
]

If your looking for a whole new floor, if have some sort of structure you're using to store your current game map, you can make an array of them to have multiple floors, so something like:

GAME_MAP_FLOOR_ONE = [ ["Room 0 - where unused objects are kept", 0, 0, False, False] ]
GAME_MAP_FLOOR_TWO = [ ["Room 0 - where unused objects are kept", 0, 0, False, False] ]
GAME_MAP_ARRAY_OF_FLOORS = [GAME_MAP_FLOOR_ONE,GAME_MAP_FLOOR_TWO]

Hope this helps point you in the right direction

\$\endgroup\$
3
  • \$\begingroup\$ I am trying to add an new room sorry for the confusion. I was thinking i would have to make a dictionary of my map with separate levels. I do not know if that would of worked, but it was an idea. The array looks like it would work, but how would i go in connecting the 3 floors. As far as using a stair case or elevator to load the new floor in the code? \$\endgroup\$ – BeastSlayer Apr 15 '20 at 20:44
  • \$\begingroup\$ I would have to see how you do movement between rooms currently... i would suggest using a room class that can have member variables and methods for moving between rooms and set it up in there \$\endgroup\$ – Jay Apr 15 '20 at 21:15
  • \$\begingroup\$ Thank you for the help. i will check it out. \$\endgroup\$ – BeastSlayer Apr 15 '20 at 21:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.