Search in sources :

Example 1 with SizeConfig

use of com.b3dgs.lionengine.game.SizeConfig in project lionengine by b3dgs.

the class ProducibleConfig method imports.

/**
 * Create the producible data from node.
 *
 * @param root The root reference (must not be <code>null</code>).
 * @return The producible data.
 * @throws LionEngineException If unable to read node.
 */
public static ProducibleConfig imports(Xml root) {
    Check.notNull(root);
    final Xml node = root.getChild(NODE_PRODUCIBLE);
    final SizeConfig size = SizeConfig.imports(root);
    final int time = node.readInteger(ATT_STEPS);
    return new ProducibleConfig(time, size.getWidth(), size.getHeight());
}
Also used : Xml(com.b3dgs.lionengine.io.Xml) SizeConfig(com.b3dgs.lionengine.game.SizeConfig)

Example 2 with SizeConfig

use of com.b3dgs.lionengine.game.SizeConfig in project lionengine by b3dgs.

the class ProducibleConfigTest method testExportsImports.

/**
 * Test exports imports.
 */
@Test
void testExportsImports() {
    final ProducibleConfig producible = new ProducibleConfig(1, 2, 3);
    final Xml root = new Xml("test");
    root.add(SizeConfig.exports(new SizeConfig(producible.getWidth(), producible.getHeight())));
    root.add(ProducibleConfig.exports(producible));
    final Media media = Medias.create("producible.xml");
    root.save(media);
    assertEquals(producible, ProducibleConfig.imports(new Xml(media)));
    assertEquals(producible, ProducibleConfig.imports(new Setup(media)));
    assertEquals(producible, ProducibleConfig.imports(new Configurer(media)));
    assertTrue(media.getFile().delete());
}
Also used : Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) SizeConfig(com.b3dgs.lionengine.game.SizeConfig) Setup(com.b3dgs.lionengine.game.feature.Setup) Configurer(com.b3dgs.lionengine.game.Configurer) Test(org.junit.jupiter.api.Test)

Example 3 with SizeConfig

use of com.b3dgs.lionengine.game.SizeConfig in project lionengine by b3dgs.

the class UtilTransformable method createMedia.

/**
 * Create the object media.
 *
 * @param caller The caller class.
 * @return The object media.
 */
public static Media createMedia(Class<?> caller) {
    final Xml root = new Xml("test");
    root.add(FeaturableConfig.exportClass(Featurable.class.getName()));
    root.add(SizeConfig.exports(new SizeConfig(16, 32)));
    final Media media = Medias.create("transformable_" + caller.getSimpleName() + Factory.FILE_DATA_DOT_EXTENSION);
    root.save(media);
    return media;
}
Also used : Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) SizeConfig(com.b3dgs.lionengine.game.SizeConfig)

Example 4 with SizeConfig

use of com.b3dgs.lionengine.game.SizeConfig in project lionengine by b3dgs.

the class ProducibleConfig method imports.

/**
 * Create the producible data from node.
 *
 * @param root The root reference (must not be <code>null</code>).
 * @return The producible data.
 * @throws LionEngineException If unable to read node.
 */
public static ProducibleConfig imports(XmlReader root) {
    Check.notNull(root);
    final XmlReader node = root.getChild(NODE_PRODUCIBLE);
    final SizeConfig size = SizeConfig.imports(root);
    final int time = node.getInteger(ATT_STEPS);
    return new ProducibleConfig(time, size.getWidth(), size.getHeight());
}
Also used : SizeConfig(com.b3dgs.lionengine.game.SizeConfig) XmlReader(com.b3dgs.lionengine.XmlReader)

Example 5 with SizeConfig

use of com.b3dgs.lionengine.game.SizeConfig in project lionengine by b3dgs.

the class UtilProducible method createProducibleMedia.

/**
 * Create media.
 *
 * @return The media.
 */
public static Media createProducibleMedia() {
    final ProducibleConfig producibleConfig = new ProducibleConfig(1, 2, 3);
    final Media media = UtilSetup.createMedia(Featurable.class);
    final Xml root = new Xml("test");
    root.add(SizeConfig.exports(new SizeConfig(producibleConfig.getWidth(), producibleConfig.getHeight())));
    root.add(ProducibleConfig.exports(producibleConfig));
    root.save(media);
    return media;
}
Also used : Xml(com.b3dgs.lionengine.Xml) Media(com.b3dgs.lionengine.Media) SizeConfig(com.b3dgs.lionengine.game.SizeConfig)

Aggregations

SizeConfig (com.b3dgs.lionengine.game.SizeConfig)5 Media (com.b3dgs.lionengine.Media)3 Xml (com.b3dgs.lionengine.Xml)3 XmlReader (com.b3dgs.lionengine.XmlReader)1 Configurer (com.b3dgs.lionengine.game.Configurer)1 Setup (com.b3dgs.lionengine.game.feature.Setup)1 Xml (com.b3dgs.lionengine.io.Xml)1 Test (org.junit.jupiter.api.Test)1