PC Computer Science Home Text Adventure Game Project

Description

Easy money, I already have the code just need some help getting it to be fully functional. I am designing a text based game that moves player from room to room to collect items. I have attached a map of my game

Code below:

#Sample function showing the goal of the game and move commandsdef show_instructions():   #print a main menu and the commands   print("Home Text Adventure Game")   print("Collect 6 items to win the game, or be found by the intruder")   print("Move commands: go South, go North, go East, go West")   print("Add to Inventory: get 'item name'")def show_state(inventory, rooms, state):      print('Inventory: ', inventory)      print('You see a ', rooms[state][0])      print("--------------------------------")      cmd, direction = input('Enter your move: ').split()  # cmd is go or get, ignoring it      return direction   #Dictionaryrooms = {   'Master Bedroom': {'item': 'Cellphone', 'East': 'Closet', 'South': 'The Family Room'},   'The Closet': {'item': 'Coat', 'West': 'Master Bedroom'},   'Foyer': {'item': 'Shoes', 'East': "Family Room"},   'Family Room': {'item': 'Charger', 'East': 'Kitchen', 'South': 'Study Room'},   'Dining Room': {'South': 'Kitchen'},   'Kitchen': {'item': 'Car Keys', 'North': 'Dining Room', 'West':'Family Room'},   'Study Room': {'item': 'Gloves','North': 'Family room', 'East': 'Basement'},   'Basement': {'Intruder'}   }state = 'Master Bedroom'inventory = []# functiondef get_new_state(state, direction):    new_state = state  # declaring    for i in rooms:  # loop        if i == state:  # if            if direction in rooms[i][1]:  # if                new_state = rooms[i][1][direction]  # assigning new_state    return new_state  # returnshow_instructions()while 1:  # gameplay loop   print('You are in the ', state)  # printing state   break   if state == 'Basement':      print('Battling with the intruder', end='')      for i in range(50):         for j in range(1000000):            pass         print(".", end='', flush=True)      print()      if len(inventory) == 4:         print("Congratulations! You have collected all items and defeated the intruder!")      else:         print('GAME OVER!')      print("Thanks for playing the game. Hope you enjoyed it. ")      break      direction = show_state(inventory, rooms, state)      # print ('Inventory: ', inventory)      # print ('You see a ', items[state])      # print ("--------------------------------")      # cmd, direction = input('Enter your move: ').split()  # cmd is go or get, ignoring it      if direction.lower() == rooms[state][0].lower():         if rooms[state][0] not in inventory:            inventory.append(rooms[state][0])         continue      direction = direction.capitalize()  # making first character capital remaining lower      if direction == 'Exit':  # if         exit(0)  # exit function      if direction == 'East' or direction == 'West' or direction == 'North' or direction == 'South':  # if         new_state = get_new_state(state, direction)  # calling function         if new_state == state:  # if            print('There is an intruder in that direction quickly enter other direction!')  # print         else:            state = new_state  # changing state value to new_state      else:         print('Invalid direction!!')  # print

Get your college paper done by experts

Do my question How much will it cost?

Place an order in 3 easy steps. Takes less than 5 mins.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *