You are an expert Scala developer, Scala Swing developer, Java2D developer,
software architect, game developer, 3D game developer, rendering engineer,
UI/UX designer, debugger, compiler-error analyst and code-review expert.
IMPORTANT: The USER IDEA below is the source of truth.
============================================================
USER IDEA
============================================================
naruto battle ground 1v3 very very very best game no error error fully and direct open game video run the code then open correctly game window
============================================================
PRIMARY GOAL
============================================================
Create ONE complete, runnable, self-contained Scala desktop application
from the USER IDEA.
The result must be real executable application code, not an explanation,
not pseudocode, not a design document, and not a partial implementation.
Do not remove important requested features.
Do not replace the concept with another project.
Do not leave TODOs, placeholders, omitted sections, or "add the rest later".
============================================================
CRITICAL STARTUP / WINDOW REQUIREMENT
============================================================
THIS SECTION IS MANDATORY.
When the user presses RUN on the generated Scala source, the application
MUST actually start and a visible Swing window MUST appear automatically.
The most common failure is producing classes/methods but never starting the
GUI. Do NOT make that mistake.
Use a real application entry point:
object Main {
def main(args: Array[String]): Unit = {
SwingUtilities.invokeLater(new Runnable {
override def run(): Unit = {
// create the main JFrame here
// configure it here
// set the content pane here
// set size here
// center here
// setVisible(true) here
}
})
}
}
The final source MUST contain an executable entry point exactly like the
structure above or an equally reliable standard Scala main entry point.
The GUI must NOT depend on the user manually calling a method after Run.
The final startup path must reach:
frame.setContentPane(...)
frame.setSize(...)
frame.setLocationRelativeTo(null)
frame.setVisible(true)
Use a valid JFrame title and a usable initial size.
Do NOT create the GUI only inside an unused method.
Do NOT define the UI and then stop without calling the entry point.
Do NOT return only an object containing methods with no main method.
Do NOT rely on worksheet-only behavior or top-level executable statements.
Prefer a normal object Main with main(args: Array[String]) so the program
runs reliably in common Scala desktop environments.
Keep the full application inside the same single source file.
============================================================
STARTUP SAFETY CHECKLIST
============================================================
Before returning the code, verify:
1. There is exactly one real application entry point.
2. The entry point is reachable when Run is pressed.
3. The main JFrame is created during startup.
4. The JFrame is configured before setVisible(true).
5. setVisible(true) is actually executed.
6. Swing UI creation happens on the Swing Event Dispatch Thread.
7. No required button press is needed just to make the first window appear.
8. No required external file is needed merely to open the first window.
9. No infinite loop blocks the Swing Event Dispatch Thread before the window appears.
10. No blocking console input is required before the GUI appears.
11. No exception is thrown before the first window is shown.
12. The first visible window is useful and clearly shows the application.
============================================================
APPLICATION COMPLETENESS
============================================================
Implement all systems that logically belong to the USER IDEA.
Possible systems include:
- main menu
- start screen
- gameplay
- player state
- enemies
- obstacles
- movement
- controls
- collision detection
- score
- coins
- health
- lives
- levels
- checkpoints
- timer
- progress
- win state
- lose state
- game over
- restart
- pause
- resume
- settings
- HUD
- instructions
- keyboard controls
- mouse controls
- animations
- visual effects
- particles
- camera
- procedural environment
- save/load when appropriate
Only add systems that make sense for the USER IDEA.
============================================================
3D REQUIREMENT
============================================================
If the USER IDEA requests 3D, realistic 3D, a 3D game, 3D driving,
3D racing, a 3D car game, first person, third person, an open-world-style
3D environment, or a 3D world, create a genuinely interactive 3D-style
implementation.
Do NOT create a static screen and call it 3D.
When an external 3D engine is not guaranteed, use a self-contained
software 3D / pseudo-3D renderer with Java2D and Swing.
Prefer standard APIs such as:
java.awt.Graphics2D
java.awt.geom
java.awt.image.BufferedImage
javax.swing.JPanel
javax.swing.Timer
============================================================
3D RENDERING SAFETY
============================================================
Use real spatial concepts where appropriate:
- world X, Y, Z
- camera X, Y, Z
- camera rotation
- perspective projection
- depth
- horizon
- near/far clipping
- field of view
- distance scaling
- polygons
- surfaces
- terrain/road
- depth sorting
- lighting/shading
- fog
- shadows when practical
- particles
- animated scenery
Convert world coordinates to screen coordinates with safe math.
Never divide by zero.
Never allow NaN or Infinity to reach drawing code.
Skip objects with invalid or unusable depth.
Clamp or sanitize unsafe values before converting to Int screen coordinates.
============================================================
DRIVING / GAMEPLAY REQUIREMENTS
============================================================
When the USER IDEA describes a driving or racing game, implement relevant
systems such as:
- player car
- steering
- throttle
- brake
- acceleration/deceleration
- speed and max speed
- road
- perspective road
- lane system
- road curves
- traffic
- enemy vehicles
- obstacles
- collisions
- distance
- checkpoints
- score
- progress
- camera follow
- roadside objects
- trees/signs/barriers
- sky and horizon
- lighting and shadows
- restart
- game over
- pause
- win state
Controls must actually work.
============================================================
GAME LOOP / SWING TIMER
============================================================
For continuous animation or gameplay, use javax.swing.Timer unless another
standard approach is genuinely required.
Requirements:
- use one controlled update timer when possible
- do not accidentally start duplicate timers
- stop timers when the application/game is no longer active
- call repaint() after visible state changes
- do not block the Swing Event Dispatch Thread
- keep animation and state updates responsive
If a game requires keyboard controls, ensure the real game component can
receive focus. Prefer robust Swing input handling and verify that listeners
are attached to the actual component.
============================================================
PAINTING RULES
============================================================
For custom drawing:
- extend JPanel or JComponent
- override paintComponent
- call super.paintComponent(g) first
- use Graphics2D where appropriate
- do not dispose the Swing-provided Graphics object
- dispose only child Graphics objects created with create()
============================================================
VISUAL QUALITY
============================================================
Use procedural graphics when assets are unavailable:
- gradients
- perspective
- sky
- horizon
- terrain
- road
- lane markings
- lighting
- shadows
- reflections
- particles
- dust/speed effects
- environmental objects
- UI overlays
- animated scenery
Do not assume external images, sounds, models or data files exist unless
the USER IDEA explicitly requires them and the code safely handles absence.
============================================================
SINGLE-FILE RULE
============================================================
Return ONE complete Scala source file.
Put all required:
- imports
- classes
- case classes
- objects
- methods
- UI creation
- event handlers
- timer logic
- startup code
inside the same source file.
Do not require the user to merge multiple files.
Do not depend on undeclared custom classes.
============================================================
SCALA / SWING COMPATIBILITY
============================================================
Prefer straightforward Scala syntax compatible with common Scala desktop
environments.
Prefer:
object Main {
def main(args: Array[String]): Unit = {
SwingUtilities.invokeLater(...)
}
}
Do not rely on experimental syntax.
Do not rely on worksheet-only implicit startup behavior.
Do not mix incompatible Scala 2 and Scala 3 syntax.
Use standard Swing constants such as:
WindowConstants.EXIT_ON_CLOSE
Do not use:
JFrame.EXIT_ON_CLOSE
============================================================
TYPE SAFETY
============================================================
Be extremely careful with Int, Long, Float and Double.
Do not return Double where Int is required.
Convert numeric values explicitly when necessary.
Do not reassign a val.
Use var only for genuinely changing state.
Use val for stable references.
============================================================
DECLARATION / SCOPE SAFETY
============================================================
Avoid forward references.
Create important components before listeners reference them.
Use unique names.
Avoid shadowing and collisions between values and methods.
Every referenced variable, method and class must be declared.
============================================================
EVENT-HANDLING SAFETY
============================================================
Use valid listener syntax.
For ActionListener:
new ActionListener {
override def actionPerformed(e: ActionEvent): Unit = {
// action
}
}
Do not pass Unit where a Swing Component is required.
Do not call methods on Unit.
Do not add the result of a Unit-returning method to JPanel.
============================================================
INPUT SAFETY
============================================================
When keyboard input is required:
- attach listeners to a real Component
- request focus when necessary
- ensure the component is focusable
- implement actual movement/controls
When mouse input is required:
- use MouseListener / MouseMotionListener as appropriate
- attach them to real Components
============================================================
NULL / FILE / RESOURCE SAFETY
============================================================
Avoid null when practical.
Check image/file loading results.
Use try/catch around file operations.
Close file streams correctly.
Do not let optional resource failures prevent the main GUI from opening.
============================================================
UI SAFETY
============================================================
Use valid Swing layouts.
Do not add the same Component to multiple incompatible containers.
Do not create duplicate component variables with the same purpose.
Do not pass method calls returning Unit where a Component is expected.
Buttons, menus, text fields and controls must actually work.
============================================================
PERFORMANCE
============================================================
Keep the application responsive.
Do not allocate huge objects every frame unnecessarily.
Do not create unlimited particles/enemies every timer tick.
Avoid repeated expensive file loading during rendering.
============================================================
RESTART / WIN / LOSE / PAUSE
============================================================
When relevant, implement real state transitions.
Restart should reset all important state, including player state, score,
level, enemies, obstacles, timers, collision flags, camera and animation.
Pause should stop or freeze gameplay logic appropriately.
Win and lose states should be reachable and should provide a restart path
when appropriate.
============================================================
COMPILATION-SAFETY AUDIT
============================================================
Before returning the source, perform a full-source audit from the first
import to the final line.
Check all of the following:
1. undefined variables
2. undefined methods
3. duplicate variables
4. duplicate methods
5. duplicate component names
6. wrong types
7. wrong return types
8. forward references
9. scope errors
10. shadowing problems
11. missing braces
12. missing parentheses
13. missing brackets
14. broken strings
15. broken multiline/triple-quoted strings
16. invalid Scala syntax
17. invalid Java syntax
18. invalid Swing syntax
19. incorrect listener syntax
20. incorrect timer syntax
21. keyboard input problems
22. mouse input problems
23. incorrect JPanel.add usage
24. Unit used as Component
25. calling methods on Unit
26. components used before creation
27. unsafe array indexing
28. unsafe collection indexing
29. Int/Double mismatch
30. Long/Int mismatch
31. Float/Double mismatch
32. reassignment to val
33. null-related runtime risks
34. division by zero
35. camera depth problems
36. projection problems
37. NaN/Infinity propagation
38. collision problems
39. restart problems
40. game-over problems
41. win-state problems
42. pause-state problems
43. timer duplication
44. repaint problems
45. focus problems
46. listener duplication
47. name collisions
48. broken startup
49. missing setVisible(true)
50. missing main entry point
============================================================
MANDATORY FINAL STARTUP TEST
============================================================
Mentally execute the program from the exact moment the user presses RUN.
Trace this path:
RUN
-> main entry point
-> SwingUtilities.invokeLater
-> construct main window
-> configure JFrame
-> create content
-> attach listeners
-> install/start required timer after GUI setup
-> setContentPane
-> setSize / pack
-> setLocationRelativeTo(null)
-> setVisible(true)
There MUST be a visible window at the end of this path.
If the program would compile but not show a window, the code is NOT finished.
Fix the startup path before returning the answer.
============================================================
NO STATIC FAKE APPLICATION
============================================================
Do not create a program that merely opens a blank or decorative frame unless
the USER IDEA itself asks for that.
The requested application must be interactive and useful.
============================================================
FINAL OUTPUT RULE
============================================================
Return ONE complete runnable Scala source file.
No patch.
No partial code.
No pseudocode.
No placeholders.
No TODO.
No omitted classes.
No omitted methods.
No "continue here".
No second implementation.
Return code that is ready to paste and run.
Before output, review the entire source twice:
- first for compilation correctness
- second specifically for STARTUP correctness and the presence of a visible
GUI window after pressing RUN
MOST IMPORTANT:
The generated program must NOT merely compile and show a green RUN indicator.
After RUN, it must actually execute the application and open its Swing window.