From 227468b47499c332776aec9d58be6c298c61a5df Mon Sep 17 00:00:00 2001 From: unknown <45179536+r3cp3ct@users.noreply.github.com> Date: Sat, 18 Jun 2022 09:52:49 +0300 Subject: [PATCH] Fixed weird collision checking Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com> Co-authored-by: sigonasr2 --- Java/scripts/filelist | 4 +- Java/scripts/md5 | 18 ++++---- maps/world1.map | Bin 299028 -> 299012 bytes sig | 2 +- src/sig/objects/Erinoah.java | 4 +- src/sig/objects/Player.java | 4 +- src/sig/objects/actor/PhysicsObject.java | 52 ++++++++++++++--------- utils/filelist | 2 +- utils/md5 | 8 ++-- 9 files changed, 52 insertions(+), 42 deletions(-) diff --git a/Java/scripts/filelist b/Java/scripts/filelist index 9e5004d..36df723 100644 --- a/Java/scripts/filelist +++ b/Java/scripts/filelist @@ -1,9 +1,9 @@ -build2.sh build.sh +build2.sh clean.sh commit.sh -jar2.sh jar.sh +jar2.sh release.sh update.sh version_info diff --git a/Java/scripts/md5 b/Java/scripts/md5 index b2c3eed..6dda21c 100644 --- a/Java/scripts/md5 +++ b/Java/scripts/md5 @@ -1,9 +1,9 @@ -build2.sh:b1c6b7c6b2eb19ba54be6824bda8805b - -build.sh:5df470d49036bf7565493739aeebeaa8 - -clean.sh:668a2f9b568c55f6a044a509315032f6 - -commit.sh:5e4448db9ad48e72ec3a1ff4f5763b41 - -jar2.sh:7977fc138ee5db798d08c34734f0be93 - -jar.sh:821d5a109324d405f05c35c4bb129375 - -release.sh:027178aa6da76180401a188d8f03af64 - -update.sh:3be721658983183efa395984acd96b03 - -zip.sh:273f5a83b80a8e54022d60514dfeec0a - +build.sh:5df470d49036bf7565493739aeebeaa8 *- +build2.sh:b1c6b7c6b2eb19ba54be6824bda8805b *- +clean.sh:668a2f9b568c55f6a044a509315032f6 *- +commit.sh:5e4448db9ad48e72ec3a1ff4f5763b41 *- +jar.sh:821d5a109324d405f05c35c4bb129375 *- +jar2.sh:7977fc138ee5db798d08c34734f0be93 *- +release.sh:027178aa6da76180401a188d8f03af64 *- +update.sh:3be721658983183efa395984acd96b03 *- +zip.sh:273f5a83b80a8e54022d60514dfeec0a *- diff --git a/maps/world1.map b/maps/world1.map index 1432afebbf7dbad5ce09a0bdcff7f9ca2f6300f4..ccabfa51df53fbcba08a683ab3479f0dc66700be 100644 GIT binary patch delta 194 zcmbQTK&WMb&}4-G$;s|65*rmRFfW!bV3{nRBQ)93MGnND%x@#a%)r37SwP}7M3Ucz zOOlZR1Rx}cW`;tB%_<^qnJ3#j*lbkT!aSK#MvRpaD9tumAV+z#z04E-$;(4zHrwkw zVV*1~Au`$8gJ-j|!2@PSpgxno(vv-11c3JOZMF}1#LW$|frEh?h#4pIn8-GJ#M@Dgn(EK0I32o!2kdN diff --git a/sig b/sig index 0cac101..8cecd6a 100755 --- a/sig +++ b/sig @@ -1,4 +1,4 @@ -export AUTO_UPDATE=true +export AUTO_UPDATE=false source utils/define.sh diff --git a/src/sig/objects/Erinoah.java b/src/sig/objects/Erinoah.java index 8d450c8..01aa294 100644 --- a/src/sig/objects/Erinoah.java +++ b/src/sig/objects/Erinoah.java @@ -39,7 +39,7 @@ public class Erinoah extends PhysicsObject implements RenderedObject{ @Override public void update(double updateMult) { super.update(updateMult); - /*lastMoved+=updateMult; + lastMoved+=updateMult; lastJumped+=updateMult; if (lastMoved>5) { switch ((int)(Math.random()*3)) { @@ -64,7 +64,7 @@ public class Erinoah extends PhysicsObject implements RenderedObject{ lastJumped=0; } } - moveTimer-=updateMult;*/ + moveTimer-=updateMult; } @Override diff --git a/src/sig/objects/Player.java b/src/sig/objects/Player.java index 2609969..2cb411a 100644 --- a/src/sig/objects/Player.java +++ b/src/sig/objects/Player.java @@ -52,7 +52,7 @@ public class Player extends PhysicsObject{ setVelocityLimits(246, 500); setGroundDrag(2000); setGroundFriction(PhysicsObject.NORMAL_FRICTION); - setAirDrag(800); + setAirDrag(1000); setAirFriction(180); setSlidingVelocity(164); setSlidingAcceleration(120); @@ -61,7 +61,7 @@ public class Player extends PhysicsObject{ @Override public Rectangle setCollisionBounds() { - return new Rectangle(10,2,12,27); + return new Rectangle(10,6,12,25); } @Override diff --git a/src/sig/objects/actor/PhysicsObject.java b/src/sig/objects/actor/PhysicsObject.java index 9fc6b93..24de1f1 100644 --- a/src/sig/objects/actor/PhysicsObject.java +++ b/src/sig/objects/actor/PhysicsObject.java @@ -1,6 +1,7 @@ package sig.objects.actor; import sig.RabiClone; +import sig.engine.Action; import sig.engine.AnimatedSprite; import sig.engine.Panel; import sig.engine.Rectangle; @@ -22,7 +23,6 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj protected byte maxJumpCount=2; protected byte jumpCount=0; protected double jump_velocity; - protected double horizontal_air_friction,horizontal_air_drag; protected double horizontal_friction,horizontal_drag; protected double sliding_velocity,sliding_acceleration; @@ -58,6 +58,9 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj boolean sideCollision = false; boolean hitAbove=false; + + double startingX=getX(); + if (y_velocity==0) { if (!(checkCollision(getX()-getSprite().getWidth()/2+getCollisionBox().getX2(),getY()-getSprite().getHeight()/2+getCollisionBounds().getY2()+2)|| checkCollision(getX()-getSprite().getWidth()/2+getCollisionBox().getX(),getY()-getSprite().getHeight()/2+getCollisionBounds().getY2()+2))) { @@ -69,12 +72,13 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj } else { double startingY=getY(); groundCollision=false; + if (displacement_y>0) { for (int y=(int)getY();y0 && state!=State.SLIDE){ + state = State.FALLING; + } + if (!sideCollision) { + handleKeyboardMovement(updateMult, right-left, horizontal_air_friction, horizontal_air_drag); + this.setX(this.getX()+displacement_x); + } + } else { + if (!sideCollision) { + handleKeyboardMovement(updateMult, right-left, horizontal_friction, horizontal_drag); + this.setX(this.getX()+displacement_x); + } + } + } + + private boolean sideCollisionChecking(double displacement_x, boolean sideCollision, boolean hitAbove, double startingX) { if (displacement_x>0.00001) { for (int x=(int)getX();x0 && state!=State.SLIDE){ - state = State.FALLING; - } - if (!sideCollision) { - handleKeyboardMovement(updateMult, right-left, horizontal_air_friction, horizontal_air_drag); - this.setX(this.getX()+displacement_x); - } - } else { - if (!sideCollision) { - handleKeyboardMovement(updateMult, right-left, horizontal_friction, horizontal_drag); - this.setX(this.getX()+displacement_x); - } - } + return sideCollision; } protected boolean checkCollision(double x,double y) { diff --git a/utils/filelist b/utils/filelist index 95ad5ff..8a9f471 100644 --- a/utils/filelist +++ b/utils/filelist @@ -1,5 +1,5 @@ .coauthors +.updateDirectories define.sh main.sh search.sh -.updateDirectories diff --git a/utils/md5 b/utils/md5 index baa339d..3ffd1ab 100644 --- a/utils/md5 +++ b/utils/md5 @@ -1,4 +1,4 @@ -define.sh:3ecab0dffe2adfb950f3eb7c7061b750 - -main.sh:d3d1bd0b56d8114eb7479964227f8576 - -search.sh:81d08f5ff48e8a44b5f68387d426da05 - -.updateDirectories:0ede00461e947494545e694040787b3f - +.updateDirectories:0ede00461e947494545e694040787b3f *- +define.sh:3ecab0dffe2adfb950f3eb7c7061b750 *- +main.sh:d3d1bd0b56d8114eb7479964227f8576 *- +search.sh:81d08f5ff48e8a44b5f68387d426da05 *-