diff --git a/Game/Flatline.mp3 b/Game/Flatline.mp3 new file mode 100644 index 0000000..6e56ef0 Binary files /dev/null and b/Game/Flatline.mp3 differ diff --git a/Game/Game.py b/Game/Game.py new file mode 100644 index 0000000..fed1ec1 --- /dev/null +++ b/Game/Game.py @@ -0,0 +1,273 @@ + +############################################### +# Name: Justin Denison, Pete Schellingerhout, John Auman +# Date: 3/30/24 (final) +# A game with many rooms and a puzzle +# Instructions: +# 1. take key and go to room 4 to interact with chest +# 2. go to room 3 to interact with statue +# 3. go to room 2 to inteact with fireplace +################################################# + +import pygame +from tkinter import * +import json + +pygame.init() +pygame.mixer.init() +pygame.mixer.music.load('PsycWard.mp3') +pygame.mixer.music.play(-1) + +# Class representing a room in the game +class Room(object): + def __init__(self, name, image): + # Initialize room attributes + self._name = name + self._image = image + self._exits = {} + self._items = {} + self._grabbables = [] + + # Getter and setter methods for room attributes + @property + def name(self): + return self._name + + @name.setter + def name(self, value): + self._name = value + + @property + def image(self): + return self._image + + @image.setter + def image(self, value): + self._image = value + + @property + def exits(self): + return self._exits + + @exits.setter + def exits(self, value): + self._exits = value + + @property + def items(self): + return self._items + + @items.setter + def items(self, value): + self._items = value + + @property + def grabbables(self): + return self._grabbables + + @grabbables.setter + def grabbables(self, value): + self._grabbables = value + + # Method to add an exit to the room + def addExit(self, exit, room): + self._exits[exit] = room + + # Method to add an item to the room + def addItem(self, item, desc): + self._items[item] = desc + + # Method to add a grabbable item to the room + def addGrabbable(self, item): + self._grabbables.append(item) + + # Method to remove a grabbable item from the room + def delGrabbable(self, item): + self._grabbables.remove(item) + + # Method to return a string description of the room + def __str__(self): + s = "You are in {}.\n".format(self.name) + s += "You see: " + for item in self.items.keys(): + s += item + " " + s += "\n" + s += "You can carry: " + for grab in self.grabbables: + s += grab + " " + s += "\n" + s += "Exits: " + for exit in self.exits.keys(): + s += exit + " " + return s + + +# Class representing the game +class Game(Frame): + def __init__(self, parent): + Frame.__init__(self, parent) + + # Method to create rooms in the game + # Method to create rooms in the game + def createRooms(self): + with open('rooms.json') as f: + data = json.load(f) + + rooms_data = data['rooms'] + + rooms = {} + for room_data in rooms_data: + room = Room(room_data['name'], room_data['image']) + room.exits = room_data.get('exits', {}) + room.items = room_data.get('items', {}) + room.grabbables = room_data.get('grabbables', []) + + # Check if there's a diary item, and if so, read its content from the file + for item, desc in room.items.items(): + if item.startswith("diary"): + diary_number = item.split("diary")[1] + with open(f"diary{diary_number}.txt", "r") as f: + diary_content = f.read() + room.items[item] = diary_content.strip() # Set the content of the diary + + rooms[room.name] = room + + # Link exits + for room_data in rooms_data: + room = rooms[room_data['name']] + for exit_dir, exit_room_name in room_data.get('exits', {}).items(): + room.addExit(exit_dir, rooms[exit_room_name]) + + # Set initial room + Game.currentRoom = rooms['Room 1'] + Game.inventory = [] + + def setupGUI(self): + self.pack(fill=BOTH, expand=1) + Game.player_input = Entry(self, bg="white") + Game.player_input.bind("", self.process) + Game.player_input.pack(side=BOTTOM, fill=X) + Game.player_input.focus() + + img = None + Game.image = Label(self, width=int(WIDTH / 2), image=img) + Game.image.image = img + Game.image.pack(side=LEFT, fill=Y) + Game.image.pack_propagate(False) + + text_frame = Frame(self, width=WIDTH / 2) + + Game.text = Text(text_frame, bg="lightgrey", state=DISABLED) + Game.text.pack(fill=Y, expand=1) + text_frame.pack(side=RIGHT, fill=Y) + text_frame.pack_propagate(False) + + # Method to set the current room image + def setRoomImage(self): + if (Game.currentRoom == None): + Game.img = PhotoImage(file="skull.gif") + else: + Game.img = PhotoImage(file=Game.currentRoom.image) + + Game.image.config(image=Game.img) + Game.image.image = Game.img + + # Method to set the status displayed on the right of the GUI + def setStatus(self, status): + Game.text.config(state=NORMAL) + Game.text.delete("1.0", END) + if (Game.currentRoom == None): + Game.text.insert(END, "You are dead") + else: + possible_actions = " Hints: \n You can type: \n -go direction \n -direction are: south, north, east, west \n -look item \n -item = check 'you see' \n -take grabbable \n -grabbable = see 'you can carry'" + Game.text.insert(END, str(Game.currentRoom) + "\nYou are carrying: " + str( + Game.inventory) + "\n\n" + status + "\n\n\n" + possible_actions) + Game.text.config(state=DISABLED) + + # Method to start playing the game + def play(self): + self.createRooms() + self.setupGUI() + self.setRoomImage() + self.setStatus("") + + # Method to process the player's input + def process(self, event): + action = Game.player_input.get() + action = action.lower() + response = "I don't understand. Try verb noun. Valid verbs are go, look, take." + if (action == "quit" or action == "exit" or action == "bye" or action == "sionara"): + exit(0) + if (Game.currentRoom == None): + Game.player_input.delete(0, END) + return + words = action.split() + if (len(words) == 2): + verb = words[0] + noun = words[1] + + done = False + + if (verb == "go"): + response = "Invalid exit." + + if (noun in Game.currentRoom.exits): + Game.currentRoom = Game.currentRoom.exits[noun] + response = "Room changed." + elif (verb == "look"): + response = "I don't see that item" + if (noun in Game.currentRoom.items): + response = Game.currentRoom.items[noun] + elif verb == "interact": + # Check if the noun is interactable + if noun in ["chair", "table", "rug", "brewrig"]: + response = Game.currentRoom.items[noun] + # Handle specific interactions based on items and inventory + elif noun == "chest": + if "key" in Game.inventory and "hammer" not in Game.inventory: + response = "Interesting! The key unlocked the chest and in it you found a hammer!" + Game.inventory.append("hammer") + else: + response = "The chest is locked." + elif noun == "statue": + if "hammer" in Game.inventory and "fire extinguisher" not in Game.inventory: + response = "Interesting! The hammer smashed the statue and you found a fire extinguisher in it!" + Game.inventory.append("fire extinguisher") + else: + response = "The statue seems sturdy." + elif noun == "fireplace": + if "fire extinguisher" in Game.inventory: + response = "You have extinguished the fireplace and escaped through a hidden door!" + exit(0) + else: + response = "The fireplace crackles warmly." + elif (verb == "take"): + response = "I don't see that item" + for grabbable in Game.currentRoom.grabbables: + if (noun == grabbable): + Game.inventory.append(grabbable) + Game.currentRoom.delGrabbable(grabbable) + response = "Item grabbed" + break + self.setStatus(response) + self.setRoomImage() + Game.player_input.delete(0, END) + + +######################MAIN######################### + +# Default size of the GUI +WIDTH = 1600 +HEIGHT = 1200 + +# Create the window +window = Tk() +window.title("Room Adventure") + +# Create the GUI as a Tkinter canvas inside the window +g = Game(window) +# Play the game +g.play() + +# Wait for the window to close +window.mainloop() diff --git a/Game/PsycWard.mp3 b/Game/PsycWard.mp3 new file mode 100644 index 0000000..f0f52f3 Binary files /dev/null and b/Game/PsycWard.mp3 differ diff --git a/Game/PsycWard.zip b/Game/PsycWard.zip new file mode 100644 index 0000000..160ccfe Binary files /dev/null and b/Game/PsycWard.zip differ diff --git a/Game/Room1.png b/Game/Room1.png new file mode 100644 index 0000000..bf52611 Binary files /dev/null and b/Game/Room1.png differ diff --git a/Game/Room10.png b/Game/Room10.png new file mode 100644 index 0000000..a95f419 Binary files /dev/null and b/Game/Room10.png differ diff --git a/Game/Room11.png b/Game/Room11.png new file mode 100644 index 0000000..5835482 Binary files /dev/null and b/Game/Room11.png differ diff --git a/Game/Room12.png b/Game/Room12.png new file mode 100644 index 0000000..d3de9a1 Binary files /dev/null and b/Game/Room12.png differ diff --git a/Game/Room13.png b/Game/Room13.png new file mode 100644 index 0000000..5ec29a4 Binary files /dev/null and b/Game/Room13.png differ diff --git a/Game/Room14.png b/Game/Room14.png new file mode 100644 index 0000000..ed18c81 Binary files /dev/null and b/Game/Room14.png differ diff --git a/Game/Room15.png b/Game/Room15.png new file mode 100644 index 0000000..5e6a8dc Binary files /dev/null and b/Game/Room15.png differ diff --git a/Game/Room16.png b/Game/Room16.png new file mode 100644 index 0000000..6301190 Binary files /dev/null and b/Game/Room16.png differ diff --git a/Game/Room17.png b/Game/Room17.png new file mode 100644 index 0000000..1f6b7a3 Binary files /dev/null and b/Game/Room17.png differ diff --git a/Game/Room18.png b/Game/Room18.png new file mode 100644 index 0000000..f2bdbaa Binary files /dev/null and b/Game/Room18.png differ diff --git a/Game/Room19.png b/Game/Room19.png new file mode 100644 index 0000000..96ca1ed Binary files /dev/null and b/Game/Room19.png differ diff --git a/Game/Room2.png b/Game/Room2.png new file mode 100644 index 0000000..6f0437f Binary files /dev/null and b/Game/Room2.png differ diff --git a/Game/Room20.png b/Game/Room20.png new file mode 100644 index 0000000..ca45c23 Binary files /dev/null and b/Game/Room20.png differ diff --git a/Game/Room21.png b/Game/Room21.png new file mode 100644 index 0000000..b37cad6 Binary files /dev/null and b/Game/Room21.png differ diff --git a/Game/Room22.png b/Game/Room22.png new file mode 100644 index 0000000..ee4b58f Binary files /dev/null and b/Game/Room22.png differ diff --git a/Game/Room23.png b/Game/Room23.png new file mode 100644 index 0000000..34c7d31 Binary files /dev/null and b/Game/Room23.png differ diff --git a/Game/Room24.png b/Game/Room24.png new file mode 100644 index 0000000..02d2c14 Binary files /dev/null and b/Game/Room24.png differ diff --git a/Game/Room3.png b/Game/Room3.png new file mode 100644 index 0000000..4e6aa4b Binary files /dev/null and b/Game/Room3.png differ diff --git a/Game/Room4.png b/Game/Room4.png new file mode 100644 index 0000000..b9f2932 Binary files /dev/null and b/Game/Room4.png differ diff --git a/Game/Room5.png b/Game/Room5.png new file mode 100644 index 0000000..b072a07 Binary files /dev/null and b/Game/Room5.png differ diff --git a/Game/Room6.png b/Game/Room6.png new file mode 100644 index 0000000..efca3d1 Binary files /dev/null and b/Game/Room6.png differ diff --git a/Game/Room7.png b/Game/Room7.png new file mode 100644 index 0000000..3f975d7 Binary files /dev/null and b/Game/Room7.png differ diff --git a/Game/Room8.png b/Game/Room8.png new file mode 100644 index 0000000..40e4ae5 Binary files /dev/null and b/Game/Room8.png differ diff --git a/Game/Room9.png b/Game/Room9.png new file mode 100644 index 0000000..f596380 Binary files /dev/null and b/Game/Room9.png differ diff --git a/Game/diary1.txt b/Game/diary1.txt new file mode 100644 index 0000000..ace538f --- /dev/null +++ b/Game/diary1.txt @@ -0,0 +1,5 @@ +4/2/22 + +I had an idea. After my late brother passed from the 'mystery disease' of deathicitis, I knew I had to find a solution. The only problem was a lack of patients to test my solution on and experiment with. I have so far been able to capture a few. They usually fight but it's nothing I can't handle. + +Dr. Zonderstrom \ No newline at end of file diff --git a/Game/diary2.txt b/Game/diary2.txt new file mode 100644 index 0000000..0ea8ef1 --- /dev/null +++ b/Game/diary2.txt @@ -0,0 +1,5 @@ +4/30/22 + +I cannot believe I did not think of this sooner! I have made a lot of progress in finding a cure. I must admit at first the screams got to me a little bit but it is all in the name of Science! I am considering ramping up testing to speed up the time to find a cure. + +Dr. Zonderstrom \ No newline at end of file diff --git a/Game/diary3.txt b/Game/diary3.txt new file mode 100644 index 0000000..11a4f08 --- /dev/null +++ b/Game/diary3.txt @@ -0,0 +1,6 @@ +5/13/22 + +I have hit a bit of a wall. I saw massive progress at first but in my latest test (No. 67) it seems the cure stops the disease temporarily but doesn't cure it. The only way onward is to further test. It's all in the name of my brother. I hate to admit it but I am not even bothered by the testing process anymore. Desensitization is an interesting phenomenon. + +Dr. Zonderstrom + \ No newline at end of file diff --git a/Game/diary4.txt b/Game/diary4.txt new file mode 100644 index 0000000..5accf60 --- /dev/null +++ b/Game/diary4.txt @@ -0,0 +1,6 @@ +6/3/22 + +I had to ramp up work a lot but I was able to crack the problem! In trial No. 115 I tried applying the solution all at once and not over a gradual period and it led to a complete cure of the disease! The only downside to this is that it causes severe memory loss and imminent death hours after waking up. I am currently working to solve this. + +Dr. Zonderstrom + \ No newline at end of file diff --git a/Game/diary5.txt b/Game/diary5.txt new file mode 100644 index 0000000..e42cd68 --- /dev/null +++ b/Game/diary5.txt @@ -0,0 +1,6 @@ +6/21/24 + +Still no cure. I have begun to get headaches from the workload. I do not know if it is some form of karma for my actions. Many people have died in my experiments so far (No. 143 currently), however, it is all for the greater good. If only people would understand this is the only way to further push science! We cannot be weak-willed and allow ourselves to be bested! + +Dr. Zonderstrom + \ No newline at end of file diff --git a/Game/diary6.txt b/Game/diary6.txt new file mode 100644 index 0000000..75a307b --- /dev/null +++ b/Game/diary6.txt @@ -0,0 +1,15 @@ +7/3/24 + +I have realized that I am unfortunately ailed by the same illness that took my brother and that I dedicated myself to solving it. All before perfecting the cure. This will most likely be my last entry due to death after I risk the medicine on my own body. It is my only hope to survive. If you are reading these then I am probably one of the numerous bodies surrounding the labs. I would've liked to have been remembered, but I do not think the world would take kindly to my experiments. I will leave my medical ID here as proof of my work and a testament to my life. It might help you to identify me. + +Dr. Zonderstrom + +------------------------------- +- - +- Medical Identification Card - +- - +- Name: Dr Jack Zonderstrom - +- - +- Director of Pathology - +- - +------------------------------- diff --git a/Game/rooms.json b/Game/rooms.json new file mode 100644 index 0000000..a65c2fd --- /dev/null +++ b/Game/rooms.json @@ -0,0 +1,273 @@ +{ + "rooms": [ + { + "name": "Room 1", + "image": "room1.png", + "exits": { + "north": "Room 2" + }, + "items": { + "chair": "it looks uncomfortable", + "table": "it looks very sturdy", + "diary1": "Contents of diary1" + }, + "grabbables": ["key"] + }, + { + "name": "Room 2", + "image": "room2.png", + "exits": { + "north": "Room 3" + }, + "items": { + "rug": "it looks very old and recently moved", + "fireplace": "it provides a nice warm atmosphere", + "medical_equipment": "old equipment from medical experiments" + }, + "grabbables": [] + }, + { + "name": "Room 3", + "image": "room3.png", + "exits": { + "north": "Room 4", + "east": "Room 17" + }, + "items": { + "bookshelf": "it has many random books on it and some big ones that stand out", + "statue": "it is small and seems to be hollow?", + "desk": "it has a drawer that needs to be unlocked" + }, + "grabbables": ["book"] + }, + { + "name": "Room 4", + "image": "room4.png", + "exits": { + "north": "Room 5" + }, + "items": { + "brewrig": "it is here for some reason, I guess", + "chest": "it seems to be a locked chest" + }, + "grabbables": ["beverage"] + }, + { + "name": "Room 5", + "image": "room5.png", + "exits": { + "north": "Room 6" + }, + "items": { + "wheelchair": "the wheels squeak eerily as you push it" + }, + "grabbables": [] + }, + { + "name": "Room 6", + "image": "room6.png", + "exits": { + "east": "Room 7" + }, + "items": {}, + "grabbables": [] + }, + { + "name": "Room 7", + "image": "room7.png", + "exits": { + "east": "Room 8" + }, + "items": {}, + "grabbables": [] + }, + { + "name": "Room 8", + "image": "room8.png", + "exits": { + "east": "Room 9" + }, + "items": {}, + "grabbables": [] + }, + { + "name": "Room 9", + "image": "room9.png", + "exits": { + "east": "Room 10" + }, + "items": {}, + "grabbables": [] + }, + { + "name": "Room 10", + "image": "room10.png", + "exits": { + "east": "Room 11" + }, + "items": {}, + "grabbables": [] + }, + { + "name": "Room 11", + "image": "room11.png", + "exits": { + "south": "Room 12" + }, + "items": { + "pill_bottles": "labels are faded and contents long gone" + }, + "grabbables": [] + }, + { + "name": "Room 12", + "image": "room12.png", + "exits": { + "south": "Room 13" + }, + "items": { + "scratched_window": "from here, doctors once observed the patients' behavior", + "diary5": "Contents of Diary 5" + }, + "grabbables": [] + }, + { + "name": "Room 13", + "image": "room13.png", + "exits": { + "south": "Room 14" + }, + "items": {}, + "grabbables": [] + }, + { + "name": "Room 14", + "image": "room14.png", + "exits": { + "south": "Room 15", + "west": "Room 24" + }, + "items": { + "floor_stain": "dark and red probably remnants of an experiment", + "diary6": "Contents of Diary 6" + }, + "grabbables": [] + }, + { + "name": "Room 15", + "image": "room15.png", + "exits": { + "south": "Room 16" + }, + "items": {}, + "grabbables": [] + }, + { + "name": "Room 16", + "image": "room16.png", + "exits": { + "north": "Room 15" + }, + "items": { + "broken_restraints": "leather straps hang loosely broken in an experiment" + }, + "grabbables": [] + }, + { + "name": "Room 17", + "image": "room17.png", + "exits": { + "east": "Room 20", + "west": "Room 3" + }, + "items": { + "experiment_files": "piles of paperwork about old patients", + "diary2": "Contents of Diary 2" + }, + "grabbables": [] + }, + { + "name": "Room 18", + "image": "room18.png", + "exits": { + "south": "Room 20", + "east": "Room 19" + }, + "items": {}, + "grabbables": [] + }, + { + "name": "Room 19", + "image": "room19.png", + "exits": { + "south": "Room 21", + "west": "Room 18" + }, + "items": {}, + "grabbables": [] + }, + { + "name": "Room 20", + "image": "room20.png", + "exits": { + "north": "Room 18", + "south": "Room 22", + "west": "Room 17", + "east": "Room 21" + }, + "items": { + "gurney": "its wheels squeal as you move it" + }, + "grabbables": [] + }, + { + "name": "Room 21", + "image": "room21.png", + "exits": { + "north": "Room 19", + "south": "Room 23", + "west": "Room 20", + "east": "Room 24" + }, + "items": { + "rusty_tools": "a testament of past experiments, they are oddly red tinted", + "diary3": "Contents of diary 3" + }, + "grabbables": [] + }, + { + "name": "Room 22", + "image": "room22.png", + "exits": { + "north": "Room 20", + "east": "Room 23" + }, + "items": {}, + "grabbables": [] + }, + { + "name": "Room 23", + "image": "room23.png", + "exits": { + "north": "Room 21", + "west": "Room 22" + }, + "items": { + "rusty_tools": "a testament of past experiments, they are oddly red tinted" + }, + "grabbables": [] + }, + { + "name": "Room 24", + "image": "room24.png", + "exits": { + "east": "Room 14", + "west": "Room 21" + }, + "items": { + "diary4": "Contents of diary4" + }, + "grabbables": [] + } + ] +}