[engine] remove tank grid align
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tankz",
|
"name": "tankz",
|
||||||
"version": "0.0.5",
|
"version": "0.0.6",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"ansi-colors": "^1.0.1",
|
"ansi-colors": "^1.0.1",
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class Rectangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function contain(point:Point):Bool {
|
public function contain(point:Point):Bool {
|
||||||
return point.x >= x && point.y >= y && point.x <= width && point.y <= height;
|
return point.x >= left && point.y >= top && point.x <= right && point.y <= bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function intersection(rect:Rectangle):Bool {
|
public function intersection(rect:Rectangle):Bool {
|
||||||
@@ -72,6 +72,10 @@ class Rectangle {
|
|||||||
rect.bottom < top);
|
rect.bottom < top);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function intersection2(line:Line):Bool {
|
||||||
|
return contain(line.point1) || contain(line.point2);
|
||||||
|
}
|
||||||
|
|
||||||
public function lean(rect:Rectangle):Void {
|
public function lean(rect:Rectangle):Void {
|
||||||
var side = rect.getSide(direction);
|
var side = rect.getSide(direction);
|
||||||
if (direction.x != 0) {
|
if (direction.x != 0) {
|
||||||
|
|||||||
@@ -188,14 +188,14 @@ class Engine {
|
|||||||
for (ent in entities) if (Std.is(ent, MobileEntity)) {
|
for (ent in entities) if (Std.is(ent, MobileEntity)) {
|
||||||
var entity:MobileEntity = cast ent;
|
var entity:MobileEntity = cast ent;
|
||||||
|
|
||||||
if (Std.is(entity, Tank)) {
|
/*if (Std.is(entity, Tank)) {
|
||||||
if (entity.direction.x != 0) {
|
if (entity.direction.x != 0) {
|
||||||
entity.rect.y = Math.round((entity.rect.y + entity.rect.height / 2) / map.cellHeight) * map.cellHeight - entity.rect.height / 2;
|
entity.rect.y = Math.round((entity.rect.y + entity.rect.height / 2) / map.cellHeight) * map.cellHeight - entity.rect.height / 2;
|
||||||
}
|
}
|
||||||
if (entity.direction.y != 0) {
|
if (entity.direction.y != 0) {
|
||||||
entity.rect.x = Math.round((entity.rect.x + entity.rect.width / 2) / map.cellWidth) * map.cellWidth - entity.rect.width / 2;
|
entity.rect.x = Math.round((entity.rect.x + entity.rect.width / 2) / map.cellWidth) * map.cellWidth - entity.rect.width / 2;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if (entity.mx != 0 || entity.my != 0) {
|
if (entity.mx != 0 || entity.my != 0) {
|
||||||
entity.rect.x += entity.mx * (d / 30);
|
entity.rect.x += entity.mx * (d / 30);
|
||||||
@@ -215,7 +215,8 @@ class Engine {
|
|||||||
|
|
||||||
for (other in entities.iterator()) {
|
for (other in entities.iterator()) {
|
||||||
if (other != ent) {
|
if (other != ent) {
|
||||||
if (ent.rect.intersection(other.rect)) {
|
if (other.rect.intersection2(side)) {
|
||||||
|
//if (ent.rect.intersection(other.rect)) {
|
||||||
var funName = 'collision${ent.type}${other.type}';
|
var funName = 'collision${ent.type}${other.type}';
|
||||||
var fun:Function = Reflect.field(this, funName);
|
var fun:Function = Reflect.field(this, funName);
|
||||||
if (fun != null) {
|
if (fun != null) {
|
||||||
@@ -228,7 +229,7 @@ class Engine {
|
|||||||
if (Std.is(entity, Bullet)) {
|
if (Std.is(entity, Bullet)) {
|
||||||
var bullet:Bullet = cast ent;
|
var bullet:Bullet = cast ent;
|
||||||
if (collision) {
|
if (collision) {
|
||||||
cells = map.grid.getCells(side.setLength(map.grid.cellWidth * 4));
|
cells = map.grid.getCells(side.setLength(map.grid.cellWidth * 3));
|
||||||
for (cell in cells) {
|
for (cell in cells) {
|
||||||
if (cell.armor > 0) {
|
if (cell.armor > 0) {
|
||||||
if (cell.armor == bullet.config.piercing) {
|
if (cell.armor == bullet.config.piercing) {
|
||||||
|
|||||||
Reference in New Issue
Block a user