Implement physics and collisions related to belly sliding

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2, Sig, Sigo 2 years ago
parent 859b05aba1
commit 2356d42495
  1. 23
      src/sig/objects/Player.java
  2. 5
      src/sig/objects/actor/PhysicsObject.java
  3. 1
      src/sig/objects/weapons/KnifeSwing.java
  4. 1
      src/sig/objects/weapons/KnifeSwing2.java

@ -6,6 +6,7 @@ import sig.engine.Panel;
import sig.engine.Rectangle;
import sig.engine.Sprite;
import sig.engine.Transform;
import sig.engine.objects.AnimatedObject;
import sig.map.Map;
import sig.map.Tile;
import sig.map.View;
@ -396,6 +397,28 @@ public class Player extends PhysicsObject{
RabiClone.level_renderer.setY(newY < 0 ? 0 : newY);
}
@Override
public void collisionEvent(AnimatedObject obj) {
if (state==State.BELLYSLIDE) {
if(obj instanceof PhysicsObject){
PhysicsObject pobj = (PhysicsObject)obj;
if(pobj.state!=State.STAGGER){
if(facing_direction){
pobj.staggerDuration=0.3;
pobj.x_velocity = -300;
pobj.y_velocity = -120;
pobj.state = State.STAGGER;
}else{
pobj.staggerDuration=0.3;
pobj.x_velocity = 300;
pobj.y_velocity = -120;
pobj.state = State.STAGGER;
}
}
}
}
}
@Override
public void draw(byte[] p) {
}

@ -61,10 +61,12 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
Math.abs(x_velocity+x_acceleration*updateMult)>x_velocity_limit
?Math.signum(x_velocity+x_acceleration*updateMult)*x_velocity_limit
:x_velocity+x_acceleration*updateMult;
if (state!=State.BELLYSLIDE) {
y_velocity =
Math.abs(y_velocity+y_acceleration*updateMult)>y_velocity_limit
?Math.signum(y_velocity+y_acceleration*updateMult)*y_velocity_limit
:y_velocity+y_acceleration*updateMult;
}
double displacement_y = y_velocity*updateMult;
double displacement_x = x_velocity*updateMult;
@ -132,9 +134,6 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
if(y_velocity>0 && state!=State.SLIDE&&state!=State.BELLYSLIDE){
state = State.FALLING;
}
if (y_velocity>FALLING_SPEED_LIMIT&&state!=State.BELLYSLIDE) {
y_velocity=FALLING_SPEED_LIMIT;
}
if (!sideCollision) {
handleKeyboardMovement(updateMult, right-left, horizontal_air_friction, horizontal_air_drag);
this.setX(this.getX()+displacement_x);

@ -34,7 +34,6 @@ public class KnifeSwing extends AttachableObject{
@Override
public void collisionEvent(AnimatedObject obj) {
//System.out.println("Bonk");
if(obj instanceof PhysicsObject){
PhysicsObject pobj = (PhysicsObject)obj;
if(pobj.state!=State.STAGGER){

@ -34,7 +34,6 @@ public class KnifeSwing2 extends AttachableObject{
@Override
public void collisionEvent(AnimatedObject obj) {
//System.out.println("Bonk");
if(obj instanceof PhysicsObject){
PhysicsObject pobj = (PhysicsObject)obj;
if(pobj.state!=State.STAGGER){

Loading…
Cancel
Save