[client] render: fixes
This commit is contained in:
2
WORK.md
2
WORK.md
@@ -7,7 +7,6 @@
|
||||
* import in game
|
||||
* save imported in local storage
|
||||
* database
|
||||
* cache
|
||||
* improve bots
|
||||
* A star
|
||||
* game config validate
|
||||
@@ -21,4 +20,3 @@
|
||||
* fix:
|
||||
* ice brick fix
|
||||
* shot delay
|
||||
* boat in tank state
|
||||
|
||||
@@ -5,5 +5,6 @@
|
||||
"SSH": {
|
||||
"PrivateKey": null,
|
||||
"Passphrase": null
|
||||
}
|
||||
},
|
||||
"Develop": false
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ const config = new Project.Config({
|
||||
pack: 'ru.m.tankz',
|
||||
author: 'shmyga <shmyga.z@gmail.com>',
|
||||
company: 'MegaLoMania',
|
||||
version: packageInfo.version,
|
||||
version: packageInfo.version + (Config.Develop ? '-SNAPSHOT' : ''),
|
||||
},
|
||||
libs: packageInfo.haxeDependencies,
|
||||
sources: [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "tankz",
|
||||
"version": "0.17.3",
|
||||
"version": "0.17.4",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"dateformat": "^3.0.3",
|
||||
|
||||
@@ -22,4 +22,8 @@ class RenderUtil {
|
||||
public static function bulletImage(skin:String):BitmapData {
|
||||
return Assets.getBitmapData('resources/image/bullet/${skin}.png');
|
||||
}
|
||||
|
||||
public static function brickImage(type:BrickType, frame:Int = 0):BitmapData {
|
||||
return Assets.getBitmapData('resources/image/map/${type}${frame > 0 ? ("-" + frame) : ""}.png');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,14 +14,14 @@ class BrickBitmapBundle {
|
||||
data = new Map();
|
||||
}
|
||||
|
||||
private function resolve(type:BrickType, cells:Array<GridPoint>):BitmapData {
|
||||
private function resolve(type:BrickType, cells:Array<GridPoint>, frame:Int):BitmapData {
|
||||
return switch cells.length {
|
||||
case 0:
|
||||
null;
|
||||
case 4:
|
||||
type == "none" ? null : Assets.getBitmapData('resources/image/map/${type}.png');
|
||||
type == "none" ? null : RenderUtil.brickImage(type, frame);
|
||||
case _:
|
||||
var image = Assets.getBitmapData('resources/image/map/${type}.png');
|
||||
var image = RenderUtil.brickImage(type, frame);
|
||||
var result = new BitmapData(image.width, image.height, true, 0x00000000);
|
||||
for (point in cells) {
|
||||
var rect = new flash.geom.Rectangle(
|
||||
@@ -35,10 +35,10 @@ class BrickBitmapBundle {
|
||||
}
|
||||
}
|
||||
|
||||
public function get(type:BrickType, cells:Array<GridPoint>):BitmapData {
|
||||
var key:String = '${type}_${cells.map(function(point) return point.toString()).join(",")}';
|
||||
public function get(type:BrickType, cells:Array<GridPoint>, frame:Int = 0):BitmapData {
|
||||
var key:String = '${type}_${cells.map(function(point) return point.toString()).join(",")}_${frame}';
|
||||
if (!data.exists(key)) {
|
||||
data.set(key, resolve(type, cells));
|
||||
data.set(key, resolve(type, cells, frame));
|
||||
}
|
||||
return data.get(key);
|
||||
}
|
||||
@@ -52,6 +52,10 @@ class BrickRenderItem extends BitmapRenderItem {
|
||||
|
||||
private var cells:Array<GridPoint>;
|
||||
|
||||
private var frames:Int;
|
||||
private var currentFrame:Int;
|
||||
private var ticks:Int;
|
||||
|
||||
private static function buildCells():Array<GridPoint> {
|
||||
return [
|
||||
new GridPoint(0, 0),
|
||||
@@ -64,6 +68,9 @@ class BrickRenderItem extends BitmapRenderItem {
|
||||
public function new(rect:Rectangle, type:BrickType) {
|
||||
super(rect);
|
||||
cells = buildCells();
|
||||
this.frames = 1;
|
||||
this.currentFrame = 0;
|
||||
this.ticks = 0;
|
||||
this.type = type;
|
||||
move(rect.position);
|
||||
}
|
||||
@@ -71,6 +78,10 @@ class BrickRenderItem extends BitmapRenderItem {
|
||||
private function set_type(value:BrickType):BrickType {
|
||||
if (type != value) {
|
||||
type = value;
|
||||
frames = switch type {
|
||||
case "water": 2;
|
||||
case _: 1;
|
||||
}
|
||||
cells = buildCells();
|
||||
redraw();
|
||||
}
|
||||
@@ -88,6 +99,20 @@ class BrickRenderItem extends BitmapRenderItem {
|
||||
}
|
||||
|
||||
public function redraw():Void {
|
||||
image = bundle.get(type, cells);
|
||||
image = bundle.get(type, cells, currentFrame);
|
||||
}
|
||||
|
||||
override public function update():Void {
|
||||
super.update();
|
||||
if (frames > 1) {
|
||||
if (++ticks >= 30) {
|
||||
ticks = 0;
|
||||
currentFrame++;
|
||||
if (currentFrame >= frames) {
|
||||
currentFrame = 0;
|
||||
}
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,11 +40,11 @@ class TankRenderItem extends BitmapRenderItem {
|
||||
protectView = AnimateBundle.tankProtect();
|
||||
protectView.visible = false;
|
||||
container.addChild(protectView);
|
||||
nameView = buildNameView();
|
||||
container.addChild(nameView);
|
||||
boatView = buildBoatView();
|
||||
boatView.visible = false;
|
||||
container.addChild(boatView);
|
||||
nameView = buildNameView();
|
||||
container.addChild(nameView);
|
||||
move(rect.position);
|
||||
}
|
||||
|
||||
@@ -60,8 +60,8 @@ class TankRenderItem extends BitmapRenderItem {
|
||||
|
||||
private function buildBoatView():Shape {
|
||||
var result = new Shape();
|
||||
result.graphics.lineStyle(4, Color.fromString("green"));
|
||||
result.graphics.drawRoundRect(0, 0, rect.width, rect.height, 10, 10);
|
||||
result.graphics.lineStyle(4, Color.fromString("green"), 0.8);
|
||||
result.graphics.drawRoundRect(-1, -1, rect.width + 2, rect.height + 2, 10, 10);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ class TankRenderItem extends BitmapRenderItem {
|
||||
super.update();
|
||||
if (moves) {
|
||||
frame++;
|
||||
if (frame > images.length - 1) {
|
||||
if (frame >= images.length) {
|
||||
frame = 0;
|
||||
}
|
||||
bitmap.bitmapData = images[frame];
|
||||
|
||||
@@ -33,7 +33,6 @@ abstract Version(Array<Int>) {
|
||||
@:op(A < B) static function lt(a:Version, b:Version):Bool return a.compare(b) < 0;
|
||||
|
||||
@:from public static function fromString(value:String):Version {
|
||||
trace("!fromString", value);
|
||||
var r = ~/(\d+)\.(\d+)\.(\d+)(-SNAPSHOT)?/;
|
||||
return if (r.match(value)) {
|
||||
new Version(
|
||||
|
||||
@@ -52,6 +52,7 @@ class EntityBuilder {
|
||||
tank.hits = info.hits;
|
||||
tank.name = info.name;
|
||||
tank.bonus = info.bonus;
|
||||
tank.boat = info.boat;
|
||||
return tank;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user