use of com.b3dgs.lionengine.game.Force in project lionengine by b3dgs.
the class MapTileSurfaceModel method getTilesHit.
@Override
public Collection<Tile> getTilesHit(double ox, double oy, double x, double y) {
final Force force = Force.fromVector(ox, oy, x, y);
final double sx = force.getDirectionHorizontal();
final double sy = force.getDirectionVertical();
double h = ox;
double v = oy;
final Collection<Tile> found = new ArrayList<>();
for (int count = 0; count < force.getVelocity(); count++) {
v += sy;
Tile tile = getTileAt(UtilMath.getRound(sx, h), UtilMath.getRound(sy, v));
if (tile != null && !found.contains(tile)) {
found.add(tile);
}
h += sx;
tile = getTileAt(UtilMath.getRound(sx, h), UtilMath.getRound(sy, v));
if (tile != null && !found.contains(tile)) {
found.add(tile);
}
}
return found;
}
use of com.b3dgs.lionengine.game.Force in project lionengine by b3dgs.
the class LaunchableConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final LaunchableConfig launchable = new LaunchableConfig("media", "sfx", 10, 1, 2, new Force(1.0, 2.0));
final Xml root = new Xml("test");
root.add(LaunchableConfig.exports(launchable));
final Media media = Medias.create("launchable.xml");
root.save(media);
assertEquals(launchable, LaunchableConfig.imports(new Xml(media).getChild(LaunchableConfig.NODE_LAUNCHABLE)));
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.game.Force in project lionengine by b3dgs.
the class LauncherConfigTest method testData.
/**
* Test data.
*/
@Test
void testData() {
final LaunchableConfig launchable = new LaunchableConfig("media", "sfx", 10, 1, 2, new Force(1.0, 2.0));
final LauncherConfig launcher = new LauncherConfig(1, 2, true, Arrays.asList(launchable));
assertEquals("media", launchable.getMedia());
assertEquals("sfx", launchable.getSfx().get());
assertEquals(10, launchable.getDelay());
assertEquals(1, launchable.getOffsetX());
assertEquals(2, launchable.getOffsetY());
assertEquals(new Force(1.0, 2.0), launchable.getVector());
assertEquals(1, launcher.getLevel());
assertEquals(2, launcher.getDelay());
assertTrue(launcher.hasMirrorable());
}
use of com.b3dgs.lionengine.game.Force in project lionengine by b3dgs.
the class LauncherConfigTest method testExportsImports.
/**
* Test exports imports.
*/
@Test
void testExportsImports() {
final LaunchableConfig launchable = new LaunchableConfig("media", "sfx", 10, 1, 2, new Force(1.0, 2.0));
final LauncherConfig launcher = new LauncherConfig(10, 10, true, Arrays.asList(launchable));
final Xml root = new Xml("test");
root.add(LauncherConfig.exports(launcher));
final Media media = Medias.create("launcher.xml");
root.save(media);
assertEquals(launcher, LauncherConfig.imports(new Xml(media).getChild(LauncherConfig.NODE_LAUNCHER)));
assertEquals(Arrays.asList(launcher), LauncherConfig.imports(new Configurer(media)));
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.game.Force in project lionengine by b3dgs.
the class UtilLaunchable method createLauncherMedia.
/**
* Create the media.
*
* @param launchableMedia The launchable.
* @param delay The desired delay.
* @return The media.
*/
public static Media createLauncherMedia(Media launchableMedia, int delay) {
final Media media = Medias.create("launcher.xml");
final LaunchableConfig launchableConfig = new LaunchableConfig(launchableMedia.getPath(), null, delay, 1, 2, new Force(1.0, 2.0));
final LauncherConfig launcherConfig = new LauncherConfig(0, 10, false, Arrays.asList(launchableConfig));
final Xml root = new Xml("test");
root.add(LauncherConfig.exports(launcherConfig));
root.add(LauncherConfig.exports(new LauncherConfig(1, 50, false, Arrays.asList(launchableConfig))));
root.save(media);
return media;
}
Aggregations