[client] add GameRoomFrame

This commit is contained in:
2019-05-23 17:57:54 +03:00
parent 864d5f3335
commit 26ad5f47cd
21 changed files with 415 additions and 498 deletions

View File

@@ -0,0 +1,60 @@
package ru.m;
#if neko
import haxe.Log;
import haxe.PosInfos;
import neko.vm.Thread;
class Timer {
private var sleep:Float;
private var stopped:Bool;
public function new(time_ms:Int) {
this.sleep = time_ms / 1000.0;
this.stopped = false;
Thread.create(function() {
while (!stopped) {
Sys.sleep(sleep);
try {
run();
} catch (error:Dynamic) {
trace(error);
}
}
});
}
public function stop() {
stopped = true;
}
public dynamic function run() {}
public static function delay(f:Void -> Void, time_ms:Int) {
var t = new Timer(time_ms);
t.run = function() {
t.stop();
f();
};
return t;
}
public static function measure<T>(f:Void -> T, ?pos:PosInfos):T {
var t0 = stamp();
var r = f();
Log.trace((stamp() - t0) + "s", pos);
return r;
}
public static inline function stamp():Float {
return Sys.time();
}
}
#else
typedef Timer = haxe.Timer;
#end

View File

@@ -1,7 +1,7 @@
package ru.m.tankz.core;
import haxe.Timer;
import haxework.signal.Signal;
import ru.m.Timer;
class Modificator extends Signal2<Int, Bool> {

View File

@@ -1,7 +1,6 @@
package ru.m.tankz.game;
import haxe.ds.Option;
import haxe.Timer;
import haxework.signal.Signal;
import ru.m.geom.Line;
import ru.m.geom.Point;
@@ -18,6 +17,7 @@ import ru.m.tankz.game.GameEvent;
import ru.m.tankz.game.IGame;
import ru.m.tankz.game.Spawner;
import ru.m.tankz.Type;
import ru.m.Timer;
class GameRunner implements EngineListener implements GameListener {
@:provide var controlFactory:IControlFactory;

View File

@@ -13,7 +13,10 @@ class State {
public var hits:Int;
public function new() {
score = 0;
frags = 0;
shots = 0;
hits = 0;
}
public function add(state:State) {

View File

@@ -1,9 +1,8 @@
package ru.m.tankz.game;
import haxe.Timer;
import ru.m.tankz.config.Config;
import ru.m.tankz.Type;
import ru.m.Timer;
typedef SpawnTask = {
var point:SpawnPoint;