diff --git a/build/client.js b/build/client.js
index ebb49f7..5eba13a 100755
--- a/build/client.js
+++ b/build/client.js
@@ -21,7 +21,7 @@ const generate = () => function generate() {
]);
};
-const build = (platform) => function build() {
+const build = (platform, values) => function build() {
const argv = yargs.argv;
return gulp.src('.')
.pipe(new Haxe().openfl({
@@ -29,6 +29,7 @@ const build = (platform) => function build() {
platform: platform,
version: version,
debug: argv.dev,
+ values: values
}))
.pipe(gulp.dest(`target/${platform}`));
};
@@ -87,6 +88,7 @@ const buildDeb = gulp.series(
exports['client:flash:html'] = gulp.parallel(flashIndex, flashJs);
exports['client:flash'] = gulp.series(prepare(Haxe.ID), generate(), build('flash'), exports['client:flash:html']);
exports['client:html5'] = gulp.series(prepare(Haxe.ID), generate(), build('html5'));
+exports['client:html5-dom'] = gulp.series(prepare(Haxe.ID), generate(), build('html5', {dom:true}));
exports['client:linux'] = gulp.series(prepare(Haxe.ID), generate(), build('linux'));
exports['client:webapp'] = webapp;
exports['client:deb'] = buildDeb;
@@ -108,9 +110,9 @@ const testFlash = function() {
.pipe(debug());
};
-const testHtml5 = function() {
+const testHtml5 = (dom) => function() {
return gulp.series(
- build('html5'),
+ build('html5', {dom:dom}),
() => gulp.src('target/html5').pipe(webserver({
host: 'localhost', port: 3000,
open: true,
@@ -130,7 +132,8 @@ const testLinux = gulp.series(
exports['client:flash:test'] = gulp.series(prepare(Haxe.ID, FlashPlayer.ID), testFlash);
-exports['client:html5:test'] = gulp.series(prepare(Haxe.ID), testHtml5);
+exports['client:html5:test'] = gulp.series(prepare(Haxe.ID), testHtml5());
+exports['client:html5-dom:test'] = gulp.series(prepare(Haxe.ID), testHtml5(true));
exports['client:linux:test'] = gulp.series(prepare(Haxe.ID), testLinux);
exports['client:test'] = exports['client:flash:test'];
diff --git a/package.json b/package.json
index b57039e..0632a79 100755
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "tankz",
- "version": "0.6.3",
+ "version": "0.6.4",
"private": true,
"devDependencies": {
"ansi-colors": "^1.0.1",
diff --git a/project.xml b/project.xml
index daf00ba..dbf7251 100755
--- a/project.xml
+++ b/project.xml
@@ -19,7 +19,7 @@
-
+
diff --git a/src/client/haxe/ru/m/tankz/Client.yaml b/src/client/haxe/ru/m/tankz/Client.yaml
index d868671..2670753 100755
--- a/src/client/haxe/ru/m/tankz/Client.yaml
+++ b/src/client/haxe/ru/m/tankz/Client.yaml
@@ -9,7 +9,7 @@ views:
pHeight: 100
skin:
$type: haxework.gui.skin.BitmapSkin
- image: "@asset:image:resources/images/background.png"
+ image: "@asset:image:resources/image/ui/background.png"
fillType: REPEAT
views:
- id: start
diff --git a/src/client/haxe/ru/m/tankz/Style.yaml b/src/client/haxe/ru/m/tankz/Style.yaml
index 72ed6fe..5d0b116 100644
--- a/src/client/haxe/ru/m/tankz/Style.yaml
+++ b/src/client/haxe/ru/m/tankz/Style.yaml
@@ -4,9 +4,9 @@ button:
height: 60
skin:
$type: haxework.gui.skin.ButtonBitmapSkin
- upImage: "@asset:image:resources/images/control/button_normal.png"
- downImage: "@asset:image:resources/images/control/button_down.png"
- overImage: "@asset:image:resources/images/control/button_over.png"
+ upImage: "@asset:image:resources/image/ui/button/normal.png"
+ downImage: "@asset:image:resources/image/ui/button/down.png"
+ overImage: "@asset:image:resources/image/ui/button/over.png"
fillType: NINEPATH
fontFamily: "@res:text:font"
fontEmbed: true
diff --git a/src/client/haxe/ru/m/tankz/frame/StartFrame.yaml b/src/client/haxe/ru/m/tankz/frame/StartFrame.yaml
index 97881ee..f355d24 100644
--- a/src/client/haxe/ru/m/tankz/frame/StartFrame.yaml
+++ b/src/client/haxe/ru/m/tankz/frame/StartFrame.yaml
@@ -3,7 +3,7 @@ pWidth: 100
pHeight: 100
views:
- $type: haxework.gui.ImageView
- image: "@asset:image:resources/images/logo/logo.png"
+ image: "@asset:image:resources/image/ui/logo.png"
contentSize: true
bottomMargin: 15
- $type: haxework.gui.LabelView
diff --git a/src/client/haxe/ru/m/tankz/render/AnimateBundle.hx b/src/client/haxe/ru/m/tankz/render/AnimateBundle.hx
index 07bf73e..bdc9475 100644
--- a/src/client/haxe/ru/m/tankz/render/AnimateBundle.hx
+++ b/src/client/haxe/ru/m/tankz/render/AnimateBundle.hx
@@ -12,7 +12,8 @@ import ru.m.tankz.Type;
class AnimateBundle {
- private static function buildAnimate(template:String, sequence:Array):OnceAnimate {
+ private static function buildAnimate(name:String, sequence:Array):OnceAnimate {
+ var template:String = 'resources/image/animate/${name}/%index%.png';
var frames = [for (i in sequence) ({
image: Assets.getBitmapData(StringTools.replace(template, '%index%', Std.string(i))),
length: 1
@@ -21,32 +22,41 @@ class AnimateBundle {
}
public static function tankSpawn():OnceAnimate {
- return buildAnimate('resources/images/tank/appear/appear-%index%.png', [
+ return buildAnimate('appear', [
0, 1, 2, 3, 3, 4, 5, 5, 6
]);
}
public static function tankBoom():OnceAnimate {
- return buildAnimate('resources/images/tank/kaboom/kaboom-%index%.png', [
+ return buildAnimate('boom', [
0, 1, 2, 3, 4, 4, 4, 1, 4, 4, 7, 7, 8, 9, 9
]);
}
public static function bulletBoom():OnceAnimate {
- return buildAnimate('resources/images/bullet/boom/boom-%index%.png', [
+ return buildAnimate('boom-sm', [
0, 1, 1, 0, 0, 1
]);
}
public static function tankProtect():Animate {
return new Animate([for (i in 0...2) ({
- image: Assets.getBitmapData('resources/images/tank/protect/protect-${i}.png'),
+ image: Assets.getBitmapData('resources/image/animate/protect/${i}.png'),
length: 5
})]);
}
public static function tankFrames(tank:Tank):Array {
- var colors:Array = [tank.color, tank.bonus ? 0xff00aa : tank.color];
+ var color:Color = switch (tank.hits) {
+ case 1: 0x869C43;
+ case 2: 0xDEAF80;
+ case 3: 0x5EA67A;
+ case _: tank.color;
+ }
+ var colors:Array = [color, color];
+ if (tank.bonus) {
+ colors[1] = 0xff00aa;
+ }
return [for (i in 0...2) ({
image: BitmapUtil.colorize(Assets.getBitmapData('resources/image/tank/${tank.config.skin}-${i}.png'), colors[i]),
length: 3
diff --git a/src/client/haxe/ru/m/tankz/render/Render.hx b/src/client/haxe/ru/m/tankz/render/Render.hx
index d3f76e5..fe8fe54 100755
--- a/src/client/haxe/ru/m/tankz/render/Render.hx
+++ b/src/client/haxe/ru/m/tankz/render/Render.hx
@@ -119,13 +119,13 @@ class Render extends SpriteView implements EngineListener {
case EntityType.BONUS(bonus):
var item = new BonusItem(bonus);
items.set(bonus.key, item);
- entryLayer.addChild(item.view);
+ upperLayer.addChild(item.view);
item.update();
case _:
}
}
- public function onChange(entity:EntityType):Void {}
+ public function onChange(entity:EntityType, ?change:EntityChange):Void {}
public function onCollision(entity:EntityType, with:EntityType):Void {
switch [entity, with] {
@@ -154,7 +154,7 @@ class Render extends SpriteView implements EngineListener {
}
case EntityType.BONUS(bonus):
if (items.exists(bonus.key)) {
- entryLayer.removeChild(items.get(bonus.key).view);
+ upperLayer.removeChild(items.get(bonus.key).view);
items.remove(bonus.key);
}
case _:
diff --git a/src/client/haxe/ru/m/tankz/render/RenderItem.hx b/src/client/haxe/ru/m/tankz/render/RenderItem.hx
index 82a734a..e6273c6 100644
--- a/src/client/haxe/ru/m/tankz/render/RenderItem.hx
+++ b/src/client/haxe/ru/m/tankz/render/RenderItem.hx
@@ -242,7 +242,9 @@ class TankItem extends RenderItem {
class BulletItem extends BitmapItem {
override private function getImage():String {
- return 'resources/images/bullet/bullet_${value.config.piercing > 1 ? 1 : 0}.png';
+ var type:String = 'normal';
+ if (value.config.piercing > 0) type = 'piercing';
+ return 'resources/image/bullet/${type}.png';
}
}
diff --git a/src/client/resources/classic/config.yaml b/src/client/resources/classic/config.yaml
index edc7629..f829a82 100644
--- a/src/client/resources/classic/config.yaml
+++ b/src/client/resources/classic/config.yaml
@@ -25,6 +25,7 @@ player:
- {type: human0, rate: 1, protect: 5}
bot: &bot
control: bot
+ color: 0xFFFFFF
life: -1
tanks:
- {type: bot0, rate: 0.25, bonus: 0.25}
diff --git a/src/client/resources/images/tank/appear/appear-0.png b/src/client/resources/image/animate/appear/0.png
similarity index 100%
rename from src/client/resources/images/tank/appear/appear-0.png
rename to src/client/resources/image/animate/appear/0.png
diff --git a/src/client/resources/images/tank/appear/appear-1.png b/src/client/resources/image/animate/appear/1.png
similarity index 100%
rename from src/client/resources/images/tank/appear/appear-1.png
rename to src/client/resources/image/animate/appear/1.png
diff --git a/src/client/resources/images/tank/appear/appear-2.png b/src/client/resources/image/animate/appear/2.png
similarity index 100%
rename from src/client/resources/images/tank/appear/appear-2.png
rename to src/client/resources/image/animate/appear/2.png
diff --git a/src/client/resources/images/tank/appear/appear-3.png b/src/client/resources/image/animate/appear/3.png
similarity index 100%
rename from src/client/resources/images/tank/appear/appear-3.png
rename to src/client/resources/image/animate/appear/3.png
diff --git a/src/client/resources/images/tank/appear/appear-4.png b/src/client/resources/image/animate/appear/4.png
similarity index 100%
rename from src/client/resources/images/tank/appear/appear-4.png
rename to src/client/resources/image/animate/appear/4.png
diff --git a/src/client/resources/images/tank/appear/appear-5.png b/src/client/resources/image/animate/appear/5.png
similarity index 100%
rename from src/client/resources/images/tank/appear/appear-5.png
rename to src/client/resources/image/animate/appear/5.png
diff --git a/src/client/resources/images/tank/appear/appear-6.png b/src/client/resources/image/animate/appear/6.png
similarity index 100%
rename from src/client/resources/images/tank/appear/appear-6.png
rename to src/client/resources/image/animate/appear/6.png
diff --git a/src/client/resources/images/bullet/boom/boom-0.png b/src/client/resources/image/animate/boom-sm/0.png
similarity index 100%
rename from src/client/resources/images/bullet/boom/boom-0.png
rename to src/client/resources/image/animate/boom-sm/0.png
diff --git a/src/client/resources/images/bullet/boom/boom-1.png b/src/client/resources/image/animate/boom-sm/1.png
similarity index 100%
rename from src/client/resources/images/bullet/boom/boom-1.png
rename to src/client/resources/image/animate/boom-sm/1.png
diff --git a/src/client/resources/images/tank/kaboom/kaboom-0.png b/src/client/resources/image/animate/boom/0.png
similarity index 100%
rename from src/client/resources/images/tank/kaboom/kaboom-0.png
rename to src/client/resources/image/animate/boom/0.png
diff --git a/src/client/resources/images/tank/kaboom/kaboom-1.png b/src/client/resources/image/animate/boom/1.png
similarity index 100%
rename from src/client/resources/images/tank/kaboom/kaboom-1.png
rename to src/client/resources/image/animate/boom/1.png
diff --git a/src/client/resources/images/tank/kaboom/kaboom-2.png b/src/client/resources/image/animate/boom/2.png
similarity index 100%
rename from src/client/resources/images/tank/kaboom/kaboom-2.png
rename to src/client/resources/image/animate/boom/2.png
diff --git a/src/client/resources/images/tank/kaboom/kaboom-3.png b/src/client/resources/image/animate/boom/3.png
similarity index 100%
rename from src/client/resources/images/tank/kaboom/kaboom-3.png
rename to src/client/resources/image/animate/boom/3.png
diff --git a/src/client/resources/images/tank/kaboom/kaboom-4.png b/src/client/resources/image/animate/boom/4.png
similarity index 100%
rename from src/client/resources/images/tank/kaboom/kaboom-4.png
rename to src/client/resources/image/animate/boom/4.png
diff --git a/src/client/resources/images/tank/kaboom/kaboom-7.png b/src/client/resources/image/animate/boom/7.png
similarity index 100%
rename from src/client/resources/images/tank/kaboom/kaboom-7.png
rename to src/client/resources/image/animate/boom/7.png
diff --git a/src/client/resources/images/tank/kaboom/kaboom-8.png b/src/client/resources/image/animate/boom/8.png
similarity index 100%
rename from src/client/resources/images/tank/kaboom/kaboom-8.png
rename to src/client/resources/image/animate/boom/8.png
diff --git a/src/client/resources/images/tank/kaboom/kaboom-9.png b/src/client/resources/image/animate/boom/9.png
similarity index 100%
rename from src/client/resources/images/tank/kaboom/kaboom-9.png
rename to src/client/resources/image/animate/boom/9.png
diff --git a/src/client/resources/images/tank/protect/protect-0.png b/src/client/resources/image/animate/protect/0.png
similarity index 100%
rename from src/client/resources/images/tank/protect/protect-0.png
rename to src/client/resources/image/animate/protect/0.png
diff --git a/src/client/resources/images/tank/protect/protect-1.png b/src/client/resources/image/animate/protect/1.png
similarity index 100%
rename from src/client/resources/images/tank/protect/protect-1.png
rename to src/client/resources/image/animate/protect/1.png
diff --git a/src/client/resources/images/bullet/bullet_0.png b/src/client/resources/image/bullet/normal.png
similarity index 100%
rename from src/client/resources/images/bullet/bullet_0.png
rename to src/client/resources/image/bullet/normal.png
diff --git a/src/client/resources/images/bullet/bullet_1.png b/src/client/resources/image/bullet/piercing.png
similarity index 100%
rename from src/client/resources/images/bullet/bullet_1.png
rename to src/client/resources/image/bullet/piercing.png
diff --git a/src/client/resources/images/background.png b/src/client/resources/image/ui/background.png
similarity index 100%
rename from src/client/resources/images/background.png
rename to src/client/resources/image/ui/background.png
diff --git a/src/client/resources/images/control/button_down.png b/src/client/resources/image/ui/button/down.png
similarity index 100%
rename from src/client/resources/images/control/button_down.png
rename to src/client/resources/image/ui/button/down.png
diff --git a/src/client/resources/images/control/button_normal.png b/src/client/resources/image/ui/button/normal.png
similarity index 100%
rename from src/client/resources/images/control/button_normal.png
rename to src/client/resources/image/ui/button/normal.png
diff --git a/src/client/resources/images/control/button_over.png b/src/client/resources/image/ui/button/over.png
similarity index 100%
rename from src/client/resources/images/control/button_over.png
rename to src/client/resources/image/ui/button/over.png
diff --git a/src/client/resources/images/logo/logo.png b/src/client/resources/image/ui/logo.png
similarity index 100%
rename from src/client/resources/images/logo/logo.png
rename to src/client/resources/image/ui/logo.png
diff --git a/src/common/haxe/ru/m/tankz/engine/Engine.hx b/src/common/haxe/ru/m/tankz/engine/Engine.hx
index 21c2c1e..cf9369c 100755
--- a/src/common/haxe/ru/m/tankz/engine/Engine.hx
+++ b/src/common/haxe/ru/m/tankz/engine/Engine.hx
@@ -1,7 +1,7 @@
package ru.m.tankz.engine;
-import ru.m.geom.Point;
import ru.m.geom.Line;
+import ru.m.geom.Point;
import ru.m.tankz.config.Config;
import ru.m.tankz.control.Control;
import ru.m.tankz.core.Bullet;
@@ -12,9 +12,15 @@ import ru.m.tankz.core.Tank;
import ru.m.tankz.map.LevelMap;
+enum EntityChange {
+ DEATH;
+ HIT;
+}
+
+
interface EngineListener {
public function onSpawn(entity:EntityType):Void;
- public function onChange(entity:EntityType):Void;
+ public function onChange(entity:EntityType, ?change:EntityChange):Void;
public function onCollision(entity:EntityType, with:EntityType):Void;
public function onDestroy(entity:EntityType):Void;
}
@@ -29,7 +35,7 @@ class CollisionProcessor implements EngineListener {
public function onSpawn(entity:EntityType):Void {}
- public function onChange(entity:EntityType):Void {}
+ public function onChange(entity:EntityType, ?change:EntityChange):Void {}
public function onCollision(entity:EntityType, with:EntityType):Void {
switch [entity, with] {
@@ -47,7 +53,7 @@ class CollisionProcessor implements EngineListener {
if (!tank.protect.active) {
if (tank.hits > 0) {
tank.hits--;
- engine.change(tank);
+ engine.change(tank, EntityChange.HIT);
} else {
engine.destroy(tank);
}
@@ -63,7 +69,7 @@ class CollisionProcessor implements EngineListener {
engine.destroy(bullet);
if (!eagle.protect.active) {
eagle.death = true;
- engine.change(eagle);
+ engine.change(eagle, EntityChange.DEATH);
}
case _:
}
@@ -101,9 +107,9 @@ class Engine implements ControlHandler {
for (l in listeners) l.onSpawn(type);
}
- public function change(entity:Entity):Void {
+ public function change(entity:Entity, ?change:EntityChange):Void {
var type = EntityTypeResolver.of(entity);
- for (l in listeners) l.onChange(type);
+ for (l in listeners) l.onChange(type, change);
}
public function destroy(entity:Entity):Void {
diff --git a/src/common/haxe/ru/m/tankz/game/Game.hx b/src/common/haxe/ru/m/tankz/game/Game.hx
index 081e966..84d13b7 100644
--- a/src/common/haxe/ru/m/tankz/game/Game.hx
+++ b/src/common/haxe/ru/m/tankz/game/Game.hx
@@ -158,13 +158,18 @@ class Game implements EngineListener {
}
}
- public function onChange(entity:EntityType):Void {
- switch (entity) {
- case EntityType.EAGLE(eagle):
+ public function onChange(entity:EntityType, ?change:EntityChange):Void {
+ switch [entity, change] {
+ case [EntityType.EAGLE(eagle), EntityChange.DEATH]:
if (eagle.death) {
lose(eagle.team);
deferred.resolve(state);
}
+ case [EntityType.TANK(tank), EntityChange.HIT]:
+ if (tank.bonus) {
+ tank.bonus = false;
+ spawnBonus();
+ }
case _:
}
}
@@ -197,7 +202,9 @@ class Game implements EngineListener {
if (!team.isAlive) {
lose(team.id);
}
- if (tank.bonus) spawnBonus();
+ if (tank.bonus) {
+ spawnBonus();
+ }
deferred.resolve(state);
case _:
}