Advertisement
here2share

# tk_Game_Development_Questionnaire.py

Aug 6th, 2024 (edited)
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.18 KB | None | 0 0
  1. # tk_Game_Development_Questionnaire.py
  2.  
  3. import tkinter as tk
  4. from tkinter import ttk
  5. import webbrowser
  6. import tempfile
  7. import re
  8.  
  9. root = tk.Tk()
  10. root.title("Game Development Questionnaire")
  11. root.geometry("1200x600+0+0")
  12.  
  13. frame = tk.Frame(root)
  14. frame.pack(fill="both", expand=True)
  15.  
  16. scrollbar = tk.Scrollbar(frame)
  17. scrollbar.pack(side="right", fill="y")
  18. canvas = tk.Canvas(frame, yscrollcommand=scrollbar.set)
  19. canvas.pack(side="left", fill="both", expand=True, padx=(5, 10))
  20. scrollbar.config(command=canvas.yview)
  21. content = tk.Frame(canvas)
  22.  
  23. questionnaire = '''
  24. Game Title: ?
  25. Screen Size: Fit-To-Screen: 800x600: 1024x768: 1280x720: 1920x1080: ?Other
  26. *Exclude: Tkinter: *Classes: *Pygame: *Numpy: *PyQt: *wxPython: *Kivy: *Pyglet: *Matplotlib: ?Other
  27. *Exclude: *Django: *Flask: *Tensorflow: *Keras: *Pandas: *Pyramid: *Scikit-learn: *OpenCV: *BeautifulSoup: *Scrapy: *Selenium: *Recursion: *File Input/Output: *CSV: *Seaborn
  28. *Input Methods: Keyboard: Mouse: Arrow Keys: WASD: Gamepad: ?Customizable Controls
  29. *Game Type: Single-Player: Co-Op: PvP: ?Multiplayer (Maximum)
  30. *Preferred Platforms: *PC: Console: Mobile: Web: ?Other
  31. *Difficulty Levels: Easy: Medium: Hard: ?Custom
  32. *Load Files: Audio: Background Image: 3D Models: Sprites
  33. Camera Angles: Top-Down: Side-Scrolling: First-Person: Third-Person
  34. Camera Movement: Static: Dynamic: Follows Player: ?Other
  35. *Game Speed: Fast: Medium: Slow
  36. *Gold Coin Placement: Random: ?Interval-Based (Distance Apart)
  37. Level Structure: Linear: Non-Linear: Maze: ?Other
  38. *Road Type: Straight: Curvy: Hilly: ?Width (Default Is Screenwidth)
  39. *Road Lanes: 2: 3: 4: 5: 6
  40. *Gameplay Settings: Countdown Timer: Health Display: Pause: Score Display: Record Time
  41. *Scoring System: Points: Levels: Achievements: ?Other
  42. Genre: Action: Adventure: Role-Playing: Simulation: Strategy: Sports: *Puzzle: ?Other
  43. *Theme: Fantasy: Sci-Fi: Modern: Historical: Horror: ?Other
  44. *Graphics: *2D: 3D: Isometric: Maze
  45. Game World: Open World: Linear Levels: Hub-Based
  46. *Preferred Font: Arial: *Verdana: Times New Roman: ?Custom Font
  47. *Save System: Auto-Save: Manual Save: Checkpoints: Cloud Save
  48. Combat Style: Turn-Based: Real-Time: Tactical: No Combat
  49. *Game Shapes As Objectives and/or Enemies*: Circle: Triangle: Square: 4-Sided Diamond: Pentagon:  5-Pointed Star: 6-Pointed Star: Plus-Sign: X
  50. Types Of Enemies: Ai Controlled: Player Controlled
  51. *Online Connectivity: Required: Leaderboards: In-Game Chat: Matchmaking System
  52. *Power-Ups/Boosts: Extra Life: Speed: Shield: Health: Magnet: Super Jump: Invincibility: Invisibility: Coin Magnet: Rocket: Growth: Slow Down:
  53. *Power-Ups/Boosts: Forward Boost: Laser: Bomb: Freeze: Double Score: Triple Score: Quad Score: Double Coins: Triple Coins: Quad Coins
  54. *Obstacles: Spikes: Pitfalls: Falling Spikes: Rising Spikes: Walls: Falling Blocks: Rolling Balls: Laser Beams: Ice Patches
  55. *Obstacles: Moving Platforms: Water Pits: Lava Pits: Fireballs: Doors: Locked Gates: Time Bombs: Rising Lava: Moving Walls
  56. *In-Game Economy: Currency: Resources: Cosmetics: Power-Ups
  57. '''.strip().splitlines()
  58.  
  59. def o(s):
  60.     return re.sub(r'^\W+', '', s)
  61.  
  62. def feature():
  63.     label = tk.Label(content, text=question_text, font=("Arial", 12, "bold"), fg="green")
  64.     label.pack(pady=5, anchor="w")
  65.  
  66. def is_other():
  67.     if option[1:]:
  68.         other_label = tk.Label(option_frame, text=option[1:]+':')
  69.         other_label.pack(side="left", anchor="w", padx=(15,0))
  70.    
  71.     entry = tk.Entry(option_frame, textvariable=option[1:], width=200)
  72.     entry.pack(side="left", pady=5, padx=(5, 0))
  73.     selected_options.append((question_text, entry))
  74.  
  75. selected_options = []
  76.  
  77. for question in questionnaire:
  78.     # Split the question and options
  79.     parts = question.split(": ")
  80.     question_text = parts[0]
  81.     options = parts[1:]
  82.  
  83.     if '*' in question_text: # Create checkbutton for the options
  84.         question_text = question_text[1:]
  85.         feature()
  86.    
  87.         option_frame = tk.Frame(content)
  88.         option_frame.pack(anchor="w")
  89.         for option in options:
  90.             selected_option = tk.BooleanVar()
  91.             selected_options += [(question_text + ': ' + o(option), selected_option)]
  92.             if '*' in option:
  93.                 selected_option.set(1)
  94.             elif '?' in option:
  95.                 is_other()
  96.                 continue
  97.             checkbutton = tk.Checkbutton(option_frame, text=o(option), variable=selected_option)
  98.             checkbutton.pack(side="left", anchor="w")
  99.            
  100.     else: # Create radiobuttons for the options
  101.         selected_option = tk.StringVar()
  102.         feature()
  103.         selected_option.set(options[0])
  104.  
  105.         option_frame = tk.Frame(content)
  106.         option_frame.pack(anchor="w")
  107.         for option in options:
  108.             if '*' in option:
  109.                 selected_option.set(o(option))
  110.             elif '?' in option:
  111.                 is_other()
  112.                 continue
  113.             radiobutton = tk.Radiobutton(option_frame, text=o(option), variable=selected_option, value=o(option))
  114.             radiobutton.pack(side="left", anchor="w")
  115.         selected_options += [(question_text, selected_option)]
  116.  
  117. def print_prompt():
  118.     selected_values = []
  119.     prev = ''
  120.     game_title = 'Untitled Game'
  121.     for feat, selected_option in selected_options:
  122.         selected_option = selected_option.get()
  123.         if ('Game Title' in feat) and o(selected_option):
  124.             game_title = selected_option
  125.         elif str(selected_option).strip():
  126.             try:
  127.                 selected_values.append(feat + ": " + selected_option.strip())
  128.                 prev = ''
  129.             except:
  130.                 if selected_option:
  131.                     curr, option = feat.split(':')
  132.                     if prev == curr:
  133.                         selected_values[-1] = selected_values[-1] + ',' + option
  134.                     else:
  135.                         selected_values.append(feat)
  136.                     prev = curr
  137.  
  138.     html_content = "<html><body><h2>Game Title: " + game_title + "</h2><ul>"
  139.     for value in selected_values:
  140.         if "Game Title" not in value:
  141.             html_content += "<li>" + value + "</li>"
  142.     html_content += "</ul><p>Prompt For Code Generation: Please Generate Code Based On The Information Provided Above.</p></body></html>"
  143.  
  144.     with tempfile.NamedTemporaryFile(suffix='.html', delete=False) as tmp:
  145.         tmp.write(html_content.encode('utf-8'))
  146.         filename = tmp.name
  147.  
  148.     webbrowser.open('file://' + filename)
  149.  
  150. print_button = tk.Button(root, text="Print", command=print_prompt, font='Verdana 12 bold', fg='#ffffff', bg='#00bb00')
  151. print_button.pack()
  152.  
  153. content.update_idletasks()
  154. canvas.create_window((0, 0), window=content, anchor="nw")
  155.  
  156. canvas.config(scrollregion=canvas.bbox("all"))
  157.  
  158. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement