1
0
mirror of https://github.com/kennycason/kumo synced 2025-03-26 08:48:49 -04:00

fixed the mask of the background

This commit is contained in:
joerg1985 2019-01-26 17:25:19 +01:00
parent faf2310c85
commit 56c6f86505
2 changed files with 7 additions and 16 deletions
kumo-core/src/main/java/com/kennycason/kumo/bg

View File

@ -68,16 +68,15 @@ public class PixelBoundryBackground implements Background {
CollisionRaster rasterOfBackground = background.getCollisionRaster();
for (int y = 0; y < dimensionOfBackground.height; y++) {
if (y > maxY) {
if (y < minY || y > maxY) {
for (int x = 0; x < dimensionOfBackground.width; x++) {
rasterOfBackground.setPixelIsNotTransparent(
position.x + x, position.y + y
);
}
} else {
for (int x = 0; x < dimensionOfBackground.width; x++) {
if (x > maxX || collisionRaster.isTransparent(x, y)) {
if (x < minX || x > maxX || collisionRaster.isTransparent(x, y)) {
rasterOfBackground.setPixelIsNotTransparent(
position.x + x, position.y + y
);

View File

@ -40,28 +40,20 @@ public class RectangleBackground implements Background {
@Override
public void mask(RectanglePixelCollidable background) {
Dimension dimensionOfShape = dimension;
Dimension dimensionOfBackground = background.getDimension();
int minY = Math.max(position.y, 0);
int minX = Math.max(position.x, 0);
int maxY = Math.min(
dimensionOfShape.height - minY,
dimensionOfBackground.height
);
int maxX = Math.min(
dimensionOfShape.width - minX,
dimensionOfBackground.width
);
int maxY = dimensionOfShape.height - position.y - 1;
int maxX = dimensionOfShape.width - position.x - 1;
Dimension dimensionOfBackground = background.getDimension();
CollisionRaster rasterOfBackground = background.getCollisionRaster();
for (int y = 0; y < dimensionOfBackground.height; y++) {
for (int x = 0; x < dimensionOfBackground.width; x++) {
if ((y < minY) || (y >= maxY) || (x < minX) || (x >= maxX)) {
rasterOfBackground.setPixelIsNotTransparent(
position.x + x, position.y + y
);
if ((y < minY) || (y > maxY) || (x < minX) || (x > maxX)) {
rasterOfBackground.setPixelIsNotTransparent(x, y);
}
}
}