16
Programming / Re: Roguelike timing systems.
« on: June 30, 2012, 06:50:03 AM »
Stop using grid based movement
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
@Test
public void shouldTriggerIfPlayerStartsThereButMovesBackAndForth() {
Game testGame = Game.newGame(database, new GameBuilderTestImplementation(false, 0));
Entity player = testGame.getPlayer();
CustomController controller = new CustomController();
controller.addAction(new IdleAction());
controller.addAction(new MoveAction(-1, 0));
controller.addAction(new MoveAction(1, 0));
controller.addAction(new OpenDoorAction(1, 0));
player.setController(controller);
LocationTrigger toAdd = new LocationTrigger(testGame);
toAdd.setLocation(new Point(2, 1));
toAdd.setActivateCallback(new ActivateCallbackImplementation());
testGame.getCurrentZone().addTrigger(toAdd);
testGame.getLoop().rebuild();
while (testGame.step())
;
Assert.assertEquals(true, wasTriggered);
}
I willingly sacrifice control for productivity-- I don't really want to deal with pointers or memory management. I like code-completion and every form of spoiling that Java developers are used to.
@Test
public void shouldTriggerIfPlayerStartsThereButMovesBackAndForth() {
Game testGame = Game.newGame(database, new GameBuilderTestImplementation(false, 0));
Entity player = testGame.getPlayer();
CustomController controller = new CustomController();
controller.addAction(new IdleAction());
controller.addAction(new MoveAction(-1, 0));
controller.addAction(new MoveAction(1, 0));
player.setController(controller);
LocationTrigger toAdd = new LocationTrigger(testGame);
toAdd.setLocation(new Point(2, 1));
toAdd.setActivateCallback(new ActivateCallbackImplementation());
testGame.getCurrentZone().addTrigger(toAdd);
testGame.getLoop().rebuild();
while (testGame.step())
;
Assert.assertEquals(true, wasTriggered);
}
@Test
public void shouldBeTheSameGame() throws SQLException {
database.getDatabase().open();
// given
Game toStore = Game.newGame(database, new GameBuilderTestImplementation());
BaseEntity player = toStore.getPlayer();
// when
Game.saveGame(toStore, database);
Game reloaded = Game.loadGame(database, null);
database.getDatabase().close();
// then
Assert.assertEquals(player.getId(), reloaded.getPlayer().getId());
Assert.assertEquals(player, reloaded.getPlayer());
reloaded.testCompareTo(toStore);
}
I have read the GW licenses and they did not seem as harsh as I though they would. They have a lot of IP and it is well worth protecting that, but as long as I give credit to GW and don't infringe (too much) on there IP I should be safe. They do encourage their fans to spread the word far and wide, as long as their trademarks remain intact and IP are not challenged. We will be safe as long as they don't intend on making a tile-based roguelike at any stage in the near or grim dark future distance future, that is!
QuoteIn C++ I would probably use a helper function to determine if a point is in an Area of Effect. But that would be hard for Java.
E.g bool isInAreaOfEffect(AreaOfEffect area, Point reference);
Because I dont believe it is the AreaOfEffect class's job to determine that.
I agree with this. In my rewriting I created a little class that contains public methods like your bool isInAreaOfEffect(AreaOfEffect area, Point reference). I do come from C/C++ and I really dislike Java's everything must be a class idea. Most of my distance from Point to Point, Monster to Player, line of sight methods will be in this little class.