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:
parent
faf2310c85
commit
56c6f86505
kumo-core/src/main/java/com/kennycason/kumo/bg
@ -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
|
||||
);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user