Skip to content

Commit

Permalink
Merge pull request #76 from FIUS/bug/fixSingleStep
Browse files Browse the repository at this point in the history
Fix single step
  • Loading branch information
neumantm authored Oct 4, 2019
2 parents bed2734 + 5aca7e9 commit 37b5355
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,11 @@ public synchronized void stop() {
public synchronized void step() {
if (this.isRunning()) throw new TimerAlreadyRunning();

new Thread(
() -> {
//FIXME this only executes a graphics tick an not neccessariely
// a simulation tick.
StandardSimulationClock.this.tick();
}, "single-step"
).start();
new Thread(() -> {
StandardSimulationClock.this.tickCount = ((StandardSimulationClock.this.tickCount
- (StandardSimulationClock.this.tickCount % 8)) + 7);
StandardSimulationClock.this.tick();
}, "single-step").start();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
*/
package de.unistuttgart.informatik.fius.icge.example.mario;

import java.util.List;

import de.unistuttgart.informatik.fius.icge.example.mario.entity.Coin;
import de.unistuttgart.informatik.fius.icge.example.mario.entity.Mario;
import de.unistuttgart.informatik.fius.icge.example.mario.entity.MarioProgram;

Expand All @@ -25,6 +28,17 @@ public void run(final Mario mario) {
while (true) {
if (mario.canMove()) {
mario.move();
} else {
mario.turnClockWise();
mario.turnClockWise();
final List<Coin> droppableCoins = mario.getCurrentlyDroppableEntities(Coin.class, false);
final List<Coin> collectableCoins = mario.getCurrentlyCollectableEntities(Coin.class, false);

if (!droppableCoins.isEmpty()) {
mario.drop(droppableCoins.get(0));
} else if (!collectableCoins.isEmpty()) {
mario.collect(collectableCoins.get(0));
}
}
}
}
Expand Down

0 comments on commit 37b5355

Please sign in to comment.