This commit is contained in:
2015-08-14 16:24:42 +03:00
parent 39ab8d30e6
commit 3643be4cd8
24 changed files with 314 additions and 71 deletions

View File

@@ -1,18 +1,29 @@
{ {
"pWidth": 100, "pHeight": 100, "layoutMargin": 3, "pWidth": 100, "pHeight": 100, "layoutMargin": 3,
"views": [ "views": [
{
"@type": "haxework.gui.LabelView",
"pWidth": 100, "height": 44, "text": "Authorization",
"@style": "label"
},
{ {
"@type": "haxework.gui.HGroupView", "@type": "haxework.gui.HGroupView",
"contentSize": true, "contentSize": true,
"views": [ "views": [
{ {
"@type": "haxework.gui.LabelView", "@type": "haxework.gui.LabelView",
"width": 150, "height": 25, "text": "Login" "width": 150, "height": 44, "text": "Login",
"@style": "label"
}, },
{ {
"id": "loginInput", "@type": "haxework.gui.InputView", "id": "loginInput", "@type": "haxework.gui.InputView",
"skin": {"@type": "haxework.gui.skin.ColorSkin", "color": "0xffffff"}, "skin": {
"width": 200, "height": 25, "text": "" "@type": "haxework.gui.skin.BitmapSkin",
"image": "@asset:image:resources/images/map/map_3-0.png",
"fillType": "REPEAT"
},
"width": 220, "height": 44, "text": "",
"@style": "label"
} }
] ]
}, },
@@ -22,12 +33,18 @@
"views": [ "views": [
{ {
"@type": "haxework.gui.LabelView", "@type": "haxework.gui.LabelView",
"width": 150, "height": 25, "text": "Password" "width": 150, "height": 44, "text": "Password",
"@style": "label"
}, },
{ {
"id": "passwordInput", "@type": "haxework.gui.InputView", "id": "passwordInput", "@type": "haxework.gui.InputView",
"skin": {"@type": "haxework.gui.skin.ColorSkin", "color": "0xffffff"}, "skin": {
"width": 200, "height": 25, "text": "" "@type": "haxework.gui.skin.BitmapSkin",
"image": "@asset:image:resources/images/map/map_3-0.png",
"fillType": "REPEAT"
},
"width": 220, "height": 44, "text": "",
"@style": "label"
} }
] ]
}, },
@@ -35,8 +52,8 @@
{ {
"id": "authButton", "id": "authButton",
"@type": "haxework.gui.ButtonView", "@type": "haxework.gui.ButtonView",
"width": 100, "height": 45, "width": 132, "height": 44,
"text": "Auth", "text": "Submit",
"@style": "button_skin" "@style": "button_skin"
} }
] ]

View File

@@ -3,7 +3,8 @@
"views": [ "views": [
{ {
"id": "name", "@type": "haxework.gui.LabelView", "id": "name", "@type": "haxework.gui.LabelView",
"pWidth": 100, "height": 25, "text": "" "pWidth": 100, "height": 44, "text": "",
"@style": "label"
}, },
{ {
"id": "render", "@type": "ru.m.tankz.render.Render", "id": "render", "@type": "ru.m.tankz.render.Render",

View File

@@ -3,11 +3,12 @@
"views": [ "views": [
{ {
"id": "name", "@type": "haxework.gui.LabelView", "id": "name", "@type": "haxework.gui.LabelView",
"pWidth": 100, "height": 25, "text": "" "pWidth": 100, "height": 44, "text": "",
"@style": "label"
}, },
{ {
"id": "create", "@type": "haxework.gui.ButtonView", "id": "create", "@type": "haxework.gui.ButtonView",
"width": 100, "height": 45, "width": 132, "height": 44,
"text": "Create", "text": "Create",
"@style": "button_skin" "@style": "button_skin"
}, },

View File

@@ -3,17 +3,18 @@
"views": [ "views": [
{ {
"id": "name", "@type": "haxework.gui.LabelView", "id": "name", "@type": "haxework.gui.LabelView",
"pWidth": 100, "height": 25, "text": "" "pWidth": 100, "height": 44, "text": "",
"@style": "label"
}, },
{ {
"id": "start", "@type": "haxework.gui.ButtonView", "id": "start", "@type": "haxework.gui.ButtonView",
"width": 100, "height": 45, "width": 132, "height": 44,
"text": "Start", "text": "Start",
"@style": "button_skin" "@style": "button_skin"
}, },
{ {
"id": "exit", "@type": "haxework.gui.ButtonView", "id": "exit", "@type": "haxework.gui.ButtonView",
"width": 100, "height": 45, "width": 132, "height": 44,
"text": "Exit", "text": "Exit",
"@style": "button_skin" "@style": "button_skin"
}, },

View File

@@ -1,6 +1,11 @@
{ {
"pWidth": 100, "pHeight": 100, "layoutMargin": 3, "paddings": 10, "pWidth": 100, "pHeight": 100, "layoutMargin": 3, "paddings": 10,
"views": [ "views": [
{
"@type": "haxework.gui.LabelView",
"pWidth": 100, "height": 44, "text": "Person select",
"@style": "label"
},
{ {
"id": "list", "@type": "haxework.gui.list.VListView<ru.m.tankz.proto.Person>", "id": "list", "@type": "haxework.gui.list.VListView<ru.m.tankz.proto.Person>",
"factory": "@class:ru.m.tankz.view.frames.list.PersonView", "factory": "@class:ru.m.tankz.view.frames.list.PersonView",

View File

@@ -4,12 +4,22 @@
"views": [ "views": [
{ {
"id":"top", "@type": "haxework.gui.HGroupView", "id":"top", "@type": "haxework.gui.HGroupView",
"pWidth": 100, "height": 30, "pWidth": 100, "height": 44,
"skin": {"@type": "haxework.gui.skin.ColorSkin", "color": "0x105000"}, "skin": {
"@type": "haxework.gui.skin.BitmapSkin",
"image": "@asset:image:resources/images/map/map_5.png",
"fillType": "REPEAT"
},
"views": [ "views": [
{
"id": "name", "@type": "haxework.gui.LabelView",
"pWidth": 100, "height": 44,
"text": "@res:text:userName",
"@style": "label"
},
{ {
"id": "logout", "@type": "haxework.gui.ButtonView", "id": "logout", "@type": "haxework.gui.ButtonView",
"width": 100, "height": 30, "width": 132, "height": 44,
"text": "Logout", "text": "Logout",
"@style": "button_skin" "@style": "button_skin"
} }
@@ -18,7 +28,11 @@
{ {
"id": "switcher", "@type": "haxework.gui.frame.FrameSwitcher", "id": "switcher", "@type": "haxework.gui.frame.FrameSwitcher",
"pWidth": 100, "pHeight": 100, "pWidth": 100, "pHeight": 100,
"skin": {"@type": "haxework.gui.skin.BitmapSkin", "image": "@asset:image:resources/images/background.png", "fillType": "REPEAT"}, "skin": {
"@type": "haxework.gui.skin.BitmapSkin",
"image": "@asset:image:resources/images/map/map_1.png",
"fillType": "REPEAT"
},
"views": [ "views": [
{ {
"id": "auth", "id": "auth",

View File

@@ -0,0 +1,18 @@
{
"person": {
"width": 440, "height": 44,
"skin": {
"@type": "haxework.gui.skin.BitmapSkin",
"image": "@asset:image:resources/images/map/map_3-0.png",
"fillType": "REPEAT"
},
"views": [
{
"id": "nameLabel",
"@type": "haxework.gui.LabelView",
"pWidth": 100, "height": 44, "text": "Выбор персонажа",
"@style": "label"
}
]
}
}

View File

@@ -2,11 +2,21 @@
"button_skin": { "button_skin": {
"skin": { "skin": {
"@type": "haxework.gui.skin.ButtonBitmapSkin", "@type": "haxework.gui.skin.ButtonBitmapSkin",
"upImage": "@asset:image:resources/images/control/button_normal.png", "image": "@asset:image:resources/images/map/map_4.png",
"downImage": "@asset:image:resources/images/control/button_down.png", "fillType": "REPEAT"
"overImage": "@asset:image:resources/images/control/button_over.png",
"fillType": "NINEPATH"
}, },
"fontColor": "0xffffff" "fontColor": "0xffffff",
"fontEmbed": true,
"fontFamily": "@res:text:fontName",
"fontSize": 16,
"shadowColor": "0x000000"
},
"label": {
"fontColor": "0xffffff",
"fontEmbed": true,
"fontFamily": "@res:text:fontName",
"fontSize": 16,
"shadowColor": "0x000000"
} }
} }

View File

@@ -1,5 +1,7 @@
package ru.m.tankz; package ru.m.tankz;
import haxework.resources.Resources;
import haxework.resources.IResources;
import haxework.gui.VGroupView; import haxework.gui.VGroupView;
import haxework.gui.ViewBuilder; import haxework.gui.ViewBuilder;
import haxework.gui.ButtonView; import haxework.gui.ButtonView;
@@ -35,16 +37,14 @@ class Client implements IConnectionHandler {
private var view:MainView; private var view:MainView;
private var switcher:FrameSwitcher;
public function new() { public function new() {
view = new MainView(); Provider.setFactory(IResources, Resources);
Root.bind(view);
switcher = view.switcher;
view.logout.onPress = this;
Provider.setFactory(GameData, GameData); Provider.setFactory(GameData, GameData);
Provider.set(IFrameSwitcher, switcher);
var font = Assets.getFont("resources/fonts/8-BIT WONDER.TTF");
Provider.get(IResources).text.put("fontName", font.fontName);
Provider.set(IPacketBuilder, new PacketBuilder()); Provider.set(IPacketBuilder, new PacketBuilder());
#if flash #if flash
Provider.set(IConnection, new ru.m.core.connect.flash.FlashConnection("localhost", 5001)); Provider.set(IConnection, new ru.m.core.connect.flash.FlashConnection("localhost", 5001));
@@ -53,7 +53,12 @@ class Client implements IConnectionHandler {
#end #end
Provider.get(IConnection).handler.addListener(this); Provider.get(IConnection).handler.addListener(this);
switcher.change(AuthFrame.ID);
view = new MainView();
Provider.set(IFrameSwitcher, view.switcher);
Root.bind(view);
view.logout.onPress = this;
view.switcher.change(AuthFrame.ID);
} }
public function onPress(view:ButtonView):Void { public function onPress(view:ButtonView):Void {
@@ -66,11 +71,11 @@ class Client implements IConnectionHandler {
public function onConnected():Void {} public function onConnected():Void {}
public function onDisconnected():Void { public function onDisconnected():Void {
switcher.change(AuthFrame.ID); view.switcher.change(AuthFrame.ID);
} }
public function onError(error:Dynamic):Void { public function onError(error:Dynamic):Void {
L.e(TAG, "", error); L.e(TAG, "", error);
switcher.change(AuthFrame.ID); view.switcher.change(AuthFrame.ID);
} }
} }

View File

@@ -1,5 +1,8 @@
package ru.m.tankz.render; package ru.m.tankz.render;
import ru.m.tankz.core.Direction;
import flash.geom.Matrix;
import openfl.Assets;
import ru.m.tankz.core.Bullet; import ru.m.tankz.core.Bullet;
import ru.m.tankz.core.Tank; import ru.m.tankz.core.Tank;
import flash.display.Sprite; import flash.display.Sprite;
@@ -51,22 +54,34 @@ class Render extends SpriteView implements IRender {
for (e in game.mobileEntities) { for (e in game.mobileEntities) {
if (Std.is(e, Tank)) { if (Std.is(e, Tank)) {
g.beginFill(0xff0000); var m = new Matrix();
m.rotate(calcRotate(e.direction));
m.translate(e.x, e.y);
g.beginBitmapFill(Assets.getBitmapData("resources/images/tank/player/tank_p0_0-0.png"), m);
g.drawRect(e.x, e.y, e.width, e.height); g.drawRect(e.x, e.y, e.width, e.height);
g.endFill(); g.endFill();
g.beginFill(0x990000);
g.drawRect(
e.x + e.width / 2 - e.width / 8 + e.direction.x * e.width / 4,
e.y + e.height / 2 - e.height / 8 + e.direction.y * e.height / 4,
e.width / 4,
e.height / 4
);
g.endFill();
} else if (Std.is(e, Bullet)) { } else if (Std.is(e, Bullet)) {
g.beginFill(0xff0000); var m = new Matrix();
m.rotate(calcRotate(e.direction));
m.translate(e.x, e.y);
g.beginBitmapFill(Assets.getBitmapData("resources/images/bullet/bullet_0.png"), m);
g.drawRect(e.x, e.y, e.width, e.height); g.drawRect(e.x, e.y, e.width, e.height);
g.endFill(); g.endFill();
} }
} }
} }
private function calcRotate(direction:Direction):Float {
return (if (direction == Direction.RIGHT) {
0;
} else if (direction == Direction.LEFT) {
180;
} else if (direction == Direction.TOP) {
270;
} else if (direction == Direction.BOTTOM) {
90;
} else {
0;
}) / (Math.PI * 2);
}
} }

View File

@@ -1,5 +1,6 @@
package ru.m.tankz.view.frames; package ru.m.tankz.view.frames;
import haxework.resources.IResources;
import haxework.gui.ViewBuilder; import haxework.gui.ViewBuilder;
import ru.m.core.connect.IConnection; import ru.m.core.connect.IConnection;
import ru.m.tankz.data.GameData; import ru.m.tankz.data.GameData;
@@ -63,6 +64,7 @@ class AuthFrame extends VGroupView implements ViewBuilder implements IPacketHand
so.setProperty("login", loginInput.text); so.setProperty("login", loginInput.text);
so.setProperty("password", passwordInput.text); so.setProperty("password", passwordInput.text);
so.flush(); so.flush();
Provider.get(IResources).text.put("userName", packet.account.login);
Provider.get(GameData).account = packet.account; Provider.get(GameData).account = packet.account;
Provider.get(IFrameSwitcher).change(PersonListFrame.ID); Provider.get(IFrameSwitcher).change(PersonListFrame.ID);
} }

View File

@@ -11,10 +11,10 @@ import ru.m.core.connect.IConnection;
import ru.m.tankz.data.GameData; import ru.m.tankz.data.GameData;
import haxework.provider.Provider; import haxework.provider.Provider;
import ru.m.tankz.proto.Person; import ru.m.tankz.proto.Person;
import haxework.gui.HGroupView; import haxework.gui.VGroupView;
@:template("layout/frames/person_list.json", "layout/styles.json") @:template("layout/frames/person_list.json", "layout/styles.json")
class PersonListFrame extends HGroupView implements ViewBuilder implements IPacketHandler implements ListViewListener<Person> { class PersonListFrame extends VGroupView implements ViewBuilder implements IPacketHandler implements ListViewListener<Person> {
private static inline var TAG = "PersonListFrame"; private static inline var TAG = "PersonListFrame";

View File

@@ -1,28 +1,16 @@
package ru.m.tankz.view.frames.list; package ru.m.tankz.view.frames.list;
import haxework.gui.ViewBuilder;
import haxework.gui.list.ListView.IListItemView; import haxework.gui.list.ListView.IListItemView;
import haxework.gui.LabelView;
import ru.m.tankz.proto.Person; import ru.m.tankz.proto.Person;
import haxework.gui.skin.ColorSkin;
import haxework.gui.HGroupView; import haxework.gui.HGroupView;
class PersonView extends HGroupView implements IListItemView<Person> { @:template("layout/other.json@person", "layout/styles.json")
class PersonView extends HGroupView implements ViewBuilder implements IListItemView<Person> {
public var item_index(default, default):Int; public var item_index(default, default):Int;
public var data(default, set):Person; public var data(default, set):Person;
private var nameLabel:LabelView;
public function new() {
super();
pWidth = 100;
height = 50;
skin = new ColorSkin(0xffffff);
nameLabel = new LabelView();
addView(nameLabel);
}
private function set_data(value:Person):Person { private function set_data(value:Person):Person {
this.data = value; this.data = value;
nameLabel.text = this.data.name; nameLabel.text = this.data.name;

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,161 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg"
><metadata
></metadata
><defs
><font horiz-adv-x="300"
><font-face font-family="8BIT WONDER" units-per-em="300" ascent="300" descent="0"
></font-face
><missing-glyph horiz-adv-x="150" d="M19 0V300H131V0H19ZM38 19h75V281H38V19Z"
></missing-glyph
><glyph unicode=" " horiz-adv-x="150" d=""
></glyph
><glyph unicode="#" d="M300 0H0V300H300V0ZM250 50V250H50V50H250Z"
></glyph
><glyph unicode="(" horiz-adv-x="150" d="M150 0H25V25H0V225H25v25H150V200H100V50h50V0Z"
></glyph
><glyph unicode=")" horiz-adv-x="150" d="M150 25H125V0H0V50H50V200H0v50H125V225h25V25Z"
></glyph
><glyph unicode="*" d="M250 220L230 200H220l-20 20v10l20 20h10l20 -20V220ZM200 165L185 150H165l-15 15v20l15 15h20l15 -15V165ZM150 110L140 100H110l-10 10v30l10 10h30l10 -10V110ZM50 220L30 200H20L0 220v10l20 20H30L50 230V220ZM100 165L85 150H65L50 165v20l15 15H85l15 -15V165ZM200 65L185 50H165L150 65V85l15 15h20L200 85V65ZM250 20L230 0H220L200 20V30l20 20h10L250 30V20ZM100 65L85 50H65L50 65V85l15 15H85L100 85V65ZM50 20L30 0H20L0 20V30L20 50H30L50 30V20Z"
></glyph
><glyph unicode="0" d="M250 25H225V0H25V25H0V225H25v25H225V225h25V25ZM150 150v50H100V150h50ZM150 50v50H100V50h50Z"
></glyph
><glyph unicode="1" horiz-adv-x="150" d="M100 0H0V200H-25v50H75V225h25V0Z"
></glyph
><glyph unicode="2" d="M250 0H0V125H25v25H150v50H0v50H225V225h25V125H225V100H100V50H250V0Z"
></glyph
><glyph unicode="3" d="M250 25H225V0H0V50H150v50H75v50h75v50H0v50H225V225h25V150H225V100h25V25Z"
></glyph
><glyph unicode="4" d="M250 0H150V100H25v25H0V250H100V150h50V250H250V0Z"
></glyph
><glyph unicode="5" d="M250 25H225V0H0V50H150v50H25v25H0V250H250V200H100V150H225V125h25V25Z"
></glyph
><glyph unicode="6" d="M250 25H225V0H25V25H0V225H25v25H250V200H100V150H225V125h25V25ZM150 50v50H100V50h50Z"
></glyph
><glyph unicode="7" d="M250 0H150V200H0v50H225V225h25V0Z"
></glyph
><glyph unicode="8" d="M250 25H225V0H25V25H0v75H25v50H0v75H25v25H225V225h25V150H225V100h25V25ZM150 150v50H100V150h50ZM150 50v50H100V50h50Z"
></glyph
><glyph unicode="9" d="M250 25H225V0H0V50H150v50H25v25H0V225H25v25H225V225h25V25ZM150 150v50H100V150h50Z"
></glyph
><glyph unicode="A" d="M250 0H150V100H100V0H0V225H25v25H225V225h25V0ZM150 150v50H100V150h50Z"
></glyph
><glyph unicode="B" d="M250 25H225V0H0V250H225V225h25V150H225V100h25V25ZM150 150v50H100V150h50ZM150 50v50H100V50h50Z"
></glyph
><glyph unicode="C" d="M250 0H25V25H0V225H25v25H250V200H100V50H250V0Z"
></glyph
><glyph unicode="D" d="M250 25H225V0H0V250H225V225h25V25ZM150 50V200H100V50h50Z"
></glyph
><glyph unicode="E" d="M250 0H25V25H0V225H25v25H250V200H100V150h75V100H100V50H250V0Z"
></glyph
><glyph unicode="F" d="M250 200H100V150h75V100H100V0H0V225H25v25H250V200Z"
></glyph
><glyph unicode="G" d="M250 0H25V25H0V225H25v25H250V200H100V50h50v50H125v50H250V0Z"
></glyph
><glyph unicode="H" d="M250 0H150V100H100V0H0V250H100V150h50V250H250V0Z"
></glyph
><glyph unicode="I" horiz-adv-x="150" d="M100 0H0V250H100V0Z"
></glyph
><glyph unicode="J" d="M250 25H225V0H0V50H150V250H250V25Z"
></glyph
><glyph unicode="K" d="M250 0H150V100H100V0H0V250H100V150h50V250H250V150H225V100h25V0Z"
></glyph
><glyph unicode="L" d="M250 0H0V250H100V50H250V0Z"
></glyph
><glyph unicode="M" horiz-adv-x="450" d="M400 0H300V200H250V0H150V200H100V0H0V250H375V225h25V0Z"
></glyph
><glyph unicode="N" d="M250 0H150V200H100V0H0V250H225V225h25V0Z"
></glyph
><glyph unicode="O" d="M250 25H225V0H25V25H0V225H25v25H225V225h25V25ZM150 50V200H100V50h50Z"
></glyph
><glyph unicode="P" d="M250 125H225V100H100V0H0V250H225V225h25V125ZM150 150v50H100V150h50Z"
></glyph
><glyph unicode="Q" d="M250 25H225V0H25V25H0V225H25v25H225V225h25V25ZM150 50V200H100V50h50Z"
></glyph
><glyph unicode="R" d="M250 0H150V100H100V0H0V250H225V225h25V150H225V100h25V0ZM150 150v50H100V150h50Z"
></glyph
><glyph unicode="S" d="M250 25H225V0H0V50H150v50H25v25H0V225H25v25H250V200H100V150H225V125h25V25Z"
></glyph
><glyph unicode="T" d="M250 200H175V0H75V200H0v50H250V200Z"
></glyph
><glyph unicode="U" d="M250 25H225V0H25V25H0V250H100V50h50V250H250V25Z"
></glyph
><glyph unicode="V" d="M250 25H225V0H0V250H100V50h50V250H250V25Z"
></glyph
><glyph unicode="W" horiz-adv-x="450" d="M400 25H375V0H0V250H100V50h50V250H250V50h50V250H400V25Z"
></glyph
><glyph unicode="X" d="M250 0H150V100H100V0H0V100H25v50H0V250H100V150h50V250H250V150H225V100h25V0Z"
></glyph
><glyph unicode="Y" d="M250 125H225V100H175V0H75V100H25v25H0V250H100V150h50V250H250V125Z"
></glyph
><glyph unicode="Z" d="M250 0H0V125H25v25H150v50H0v50H250V125H225V100H100V50H250V0Z"
></glyph
><glyph unicode="[" horiz-adv-x="150" d="M150 0H0V250H150V200H100V50h50V0Z"
></glyph
><glyph unicode="]" horiz-adv-x="150" d="M150 0H0V50H50V200H0v50H150V0Z"
></glyph
><glyph unicode="a" d="M250 0H150V100H100V0H0V225H25v25H225V225h25V0ZM150 150v50H100V150h50Z"
></glyph
><glyph unicode="b" d="M250 25H225V0H0V250H225V225h25V150H225V100h25V25ZM150 150v50H100V150h50ZM150 50v50H100V50h50Z"
></glyph
><glyph unicode="c" d="M250 0H25V25H0V225H25v25H250V200H100V50H250V0Z"
></glyph
><glyph unicode="d" d="M250 25H225V0H0V250H225V225h25V25ZM150 50V200H100V50h50Z"
></glyph
><glyph unicode="e" d="M250 0H25V25H0V225H25v25H250V200H100V150h75V100H100V50H250V0Z"
></glyph
><glyph unicode="f" d="M250 200H100V150h75V100H100V0H0V225H25v25H250V200Z"
></glyph
><glyph unicode="g" d="M250 0H25V25H0V225H25v25H250V200H100V50h50v50H125v50H250V0Z"
></glyph
><glyph unicode="h" d="M250 0H150V100H100V0H0V250H100V150h50V250H250V0Z"
></glyph
><glyph unicode="i" horiz-adv-x="150" d="M100 0H0V250H100V0Z"
></glyph
><glyph unicode="j" d="M250 25H225V0H0V50H150V250H250V25Z"
></glyph
><glyph unicode="k" d="M250 0H150V100H100V0H0V250H100V150h50V250H250V150H225V100h25V0Z"
></glyph
><glyph unicode="l" d="M250 0H0V250H100V50H250V0Z"
></glyph
><glyph unicode="m" horiz-adv-x="450" d="M400 0H300V200H250V0H150V200H100V0H0V250H375V225h25V0Z"
></glyph
><glyph unicode="n" d="M250 0H150V200H100V0H0V250H225V225h25V0Z"
></glyph
><glyph unicode="o" d="M250 25H225V0H25V25H0V225H25v25H225V225h25V25ZM150 50V200H100V50h50Z"
></glyph
><glyph unicode="p" d="M250 125H225V100H100V0H0V250H225V225h25V125ZM150 150v50H100V150h50Z"
></glyph
><glyph unicode="q" d="M250 25H225V0H25V25H0V225H25v25H225V225h25V25ZM150 50V200H100V50h50Z"
></glyph
><glyph unicode="r" d="M250 0H150V100H100V0H0V250H225V225h25V150H225V100h25V0ZM150 150v50H100V150h50Z"
></glyph
><glyph unicode="s" d="M250 25H225V0H0V50H150v50H25v25H0V225H25v25H250V200H100V150H225V125h25V25Z"
></glyph
><glyph unicode="t" d="M250 200H175V0H75V200H0v50H250V200Z"
></glyph
><glyph unicode="u" d="M250 25H225V0H25V25H0V250H100V50h50V250H250V25Z"
></glyph
><glyph unicode="v" d="M250 25H225V0H0V250H100V50h50V250H250V25Z"
></glyph
><glyph unicode="w" horiz-adv-x="450" d="M400 25H375V0H0V250H100V50h50V250H250V50h50V250H400V25Z"
></glyph
><glyph unicode="x" d="M250 0H150V100H100V0H0V100H25v50H0V250H100V150h50V250H250V150H225V100h25V0Z"
></glyph
><glyph unicode="y" d="M250 125H225V100H175V0H75V100H25v25H0V250H100V150h50V250H250V125Z"
></glyph
><glyph unicode="z" d="M250 0H0V125H25v25H150v50H0v50H250V125H225V100H100V50H250V0Z"
></glyph
></font
></defs
><g style="font-family: &quot;8BIT WONDER&quot;; font-size:50;fill:black"
><text x="20" y="50"
>!&quot;#$%&amp;&#39;()*+,-./0123456789:;&#229;&lt;&gt;?</text
><text x="20" y="100"
>@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_</text
><text x="20" y="150"
>` abcdefghijklmnopqrstuvwxyz|{}~</text
></g
></svg
>

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

View File

@@ -31,6 +31,7 @@ class NekoConnection extends BaseConnection {
socket.output.write(bytes); socket.output.write(bytes);
socket.output.flush(); socket.output.flush();
} catch (e:Dynamic) { } catch (e:Dynamic) {
trace("Error send packet: " + packet);
trace(e); trace(e);
} }
} }

View File

@@ -14,8 +14,8 @@ typedef TankzConfig = {
class DEFAULT { class DEFAULT {
public static var CONFIG:TankzConfig = { public static var CONFIG:TankzConfig = {
map: { map: {
cellWidth: 20, cellWidth: 22,
cellHeight: 20, cellHeight: 22,
gridWidth: 26, gridWidth: 26,
gridHeight: 26 gridHeight: 26
} }

View File

@@ -7,7 +7,7 @@ class Bullet extends MobileEntity {
public function new(personId:Int, id:Int, x:Float, y:Float, speed:Float, direction:Direction) { public function new(personId:Int, id:Int, x:Float, y:Float, speed:Float, direction:Direction) {
super(id, x, y, speed, direction); super(id, x, y, speed, direction);
this.personId = personId; this.personId = personId;
this.width = 10; this.width = 12;
this.height = 10; this.height = 12;
} }
} }

View File

@@ -13,7 +13,7 @@ class Direction {
public var x(default, null):Int; public var x(default, null):Int;
public var y(default, null):Int; public var y(default, null):Int;
public function new(x, y) { private function new(x, y) {
this.x = x; this.x = x;
this.y = y; this.y = y;
directions.set(x + y * 10, this); directions.set(x + y * 10, this);
@@ -22,4 +22,8 @@ class Direction {
public function reverse():Direction { public function reverse():Direction {
return directions.get(-x + (-y) * 10); return directions.get(-x + (-y) * 10);
} }
public static function from(x:Int, y:Int):Direction {
return directions.get(x + y * 10);
}
} }

View File

@@ -14,8 +14,8 @@ class Tank extends MobileEntity {
public function new(personId:Int, id:Int, x:Float, y:Float, direction:Direction) { public function new(personId:Int, id:Int, x:Float, y:Float, direction:Direction) {
super(id, x, y, 4, direction); super(id, x, y, 4, direction);
this.personId = personId; this.personId = personId;
width = 34; width = 36;
height = 34; height = 36;
} }
public function shot():Null<Bullet> { public function shot():Null<Bullet> {

View File

@@ -71,18 +71,18 @@ class Engine implements IEngine {
case GameChangeType.APPEND: case GameChangeType.APPEND:
switch (change.objectType) { switch (change.objectType) {
case GameObjectType.TANK: case GameObjectType.TANK:
var tank:Tank = buildTank(change.personId, change.objectId, change.x, change.y, new Direction(change.directionY, change.directionY)); var tank:Tank = buildTank(change.personId, change.objectId, change.x, change.y, Direction.from(change.directionY, change.directionY));
mobileEntities.set(tank.id, tank); mobileEntities.set(tank.id, tank);
tanks.set(tank.personId, tank); tanks.set(tank.personId, tank);
case GameObjectType.BULLET: case GameObjectType.BULLET:
var bullet:Bullet = new Bullet(change.personId, change.objectId, change.x, change.y, 0, new Direction(change.directionY, change.directionY)); var bullet:Bullet = new Bullet(change.personId, change.objectId, change.x, change.y, 0, Direction.from(change.directionY, change.directionY));
mobileEntities.set(bullet.id, bullet); mobileEntities.set(bullet.id, bullet);
} }
case GameChangeType.DESTROED: case GameChangeType.DESTROED:
mobileEntities.remove(change.objectId); mobileEntities.remove(change.objectId);
case GameChangeType.DIRECTION: case GameChangeType.DIRECTION:
var target = mobileEntities.get(change.objectId); var target = mobileEntities.get(change.objectId);
target.direction = new Direction(change.directionX, change.directionY); target.direction = Direction.from(change.directionX, change.directionY);
case GameChangeType.MOVED: case GameChangeType.MOVED:
var target = mobileEntities.get(change.objectId); var target = mobileEntities.get(change.objectId);
target.x = change.x; target.x = change.x;

View File

@@ -163,7 +163,7 @@ class GameManager {
); );
} }
case GameActionType.MOVE: case GameActionType.MOVE:
tank.move(new Direction(action.directionX, action.directionY)); tank.move(Direction.from(action.directionX, action.directionY));
changes.push(new GameChange() changes.push(new GameChange()
.setType(GameChangeType.DIRECTION) .setType(GameChangeType.DIRECTION)
.setObjectType(GameObjectType.TANK) .setObjectType(GameObjectType.TANK)