only draw ripples underwater

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2 3 years ago
parent e3b84fcb3f
commit 118ec8aa61
  1. 16
      src/sig/objects/LevelRenderer.java

@ -66,6 +66,12 @@ public class LevelRenderer extends Object{
staggerOffsetX*=-1; staggerOffsetX*=-1;
staggerTimer=staggerJitterWaitTime; staggerTimer=staggerJitterWaitTime;
} }
if (RabiClone.player!=null&&RabiClone.player.isUnderwater()) {
updateRipples(updateMult);
}
}
private void updateRipples(double updateMult) {
if ((nextRipple-=updateMult)<0) { if ((nextRipple-=updateMult)<0) {
if (Math.random()*RIPPLE_CHANCE<1) { if (Math.random()*RIPPLE_CHANCE<1) {
int selectedIndex=(int)(Math.random()*ripples.length); int selectedIndex=(int)(Math.random()*ripples.length);
@ -104,7 +110,7 @@ public class LevelRenderer extends Object{
} }
nextRipple=0.2; nextRipple=0.2;
} }
} }
@Override @Override
public void draw(byte[] p) { public void draw(byte[] p) {
@ -132,7 +138,13 @@ public class LevelRenderer extends Object{
} }
} }
} }
if (RabiClone.player!=null) { if (RabiClone.player!=null) {
if (RabiClone.player.isUnderwater()) {
drawRipples(p);
}
Draw_Text(4,4,new String(RabiClone.player.getYVelocity()),Font.PROFONT_12); Draw_Text(4,4,new String(RabiClone.player.getYVelocity()),Font.PROFONT_12);
Draw_Text(4,4+Font.PROFONT_12.getGlyphHeight(),new String(RabiClone.scaleTime),Font.PROFONT_12); Draw_Text(4,4+Font.PROFONT_12.getGlyphHeight(),new String(RabiClone.scaleTime),Font.PROFONT_12);
} }
@ -178,7 +190,9 @@ public class LevelRenderer extends Object{
} }
} }
} }
}
private void drawRipples(byte[] p) {
for (int i=0;i<ripples.length;i++) { for (int i=0;i<ripples.length;i++) {
if (ripples[i]!=0) { if (ripples[i]!=0) {
for (int y=-MAX_RIPPLE_SIZE/2;y<MAX_RIPPLE_SIZE/2;y++) { for (int y=-MAX_RIPPLE_SIZE/2;y<MAX_RIPPLE_SIZE/2;y++) {

Loading…
Cancel
Save