srcimon / screwbox

Minimalist 2D Java game engine. Result of covid lockdown.
MIT License
8 stars 0 forks source link

Add spring builder like pattern to interact with the main systems (example inside) #332

Closed srcimon closed 4 months ago

srcimon commented 4 months ago

ScrewBox.createEngine("Vacuum Outlaws") .scenes(scenes -> scenes.add(new GameScene())) .start(GameScene.class);

srcimon commented 4 months ago

Actually this was a bad idea. Doen't look pretty. But is kind of complicated to understand.

srcimon commented 4 months ago
    ScrewBox.createEngine("Hello World", ScrewBox.setup()
                    .assets(assets -> assets
                            .enableLogging().prepareClassPackageAsync(PathfindingApp.class))
                    .scenes(scenes -> scenes
                            .add(new DemoScene()))
                    .camera(camera -> camera
                            .setZoom(2.7))
            ).start();
srcimon commented 4 months ago
    ScrewBox.createEngine("Particles").setup()
            .environment(environment -> environment
                    .enableTweening()
                    .enableParticles()
                    .enablePhysics()
                    .addEntity("particle spawner",
                            new TransformComponent(screwBox.graphics().world().visibleArea()),
                            new ParticleEmitterComponent(Duration.ofMillis(10), AREA, CONFETTI))
                    .addSystem(new LogFpsSystem())
                    .addEntity("particle interactor",
                            new CursorAttachmentComponent(),
                            new PhysicsComponent(),
                            new TransformComponent(-60, -60, 120, 120),
                            new ParticleInteractionComponent(80))
                    .enableRendering())
            .quitSetupAndStart();
srcimon commented 4 months ago
 ScrewBox.setup()
            .assets(assets -> assets
                    .enableLogging())
            .environment(environment -> environment
                    .environment()
                    .enableTweening()
                    .enableParticles())
            .start() // or. createEngine()

ScrewBox.createEngine();

srcimon commented 4 months ago
  ScrewBox.createEngine("Particles", setup -> setup
            .assets(assets -> assets.enableLogging())
            .assets(assets -> assets.enableLogging())
    ).start();
srcimon commented 4 months ago
    Engine screwBox = ScrewBox.createEngine("Particles",
            engine -> engine.environment()
                    .enableTweening()
                    .enableParticles()
                    .enablePhysics(),

            engine -> engine.environment()
                    .enableTweening()
                    .enableParticles()
                    .enablePhysics());
srcimon commented 4 months ago
    ScrewBox.createEngine("Particles",
            Customizer.assets(assets -> assets
                    .enableLogging()
                    .prepareEngineAssets()),
            Customizer.environment(environment -> environment
                    .enableTweening()
                    .enableParticles()
                    .enablePhysics()))
            .start();
srcimon commented 4 months ago

finally removing this idea from my brain.