Merge branch 'main' of https://github.com/sigonasr2/RabiClone
This commit is contained in:
commit
471a9e5dbf
BIN
maps/world1.map
BIN
maps/world1.map
Binary file not shown.
@ -9,10 +9,23 @@ import sig.objects.actor.RenderedObject;
|
|||||||
|
|
||||||
public class Erinoah extends PhysicsObject implements RenderedObject{
|
public class Erinoah extends PhysicsObject implements RenderedObject{
|
||||||
|
|
||||||
|
double lastMoved = 0;
|
||||||
|
boolean moveDir = false;
|
||||||
|
double moveTimer = 0;
|
||||||
|
|
||||||
public Erinoah(double x, double y) {
|
public Erinoah(double x, double y) {
|
||||||
super(Sprite.ERINOAH,6.5,RabiClone.p);
|
super(Sprite.ERINOAH,6.5,RabiClone.p);
|
||||||
setX(x);
|
setX(x);
|
||||||
setY(y);
|
setY(y);
|
||||||
|
setAccelerationLimits(100, 100);
|
||||||
|
setVelocityLimits(246, 500);
|
||||||
|
setGroundDrag(2000);
|
||||||
|
setGroundFriction(PhysicsObject.NORMAL_FRICTION);
|
||||||
|
setAirDrag(800);
|
||||||
|
setAirFriction(180);
|
||||||
|
setSlidingVelocity(164);
|
||||||
|
setSlidingAcceleration(120);
|
||||||
|
setJumpVelocity(PhysicsObject.NORMAL_JUMP_VELOCITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -23,6 +36,23 @@ public class Erinoah extends PhysicsObject implements RenderedObject{
|
|||||||
@Override
|
@Override
|
||||||
public void update(double updateMult) {
|
public void update(double updateMult) {
|
||||||
super.update(updateMult);
|
super.update(updateMult);
|
||||||
|
lastMoved+=updateMult;
|
||||||
|
if (lastMoved>5) {
|
||||||
|
switch ((int)(Math.random()*3)) {
|
||||||
|
case 0:{
|
||||||
|
moveDir=true;
|
||||||
|
moveTimer=Math.random()*3;
|
||||||
|
}break;
|
||||||
|
case 1:{
|
||||||
|
moveDir=false;
|
||||||
|
moveTimer=Math.random()*3;
|
||||||
|
}break;
|
||||||
|
case 2:{
|
||||||
|
lastMoved=0;
|
||||||
|
}break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
moveTimer-=updateMult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -36,11 +66,11 @@ public class Erinoah extends PhysicsObject implements RenderedObject{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean rightKeyHeld() {
|
public boolean rightKeyHeld() {
|
||||||
return false;
|
return moveTimer>0&&moveDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean leftKeyHeld() {
|
public boolean leftKeyHeld() {
|
||||||
return false;
|
return moveTimer>0&&!moveDir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ public class LevelRenderer extends Object{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (RabiClone.player!=null) {
|
if (RabiClone.player!=null) {
|
||||||
Draw_Text(4,4,new String(RabiClone.player.y_velocity),Font.PROFONT_12);
|
Draw_Text(4,4,new String(RabiClone.player.getYVelocity()),Font.PROFONT_12);
|
||||||
Draw_Text(4,4+Font.PROFONT_12.getGlyphHeight(),new String(RabiClone.scaleTime),Font.PROFONT_12);
|
Draw_Text(4,4+Font.PROFONT_12.getGlyphHeight(),new String(RabiClone.scaleTime),Font.PROFONT_12);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,34 +21,12 @@ public class Player extends PhysicsObject implements RenderedObject{
|
|||||||
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);
|
||||||
|
|
||||||
double y_acceleration = PhysicsObject.GRAVITY;
|
|
||||||
double y_acceleration_limit = 100;
|
|
||||||
double x_acceleration = 0;
|
|
||||||
double x_acceleration_limit = 100;
|
|
||||||
double x_velocity = 0;
|
|
||||||
double x_velocity_limit = 246;
|
|
||||||
double y_velocity = 5;
|
|
||||||
double y_velocity_limit = 500;
|
|
||||||
double sliding_velocity = 164;
|
|
||||||
double sliding_acceleration = 120;
|
|
||||||
|
|
||||||
double horizontal_drag = 2000;
|
|
||||||
double horizontal_friction = PhysicsObject.NORMAL_FRICTION;
|
|
||||||
double horizontal_air_drag = 800;
|
|
||||||
double horizontal_air_friction = 180;
|
|
||||||
|
|
||||||
double jump_velocity = PhysicsObject.NORMAL_JUMP_VELOCITY;
|
|
||||||
|
|
||||||
int maxJumpCount = 2;
|
|
||||||
int jumpCount = maxJumpCount;
|
|
||||||
State state = State.IDLE;
|
|
||||||
State prvState = state;
|
State prvState = state;
|
||||||
|
|
||||||
final double viewBoundaryX = RabiClone.BASE_WIDTH / 3;
|
final double viewBoundaryX = RabiClone.BASE_WIDTH / 3;
|
||||||
final double viewBoundaryY = RabiClone.BASE_HEIGHT / 3;
|
final double viewBoundaryY = RabiClone.BASE_HEIGHT / 3;
|
||||||
View lastCameraView = View.FIXED;
|
View lastCameraView = View.FIXED;
|
||||||
|
|
||||||
boolean groundCollision = false;
|
|
||||||
boolean spacebarReleased = true;
|
boolean spacebarReleased = true;
|
||||||
boolean facing_direction = RIGHT;
|
boolean facing_direction = RIGHT;
|
||||||
|
|
||||||
@ -66,6 +44,15 @@ public class Player extends PhysicsObject implements RenderedObject{
|
|||||||
super(Sprite.ERINA, 5, panel);
|
super(Sprite.ERINA, 5, panel);
|
||||||
setX(RabiClone.BASE_WIDTH / 2 - getAnimatedSpr().getWidth() / 2);
|
setX(RabiClone.BASE_WIDTH / 2 - getAnimatedSpr().getWidth() / 2);
|
||||||
setY(RabiClone.BASE_HEIGHT * (2 / 3d) - getAnimatedSpr().getHeight() / 2);
|
setY(RabiClone.BASE_HEIGHT * (2 / 3d) - getAnimatedSpr().getHeight() / 2);
|
||||||
|
setAccelerationLimits(100, 100);
|
||||||
|
setVelocityLimits(246, 500);
|
||||||
|
setGroundDrag(2000);
|
||||||
|
setGroundFriction(PhysicsObject.NORMAL_FRICTION);
|
||||||
|
setAirDrag(800);
|
||||||
|
setAirFriction(180);
|
||||||
|
setSlidingVelocity(164);
|
||||||
|
setSlidingAcceleration(120);
|
||||||
|
setJumpVelocity(PhysicsObject.NORMAL_JUMP_VELOCITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -76,7 +63,6 @@ public class Player extends PhysicsObject implements RenderedObject{
|
|||||||
@Override
|
@Override
|
||||||
public void update(double updateMult) {
|
public void update(double updateMult) {
|
||||||
super.update(updateMult);
|
super.update(updateMult);
|
||||||
handleMovementPhysics(updateMult);
|
|
||||||
handleCameraRoomMovement();
|
handleCameraRoomMovement();
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
@ -365,4 +351,8 @@ public class Player extends PhysicsObject implements RenderedObject{
|
|||||||
public boolean leftKeyHeld() {
|
public boolean leftKeyHeld() {
|
||||||
return KeyHeld(Action.MOVE_LEFT);
|
return KeyHeld(Action.MOVE_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getYVelocity() {
|
||||||
|
return y_velocity;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,16 +13,19 @@ 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;
|
||||||
|
|
||||||
State state = State.IDLE;
|
protected State state = State.IDLE;
|
||||||
double x_velocity,y_velocity;
|
protected double x_velocity,y_velocity;
|
||||||
double x_acceleration,y_acceleration;
|
protected double x_acceleration,y_acceleration;
|
||||||
double x_velocity_limit,y_velocity_limit;
|
protected double x_velocity_limit,y_velocity_limit;
|
||||||
boolean groundCollision;
|
protected double x_acceleration_limit,y_acceleration_limit;
|
||||||
byte maxJumpCount=2;
|
protected boolean groundCollision;
|
||||||
byte jumpCount=0;
|
protected byte maxJumpCount=2;
|
||||||
|
protected byte jumpCount=0;
|
||||||
|
protected double jump_velocity;
|
||||||
|
|
||||||
double horizontal_air_friction,horizontal_air_drag;
|
protected double horizontal_air_friction,horizontal_air_drag;
|
||||||
double horizontal_friction,horizontal_drag;
|
protected double horizontal_friction,horizontal_drag;
|
||||||
|
protected double sliding_velocity,sliding_acceleration;
|
||||||
|
|
||||||
protected PhysicsObject(AnimatedSprite spr, double animationSpd, Panel panel) {
|
protected PhysicsObject(AnimatedSprite spr, double animationSpd, Panel panel) {
|
||||||
super(spr, animationSpd, panel);
|
super(spr, animationSpd, panel);
|
||||||
@ -216,4 +219,58 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
|
|||||||
return getCollisionBox();
|
return getCollisionBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setVelocityLimits(double x, double y) {
|
||||||
|
this.x_velocity_limit=x;
|
||||||
|
this.y_velocity_limit=y;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAccelerationLimits(double x, double y) {
|
||||||
|
this.x_acceleration_limit=x;
|
||||||
|
this.y_acceleration_limit=y;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setMaxJumpCount(byte jumps) {
|
||||||
|
this.maxJumpCount=jumps;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setGroundFriction(double x) {
|
||||||
|
this.horizontal_friction=x;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAirFriction(double x) {
|
||||||
|
this.horizontal_air_friction=x;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setGroundDrag(double x) {
|
||||||
|
this.horizontal_drag=x;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAirDrag(double x) {
|
||||||
|
this.horizontal_air_drag=x;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSlidingVelocity(double x) {
|
||||||
|
this.sliding_velocity=x;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSlidingAcceleration(double x) {
|
||||||
|
this.sliding_acceleration=x;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setJumpVelocity(double x) {
|
||||||
|
this.jump_velocity=x;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,4 +7,14 @@ public interface PhysicsObjectRequirements {
|
|||||||
boolean leftKeyHeld();
|
boolean leftKeyHeld();
|
||||||
Rectangle getCollisionBounds();
|
Rectangle getCollisionBounds();
|
||||||
Rectangle setCollisionBounds();
|
Rectangle setCollisionBounds();
|
||||||
|
void setVelocityLimits(double x,double y);
|
||||||
|
void setAccelerationLimits(double x,double y);
|
||||||
|
void setMaxJumpCount(byte jumps);
|
||||||
|
void setGroundFriction(double x);
|
||||||
|
void setAirFriction(double x);
|
||||||
|
void setGroundDrag(double x);
|
||||||
|
void setAirDrag(double x);
|
||||||
|
void setSlidingVelocity(double x);
|
||||||
|
void setSlidingAcceleration(double x);
|
||||||
|
void setJumpVelocity(double x);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user