v0.4.2: Game logic now occurs in a separate thread
This is going to cause a LOT of bugs, next several commits will likely be fixing them.
This commit is contained in:
parent
a54bb5fdc8
commit
36aa02de2b
|
@ -164,6 +164,10 @@ public abstract class Actor implements Bundlable {
|
|||
current = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean processing(){
|
||||
return current != null;
|
||||
}
|
||||
|
||||
public static void process() {
|
||||
|
||||
|
@ -191,7 +195,8 @@ public abstract class Actor implements Bundlable {
|
|||
|
||||
if (current != null) {
|
||||
|
||||
if (current instanceof Char && ((Char)current).sprite.isMoving) {
|
||||
if (current instanceof Char &&
|
||||
((Char) current).sprite != null && ((Char)current).sprite.isMoving) {
|
||||
// If it's character's turn to act, but its sprite
|
||||
// is moving, wait till the movement is over
|
||||
current = null;
|
||||
|
|
|
@ -400,6 +400,8 @@ public class GameScene extends PixelScene {
|
|||
}
|
||||
}
|
||||
|
||||
private Thread t;
|
||||
|
||||
@Override
|
||||
public synchronized void update() {
|
||||
if (Dungeon.hero == null || scene == null) {
|
||||
|
@ -410,7 +412,17 @@ public class GameScene extends PixelScene {
|
|||
|
||||
if (!freezeEmitters) water.offset( 0, -5 * Game.elapsed );
|
||||
|
||||
Actor.process();
|
||||
if (!Actor.processing() && (t == null || !t.isAlive())) {
|
||||
t = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
Actor.process();
|
||||
}
|
||||
};
|
||||
//if cpu time is limited, game should prefer drawing the current frame
|
||||
t.setPriority(Thread.MIN_PRIORITY);
|
||||
t.start();
|
||||
}
|
||||
|
||||
if (Dungeon.hero.ready && Dungeon.hero.paralysed == 0) {
|
||||
log.newLine();
|
||||
|
|
Loading…
Reference in New Issue
Block a user