diff --git a/bin/RabiClone.jar b/bin/RabiClone.jar index 2c2cbc2..fc7db09 100644 Binary files a/bin/RabiClone.jar and b/bin/RabiClone.jar differ diff --git a/src/sig/objects/LevelRenderer.java b/src/sig/objects/LevelRenderer.java index a6bedf1..0373b4d 100644 --- a/src/sig/objects/LevelRenderer.java +++ b/src/sig/objects/LevelRenderer.java @@ -21,15 +21,20 @@ import sig.map.Tile; import sig.objects.actor.PhysicsObject; import sig.objects.actor.RenderedObject; import sig.objects.actor.State; -import sig.utils.TimeUtils; public class LevelRenderer extends Object{ - final static long staggerJitterWaitTime=TimeUtils.millisToNanos(200); + final static double staggerJitterWaitTime=0.05; - long staggerTimer=0; + double staggerTimer=0; int staggerOffsetX=2; + public final static byte MAX_RIPPLE_SIZE = (byte)4; + public final static byte RIPPLE_CHANCE = (byte)3; + //Ripples will store bit 8 for the direction the ripple is moving. Bits 1-7 are used as the actual value for ripples up to 64 in size (Half used for movement in each direction). + byte[] ripples = new byte[RabiClone.BASE_HEIGHT/MAX_RIPPLE_SIZE]; + long nextRipple = 0; + public LevelRenderer(Panel panel) { super(panel); this.setSprite(Sprite.TILE_SHEET); @@ -52,8 +57,41 @@ public class LevelRenderer extends Object{ } } } - if (RabiClone.TIME-staggerTimer>staggerJitterWaitTime) { + if ((staggerTimer-=updateMult)<=0) { staggerOffsetX*=-1; + staggerTimer=staggerJitterWaitTime; + } + if ((nextRipple-=updateMult)<0) { + if (Math.random()*RIPPLE_CHANCE<1) { + int selectedIndex=((int)Math.random()*ripples.length); + if (ripples[selectedIndex]==0) { + if (Math.random()<0.5) { + ripples[selectedIndex]=(byte)(MAX_RIPPLE_SIZE|0b10000000); + } else { + ripples[selectedIndex]=(byte)(MAX_RIPPLE_SIZE|0b00000000); + } + } + } + for (int i=0;i>>7==1) { + //We are moving left. + ripples[i]=(byte)((ripples[i]&0b10000000)+((ripples[i]&0b1111111)-1)); + if ((ripples[i]&0b1111111)==0) //Flip the sign. + { + ripples[i]=(byte)(((ripples[i]&0b1111111)+1)); + } + } else { + //We are moving right. + ripples[i]=(byte)((ripples[i]&0b10000000)+((ripples[i]&0b1111111)+1)); + if ((ripples[i]&0b1111111)==MAX_RIPPLE_SIZE*2) //Flip the sign. + { + ripples[i]=(byte)((ripples[i]&0b10000000)+((ripples[i]&0b1111111)-1)); + } + } + } + } + nextRipple=1; } }