Setup framework for screen door transparency

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2, Sig, Sigo 2 years ago committed by GitHub
parent 2c9357ab6a
commit b2dda88107
  1. BIN
      bin/RabiClone.jar
  2. 46
      src/sig/DrawLoop.java
  3. 35
      src/sig/engine/Alpha.java

Binary file not shown.

@ -164,48 +164,16 @@ public class DrawLoop {
boolean horizontal = transform==Transform.HORIZONTAL||transform==Transform.HORIZ_VERTIC;
boolean vertical = transform==Transform.VERTICAL||transform==Transform.HORIZ_VERTIC;
byte[] p = panel.pixel;
if (transform==Transform.NONE&&col==PaletteColor.NORMAL) {
int transparentTotalCount=alpha.getB();
int transparentRunCount=0;
for(int X=(int)xOffset;X<(int)(w+xOffset);X++){
for(int Y=(int)yOffset;Y<(int)(h+yOffset);Y++){
if (X+x-xOffset<0||Y+y-yOffset<0||X-xOffset+x>=RabiClone.BASE_WIDTH||Y-yOffset+y>=RabiClone.BASE_HEIGHT) {
continue;
} else {
int index = ((int)y)*RabiClone.BASE_WIDTH+(int)x;
if (sprite.getBi_array()[Y*sprite.getCanvasWidth()+X]==32||index<0||index>=p.length) {
continue;
} else {
Draw(p,index,sprite.getBi_array()[Y*sprite.getCanvasWidth()+X],alpha);
}
}
}
}
} else
if (col==PaletteColor.NORMAL) {
for(int X=(int)xOffset;X<(int)(w+xOffset);X++){
for(int Y=(int)yOffset;Y<(int)(h+yOffset);Y++){
if (X+x-xOffset<0||Y+y-yOffset<0||X-xOffset+x>=RabiClone.BASE_WIDTH||Y-yOffset+y>=RabiClone.BASE_HEIGHT) {
continue;
} else {
int index =
((vertical?
sprite.getHeight()-(Y-(int)yOffset):
(Y-(int)yOffset))
+(int)y)*RabiClone.BASE_WIDTH+
(horizontal?
sprite.getWidth()-(X-(int)xOffset):
(X-(int)xOffset))
+(int)x;
if (sprite.getBi_array()[Y*sprite.getCanvasWidth()+X]==32||index<0||index>=p.length) {
if (alpha!=Alpha.ALPHA0) {
if (transparentRunCount++==transparentTotalCount) {
transparentRunCount=0;
continue;
} else {
Draw(p,index,sprite.getBi_array()[Y*sprite.getCanvasWidth()+X],alpha);
}
}
}
}
} else {
for(int X=(int)xOffset;X<(int)(w+xOffset);X++){
for(int Y=(int)yOffset;Y<(int)(h+yOffset);Y++){
if (X+x-xOffset<0||Y+y-yOffset<0||X-xOffset+x>=RabiClone.BASE_WIDTH||Y-yOffset+y>=RabiClone.BASE_HEIGHT) {
continue;
} else {
@ -218,11 +186,11 @@ public class DrawLoop {
sprite.getWidth()-(X-(int)xOffset):
(X-(int)xOffset))
+(int)x;
if (sprite.getBi_array()[Y*sprite.getCanvasWidth()+X]==32||index<0||index>=p.length) {
continue;
} else {
Draw(p,index,(byte)col.ordinal(),alpha);
}
Draw(p,index,(col==PaletteColor.NORMAL)?sprite.getBi_array()[Y*sprite.getCanvasWidth()+X]:(byte)col.ordinal(),alpha);
}
}
}

@ -1,13 +1,30 @@
package sig.engine;
public enum Alpha {
ALPHA0,
ALPHA32,
ALPHA64,
ALPHA96,
ALPHA128,
ALPHA160,
ALPHA192,
ALPHA224,
ALPHA256;
ALPHA0(1,1),
ALPHA32(7,8), //7/8
ALPHA64(3,4), //3/4
ALPHA96(5,8), //5/8
ALPHA128(1,2), //1/2
ALPHA160(3,8), //3/8
ALPHA192(1,4), //1/4
ALPHA224(1,8), //1/8
ALPHA256(0,8); //0/8
int A,B;
/** For every B pixels, A are visible.*/
Alpha(int A,int B) {
this.A=A;
this.B=B;
}
public int getA() {
return A;
}
public int getB() {
return B;
}
}

Loading…
Cancel
Save