Search in sources :

Example 1 with SourceResolutionProvider

use of com.b3dgs.lionengine.graphic.engine.SourceResolutionProvider in project lionengine by b3dgs.

the class ParallaxTest method testParallax.

/**
 * Test clouds.
 */
@Test
void testParallax() {
    final Parallax parallax = new Parallax(new SourceResolutionProvider() {

        @Override
        public int getWidth() {
            return 320;
        }

        @Override
        public int getHeight() {
            return 240;
        }

        @Override
        public int getRate() {
            return 60;
        }
    }, Medias.create("surface.png"), 11, 1, 2, 100, 100);
    parallax.setScreenSize(320, 240);
    parallax.update(1.0, 1, 0, 200.0);
    parallax.update(1.0, 1, 200, 200.0);
    parallax.update(1.0, 1, 300, 200.0);
    parallax.update(1.0, 1, 0, -200.0);
    parallax.update(1.0, 1, 0, -200.0);
    parallax.update(1.0, 1, 0, -200.0);
    final Graphic g = Graphics.createGraphic();
    parallax.render(g);
    g.dispose();
}
Also used : Graphic(com.b3dgs.lionengine.graphic.Graphic) SourceResolutionProvider(com.b3dgs.lionengine.graphic.engine.SourceResolutionProvider) Test(org.junit.jupiter.api.Test)

Example 2 with SourceResolutionProvider

use of com.b3dgs.lionengine.graphic.engine.SourceResolutionProvider in project lionengine by b3dgs.

the class WorldTest method prepare.

/**
 * Prepare test.
 */
@BeforeEach
public void prepare() {
    services.add(new Context() {

        @Override
        public int getX() {
            return 0;
        }

        @Override
        public int getY() {
            return 0;
        }

        @Override
        public int getWidth() {
            return 0;
        }

        @Override
        public int getHeight() {
            return 0;
        }

        @Override
        public <T extends InputDevice> T getInputDevice(Class<T> type) {
            return null;
        }

        @Override
        public Config getConfig() {
            return config;
        }
    });
    services.add(new SourceResolutionProvider() {

        @Override
        public int getWidth() {
            return output.getWidth();
        }

        @Override
        public int getHeight() {
            return output.getHeight();
        }

        @Override
        public int getRate() {
            return output.getRate();
        }
    });
    services.add(new Sequencer() {

        @Override
        public void end(Class<? extends Sequencable> nextSequenceClass, Object... arguments) {
        // Mock
        }

        @Override
        public void end() {
        // Mock
        }

        @Override
        public void load(Class<? extends Sequencable> nextSequenceClass, Object... arguments) {
        // Mock
        }

        @Override
        public void setSystemCursorVisible(boolean visible) {
        // Mock
        }
    });
    services.add(new Rasterbar() {

        @Override
        public void setRasterbarY(int y1, int y2) {
        // Mock
        }

        @Override
        public void setRasterbarOffset(int offsetY, int factorY) {
        // Mock
        }

        @Override
        public void renderRasterbar() {
        // Mock
        }

        @Override
        public void clearRasterbarColor() {
        // Mock
        }

        @Override
        public void addRasterbarColor(ImageBuffer buffer) {
        // Mock
        }
    });
}
Also used : Context(com.b3dgs.lionengine.Context) Sequencer(com.b3dgs.lionengine.graphic.engine.Sequencer) ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) Config(com.b3dgs.lionengine.Config) SourceResolutionProvider(com.b3dgs.lionengine.graphic.engine.SourceResolutionProvider) Rasterbar(com.b3dgs.lionengine.graphic.engine.Rasterbar) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with SourceResolutionProvider

use of com.b3dgs.lionengine.graphic.engine.SourceResolutionProvider in project lionengine by b3dgs.

the class ExtractorModelTest method prepare.

/**
 * Prepare test.
 */
@BeforeEach
public void prepare() {
    services.add(new SourceResolutionProvider() {

        @Override
        public int getWidth() {
            return 0;
        }

        @Override
        public int getHeight() {
            return 0;
        }

        @Override
        public int getRate() {
            return 50;
        }
    });
    services.add(new MapTileGame());
}
Also used : MapTileGame(com.b3dgs.lionengine.game.feature.tile.map.MapTileGame) SourceResolutionProvider(com.b3dgs.lionengine.graphic.engine.SourceResolutionProvider) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with SourceResolutionProvider

use of com.b3dgs.lionengine.graphic.engine.SourceResolutionProvider in project lionengine by b3dgs.

the class CameraTest method testCameraView.

/**
 * Test the camera view.
 */
@Test
void testCameraView() {
    camera.setView(1, 2, 3, 4, 4);
    assertEquals(1, camera.getViewX());
    assertEquals(2, camera.getViewY());
    assertEquals(3, camera.getWidth());
    assertEquals(4, camera.getHeight());
    camera.drawFov(new GraphicMock(), 0, 0, 1, 1, surface);
    assertThrows(() -> camera.setView(null, 0, 0, null), "Unexpected null argument !");
    camera.setView(new SourceResolutionProvider() {

        @Override
        public int getWidth() {
            return 320;
        }

        @Override
        public int getHeight() {
            return 240;
        }

        @Override
        public int getRate() {
            return 60;
        }
    }, 10, 20, Origin.TOP_LEFT);
    assertEquals(10, camera.getViewX());
    assertEquals(20, camera.getViewY());
    assertEquals(310, camera.getWidth());
    assertEquals(220, camera.getHeight());
}
Also used : GraphicMock(com.b3dgs.lionengine.graphic.GraphicMock) SourceResolutionProvider(com.b3dgs.lionengine.graphic.engine.SourceResolutionProvider) Test(org.junit.jupiter.api.Test)

Example 5 with SourceResolutionProvider

use of com.b3dgs.lionengine.graphic.engine.SourceResolutionProvider in project lionengine by b3dgs.

the class ProducerModelTest method prepare.

/**
 * Prepare test.
 */
@BeforeEach
public void prepare() {
    services.add(new Handler(services));
    services.add(new SourceResolutionProvider() {

        @Override
        public int getWidth() {
            return 0;
        }

        @Override
        public int getHeight() {
            return 0;
        }

        @Override
        public int getRate() {
            return 50;
        }
    });
    producer = new ProducerModel(services, setup);
    producer.prepare(object);
}
Also used : Handler(com.b3dgs.lionengine.game.feature.Handler) SourceResolutionProvider(com.b3dgs.lionengine.graphic.engine.SourceResolutionProvider) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

SourceResolutionProvider (com.b3dgs.lionengine.graphic.engine.SourceResolutionProvider)5 BeforeEach (org.junit.jupiter.api.BeforeEach)3 Test (org.junit.jupiter.api.Test)2 Config (com.b3dgs.lionengine.Config)1 Context (com.b3dgs.lionengine.Context)1 Handler (com.b3dgs.lionengine.game.feature.Handler)1 MapTileGame (com.b3dgs.lionengine.game.feature.tile.map.MapTileGame)1 Graphic (com.b3dgs.lionengine.graphic.Graphic)1 GraphicMock (com.b3dgs.lionengine.graphic.GraphicMock)1 ImageBuffer (com.b3dgs.lionengine.graphic.ImageBuffer)1 Rasterbar (com.b3dgs.lionengine.graphic.engine.Rasterbar)1 Sequencer (com.b3dgs.lionengine.graphic.engine.Sequencer)1