[client] gamepad: update SmartActionAreaBuilder

This commit is contained in:
2019-08-27 21:17:26 +03:00
parent 9d4558ca47
commit 0f3392aa0c
5 changed files with 12 additions and 41 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "tankz", "name": "tankz",
"version": "0.16.8", "version": "0.16.9",
"private": true, "private": true,
"devDependencies": { "devDependencies": {
"dateformat": "^3.0.3", "dateformat": "^3.0.3",

View File

@@ -1,31 +0,0 @@
-- mysql -u shmyga -pxkbp8jh9z2 armageddon --protocol TCP
CREATE USER 'shmyga'@'localhost' IDENTIFIED BY 'xkbp8jh9z2';
DROP DATABASE IF EXISTS armageddon;
CREATE DATABASE IF NOT EXISTS armageddon;
GRANT ALL ON armageddon.* TO 'shmyga'@'localhost' IDENTIFIED BY 'xkbp8jh9z2';
DROP TABLE IF EXISTS armageddon.account;
CREATE TABLE IF NOT EXISTS armageddon.account (
id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
login VARCHAR(255) UNIQUE,
password VARCHAR(32)
);
DROP TABLE IF EXISTS armageddon.person;
CREATE TABLE IF NOT EXISTS armageddon.person (
id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
account_id INT UNSIGNED NOT NULL,
name VARCHAR(255),
CONSTRAINT person_2_account FOREIGN KEY (account_id) REFERENCES armageddon.account(id)
MATCH SIMPLE ON DELETE CASCADE ON UPDATE NO ACTION
);
INSERT INTO armageddon.account (id,login,password) VALUES(1,'shmyga', 'd48cc4eb42c058869ae90daef9606e43');
INSERT INTO armageddon.person (id,account_id,name) VALUES(1,1,'-=Shmyga=-');
INSERT INTO armageddon.account (id,login,password) VALUES(2,'a', md5('a'));
INSERT INTO armageddon.person (id,account_id,name) VALUES(2,2,'a');

View File

@@ -50,6 +50,7 @@ class SettingsStorage extends SharedObjectStorage {
MOVE(Direction.RIGHT) => null, MOVE(Direction.RIGHT) => null,
SHOT(0) => null, SHOT(0) => null,
SHOT(1) => null, SHOT(1) => null,
SHOT(2) => null,
]; ];
} }

View File

@@ -13,7 +13,7 @@ views:
- $type: haxework.view.form.ButtonView - $type: haxework.view.form.ButtonView
style: button.close style: button.close
geometry.position: absolute geometry.position: absolute
geometry.hAlign: right geometry.hAlign: left
geometry.vAlign: bottom geometry.vAlign: top
geometry.margin: 10 geometry.margin: 10
+onPress: ~close() +onPress: ~close()

View File

@@ -1,5 +1,6 @@
package ru.m.tankz.view.gamepad; package ru.m.tankz.view.gamepad;
import haxework.view.geometry.Box;
import ru.m.control.DeviceAction; import ru.m.control.DeviceAction;
import ru.m.geom.Circle; import ru.m.geom.Circle;
import ru.m.geom.Direction; import ru.m.geom.Direction;
@@ -12,36 +13,36 @@ class SmartActionAreaBuilder implements IActionAreaBuilder {
public function build(width:Float, height:Float):Array<IActionArea> { public function build(width:Float, height:Float):Array<IActionArea> {
var areas:Array<IActionArea> = []; var areas:Array<IActionArea> = [];
var size = Math.min(width, height) / 5; var size = Math.min(width, height) / 5;
var padding = size / 3; var padding = Box.fromArray([size / 4, size / 3]);
// top // top
areas.push(new RhombusActionArea( areas.push(new RhombusActionArea(
DIRECTION(Direction.TOP), DIRECTION(Direction.TOP),
new Rectangle(padding + size * 0.5, height - size * 2 - padding, size, size ) new Rectangle(padding.left + size * 0.5, height - size * 2 - padding.bottom, size, size )
)); ));
// left // left
areas.push(new RhombusActionArea( areas.push(new RhombusActionArea(
DIRECTION(Direction.LEFT), DIRECTION(Direction.LEFT),
new Rectangle(padding, height - size * 1.5 - padding, size, size) new Rectangle(padding.left, height - size * 1.5 - padding.bottom, size, size)
)); ));
// bottom // bottom
areas.push(new RhombusActionArea( areas.push(new RhombusActionArea(
DIRECTION(Direction.BOTTOM), DIRECTION(Direction.BOTTOM),
new Rectangle(padding + size * 0.5, height - size - padding, size, size) new Rectangle(padding.left + size * 0.5, height - size - padding.bottom, size, size)
)); ));
// right // right
areas.push(new RhombusActionArea( areas.push(new RhombusActionArea(
DIRECTION(Direction.RIGHT), DIRECTION(Direction.RIGHT),
new Rectangle(padding + size, height - size * 1.5 - padding, size, size) new Rectangle(padding.left + size, height - size * 1.5 - padding.bottom, size, size)
)); ));
// key 0 // key 0
areas.push(new CircleActionArea( areas.push(new CircleActionArea(
KEY(0), KEY(0),
new Circle(width - size * 1 - padding, height - size * 0.5 - padding, size / 2) new Circle(width - size * 0.5 - padding.right, height - size * 0.5 - padding.bottom, size / 2)
)); ));
// key 1 // key 1
areas.push(new CircleActionArea( areas.push(new CircleActionArea(
KEY(1), KEY(1),
new Circle(width - size * 1 - padding, height - size * 1.5 - padding, size / 2) new Circle(width - size * 0.5 - padding.right, height - size * 1.5 - padding.bottom, size / 2)
)); ));
return areas; return areas;
} }