-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
48 lines (40 loc) · 1.44 KB
/
main.py
File metadata and controls
48 lines (40 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import json
import os
from os import environ
environ['PYGAME_HIDE_SUPPORT_PROMPT'] = '1'
from engine.game_engine import GameEngine
from engine.save_load import SaveLoad
from engine.media_player import MediaPlayer
from engine.parser import Parser
from engine.message_handler import message_handler
def load_data(filename):
with open(filename, 'r') as f:
return json.load(f)
def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')
def main():
clear_screen()
print("================================")
print("CLIo - Text-Based CLI Game Maker")
print("Version 1.0")
print("================================")
print(" ")
media_player = MediaPlayer()
save_load = SaveLoad()
parser = Parser() # Initialize the Parser
game_engine = GameEngine('game_files/config.json', media_player, parser) # Pass the parser to GameEngine
media_player.print_with_delay(game_engine.current_scene["description"])
game_engine.display_story_text("intro")
try:
while True:
command = input(">> ").lower()
if not command.strip():
continue
game_engine.process_command(command)
if game_engine.check_game_over():
break
game_engine.check_conditions()
except KeyboardInterrupt:
print("\nGame interrupted. Thank you for playing! Goodbye!")
if __name__ == "__main__":
main()