Fixed weird collision checking

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
unknown 2 years ago
parent 5e71aee562
commit 227468b474
  1. 4
      Java/scripts/filelist
  2. 18
      Java/scripts/md5
  3. BIN
      maps/world1.map
  4. 2
      sig
  5. 4
      src/sig/objects/Erinoah.java
  6. 4
      src/sig/objects/Player.java
  7. 50
      src/sig/objects/actor/PhysicsObject.java
  8. 2
      utils/filelist
  9. 8
      utils/md5

@ -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

@ -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 *-

Binary file not shown.

2
sig

@ -1,4 +1,4 @@
export AUTO_UPDATE=true
export AUTO_UPDATE=false
source utils/define.sh

@ -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

@ -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

@ -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();y<startingY+displacement_y;y++) {
if (y==getY()) {
continue;
}
if (checkCollision(getX()-getSprite().getWidth()/2+getCollisionBox().getX2()-1,y+getCollisionBox().getY2()-getSprite().getHeight()/2)||
if (checkCollision(getX()-getSprite().getWidth()/2+getCollisionBox().getX2(),y+getCollisionBox().getY2()-getSprite().getHeight()/2)||
checkCollision(getX()-getSprite().getWidth()/2+getCollisionBox().getX()+1,y+getCollisionBox().getY2()-getSprite().getHeight()/2)) {
setY(y-0.1);
//System.out.println("Running"+System.currentTimeMillis());
@ -92,7 +96,7 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
if (y==getY()) {
continue;
}
if (checkCollision(getX()-getSprite().getWidth()/2+getCollisionBox().getX2()-1,y+getCollisionBox().getY()-getSprite().getHeight()/2)||
if (checkCollision(getX()-getSprite().getWidth()/2+getCollisionBox().getX2(),y+getCollisionBox().getY()-getSprite().getHeight()/2)||
checkCollision(getX()-getSprite().getWidth()/2+getCollisionBox().getX()+1,y+getCollisionBox().getY()-getSprite().getHeight()/2)) {
setY(y+1);
hitAbove=true;
@ -107,7 +111,28 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
}
}
double startingX=getX();
sideCollision = sideCollisionChecking(displacement_x, sideCollision, hitAbove, startingX);
if (!groundCollision){
this.setY(this.getY()+displacement_y);
y_acceleration = GRAVITY;
if(y_velocity>0 && 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();x<startingX+displacement_x;x++) {
if (x==getX()) {
@ -162,22 +187,7 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
}
}
}
if (!groundCollision){
this.setY(this.getY()+displacement_y);
y_acceleration = GRAVITY;
if(y_velocity>0 && 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) {

@ -1,5 +1,5 @@
.coauthors
.updateDirectories
define.sh
main.sh
search.sh
.updateDirectories

@ -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 *-

Loading…
Cancel
Save