Search in sources :

Example 31 with ImageBuffer

use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.

the class SpriteTiledTest method testConstructorSurface.

/**
 * Test constructor with surface.
 */
@Test
void testConstructorSurface() {
    final ImageBuffer surface = Graphics.createImageBuffer(64, 32);
    final SpriteTiled sprite = new SpriteTiledImpl(surface, 16, 8);
    assertTrue(sprite.isLoaded());
    assertEquals(surface, sprite.getSurface());
    assertEquals(64, sprite.getWidth());
    assertEquals(32, sprite.getHeight());
    assertEquals(16, sprite.getTileWidth());
    assertEquals(8, sprite.getTileHeight());
    assertEquals(4, sprite.getTilesHorizontal());
    assertEquals(4, sprite.getTilesVertical());
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) Test(org.junit.jupiter.api.Test)

Example 32 with ImageBuffer

use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.

the class SpriteAnimatedTest method testConstructorSurface.

/**
 * Test constructor with surface.
 */
@Test
void testConstructorSurface() {
    final ImageBuffer surface = Graphics.createImageBuffer(64, 32);
    final SpriteAnimated sprite = new SpriteAnimatedImpl(surface, 16, 8);
    assertTrue(sprite.isLoaded());
    assertEquals(surface, sprite.getSurface());
    assertEquals(64, sprite.getWidth());
    assertEquals(32, sprite.getHeight());
    assertEquals(4, sprite.getTileWidth());
    assertEquals(4, sprite.getTileHeight());
    assertEquals(16, sprite.getFramesHorizontal());
    assertEquals(8, sprite.getFramesVertical());
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) Test(org.junit.jupiter.api.Test)

Example 33 with ImageBuffer

use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.

the class SpriteTest method testConstructorSurface.

/**
 * Test constructor with surface.
 */
@Test
void testConstructorSurface() {
    final ImageBuffer surface = Graphics.createImageBuffer(64, 32);
    final Sprite sprite = new SpriteImpl(surface);
    assertTrue(sprite.isLoaded());
    assertEquals(surface, sprite.getSurface());
    assertEquals(64, sprite.getWidth());
    assertEquals(32, sprite.getHeight());
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) Test(org.junit.jupiter.api.Test)

Example 34 with ImageBuffer

use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.

the class SpriteTest method testHashCode.

/**
 * Test hash code.
 */
@Test
void testHashCode() {
    final ImageBuffer surface = Graphics.createImageBuffer(64, 32);
    final Sprite sprite = new SpriteImpl(surface);
    final Media media = Medias.create("image.png");
    final Sprite spriteMedia = new SpriteImpl(media);
    spriteMedia.load();
    assertHashEquals(sprite, new SpriteImpl(surface));
    assertHashNotEquals(sprite, new Object());
    assertHashNotEquals(spriteMedia, new SpriteImpl(media));
    assertHashNotEquals(sprite, new SpriteImpl(Graphics.createImageBuffer(64, 32)));
    assertHashNotEquals(sprite, new SpriteImpl(Graphics.createImageBuffer(32, 32)));
    assertHashNotEquals(sprite, new SpriteImpl(Graphics.createImageBuffer(64, 64)));
    assertHashNotEquals(sprite, new SpriteImpl(Graphics.createImageBuffer(32, 64)));
    sprite.dispose();
    spriteMedia.dispose();
    surface.dispose();
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) Media(com.b3dgs.lionengine.Media) Test(org.junit.jupiter.api.Test)

Example 35 with ImageBuffer

use of com.b3dgs.lionengine.graphic.ImageBuffer in project lionengine by b3dgs.

the class ImageTest method testHashCode.

/**
 * Test hash code.
 */
@Test
void testHashCode() {
    final ImageBuffer surface = Graphics.createImageBuffer(64, 32);
    final Image image = new ImageImpl(surface);
    final Image imageMedia = new ImageImpl(media);
    imageMedia.load();
    assertHashEquals(image, new ImageImpl(surface));
    assertHashNotEquals(image, new Object());
    assertHashNotEquals(imageMedia, new ImageImpl(media));
    assertHashNotEquals(image, new ImageImpl(Graphics.createImageBuffer(64, 32)));
    assertHashNotEquals(image, new ImageImpl(Graphics.createImageBuffer(32, 32)));
    assertHashNotEquals(image, new ImageImpl(Graphics.createImageBuffer(64, 64)));
    assertHashNotEquals(image, new ImageImpl(Graphics.createImageBuffer(32, 64)));
    image.dispose();
    imageMedia.dispose();
    surface.dispose();
}
Also used : ImageBuffer(com.b3dgs.lionengine.graphic.ImageBuffer) Test(org.junit.jupiter.api.Test)

Aggregations

ImageBuffer (com.b3dgs.lionengine.graphic.ImageBuffer)110 Test (org.junit.Test)34 Test (org.junit.jupiter.api.Test)28 Media (com.b3dgs.lionengine.Media)16 Graphic (com.b3dgs.lionengine.graphic.Graphic)12 GraphicTest (com.b3dgs.lionengine.graphic.GraphicTest)12 FactoryGraphic (com.b3dgs.lionengine.graphic.FactoryGraphic)9 BufferedImage (java.awt.image.BufferedImage)9 SpriteTiled (com.b3dgs.lionengine.graphic.SpriteTiled)6 SpriteTiled (com.b3dgs.lionengine.graphic.drawable.SpriteTiled)5 ColorRgba (com.b3dgs.lionengine.graphic.ColorRgba)3 FactoryGraphicTest (com.b3dgs.lionengine.graphic.FactoryGraphicTest)3 Image (com.b3dgs.lionengine.graphic.Image)3 Sprite (com.b3dgs.lionengine.graphic.Sprite)3 SpriteAnimated (com.b3dgs.lionengine.graphic.SpriteAnimated)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 TilesExtractor (com.b3dgs.lionengine.game.feature.tile.TilesExtractor)2 ArrayList (java.util.ArrayList)2 BeforeAll (org.junit.jupiter.api.BeforeAll)2 Config (com.b3dgs.lionengine.Config)1