Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Coding a Charlie Brown text based adventure game. My code is nearly complete but it is still buggy and I cannot figure out what's wrong.

Coding a Charlie Brown text based adventure game. My code is nearly complete but it is still buggy and I cannot figure out what's wrong. Please help! This was due weeks ago!!

You work for a small company that creates text-based games. You recently pitched your design ideas for a text-based adventure game to your team. Your team was impressed by all of your designs, and would like you to develop the game! You will be able to use the map and the pseudocode or flowcharts from your designs to help you develop the code for the game. In your code, you have been asked to include clear naming conventions for functions, variables, and so on, along with in-line comments. Not only will these help you keep track as you develop, but they will help your team read and understand your code. This will make it easier to adapt for other games in the future.

Recall that the game requires players to type in a command line prompt to move through the different rooms and get items from each room. The goal of the game is for the player to get all of the items before encountering the room that contains the villain. Each step of the game will require a text output to let the player know where they are in the game, and an option of whether or not to obtain the item in each room.

 # Kenny James rooms = { 'The Living Room': {'South': 'The Study', 'North':'The Garage', 'West':'The Porch', 'East':'The Kitchen'}, 'The Study': {'North': 'Living Room', 'East': 'Your Bedroom'}, 'Your Bedroom': {'West': 'The Study'}, 'The Porch': {'East':'Living Room'}, 'The Garage': {'South':'Living Room', 'East':'a Football Field'}, 'The Basement': {'South':'The Kitchen'}, 'The Kitchen': {'North':'The Basement', 'West':'The Living Room'} } items = { 'The Living Room': '', 'The Study': 'a Book,How to Kick a Football', 'Your Bedroom': 'a Record, Schroeder Plays Beethoven', 'The Porch': 'a Helmet', 'The Garage': 'a Football', 'The Basement': 'a Pair of Shoulder Pads', 'The Kitchen': 'Bag of Peanuts', 'a Football Field': 'Lucy' } status = 'The Living Room' inventory = [] # function def get_new_status(status, direction): new_status = status for i in rooms: if i == status: if direction in rooms[i]: new_status = rooms[i][direction] return new_status # return while 1: # gameplay loop print('You are in', status) if status == 'a Football Field': print('You see Lucy holding the football', end='') for i in range(50): for j in range(1000000): pass print(".", end='', flush=True) print() if len(inventory) == 4: print('You kicked the football! Way to go Charlie Brown!!') else: print('AAAHHGG, you missed again you blockhead!!') break if items[status] != '': print("You see", items[status]) print("You've got", inventory) direction = input('What should we do?') if direction.lower() == items[status].lower(): if items[status] not in inventory: inventory.append(items[status]) continue direction = direction.capitalize() if direction == 'Exit': print("See ya later Charlie Brown") exit(0) if direction == 'East' or direction == 'West' or direction == 'North' or direction == 'South': new_status = get_new_status(status, direction) if new_status == status: print("You can't go that way you blockhead!!") else: status = new_status else: print("You can't go that way you blockhead!!")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Oriented Databases Prentice Hall International Series In Computer Science

Authors: John G. Hughes

1st Edition

0136298745, 978-0136298748

More Books

Students also viewed these Databases questions

Question

LO 1-5 Demonstrate how businesses can meet and beat competition.

Answered: 1 week ago

Question

How did you feel about taking piano lessons as a child? (general)

Answered: 1 week ago