Merge
This commit is contained in:
commit
94bf7406e6
@ -37,6 +37,8 @@ Underwater / Water Dashing (Propelling motion)
|
|||||||
Side Roll -> Slide
|
Side Roll -> Slide
|
||||||
Wall Jumping
|
Wall Jumping
|
||||||
|
|
||||||
|
Controller Deadzones..
|
||||||
|
|
||||||
Movement Systems
|
Movement Systems
|
||||||
Collectibles
|
Collectibles
|
||||||
Combat Systems
|
Combat Systems
|
||||||
|
Binary file not shown.
Binary file not shown.
BIN
bin/controls.config
Normal file
BIN
bin/controls.config
Normal file
Binary file not shown.
@ -140,6 +140,7 @@ public class RabiClone implements ControllerListener{
|
|||||||
long dt = 0;
|
long dt = 0;
|
||||||
|
|
||||||
CONTROLLERS = ControllerEnvironment.getDefaultEnvironment().getControllers();
|
CONTROLLERS = ControllerEnvironment.getDefaultEnvironment().getControllers();
|
||||||
|
ConfigureControls.LoadControls();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
dt += System.nanoTime() - lastGameTime;
|
dt += System.nanoTime() - lastGameTime;
|
||||||
@ -268,6 +269,18 @@ public class RabiClone implements ControllerListener{
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!CONTROLLERS[i].poll()) {
|
if (!CONTROLLERS[i].poll()) {
|
||||||
|
if (control_settings_menu!=null) {
|
||||||
|
for (Action a : Action.values()) {
|
||||||
|
List<KeyBind> binds = KeyBind.KEYBINDS.get(a);
|
||||||
|
for (int j=0;j<binds.size();j++) {
|
||||||
|
if (binds.get(j).port==i) {
|
||||||
|
binds.remove(j--);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
KeyBind.KEYBINDS.put(a,binds);
|
||||||
|
ConfigureControls.updateHighlightSections();
|
||||||
|
}
|
||||||
|
}
|
||||||
Controller[] newArr = new Controller[CONTROLLERS.length - 1];
|
Controller[] newArr = new Controller[CONTROLLERS.length - 1];
|
||||||
for (int j = 0; j < CONTROLLERS.length; j++) {
|
for (int j = 0; j < CONTROLLERS.length; j++) {
|
||||||
if (j != i) {
|
if (j != i) {
|
||||||
|
@ -65,7 +65,8 @@ public class KeyBind {
|
|||||||
return Math.abs(RabiClone.CONTROLLERS[port].getComponent(id).getPollData())>=RabiClone.CONTROLLERS[port].getComponent(id).getDeadZone()&&Math.signum(RabiClone.CONTROLLERS[port].getComponent(id).getPollData())==Math.signum(val);
|
return Math.abs(RabiClone.CONTROLLERS[port].getComponent(id).getPollData())>=RabiClone.CONTROLLERS[port].getComponent(id).getDeadZone()&&Math.signum(RabiClone.CONTROLLERS[port].getComponent(id).getPollData())==Math.signum(val);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new UnsupportedOperationException("Could not find proper recognition for component "+id.getName());
|
return false;
|
||||||
|
//throw new UnsupportedOperationException("Could not find proper recognition for component "+id.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,6 @@ public class ConfigureControls extends Object{
|
|||||||
//Discard these bits of data as we didn't find a controller.
|
//Discard these bits of data as we didn't find a controller.
|
||||||
readString(stream);
|
readString(stream);
|
||||||
stream.readFloat();
|
stream.readFloat();
|
||||||
continue;
|
|
||||||
} else {
|
} else {
|
||||||
java.lang.String componentName = readString(stream);
|
java.lang.String componentName = readString(stream);
|
||||||
Component c=null;
|
Component c=null;
|
||||||
@ -97,7 +96,7 @@ public class ConfigureControls extends Object{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
port = stream.readByte();
|
port = stream.readByte();
|
||||||
} while (port!='\0');
|
} while (port!=(byte)-2);
|
||||||
}
|
}
|
||||||
updateHighlightSections();
|
updateHighlightSections();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -130,6 +129,7 @@ public class ConfigureControls extends Object{
|
|||||||
for (Action a : Action.values()) {
|
for (Action a : Action.values()) {
|
||||||
writeString(a.name(),stream);
|
writeString(a.name(),stream);
|
||||||
for (KeyBind k : KeyBind.KEYBINDS.get(a)) {
|
for (KeyBind k : KeyBind.KEYBINDS.get(a)) {
|
||||||
|
if (k.port==-1||k.port<RabiClone.CONTROLLERS.length) {
|
||||||
stream.writeByte(k.port);
|
stream.writeByte(k.port);
|
||||||
if (k.port==(byte)-1) {
|
if (k.port==(byte)-1) {
|
||||||
stream.writeInt(((Key)k.id).getKeyCode());
|
stream.writeInt(((Key)k.id).getKeyCode());
|
||||||
@ -139,7 +139,8 @@ public class ConfigureControls extends Object{
|
|||||||
stream.writeFloat(k.getVal());
|
stream.writeFloat(k.getVal());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stream.writeByte('\0');
|
}
|
||||||
|
stream.writeByte((byte)-2);
|
||||||
}
|
}
|
||||||
stream.close();
|
stream.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -152,7 +153,7 @@ public class ConfigureControls extends Object{
|
|||||||
stream.writeChar('\0');
|
stream.writeChar('\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void updateHighlightSections() {
|
public static void updateHighlightSections() {
|
||||||
for (int i=0;i<Action.values().length;i++) {
|
for (int i=0;i<Action.values().length;i++) {
|
||||||
Action a = Action.values()[i];
|
Action a = Action.values()[i];
|
||||||
actionHighlightSections.add(new ArrayList<Integer>());
|
actionHighlightSections.add(new ArrayList<Integer>());
|
||||||
|
@ -18,10 +18,18 @@ import sig.map.Background;
|
|||||||
import sig.map.DataTile;
|
import sig.map.DataTile;
|
||||||
import sig.map.Map;
|
import sig.map.Map;
|
||||||
import sig.map.Tile;
|
import sig.map.Tile;
|
||||||
|
import sig.objects.actor.PhysicsObject;
|
||||||
import sig.objects.actor.RenderedObject;
|
import sig.objects.actor.RenderedObject;
|
||||||
|
import sig.objects.actor.State;
|
||||||
|
import sig.utils.TimeUtils;
|
||||||
|
|
||||||
public class LevelRenderer extends Object{
|
public class LevelRenderer extends Object{
|
||||||
|
|
||||||
|
final static long staggerJitterWaitTime=TimeUtils.millisToNanos(200);
|
||||||
|
|
||||||
|
long staggerTimer=0;
|
||||||
|
int staggerOffsetX=2;
|
||||||
|
|
||||||
public LevelRenderer(Panel panel) {
|
public LevelRenderer(Panel panel) {
|
||||||
super(panel);
|
super(panel);
|
||||||
this.setSprite(Sprite.TILE_SHEET);
|
this.setSprite(Sprite.TILE_SHEET);
|
||||||
@ -44,6 +52,9 @@ public class LevelRenderer extends Object{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (RabiClone.TIME-staggerTimer>staggerJitterWaitTime) {
|
||||||
|
staggerOffsetX*=-1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -138,8 +149,13 @@ public class LevelRenderer extends Object{
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void Draw_Animated_Object(AnimatedObject object, Transform transform){
|
protected void Draw_Animated_Object(AnimatedObject object, Transform transform){
|
||||||
|
if (object instanceof PhysicsObject) {
|
||||||
|
PhysicsObject po = (PhysicsObject)object;
|
||||||
|
super.Draw_Animated_Sprite(object.getX()-this.getX()-object.getAnimatedSpr().getWidth()/2+(po.state==State.STAGGER?staggerOffsetX:0), Math.round(object.getY()-this.getY()-object.getAnimatedSpr().getHeight()/2), object.getAnimatedSpr(), object.getCurrentFrame(), transform);
|
||||||
|
} else {
|
||||||
super.Draw_Animated_Sprite(object.getX()-this.getX()-object.getAnimatedSpr().getWidth()/2, Math.round(object.getY()-this.getY()-object.getAnimatedSpr().getHeight()/2), object.getAnimatedSpr(), object.getCurrentFrame(), transform);
|
super.Draw_Animated_Sprite(object.getX()-this.getX()-object.getAnimatedSpr().getWidth()/2, Math.round(object.getY()-this.getY()-object.getAnimatedSpr().getHeight()/2), object.getAnimatedSpr(), object.getCurrentFrame(), transform);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void DrawTile(double x, double y, Tile tile) {
|
private void DrawTile(double x, double y, Tile tile) {
|
||||||
Draw_Sprite_Partial(x,y, tile.getSpriteSheetX()*tile.getTileWidth(), tile.getSpriteSheetY()*tile.getTileHeight(), tile.getTileWidth(), tile.getTileHeight(), getSprite(), 0, Transform.NONE);
|
Draw_Sprite_Partial(x,y, tile.getSpriteSheetX()*tile.getTileWidth(), tile.getSpriteSheetY()*tile.getTileHeight(), tile.getTileWidth(), tile.getTileHeight(), getSprite(), 0, Transform.NONE);
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
package sig.objects;
|
package sig.objects;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import sig.RabiClone;
|
import sig.RabiClone;
|
||||||
import sig.engine.Action;
|
import sig.engine.Action;
|
||||||
import sig.engine.Panel;
|
import sig.engine.Panel;
|
||||||
import sig.engine.Rectangle;
|
import sig.engine.Rectangle;
|
||||||
import sig.engine.Sprite;
|
import sig.engine.Sprite;
|
||||||
import sig.engine.Transform;
|
import sig.engine.Transform;
|
||||||
|
import sig.engine.objects.AnimatedObject;
|
||||||
import sig.map.Map;
|
import sig.map.Map;
|
||||||
import sig.map.Tile;
|
import sig.map.Tile;
|
||||||
import sig.map.View;
|
import sig.map.View;
|
||||||
@ -20,7 +24,13 @@ public class Player extends PhysicsObject{
|
|||||||
final static long jump_fall_AnimationWaitTime = TimeUtils.millisToNanos(200);
|
final static long jump_fall_AnimationWaitTime = TimeUtils.millisToNanos(200);
|
||||||
final static long slide_AnimationWaitTime = TimeUtils.millisToNanos(100);
|
final static long slide_AnimationWaitTime = TimeUtils.millisToNanos(100);
|
||||||
final static long slide_duration = TimeUtils.millisToNanos(700);
|
final static long slide_duration = TimeUtils.millisToNanos(700);
|
||||||
|
final static long bellySlideDuration = TimeUtils.millisToNanos(400);
|
||||||
final static long weaponSwingAnimationTime = TimeUtils.millisToNanos(333);
|
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;
|
long weaponSwingTime = 0;
|
||||||
|
|
||||||
@ -32,11 +42,13 @@ public class Player extends PhysicsObject{
|
|||||||
|
|
||||||
boolean spacebarReleased = true;
|
boolean spacebarReleased = true;
|
||||||
boolean facing_direction = RIGHT;
|
boolean facing_direction = RIGHT;
|
||||||
|
boolean landedBellySlide=false;
|
||||||
|
|
||||||
long spacebarPressed = RabiClone.TIME;
|
long spacebarPressed = RabiClone.TIME;
|
||||||
long jump_slide_fall_StartAnimationTimer = -1;
|
long jump_slide_fall_StartAnimationTimer = -1;
|
||||||
long slide_time = -1;
|
long slide_time = -1;
|
||||||
long jumpHoldTime = TimeUtils.millisToNanos(150);
|
long jumpHoldTime = TimeUtils.millisToNanos(150);
|
||||||
|
long bellySlideTime = -1;
|
||||||
|
|
||||||
final static long slideBufferTime = TimeUtils.millisToNanos(200);
|
final static long slideBufferTime = TimeUtils.millisToNanos(200);
|
||||||
long slidePressed = -1;
|
long slidePressed = -1;
|
||||||
@ -68,6 +80,7 @@ public class Player extends PhysicsObject{
|
|||||||
public void update(double updateMult) {
|
public void update(double updateMult) {
|
||||||
super.update(updateMult);
|
super.update(updateMult);
|
||||||
handleCameraRoomMovement();
|
handleCameraRoomMovement();
|
||||||
|
handleCollisionBatch();
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case ATTACK:
|
case ATTACK:
|
||||||
@ -75,6 +88,16 @@ public class Player extends PhysicsObject{
|
|||||||
state=State.IDLE;
|
state=State.IDLE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ATTACK2:
|
||||||
|
if (RabiClone.TIME - weaponSwingTime > weaponSwingAnimationTime) {
|
||||||
|
state=State.IDLE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ATTACK3:
|
||||||
|
if (RabiClone.TIME - weaponSwingTime > weaponSwingAnimationTime) {
|
||||||
|
state=State.IDLE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case FALLING:
|
case FALLING:
|
||||||
if (prvState != State.FALLING) {
|
if (prvState != State.FALLING) {
|
||||||
jump_slide_fall_StartAnimationTimer = RabiClone.TIME;
|
jump_slide_fall_StartAnimationTimer = RabiClone.TIME;
|
||||||
@ -87,7 +110,7 @@ public class Player extends PhysicsObject{
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IDLE:
|
case IDLE:
|
||||||
if (RabiClone.TIME - slidePressed <= slideBufferTime) {
|
if (RabiClone.TIME - slidePressed <= slideBufferTime && state!=State.BELLYSLIDE) {
|
||||||
performSlide();
|
performSlide();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -108,9 +131,6 @@ public class Player extends PhysicsObject{
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case JUMP:
|
case JUMP:
|
||||||
if (prvState == State.SLIDE) {
|
|
||||||
// jump_velocity=-500;
|
|
||||||
}
|
|
||||||
if (jump_slide_fall_StartAnimationTimer == -1) {
|
if (jump_slide_fall_StartAnimationTimer == -1) {
|
||||||
jump_slide_fall_StartAnimationTimer = RabiClone.TIME;
|
jump_slide_fall_StartAnimationTimer = RabiClone.TIME;
|
||||||
setAnimatedSpr(Sprite.ERINA_JUMP_RISE1);
|
setAnimatedSpr(Sprite.ERINA_JUMP_RISE1);
|
||||||
@ -149,6 +169,36 @@ public class Player extends PhysicsObject{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
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;
|
||||||
|
}
|
||||||
|
if (KeyHeld(Action.MOVE_RIGHT)) {
|
||||||
|
facing_direction = RIGHT;
|
||||||
|
}
|
||||||
|
state = State.IDLE;
|
||||||
|
}
|
||||||
|
if (KeyHeld(Action.MOVE_LEFT) && !KeyHeld(Action.MOVE_RIGHT)) {
|
||||||
|
if (facing_direction == LEFT && x_velocity > -sliding_velocity * 1.5 ||
|
||||||
|
facing_direction == RIGHT && x_velocity > sliding_velocity * 0.5) {
|
||||||
|
x_velocity -= sliding_acceleration * updateMult;
|
||||||
|
}
|
||||||
|
} else if (KeyHeld(Action.MOVE_RIGHT) && !KeyHeld(Action.MOVE_LEFT)) {
|
||||||
|
if (facing_direction == LEFT && x_velocity < -sliding_velocity * 0.5 ||
|
||||||
|
facing_direction == RIGHT && x_velocity < sliding_velocity * 1.5) {
|
||||||
|
x_velocity += sliding_acceleration * updateMult;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}break;
|
||||||
case STAGGER:
|
case STAGGER:
|
||||||
break;
|
break;
|
||||||
case UNCONTROLLABLE:
|
case UNCONTROLLABLE:
|
||||||
@ -157,19 +207,44 @@ public class Player extends PhysicsObject{
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
prvState = state;
|
prvState = state;
|
||||||
if (KeyHeld(Action.JUMP) && RabiClone.TIME - spacebarPressed < jumpHoldTime) {
|
if (KeyHeld(Action.JUMP) && RabiClone.TIME - spacebarPressed < jumpHoldTime
|
||||||
|
&& state!=State.ATTACK2&&state!=State.ATTACK3&&state!=State.BELLYSLIDE) {
|
||||||
y_velocity = jump_velocity;
|
y_velocity = jump_velocity;
|
||||||
}
|
}
|
||||||
// System.out.println(state);
|
// 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
|
@Override
|
||||||
public void KeyReleased(Action a) {
|
public void KeyReleased(Action a) {
|
||||||
if (a == Action.JUMP) {
|
if (a == Action.JUMP) {
|
||||||
spacebarPressed = 0;
|
spacebarPressed = 0;
|
||||||
spacebarReleased = true;
|
spacebarReleased = true;
|
||||||
}
|
}
|
||||||
if (state != State.SLIDE) {
|
if (state != State.SLIDE&&state!=State.BELLYSLIDE) {
|
||||||
if ((a == Action.MOVE_LEFT) && (KeyHeld(Action.MOVE_RIGHT))) {
|
if ((a == Action.MOVE_LEFT) && (KeyHeld(Action.MOVE_RIGHT))) {
|
||||||
facing_direction = RIGHT;
|
facing_direction = RIGHT;
|
||||||
} else if ((a == Action.MOVE_RIGHT) && (KeyHeld(Action.MOVE_LEFT))) {
|
} else if ((a == Action.MOVE_RIGHT) && (KeyHeld(Action.MOVE_LEFT))) {
|
||||||
@ -183,6 +258,24 @@ public class Player extends PhysicsObject{
|
|||||||
public void KeyPressed(Action a) {
|
public void KeyPressed(Action a) {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case ATTACK:
|
case ATTACK:
|
||||||
|
if (a==Action.ATTACK&&RabiClone.TIME-weaponSwingTime>weaponComboWaitTime) {
|
||||||
|
state=State.ATTACK2;
|
||||||
|
weaponSwingTime=RabiClone.TIME;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ATTACK2:
|
||||||
|
if (a==Action.ATTACK&&RabiClone.TIME-weaponSwingTime>weaponComboWaitTime) {
|
||||||
|
state=State.ATTACK3;
|
||||||
|
weaponSwingTime=RabiClone.TIME;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ATTACK3:
|
||||||
|
if (a==Action.ATTACK&&RabiClone.TIME-weaponSwingTime>weaponComboWaitTime) {
|
||||||
|
state=State.ATTACK4;
|
||||||
|
weaponSwingTime=RabiClone.TIME;
|
||||||
|
y_velocity = finalComboJumpBackSpeedY;
|
||||||
|
x_velocity = finalComboJumpBackSpeedX*(facing_direction?1:-1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case IDLE:
|
case IDLE:
|
||||||
if (a == Action.SLIDE || a == Action.FALL) {
|
if (a == Action.SLIDE || a == Action.FALL) {
|
||||||
@ -211,13 +304,22 @@ public class Player extends PhysicsObject{
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (a==Action.FALL&&(state==State.JUMP||state==State.FALLING)) {
|
||||||
|
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)) {
|
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));
|
RabiClone.OBJ.add(new KnifeSwing(Sprite.KNIFE_SWING,40,RabiClone.p,this));
|
||||||
state=State.ATTACK;
|
state=State.ATTACK;
|
||||||
weaponSwingTime=RabiClone.TIME;
|
weaponSwingTime=RabiClone.TIME;
|
||||||
}
|
}
|
||||||
if (groundCollision) {
|
if (groundCollision) {
|
||||||
if (spacebarReleased && (a == Action.JUMP) && jumpCount > 0) {
|
if (spacebarReleased && (a == Action.JUMP) && jumpCount > 0
|
||||||
|
&&state!=State.ATTACK2&&state!=State.ATTACK3) {
|
||||||
state = State.JUMP;
|
state = State.JUMP;
|
||||||
jumpCount--;
|
jumpCount--;
|
||||||
y_velocity = jump_velocity;
|
y_velocity = jump_velocity;
|
||||||
@ -226,7 +328,7 @@ public class Player extends PhysicsObject{
|
|||||||
// System.out.println("Jump");
|
// System.out.println("Jump");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (state != State.SLIDE) {
|
if (state != State.SLIDE&&state!=State.BELLYSLIDE) {
|
||||||
switch (a) {
|
switch (a) {
|
||||||
case MOVE_LEFT:
|
case MOVE_LEFT:
|
||||||
facing_direction = LEFT;
|
facing_direction = LEFT;
|
||||||
@ -337,6 +439,18 @@ public class Player extends PhysicsObject{
|
|||||||
RabiClone.level_renderer.setY(newY < 0 ? 0 : newY);
|
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.isInvulnerable()){
|
||||||
|
collisionBatch.add(pobj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(byte[] p) {
|
public void draw(byte[] p) {
|
||||||
}
|
}
|
||||||
@ -356,12 +470,12 @@ public class Player extends PhysicsObject{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean rightKeyHeld() {
|
public boolean rightKeyHeld() {
|
||||||
return KeyHeld(Action.MOVE_RIGHT);
|
return state!=State.ATTACK2&&state!=State.ATTACK3&&KeyHeld(Action.MOVE_RIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean leftKeyHeld() {
|
public boolean leftKeyHeld() {
|
||||||
return KeyHeld(Action.MOVE_LEFT);
|
return state!=State.ATTACK2&&state!=State.ATTACK3&&KeyHeld(Action.MOVE_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getYVelocity() {
|
public double getYVelocity() {
|
||||||
|
@ -12,10 +12,14 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
|
|||||||
final public static double NORMAL_FRICTION = 6400;
|
final public static double NORMAL_FRICTION = 6400;
|
||||||
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;
|
||||||
|
final public static double FALLING_SPEED_LIMIT = 500;
|
||||||
|
|
||||||
public State state = State.IDLE;
|
public State state = State.IDLE;
|
||||||
public double x_velocity;
|
public double x_velocity;
|
||||||
public double staggerDuration = 0;
|
protected double staggerDuration = 0;
|
||||||
|
protected State resumeState=null;
|
||||||
|
protected double uncontrollableDuration = 0;
|
||||||
|
protected double invulnerabilityDuration = 0;
|
||||||
public double y_velocity;
|
public double y_velocity;
|
||||||
protected double gravity = GRAVITY;
|
protected double gravity = GRAVITY;
|
||||||
protected double x_acceleration,y_acceleration;
|
protected double x_acceleration,y_acceleration;
|
||||||
@ -42,14 +46,26 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
|
|||||||
staggerDuration-=updateMult;
|
staggerDuration-=updateMult;
|
||||||
}else
|
}else
|
||||||
if(state==State.STAGGER && staggerDuration<=0){
|
if(state==State.STAGGER && staggerDuration<=0){
|
||||||
state=State.IDLE;
|
state=resumeState;
|
||||||
|
}
|
||||||
|
if(state==State.UNCONTROLLABLE && uncontrollableDuration>0){
|
||||||
|
uncontrollableDuration-=updateMult;
|
||||||
|
}else
|
||||||
|
if(state==State.UNCONTROLLABLE && uncontrollableDuration<=0){
|
||||||
|
state=resumeState;
|
||||||
|
}
|
||||||
|
if (invulnerabilityDuration>0) {
|
||||||
|
invulnerabilityDuration-=updateMult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleMovementPhysics(double updateMult) {
|
protected void handleMovementPhysics(double updateMult) {
|
||||||
|
if (state==State.STAGGER||state==State.UNCONTROLLABLE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
int right = rightKeyHeld()?1:0;
|
int right = rightKeyHeld()?1:0;
|
||||||
int left = leftKeyHeld()?1:0;
|
int left = leftKeyHeld()?1:0;
|
||||||
if(state==State.SLIDE){
|
if(state==State.SLIDE||state==State.BELLYSLIDE){
|
||||||
right=0;
|
right=0;
|
||||||
left=0;
|
left=0;
|
||||||
}
|
}
|
||||||
@ -93,7 +109,7 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
|
|||||||
y_acceleration = 0;
|
y_acceleration = 0;
|
||||||
y_velocity = 0;
|
y_velocity = 0;
|
||||||
groundCollision = true;
|
groundCollision = true;
|
||||||
if (state != State.SLIDE) {
|
if (state != State.SLIDE&&state!=State.BELLYSLIDE) {
|
||||||
state = State.IDLE;
|
state = State.IDLE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -125,7 +141,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.BELLYSLIDE){
|
||||||
state = State.FALLING;
|
state = State.FALLING;
|
||||||
}
|
}
|
||||||
if (!sideCollision) {
|
if (!sideCollision) {
|
||||||
@ -198,6 +214,46 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
|
|||||||
return sideCollision;
|
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
|
||||||
|
* was in when the stagger state completes.
|
||||||
|
* @param duration Amount of time in seconds.
|
||||||
|
* */
|
||||||
|
public void setStagger(double duration) {
|
||||||
|
staggerDuration=duration;
|
||||||
|
if (state!=State.STAGGER) {
|
||||||
|
resumeState=state;
|
||||||
|
}
|
||||||
|
state=State.STAGGER;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets how long this object will remain in the uncontrollable state.
|
||||||
|
* Automatically resets the state to the previous state the object
|
||||||
|
* was in when the uncontrollable state completes.
|
||||||
|
* @param duration Amount of time in seconds.
|
||||||
|
* */
|
||||||
|
public void setUncontrollable(double duration) {
|
||||||
|
uncontrollableDuration=duration;
|
||||||
|
if (state!=State.UNCONTROLLABLE) {
|
||||||
|
resumeState=state;
|
||||||
|
}
|
||||||
|
state=State.UNCONTROLLABLE;
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean checkCollision(double x,double y) {
|
protected boolean checkCollision(double x,double y) {
|
||||||
int index = (int)y*RabiClone.BASE_WIDTH*Tile.TILE_WIDTH+(int)x;
|
int index = (int)y*RabiClone.BASE_WIDTH*Tile.TILE_WIDTH+(int)x;
|
||||||
if (index>=0&&index<RabiClone.COLLISION.length) {
|
if (index>=0&&index<RabiClone.COLLISION.length) {
|
||||||
|
@ -3,9 +3,13 @@ package sig.objects.actor;
|
|||||||
public enum State{
|
public enum State{
|
||||||
IDLE,
|
IDLE,
|
||||||
SLIDE,
|
SLIDE,
|
||||||
|
BELLYSLIDE,
|
||||||
JUMP,
|
JUMP,
|
||||||
FALLING,
|
FALLING,
|
||||||
ATTACK,
|
ATTACK,
|
||||||
|
ATTACK2,
|
||||||
|
ATTACK3,
|
||||||
|
ATTACK4,
|
||||||
STAGGER,
|
STAGGER,
|
||||||
UNCONTROLLABLE
|
UNCONTROLLABLE
|
||||||
}
|
}
|
@ -34,20 +34,17 @@ public class KnifeSwing extends AttachableObject{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void collisionEvent(AnimatedObject obj) {
|
public void collisionEvent(AnimatedObject obj) {
|
||||||
System.out.println("Bonk");
|
|
||||||
if(obj instanceof PhysicsObject){
|
if(obj instanceof PhysicsObject){
|
||||||
PhysicsObject pobj = (PhysicsObject)obj;
|
PhysicsObject pobj = (PhysicsObject)obj;
|
||||||
if(pobj.state!=State.STAGGER){
|
if(!pobj.isInvulnerable()){
|
||||||
if(getSpriteTransform()==Transform.NONE){
|
if(getSpriteTransform()==Transform.NONE){
|
||||||
pobj.staggerDuration=0.3;
|
pobj.setStagger(0.3);
|
||||||
pobj.x_velocity = -500;
|
pobj.x_velocity = -500;
|
||||||
pobj.y_velocity = -300;
|
pobj.y_velocity = -300;
|
||||||
pobj.state = State.STAGGER;
|
|
||||||
}else{
|
}else{
|
||||||
pobj.staggerDuration=0.3;
|
pobj.setStagger(0.3);
|
||||||
pobj.x_velocity = 500;
|
pobj.x_velocity = 500;
|
||||||
pobj.y_velocity = -300;
|
pobj.y_velocity = -300;
|
||||||
pobj.state = State.STAGGER;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
66
src/sig/objects/weapons/KnifeSwing2.java
Normal file
66
src/sig/objects/weapons/KnifeSwing2.java
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
package sig.objects.weapons;
|
||||||
|
|
||||||
|
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 KnifeSwing2 extends AttachableObject{
|
||||||
|
|
||||||
|
final byte frameCount = 5; //Number of frames before animation ends.
|
||||||
|
|
||||||
|
public KnifeSwing2(AnimatedSprite spr, double animationSpd, Panel panel, Object attachedObj) {
|
||||||
|
super(spr, animationSpd, panel, attachedObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(double updateMult) {
|
||||||
|
super.update(updateMult);
|
||||||
|
if (getCurrentFrame()>frameCount) {
|
||||||
|
setMarkedForDeletion(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (getSpriteTransform()==Transform.HORIZONTAL) {
|
||||||
|
setX(getAttachedObject().getX()+getAnimatedSpr().getWidth()/2);
|
||||||
|
} else {
|
||||||
|
setX(getAttachedObject().getX()-getAnimatedSpr().getWidth()/2);
|
||||||
|
}
|
||||||
|
setY(getAttachedObject().getY());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void collisionEvent(AnimatedObject obj) {
|
||||||
|
if(obj instanceof PhysicsObject){
|
||||||
|
PhysicsObject pobj = (PhysicsObject)obj;
|
||||||
|
if(!pobj.isInvulnerable()){
|
||||||
|
if(getSpriteTransform()==Transform.NONE){
|
||||||
|
pobj.setStagger(0.3);
|
||||||
|
pobj.x_velocity = -500;
|
||||||
|
pobj.y_velocity = -300;
|
||||||
|
}else{
|
||||||
|
pobj.setStagger(0.3);
|
||||||
|
pobj.x_velocity = 500;
|
||||||
|
pobj.y_velocity = -300;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(byte[] p) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Transform getSpriteTransform() {
|
||||||
|
return getAttached().getSpriteTransform();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFriendlyObject() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user