Physics updates and prepare new moveset setups
Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com> Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
e589a8585e
commit
ec3ff72934
@ -37,6 +37,8 @@ Underwater / Water Dashing (Propelling motion)
|
||||
Side Roll -> Slide
|
||||
Wall Jumping
|
||||
|
||||
Controller Deadzones..
|
||||
|
||||
Movement Systems
|
||||
Collectibles
|
||||
Combat Systems
|
||||
|
@ -56,7 +56,6 @@ public class ConfigureControls extends Object{
|
||||
while (stream.available()>0) {
|
||||
Action a = Action.valueOf(readString(stream));
|
||||
byte port = stream.readByte();
|
||||
System.out.println("PI:"+port);
|
||||
do {
|
||||
if (port==(byte)-1) {
|
||||
int keycode = stream.readInt();
|
||||
@ -64,7 +63,6 @@ public class ConfigureControls extends Object{
|
||||
appendToKeybind(a,kb);
|
||||
} else {
|
||||
java.lang.String controllerName = readString(stream);
|
||||
System.out.println("CONT:"+controllerName);
|
||||
Controller controller=null;
|
||||
for (int i = 0; i < RabiClone.CONTROLLERS.length; i++) {
|
||||
if (RabiClone.CONTROLLERS[i].getType() == Controller.Type.KEYBOARD
|
||||
@ -77,12 +75,10 @@ public class ConfigureControls extends Object{
|
||||
}
|
||||
if (controller==null) {
|
||||
//Discard these bits of data as we didn't find a controller.
|
||||
java.lang.String comName = readString(stream);
|
||||
System.out.println("NULL:"+comName);
|
||||
readString(stream);
|
||||
stream.readFloat();
|
||||
} else {
|
||||
java.lang.String componentName = readString(stream);
|
||||
System.out.println("COM:"+componentName);
|
||||
Component c=null;
|
||||
for (Component cc : controller.getComponents()) {
|
||||
if (cc.getName().equals(componentName)) {
|
||||
@ -100,7 +96,6 @@ public class ConfigureControls extends Object{
|
||||
}
|
||||
}
|
||||
port = stream.readByte();
|
||||
System.out.println("P:"+port);
|
||||
} while (port!=(byte)-2);
|
||||
}
|
||||
updateHighlightSections();
|
||||
|
@ -1,5 +1,8 @@
|
||||
package sig.objects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import sig.RabiClone;
|
||||
import sig.engine.Action;
|
||||
import sig.engine.Panel;
|
||||
@ -21,12 +24,14 @@ public class Player extends PhysicsObject{
|
||||
final static long jump_fall_AnimationWaitTime = TimeUtils.millisToNanos(200);
|
||||
final static long slide_AnimationWaitTime = TimeUtils.millisToNanos(100);
|
||||
final static long slide_duration = TimeUtils.millisToNanos(700);
|
||||
final static long bellySlideDuration = TimeUtils.millisToNanos(1000);
|
||||
final static long bellySlideDuration = TimeUtils.millisToNanos(400);
|
||||
final static long weaponSwingAnimationTime = TimeUtils.millisToNanos(333);
|
||||
final static long weaponComboWaitTime = TimeUtils.millisToNanos(60);
|
||||
final static double finalComboJumpBackSpeedX = -185;
|
||||
final static double finalComboJumpBackSpeedY = -110;
|
||||
|
||||
List<PhysicsObject> collisionBatch = new ArrayList<PhysicsObject>();
|
||||
|
||||
long weaponSwingTime = 0;
|
||||
|
||||
State prvState = state;
|
||||
@ -37,6 +42,7 @@ public class Player extends PhysicsObject{
|
||||
|
||||
boolean spacebarReleased = true;
|
||||
boolean facing_direction = RIGHT;
|
||||
boolean landedBellySlide=false;
|
||||
|
||||
long spacebarPressed = RabiClone.TIME;
|
||||
long jump_slide_fall_StartAnimationTimer = -1;
|
||||
@ -74,6 +80,7 @@ public class Player extends PhysicsObject{
|
||||
public void update(double updateMult) {
|
||||
super.update(updateMult);
|
||||
handleCameraRoomMovement();
|
||||
handleCollisionBatch();
|
||||
|
||||
switch (state) {
|
||||
case ATTACK:
|
||||
@ -163,6 +170,14 @@ public class Player extends PhysicsObject{
|
||||
}
|
||||
break;
|
||||
case BELLYSLIDE:{
|
||||
horizontal_friction = 0;
|
||||
if (y_velocity>0) {
|
||||
bellySlideTime=RabiClone.TIME;
|
||||
}
|
||||
if (groundCollision&&!landedBellySlide){
|
||||
landedBellySlide=true;
|
||||
x_velocity = sliding_velocity*(facing_direction?1:-1);
|
||||
}
|
||||
if (RabiClone.TIME - bellySlideTime > bellySlideDuration) {
|
||||
if (KeyHeld(Action.MOVE_LEFT)) {
|
||||
facing_direction = LEFT;
|
||||
@ -193,12 +208,36 @@ public class Player extends PhysicsObject{
|
||||
}
|
||||
prvState = state;
|
||||
if (KeyHeld(Action.JUMP) && RabiClone.TIME - spacebarPressed < jumpHoldTime
|
||||
&& state!=State.ATTACK2&&state!=State.ATTACK3) {
|
||||
&& state!=State.ATTACK2&&state!=State.ATTACK3&&state!=State.BELLYSLIDE) {
|
||||
y_velocity = jump_velocity;
|
||||
}
|
||||
// System.out.println(state);
|
||||
}
|
||||
|
||||
private void handleCollisionBatch() {
|
||||
for (int p=0;p<collisionBatch.size();p++) {
|
||||
PhysicsObject pobj = collisionBatch.get(p);
|
||||
if(facing_direction){
|
||||
if (state!=State.UNCONTROLLABLE) {
|
||||
setUncontrollable(0.2);
|
||||
}
|
||||
pobj.setStagger(0.3);
|
||||
pobj.setInvulnerability(1);
|
||||
pobj.x_velocity = -300;
|
||||
pobj.y_velocity = -120;
|
||||
}else{
|
||||
if (state!=State.UNCONTROLLABLE) {
|
||||
setUncontrollable(0.2);
|
||||
}
|
||||
pobj.setStagger(0.3);
|
||||
pobj.setInvulnerability(1);
|
||||
pobj.x_velocity = 300;
|
||||
pobj.y_velocity = -120;
|
||||
}
|
||||
}
|
||||
collisionBatch.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void KeyReleased(Action a) {
|
||||
if (a == Action.JUMP) {
|
||||
@ -269,6 +308,9 @@ public class Player extends PhysicsObject{
|
||||
state=State.BELLYSLIDE;
|
||||
y_velocity=y_velocity_limit;
|
||||
x_velocity=60*(facing_direction?1:-1);
|
||||
bellySlideTime=RabiClone.TIME;
|
||||
landedBellySlide=false;
|
||||
spacebarPressed = 0;
|
||||
} else
|
||||
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,40,RabiClone.p,this));
|
||||
@ -402,18 +444,8 @@ public class Player extends PhysicsObject{
|
||||
if (state==State.BELLYSLIDE) {
|
||||
if(obj instanceof PhysicsObject){
|
||||
PhysicsObject pobj = (PhysicsObject)obj;
|
||||
if(pobj.state!=State.STAGGER){
|
||||
if(facing_direction){
|
||||
setUncontrollable(0.2);
|
||||
pobj.setStagger(0.3);
|
||||
pobj.x_velocity = -300;
|
||||
pobj.y_velocity = -120;
|
||||
}else{
|
||||
setUncontrollable(0.2);
|
||||
pobj.setStagger(0.3);
|
||||
pobj.x_velocity = 300;
|
||||
pobj.y_velocity = -120;
|
||||
}
|
||||
if(!pobj.isInvulnerable()){
|
||||
collisionBatch.add(pobj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
|
||||
protected double staggerDuration = 0;
|
||||
protected State resumeState=null;
|
||||
protected double uncontrollableDuration = 0;
|
||||
protected double invulnerabilityDuration = 0;
|
||||
public double y_velocity;
|
||||
protected double gravity = GRAVITY;
|
||||
protected double x_acceleration,y_acceleration;
|
||||
@ -53,6 +54,9 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
|
||||
if(state==State.UNCONTROLLABLE && uncontrollableDuration<=0){
|
||||
state=resumeState;
|
||||
}
|
||||
if (invulnerabilityDuration>0) {
|
||||
invulnerabilityDuration-=updateMult;
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleMovementPhysics(double updateMult) {
|
||||
@ -61,7 +65,7 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
|
||||
}
|
||||
int right = rightKeyHeld()?1:0;
|
||||
int left = leftKeyHeld()?1:0;
|
||||
if(state==State.SLIDE){
|
||||
if(state==State.SLIDE||state==State.BELLYSLIDE){
|
||||
right=0;
|
||||
left=0;
|
||||
}
|
||||
@ -69,12 +73,10 @@ 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;
|
||||
|
||||
@ -107,7 +109,7 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
|
||||
y_acceleration = 0;
|
||||
y_velocity = 0;
|
||||
groundCollision = true;
|
||||
if (state != State.SLIDE) {
|
||||
if (state != State.SLIDE&&state!=State.BELLYSLIDE) {
|
||||
state = State.IDLE;
|
||||
}
|
||||
break;
|
||||
@ -212,6 +214,18 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
|
||||
return sideCollision;
|
||||
}
|
||||
|
||||
/**
|
||||
* How long to set invincibility for this object.
|
||||
* @param duration Amount of time in seconds.
|
||||
*/
|
||||
public void setInvulnerability(double duration) {
|
||||
this.invulnerabilityDuration = duration;
|
||||
}
|
||||
|
||||
public boolean isInvulnerable() {
|
||||
return this.invulnerabilityDuration>0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets how long this object will remain in the stagger state.
|
||||
* Automatically resets the state to the previous state the object
|
||||
@ -220,7 +234,9 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
|
||||
* */
|
||||
public void setStagger(double duration) {
|
||||
staggerDuration=duration;
|
||||
if (state!=State.STAGGER) {
|
||||
resumeState=state;
|
||||
}
|
||||
state=State.STAGGER;
|
||||
}
|
||||
|
||||
@ -232,7 +248,9 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
|
||||
* */
|
||||
public void setUncontrollable(double duration) {
|
||||
uncontrollableDuration=duration;
|
||||
if (state!=State.UNCONTROLLABLE) {
|
||||
resumeState=state;
|
||||
}
|
||||
state=State.UNCONTROLLABLE;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class KnifeSwing extends AttachableObject{
|
||||
public void collisionEvent(AnimatedObject obj) {
|
||||
if(obj instanceof PhysicsObject){
|
||||
PhysicsObject pobj = (PhysicsObject)obj;
|
||||
if(pobj.state!=State.STAGGER){
|
||||
if(!pobj.isInvulnerable()){
|
||||
if(getSpriteTransform()==Transform.NONE){
|
||||
pobj.setStagger(0.3);
|
||||
pobj.x_velocity = -500;
|
||||
|
@ -36,7 +36,7 @@ public class KnifeSwing2 extends AttachableObject{
|
||||
public void collisionEvent(AnimatedObject obj) {
|
||||
if(obj instanceof PhysicsObject){
|
||||
PhysicsObject pobj = (PhysicsObject)obj;
|
||||
if(pobj.state!=State.STAGGER){
|
||||
if(!pobj.isInvulnerable()){
|
||||
if(getSpriteTransform()==Transform.NONE){
|
||||
pobj.setStagger(0.3);
|
||||
pobj.x_velocity = -500;
|
||||
|
Loading…
x
Reference in New Issue
Block a user