import javax.swing._
import java.awt._
import java.awt.event._
import java.awt.datatransfer.StringSelection
import java.io._
import java.security.MessageDigest
import java.util.Arrays
// =====================================================
// MY IDEA - CHATGPT PROMPT STUDIO
// COMPLETE PASSWORD PROTECTED VERSION
// =====================================================
object MyGamePromptStudio {
// ===================================================
// 1. SHA-256 SECURITY
// ===================================================
private val PASSWORD_HASH =
"7f3f667469f4945d7b63b6831e26f1bd84bd02d57b455542b6144fe2b2a6a92d"
private val EXPECTED_HASH: Array[Byte] =
PASSWORD_HASH.grouped(2).map { part =>
Integer.parseInt(part, 16).toByte
}.toArray
private def authenticate(): Boolean = {
var attempts = 0
val maxAttempts = 3
while (attempts < maxAttempts) {
val passwordField = new JPasswordField(22)
passwordField.setFont(
new Font("Arial", Font.PLAIN, 17)
)
val loginTitle = new JLabel(
"Enter your application password:"
)
loginTitle.setFont(
new Font("Arial", Font.BOLD, 15)
)
val loginPanel = new JPanel(
new BorderLayout(10, 12)
)
loginPanel.setBorder(
BorderFactory.createEmptyBorder(15, 15, 15, 15)
)
loginPanel.add(
loginTitle,
BorderLayout.NORTH
)
loginPanel.add(
passwordField,
BorderLayout.CENTER
)
val result = JOptionPane.showConfirmDialog(
null,
loginPanel,
"SECURE LOGIN - MY IDEA STUDIO",
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE
)
if (result != JOptionPane.OK_OPTION) {
return false
}
val entered = passwordField.getPassword
var passwordBytes: Array[Byte] = Array.empty[Byte]
val valid = try {
passwordBytes =
new String(entered).getBytes("UTF-8")
val actualHash =
MessageDigest
.getInstance("SHA-256")
.digest(passwordBytes)
MessageDigest.isEqual(
actualHash,
EXPECTED_HASH
)
}
catch {
case _: Exception => false
}
finally {
Arrays.fill(entered, '\u0000')
Arrays.fill(
passwordBytes,
0.toByte
)
}
if (valid) {
JOptionPane.showMessageDialog(
null,
"ACCESS GRANTED!\nWelcome to MY IDEA STUDIO.",
"LOGIN SUCCESSFUL",
JOptionPane.INFORMATION_MESSAGE
)
return true
}
else {
attempts += 1
JOptionPane.showMessageDialog(
null,
"Incorrect Password!\n\nAttempts remaining: " +
(maxAttempts - attempts),
"ACCESS DENIED",
JOptionPane.ERROR_MESSAGE
)
}
}
JOptionPane.showMessageDialog(
null,
"Maximum login attempts reached.\nApplication will close.",
"SECURITY LOCK",
JOptionPane.ERROR_MESSAGE
)
false
}
// ===================================================
// 2. PROFESSIONAL PROMPT GENERATOR ENGINE
// ===================================================
private def createPrompt(
name: String,
idea: String,
features: String,
language: String
): String = {
val gameTitle =
if (name.trim.nonEmpty)
name.trim
else
"Choose a suitable game name"
val extraFeatures =
if (features.trim.nonEmpty)
features.trim
else
"Select suitable features based on the game concept."
val kojoRules =
if (language.startsWith("Kojo")) {
"""
==================================================
CRITICAL KOJO 2.9.35 EXECUTION INSTRUCTIONS
==================================================
This code will be pasted DIRECTLY into the Kojo
2.9.35 Scala Script Editor.
The user will press the RUN button.
MOST IMPORTANT:
The code MUST execute and display the actual game.
SCRIPT STRUCTURE:
1. Generate a direct executable Scala script.
2. Put executable statements at the script's top level.
3. Do NOT wrap the entire script inside object Main.
4. Do NOT use object Main extends App.
5. Do NOT put the whole program inside def main().
6. Do NOT place the game startup inside an unused function.
7. Do NOT require the user to manually call a function.
8. Do NOT create a JFrame that is never displayed.
9. Do NOT create an empty JPanel as the final output.
10. Do NOT finish with only variable declarations.
11. Do NOT finish with only function definitions.
WHEN THE USER PRESSES RUN:
The actual requested game must become visible.
If using Kojo's built-in graphics:
- Execute the required drawing commands immediately.
- Initialize the game scene.
- Display the actual game.
- Start its animation and interaction systems.
If using Java Swing:
- Create the real game window.
- Create and initialize the real game panel.
- Add the game panel to the window.
- Set an appropriate window size.
- Set the window position.
- Make the window visible.
- Start the game timer if required.
Example structure for Java Swing:
val gameFrame = new javax.swing.JFrame("My Game")
val gamePanel = new javax.swing.JPanel {
override def paintComponent(
g: java.awt.Graphics
): Unit = {
super.paintComponent(g)
// Draw the actual game here.
}
}
gameFrame.setContentPane(gamePanel)
gameFrame.setSize(1100, 750)
gameFrame.setLocationRelativeTo(null)
gameFrame.setVisible(true)
This is only an illustration of the startup structure.
Create the ACTUAL requested game, not this empty example.
IMPORTANT COMPATIBILITY:
- Target Kojo 2.9.35.
- Use compatible Scala syntax.
- Use available Java AWT and Swing APIs when needed.
- Use Java2D for advanced graphics.
- Use javax.swing.Timer for animations.
- Avoid unsupported external dependencies.
- Avoid imaginary methods.
- Avoid unsupported Scala 3-only syntax.
- Avoid unnecessary external image assets.
STARTUP VERIFICATION:
Before returning the code, check:
1. Does the script execute directly?
2. Does the actual game become visible?
3. Is the game panel attached to the window?
4. Is the game rendering method called?
5. Are game objects initialized?
6. Are animations started?
7. Are buttons connected to their actions?
8. Do keyboard controls work?
9. Does the game remain open?
10. Can the user actually play?
Never return code that merely runs silently.
==================================================
"""
}
else {
"""
TARGET ENVIRONMENT:
""" + language + """
Create a complete executable application.
Use the proper startup entry point for the selected environment.
The actual application must appear when executed.
Do not provide only function declarations.
Do not create an empty window.
Do not provide pseudocode.
"""
}
s"""
==================================================
PROFESSIONAL GAME DEVELOPMENT PROMPT
==================================================
ROLE:
You are an expert game developer, software architect,
professional programmer, game designer and debugging specialist.
Your task is to create MY EXACT GAME IDEA.
==================================================
1. MY GAME DETAILS
==================================================
GAME NAME:
$gameTitle
MY OWN GAME IDEA:
$idea
ADDITIONAL FEATURES I WANT:
$extraFeatures
==================================================
2. TARGET PROGRAMMING ENVIRONMENT
==================================================
$language
$kojoRules
==================================================
3. COMPLETE GAME DEVELOPMENT
==================================================
Create a complete, fully playable game.
Include the appropriate features:
1. Professional start menu.
2. Attractive game title screen.
3. Working play button.
4. Game instructions.
5. Actual gameplay.
6. Smooth animations.
7. Attractive original graphics.
8. Score system.
9. Multiple levels where appropriate.
10. Increasing difficulty.
11. Pause and resume.
12. Restart option.
13. Game over screen.
14. Winning screen.
15. Replay functionality.
16. Keyboard controls.
17. Mouse controls where appropriate.
18. Proper collision detection.
19. Sound effects where practical.
20. High score system where appropriate.
Every button must perform its actual action.
==================================================
4. EXACT GAME MECHANICS
==================================================
Understand my game idea.
Create the mechanics specifically for my game.
Implement the required:
- Player behaviour.
- Object movement.
- Obstacles.
- Enemies where appropriate.
- Game physics.
- Collision detection.
- Game objectives.
- Rewards.
- Level progression.
- Difficulty progression.
Do not replace my game idea with a generic game.
==================================================
5. PROFESSIONAL GRAPHICS
==================================================
Create attractive original graphics.
Use appropriate drawing methods.
Include:
- Anti-aliasing.
- Smooth movement.
- Detailed backgrounds.
- Attractive colors.
- Shadows and gradients.
- Animated effects.
- Professional menus.
- Proper layouts.
- Detailed game objects.
Avoid using basic placeholder shapes for
important characters and objects.
==================================================
6. ERROR PREVENTION
==================================================
Carefully review every section of the code.
Check:
1. Missing imports.
2. Duplicate variables.
3. Undefined variables.
4. Incorrect function calls.
5. Scala type mismatches.
6. Brackets and parentheses.
7. Event listeners.
8. Timer implementation.
9. Graphics methods.
10. Keyboard controls.
11. Collision detection.
12. Missing object references.
13. Unsupported methods.
14. Window initialization.
15. Script execution.
16. Rendering and repainting.
17. Game loop.
18. Program closing behaviour.
Fix all identifiable errors before responding.
Do not invent functions or libraries.
Do not leave incomplete methods.
Never write:
"Rest of code here."
==================================================
7. MOST IMPORTANT - VISIBLE GAME
==================================================
I DO NOT WANT:
- An empty window.
- A blank screen.
- Only a title label.
- Only a menu without a working game.
- Only variable declarations.
- Only function declarations.
- A program that runs without displaying anything.
- A game hidden inside an unused main method.
I WANT:
THE ACTUAL REQUESTED GAME TO APPEAR WHEN I
PRESS RUN IN THE SELECTED PROGRAMMING ENVIRONMENT.
Make sure the startup code is executed immediately.
The final executable statement must not leave
the user with an empty application.
==================================================
8. COMPLETE SOURCE CODE
==================================================
Provide the FULL SOURCE CODE.
Include:
- All imports.
- All required variables.
- All classes.
- All functions.
- All game mechanics.
- All event listeners.
- All graphics.
- All required startup statements.
Prefer one complete script whenever practical.
If multiple files are required, provide
every file separately with its filename.
No pseudocode.
No missing sections.
No incomplete examples.
No unnecessary external dependencies.
==================================================
9. FINAL QUALITY REVIEW
==================================================
Before giving the answer, carefully review
the source code from beginning to end.
Check the actual startup sequence.
Fix identifiable issues.
Do not claim compilation or testing unless
you actually compiled or tested the code.
Explain any unavoidable environment limitations.
==================================================
FINAL INSTRUCTION
==================================================
Build MY EXACT GAME IDEA.
Make the actual game visible and playable.
Give me the complete runnable source code now.
"""
}
// ===================================================
// 3. APPLICATION WINDOW
// ===================================================
private def launchApplication(): Unit = {
val frame = new JFrame(
"MY IDEA - CHATGPT PROMPT GENERATOR"
)
frame.setSize(1100, 800)
frame.setDefaultCloseOperation(
WindowConstants.DISPOSE_ON_CLOSE
)
frame.setLocationRelativeTo(null)
// -----------------------------------------------
// COLORS
// -----------------------------------------------
val dark = new Color(19, 24, 39)
val panel = new Color(30, 38, 56)
val blue = new Color(65, 155, 255)
val green = new Color(75, 225, 155)
// -----------------------------------------------
// HEADER
// -----------------------------------------------
val heading = new JLabel(
" MY IDEA -> CHATGPT PROMPT STUDIO"
)
heading.setFont(
new Font("Arial", Font.BOLD, 27)
)
heading.setForeground(blue)
val subtitle = new JLabel(
" Write anything. Generate a professional coding prompt."
)
subtitle.setForeground(Color.LIGHT_GRAY)
subtitle.setFont(
new Font("Arial", Font.PLAIN, 14)
)
val header = new JPanel(
new GridLayout(2, 1)
)
header.setBackground(dark)
header.add(heading)
header.add(subtitle)
// -----------------------------------------------
// GAME NAME
// -----------------------------------------------
val gameName = new JTextField()
gameName.setFont(
new Font("Arial", Font.PLAIN, 16)
)
gameName.setBackground(panel)
gameName.setForeground(Color.WHITE)
gameName.setCaretColor(Color.WHITE)
// -----------------------------------------------
// OWN GAME IDEA
// -----------------------------------------------
val ideaArea = new JTextArea(8, 60)
ideaArea.setFont(
new Font("Arial", Font.PLAIN, 17)
)
ideaArea.setLineWrap(true)
ideaArea.setWrapStyleWord(true)
ideaArea.setBackground(panel)
ideaArea.setForeground(Color.WHITE)
ideaArea.setCaretColor(Color.WHITE)
ideaArea.setText(
"Describe your own game idea here..."
)
// -----------------------------------------------
// EXTRA FEATURES
// -----------------------------------------------
val featuresArea = new JTextArea(4, 60)
featuresArea.setFont(
new Font("Arial", Font.PLAIN, 15)
)
featuresArea.setLineWrap(true)
featuresArea.setWrapStyleWord(true)
featuresArea.setBackground(panel)
featuresArea.setForeground(Color.WHITE)
featuresArea.setCaretColor(Color.WHITE)
// -----------------------------------------------
// LANGUAGE SELECTION
// -----------------------------------------------
val language = new JComboBox[String](
Array(
"Kojo 2.9.35 - Scala Script",
"Scala Swing",
"Java Swing",
"Python",
"HTML CSS JavaScript",
"C++",
"C#",
"Kotlin",
"Let ChatGPT Decide"
)
)
language.setFont(
new Font("Arial", Font.PLAIN, 14)
)
// -----------------------------------------------
// OUTPUT AREA
// -----------------------------------------------
val promptOutput = new JTextArea()
promptOutput.setFont(
new Font("Consolas", Font.PLAIN, 14)
)
promptOutput.setLineWrap(true)
promptOutput.setWrapStyleWord(true)
promptOutput.setBackground(
new Color(9, 15, 29)
)
promptOutput.setForeground(green)
promptOutput.setCaretColor(Color.WHITE)
// -----------------------------------------------
// STATUS
// -----------------------------------------------
val status = new JLabel(
" Ready. Write your own game idea!"
)
status.setForeground(green)
status.setFont(
new Font("Arial", Font.BOLD, 14)
)
// -----------------------------------------------
// BUTTONS
// -----------------------------------------------
val generateButton = new JButton(
"GENERATE CHATGPT PROMPT"
)
val copyButton = new JButton(
"COPY PROMPT"
)
val saveButton = new JButton(
"SAVE PROMPT"
)
val clearButton = new JButton(
"CLEAR"
)
generateButton.setBackground(blue)
generateButton.setForeground(Color.WHITE)
// -----------------------------------------------
// GENERATE BUTTON
// -----------------------------------------------
generateButton.addActionListener(
new ActionListener {
def actionPerformed(
e: ActionEvent
): Unit = {
val idea = ideaArea.getText.trim
if (idea.isEmpty ||
idea == "Describe your own game idea here...") {
status.setText(
" Please write your own game idea first!"
)
ideaArea.requestFocus()
}
else {
val generated = createPrompt(
gameName.getText,
idea,
featuresArea.getText,
language.getSelectedItem.toString
)
promptOutput.setText(generated)
promptOutput.setCaretPosition(0)
status.setText(
" Professional game prompt generated successfully!"
)
}
}
}
)
// -----------------------------------------------
// COPY BUTTON
// -----------------------------------------------
copyButton.addActionListener(
new ActionListener {
def actionPerformed(
e: ActionEvent
): Unit = {
if (promptOutput.getText.trim.nonEmpty) {
val selection = new StringSelection(
promptOutput.getText
)
Toolkit.getDefaultToolkit
.getSystemClipboard
.setContents(selection, null)
status.setText(
" Complete prompt copied! Paste it into ChatGPT."
)
} else {
status.setText(
" Generate a prompt first!"
)
}
}
}
)
// -----------------------------------------------
// SAVE BUTTON
// -----------------------------------------------
saveButton.addActionListener(
new ActionListener {
def actionPerformed(
e: ActionEvent
): Unit = {
if (promptOutput.getText.trim.nonEmpty) {
val chooser = new JFileChooser()
chooser.setSelectedFile(
new File("My-Game-Prompt.txt")
)
if (
chooser.showSaveDialog(frame) ==
JFileChooser.APPROVE_OPTION
) {
try {
val writer = new OutputStreamWriter(
new FileOutputStream(
chooser.getSelectedFile
),
"UTF-8"
)
try {
writer.write(promptOutput.getText)
}
finally {
writer.close()
}
status.setText(
" Prompt saved successfully!"
)
}
catch {
case ex: Exception =>
status.setText(
" Save error: " + ex.getMessage
)
}
}
}
else {
status.setText(
" Generate a prompt first!"
)
}
}
}
)
// -----------------------------------------------
// CLEAR BUTTON
// -----------------------------------------------
clearButton.addActionListener(
new ActionListener {
def actionPerformed(
e: ActionEvent
): Unit = {
gameName.setText("")
ideaArea.setText("")
featuresArea.setText("")
promptOutput.setText("")
status.setText(
" Ready for a completely new idea!"
)
}
}
)
// -----------------------------------------------
// LABEL HELPER
// -----------------------------------------------
def makeLabel(text: String): JLabel = {
val label = new JLabel(text)
label.setFont(
new Font("Arial", Font.BOLD, 16)
)
label.setForeground(blue)
label
}
// -----------------------------------------------
// FORM PANEL
// -----------------------------------------------
val form = new JPanel(
new GridBagLayout()
)
form.setBackground(dark)
val gbc = new GridBagConstraints()
gbc.gridx = 0
gbc.gridy = 0
gbc.gridwidth = 1
gbc.weightx = 1.0
gbc.fill = GridBagConstraints.HORIZONTAL
gbc.insets = new Insets(
5, 8, 5, 8
)
form.add(
makeLabel("1. GAME NAME (OPTIONAL)"),
gbc
)
gbc.gridy += 1
form.add(
gameName,
gbc
)
gbc.gridy += 1
form.add(
makeLabel("2. WRITE YOUR OWN GAME IDEA"),
gbc
)
gbc.gridy += 1
gbc.weighty = 0.42
gbc.fill = GridBagConstraints.BOTH
form.add(
new JScrollPane(ideaArea),
gbc
)
gbc.gridy += 1
gbc.weighty = 0
gbc.fill = GridBagConstraints.HORIZONTAL
form.add(
makeLabel("3. EXTRA FEATURES (OPTIONAL)"),
gbc
)
gbc.gridy += 1
gbc.weighty = 0.22
gbc.fill = GridBagConstraints.BOTH
form.add(
new JScrollPane(featuresArea),
gbc
)
gbc.gridy += 1
gbc.weighty = 0
gbc.fill = GridBagConstraints.HORIZONTAL
form.add(
makeLabel("4. PROGRAMMING LANGUAGE"),
gbc
)
gbc.gridy += 1
form.add(
language,
gbc
)
// -----------------------------------------------
// ACTION BUTTON PANEL
// -----------------------------------------------
val buttons = new JPanel(
new FlowLayout(FlowLayout.LEFT)
)
buttons.setBackground(panel)
buttons.add(generateButton)
buttons.add(copyButton)
buttons.add(saveButton)
buttons.add(clearButton)
gbc.gridy += 1
form.add(
buttons,
gbc
)
// -----------------------------------------------
// OUTPUT PANEL
// -----------------------------------------------
val outputTitle = makeLabel(
"GENERATED CHATGPT PROMPT"
)
outputTitle.setForeground(green)
val outputPanel = new JPanel(
new BorderLayout(5, 5)
)
outputPanel.setBackground(dark)
outputPanel.add(
outputTitle,
BorderLayout.NORTH
)
outputPanel.add(
new JScrollPane(promptOutput),
BorderLayout.CENTER
)
// -----------------------------------------------
// MAIN SPLIT
// -----------------------------------------------
val split = new JSplitPane(
JSplitPane.VERTICAL_SPLIT,
form,
outputPanel
)
split.setDividerLocation(405)
split.setResizeWeight(0.50)
// -----------------------------------------------
// ROOT PANEL
// -----------------------------------------------
val root = new JPanel(
new BorderLayout(8, 8)
)
root.setBackground(dark)
root.setBorder(
BorderFactory.createEmptyBorder(
12, 12, 12, 12
)
)
root.add(
header,
BorderLayout.NORTH
)
root.add(
split,
BorderLayout.CENTER
)
root.add(
status,
BorderLayout.SOUTH
)
// -----------------------------------------------
// SHOW APPLICATION
// -----------------------------------------------
frame.setContentPane(root)
frame.setVisible(true)
}
// ===================================================
// 4. RUN APPLICATION
// ===================================================
def main(args: Array[String]): Unit = {
if (authenticate()) {
SwingUtilities.invokeLater(
new Runnable {
def run(): Unit = {
launchApplication()
}
}
)
}
}
}
// =====================================================
// START
// =====================================================
MyGamePromptStudio.main(Array.empty[String])