Bonk the buns now

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
unknown 2 years ago
parent 4b2d056488
commit d05007ad6b
  1. BIN
      maps/world1.map
  2. 5
      src/sig/objects/Erinoah.java
  3. 3
      src/sig/objects/Player.java
  4. 23
      src/sig/objects/actor/PhysicsObject.java
  5. 1
      src/sig/objects/actor/PhysicsObjectRequirements.java
  6. 24
      src/sig/objects/weapons/KnifeSwing.java

Binary file not shown.

@ -9,7 +9,7 @@ import sig.objects.actor.PhysicsObject;
import sig.objects.actor.RenderedObject;
import sig.objects.weapons.KnifeSwing;
public class Erinoah extends PhysicsObject implements RenderedObject{
public class Erinoah extends PhysicsObject{
double lastMoved = 0;
double lastJumped = 0;
@ -21,7 +21,7 @@ public class Erinoah extends PhysicsObject implements RenderedObject{
setX(x);
setY(y);
setAccelerationLimits(100, 100);
setVelocityLimits(246, 500);
setVelocityLimits(500, 500);
setGroundDrag(2000);
setGroundFriction(PhysicsObject.NORMAL_FRICTION);
setAirDrag(800);
@ -29,6 +29,7 @@ public class Erinoah extends PhysicsObject implements RenderedObject{
setSlidingVelocity(164);
setSlidingAcceleration(120);
setJumpVelocity(PhysicsObject.NORMAL_JUMP_VELOCITY);
setGravity(450);
}
@Override

@ -57,6 +57,7 @@ public class Player extends PhysicsObject{
setSlidingVelocity(164);
setSlidingAcceleration(120);
setJumpVelocity(PhysicsObject.NORMAL_JUMP_VELOCITY);
setGravity(1300);
}
@Override
@ -212,7 +213,7 @@ public class Player extends PhysicsObject{
break;
}
if (a == Action.ATTACK&&(state==State.IDLE||state==State.FALLING||state==State.JUMP)&&(RabiClone.TIME-weaponSwingTime>=weaponSwingAnimationTime)) {
RabiClone.OBJ.add(new KnifeSwing(Sprite.KNIFE_SWING,15,RabiClone.p,this));
RabiClone.OBJ.add(new KnifeSwing(Sprite.KNIFE_SWING,40,RabiClone.p,this));
state=State.ATTACK;
weaponSwingTime=RabiClone.TIME;
}

@ -14,8 +14,11 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
final public static double NORMAL_JUMP_VELOCITY = -300;
final public static double WALKING_SPEED_LIMIT = 164;
protected State state = State.IDLE;
protected double x_velocity,y_velocity;
public State state = State.IDLE;
public double x_velocity;
public double staggerDuration = 0;
public double y_velocity;
protected double gravity = GRAVITY;
protected double x_acceleration,y_acceleration;
protected double x_velocity_limit,y_velocity_limit;
protected double x_acceleration_limit,y_acceleration_limit;
@ -36,6 +39,12 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
public void update(double updateMult) {
super.update(updateMult);
handleMovementPhysics(updateMult);
if(state==State.STAGGER && staggerDuration>0){
staggerDuration-=updateMult;
}else
if(state==State.STAGGER && staggerDuration<=0){
state=State.IDLE;
}
}
protected void handleMovementPhysics(double updateMult) {
@ -116,7 +125,7 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
if (!groundCollision){
this.setY(this.getY()+displacement_y);
y_acceleration = GRAVITY;
y_acceleration = gravity;
if(y_velocity>0 && state!=State.SLIDE){
state = State.FALLING;
}
@ -283,4 +292,12 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
this.jump_velocity=x;
}
@Override
public void setGravity(double gravity) {
this.gravity = gravity;
}
public double getGravity() {
return gravity;
}
}

@ -17,4 +17,5 @@ public interface PhysicsObjectRequirements {
void setSlidingVelocity(double x);
void setSlidingAcceleration(double x);
void setJumpVelocity(double x);
void setGravity(double gravity);
}

@ -4,6 +4,9 @@ import sig.engine.AnimatedSprite;
import sig.engine.Panel;
import sig.engine.Transform;
import sig.objects.actor.AttachableObject;
import sig.objects.actor.PhysicsObject;
import sig.objects.actor.State;
import sig.engine.objects.AnimatedObject;
import sig.engine.objects.Object;
public class KnifeSwing extends AttachableObject{
@ -29,6 +32,27 @@ public class KnifeSwing extends AttachableObject{
setY(getAttachedObject().getY());
}
@Override
public void collisionEvent(AnimatedObject obj) {
System.out.println("Bonk");
if(obj instanceof PhysicsObject){
PhysicsObject pobj = (PhysicsObject)obj;
if(pobj.state!=State.STAGGER){
if(getSpriteTransform()==Transform.NONE){
pobj.staggerDuration=0.3;
pobj.x_velocity = -300;
pobj.y_velocity = -300;
pobj.state = State.STAGGER;
}else{
pobj.staggerDuration=0.3;
pobj.x_velocity = 300;
pobj.y_velocity = -300;
pobj.state = State.STAGGER;
}
}
}
}
@Override
public void draw(byte[] p) {
}

Loading…
Cancel
Save