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

@ -57,6 +57,7 @@ public class Player extends PhysicsObject{
setSlidingVelocity(164); setSlidingVelocity(164);
setSlidingAcceleration(120); setSlidingAcceleration(120);
setJumpVelocity(PhysicsObject.NORMAL_JUMP_VELOCITY); setJumpVelocity(PhysicsObject.NORMAL_JUMP_VELOCITY);
setGravity(1300);
} }
@Override @Override
@ -212,7 +213,7 @@ public class Player extends PhysicsObject{
break; break;
} }
if (a == Action.ATTACK&&(state==State.IDLE||state==State.FALLING||state==State.JUMP)&&(RabiClone.TIME-weaponSwingTime>=weaponSwingAnimationTime)) { 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; state=State.ATTACK;
weaponSwingTime=RabiClone.TIME; 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 NORMAL_JUMP_VELOCITY = -300;
final public static double WALKING_SPEED_LIMIT = 164; final public static double WALKING_SPEED_LIMIT = 164;
protected State state = State.IDLE; public State state = State.IDLE;
protected double x_velocity,y_velocity; 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_acceleration,y_acceleration;
protected double x_velocity_limit,y_velocity_limit; protected double x_velocity_limit,y_velocity_limit;
protected double x_acceleration_limit,y_acceleration_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) { public void update(double updateMult) {
super.update(updateMult); super.update(updateMult);
handleMovementPhysics(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) { protected void handleMovementPhysics(double updateMult) {
@ -116,7 +125,7 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
if (!groundCollision){ if (!groundCollision){
this.setY(this.getY()+displacement_y); this.setY(this.getY()+displacement_y);
y_acceleration = GRAVITY; y_acceleration = gravity;
if(y_velocity>0 && state!=State.SLIDE){ if(y_velocity>0 && state!=State.SLIDE){
state = State.FALLING; state = State.FALLING;
} }
@ -283,4 +292,12 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
this.jump_velocity=x; 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 setSlidingVelocity(double x);
void setSlidingAcceleration(double x); void setSlidingAcceleration(double x);
void setJumpVelocity(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.Panel;
import sig.engine.Transform; import sig.engine.Transform;
import sig.objects.actor.AttachableObject; 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; import sig.engine.objects.Object;
public class KnifeSwing extends AttachableObject{ public class KnifeSwing extends AttachableObject{
@ -29,6 +32,27 @@ public class KnifeSwing extends AttachableObject{
setY(getAttachedObject().getY()); 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 @Override
public void draw(byte[] p) { public void draw(byte[] p) {
} }

Loading…
Cancel
Save