[client] resource images rename

This commit is contained in:
2018-02-18 21:22:46 +03:00
parent 5456a01551
commit 11aea59cf8
38 changed files with 61 additions and 32 deletions

View File

@@ -21,7 +21,7 @@ const generate = () => function generate() {
]); ]);
}; };
const build = (platform) => function build() { const build = (platform, values) => function build() {
const argv = yargs.argv; const argv = yargs.argv;
return gulp.src('.') return gulp.src('.')
.pipe(new Haxe().openfl({ .pipe(new Haxe().openfl({
@@ -29,6 +29,7 @@ const build = (platform) => function build() {
platform: platform, platform: platform,
version: version, version: version,
debug: argv.dev, debug: argv.dev,
values: values
})) }))
.pipe(gulp.dest(`target/${platform}`)); .pipe(gulp.dest(`target/${platform}`));
}; };
@@ -87,6 +88,7 @@ const buildDeb = gulp.series(
exports['client:flash:html'] = gulp.parallel(flashIndex, flashJs); 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: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'] = 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:linux'] = gulp.series(prepare(Haxe.ID), generate(), build('linux'));
exports['client:webapp'] = webapp; exports['client:webapp'] = webapp;
exports['client:deb'] = buildDeb; exports['client:deb'] = buildDeb;
@@ -108,9 +110,9 @@ const testFlash = function() {
.pipe(debug()); .pipe(debug());
}; };
const testHtml5 = function() { const testHtml5 = (dom) => function() {
return gulp.series( return gulp.series(
build('html5'), build('html5', {dom:dom}),
() => gulp.src('target/html5').pipe(webserver({ () => gulp.src('target/html5').pipe(webserver({
host: 'localhost', port: 3000, host: 'localhost', port: 3000,
open: true, open: true,
@@ -130,7 +132,8 @@ const testLinux = gulp.series(
exports['client:flash:test'] = gulp.series(prepare(Haxe.ID, FlashPlayer.ID), testFlash); 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:linux:test'] = gulp.series(prepare(Haxe.ID), testLinux);
exports['client:test'] = exports['client:flash:test']; exports['client:test'] = exports['client:flash:test'];

View File

@@ -1,6 +1,6 @@
{ {
"name": "tankz", "name": "tankz",
"version": "0.6.3", "version": "0.6.4",
"private": true, "private": true,
"devDependencies": { "devDependencies": {
"ansi-colors": "^1.0.1", "ansi-colors": "^1.0.1",

View File

@@ -19,7 +19,7 @@
<haxeflag name="-D" value="native-trace"/> <haxeflag name="-D" value="native-trace"/>
<!--<haxeflag name="-D" value="proto_debug"/>--> <!--<haxeflag name="-D" value="proto_debug"/>-->
<haxeflag name="-dce" value="no"/> <haxeflag name="-dce" value="no"/>
<haxeflag name="-D" value="dom"/> <!--<haxeflag name="-D" value="dom"/>-->
<haxeflag name="--macro" value="yield.parser.Parser.auto()"/> <haxeflag name="--macro" value="yield.parser.Parser.auto()"/>
<!--<template path="src/client/webapp/index_template.html" rename="index.html"/>--> <!--<template path="src/client/webapp/index_template.html" rename="index.html"/>-->

View File

@@ -9,7 +9,7 @@ views:
pHeight: 100 pHeight: 100
skin: skin:
$type: haxework.gui.skin.BitmapSkin $type: haxework.gui.skin.BitmapSkin
image: "@asset:image:resources/images/background.png" image: "@asset:image:resources/image/ui/background.png"
fillType: REPEAT fillType: REPEAT
views: views:
- id: start - id: start

View File

@@ -4,9 +4,9 @@ button:
height: 60 height: 60
skin: skin:
$type: haxework.gui.skin.ButtonBitmapSkin $type: haxework.gui.skin.ButtonBitmapSkin
upImage: "@asset:image:resources/images/control/button_normal.png" upImage: "@asset:image:resources/image/ui/button/normal.png"
downImage: "@asset:image:resources/images/control/button_down.png" downImage: "@asset:image:resources/image/ui/button/down.png"
overImage: "@asset:image:resources/images/control/button_over.png" overImage: "@asset:image:resources/image/ui/button/over.png"
fillType: NINEPATH fillType: NINEPATH
fontFamily: "@res:text:font" fontFamily: "@res:text:font"
fontEmbed: true fontEmbed: true

View File

@@ -3,7 +3,7 @@ pWidth: 100
pHeight: 100 pHeight: 100
views: views:
- $type: haxework.gui.ImageView - $type: haxework.gui.ImageView
image: "@asset:image:resources/images/logo/logo.png" image: "@asset:image:resources/image/ui/logo.png"
contentSize: true contentSize: true
bottomMargin: 15 bottomMargin: 15
- $type: haxework.gui.LabelView - $type: haxework.gui.LabelView

View File

@@ -12,7 +12,8 @@ import ru.m.tankz.Type;
class AnimateBundle { class AnimateBundle {
private static function buildAnimate(template:String, sequence:Array<Int>):OnceAnimate { private static function buildAnimate(name:String, sequence:Array<Int>):OnceAnimate {
var template:String = 'resources/image/animate/${name}/%index%.png';
var frames = [for (i in sequence) ({ var frames = [for (i in sequence) ({
image: Assets.getBitmapData(StringTools.replace(template, '%index%', Std.string(i))), image: Assets.getBitmapData(StringTools.replace(template, '%index%', Std.string(i))),
length: 1 length: 1
@@ -21,32 +22,41 @@ class AnimateBundle {
} }
public static function tankSpawn():OnceAnimate { 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 0, 1, 2, 3, 3, 4, 5, 5, 6
]); ]);
} }
public static function tankBoom():OnceAnimate { 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 0, 1, 2, 3, 4, 4, 4, 1, 4, 4, 7, 7, 8, 9, 9
]); ]);
} }
public static function bulletBoom():OnceAnimate { public static function bulletBoom():OnceAnimate {
return buildAnimate('resources/images/bullet/boom/boom-%index%.png', [ return buildAnimate('boom-sm', [
0, 1, 1, 0, 0, 1 0, 1, 1, 0, 0, 1
]); ]);
} }
public static function tankProtect():Animate { public static function tankProtect():Animate {
return new Animate([for (i in 0...2) ({ 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 length: 5
})]); })]);
} }
public static function tankFrames(tank:Tank):Array<Frame> { public static function tankFrames(tank:Tank):Array<Frame> {
var colors:Array<Color> = [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, color];
if (tank.bonus) {
colors[1] = 0xff00aa;
}
return [for (i in 0...2) ({ return [for (i in 0...2) ({
image: BitmapUtil.colorize(Assets.getBitmapData('resources/image/tank/${tank.config.skin}-${i}.png'), colors[i]), image: BitmapUtil.colorize(Assets.getBitmapData('resources/image/tank/${tank.config.skin}-${i}.png'), colors[i]),
length: 3 length: 3

View File

@@ -119,13 +119,13 @@ class Render extends SpriteView implements EngineListener {
case EntityType.BONUS(bonus): case EntityType.BONUS(bonus):
var item = new BonusItem(bonus); var item = new BonusItem(bonus);
items.set(bonus.key, item); items.set(bonus.key, item);
entryLayer.addChild(item.view); upperLayer.addChild(item.view);
item.update(); item.update();
case _: case _:
} }
} }
public function onChange(entity:EntityType):Void {} public function onChange(entity:EntityType, ?change:EntityChange):Void {}
public function onCollision(entity:EntityType, with:EntityType):Void { public function onCollision(entity:EntityType, with:EntityType):Void {
switch [entity, with] { switch [entity, with] {
@@ -154,7 +154,7 @@ class Render extends SpriteView implements EngineListener {
} }
case EntityType.BONUS(bonus): case EntityType.BONUS(bonus):
if (items.exists(bonus.key)) { if (items.exists(bonus.key)) {
entryLayer.removeChild(items.get(bonus.key).view); upperLayer.removeChild(items.get(bonus.key).view);
items.remove(bonus.key); items.remove(bonus.key);
} }
case _: case _:

View File

@@ -242,7 +242,9 @@ class TankItem extends RenderItem<Tank, Sprite> {
class BulletItem extends BitmapItem<Bullet> { class BulletItem extends BitmapItem<Bullet> {
override private function getImage():String { 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';
} }
} }

View File

@@ -25,6 +25,7 @@ player:
- {type: human0, rate: 1, protect: 5} - {type: human0, rate: 1, protect: 5}
bot: &bot bot: &bot
control: bot control: bot
color: 0xFFFFFF
life: -1 life: -1
tanks: tanks:
- {type: bot0, rate: 0.25, bonus: 0.25} - {type: bot0, rate: 0.25, bonus: 0.25}

View File

Before

Width:  |  Height:  |  Size: 110 B

After

Width:  |  Height:  |  Size: 110 B

View File

Before

Width:  |  Height:  |  Size: 141 B

After

Width:  |  Height:  |  Size: 141 B

View File

Before

Width:  |  Height:  |  Size: 144 B

After

Width:  |  Height:  |  Size: 144 B

View File

Before

Width:  |  Height:  |  Size: 186 B

After

Width:  |  Height:  |  Size: 186 B

View File

Before

Width:  |  Height:  |  Size: 144 B

After

Width:  |  Height:  |  Size: 144 B

View File

Before

Width:  |  Height:  |  Size: 186 B

After

Width:  |  Height:  |  Size: 186 B

View File

Before

Width:  |  Height:  |  Size: 144 B

After

Width:  |  Height:  |  Size: 144 B

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Before

Width:  |  Height:  |  Size: 292 B

After

Width:  |  Height:  |  Size: 292 B

View File

Before

Width:  |  Height:  |  Size: 386 B

After

Width:  |  Height:  |  Size: 386 B

View File

Before

Width:  |  Height:  |  Size: 389 B

After

Width:  |  Height:  |  Size: 389 B

View File

Before

Width:  |  Height:  |  Size: 375 B

After

Width:  |  Height:  |  Size: 375 B

View File

Before

Width:  |  Height:  |  Size: 9.8 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

@@ -1,7 +1,7 @@
package ru.m.tankz.engine; package ru.m.tankz.engine;
import ru.m.geom.Point;
import ru.m.geom.Line; import ru.m.geom.Line;
import ru.m.geom.Point;
import ru.m.tankz.config.Config; import ru.m.tankz.config.Config;
import ru.m.tankz.control.Control; import ru.m.tankz.control.Control;
import ru.m.tankz.core.Bullet; import ru.m.tankz.core.Bullet;
@@ -12,9 +12,15 @@ import ru.m.tankz.core.Tank;
import ru.m.tankz.map.LevelMap; import ru.m.tankz.map.LevelMap;
enum EntityChange {
DEATH;
HIT;
}
interface EngineListener { interface EngineListener {
public function onSpawn(entity:EntityType):Void; 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 onCollision(entity:EntityType, with:EntityType):Void;
public function onDestroy(entity:EntityType):Void; public function onDestroy(entity:EntityType):Void;
} }
@@ -29,7 +35,7 @@ class CollisionProcessor implements EngineListener {
public function onSpawn(entity:EntityType):Void {} 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 onCollision(entity:EntityType, with:EntityType):Void {
switch [entity, with] { switch [entity, with] {
@@ -47,7 +53,7 @@ class CollisionProcessor implements EngineListener {
if (!tank.protect.active) { if (!tank.protect.active) {
if (tank.hits > 0) { if (tank.hits > 0) {
tank.hits--; tank.hits--;
engine.change(tank); engine.change(tank, EntityChange.HIT);
} else { } else {
engine.destroy(tank); engine.destroy(tank);
} }
@@ -63,7 +69,7 @@ class CollisionProcessor implements EngineListener {
engine.destroy(bullet); engine.destroy(bullet);
if (!eagle.protect.active) { if (!eagle.protect.active) {
eagle.death = true; eagle.death = true;
engine.change(eagle); engine.change(eagle, EntityChange.DEATH);
} }
case _: case _:
} }
@@ -101,9 +107,9 @@ class Engine implements ControlHandler {
for (l in listeners) l.onSpawn(type); 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); 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 { public function destroy(entity:Entity):Void {

View File

@@ -158,13 +158,18 @@ class Game implements EngineListener {
} }
} }
public function onChange(entity:EntityType):Void { public function onChange(entity:EntityType, ?change:EntityChange):Void {
switch (entity) { switch [entity, change] {
case EntityType.EAGLE(eagle): case [EntityType.EAGLE(eagle), EntityChange.DEATH]:
if (eagle.death) { if (eagle.death) {
lose(eagle.team); lose(eagle.team);
deferred.resolve(state); deferred.resolve(state);
} }
case [EntityType.TANK(tank), EntityChange.HIT]:
if (tank.bonus) {
tank.bonus = false;
spawnBonus();
}
case _: case _:
} }
} }
@@ -197,7 +202,9 @@ class Game implements EngineListener {
if (!team.isAlive) { if (!team.isAlive) {
lose(team.id); lose(team.id);
} }
if (tank.bonus) spawnBonus(); if (tank.bonus) {
spawnBonus();
}
deferred.resolve(state); deferred.resolve(state);
case _: case _:
} }