Jumping from slopes now works, facing direction is correct during jump if you changed direction during a belly slide, squigly platform no longer makes you infinitely slide

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
unknown 2 years ago
parent 8836a38fda
commit 2061be33a6
  1. BIN
      Woolookologie.wav
  2. BIN
      maps/world1.map
  3. BIN
      sprites/tiles.gif
  4. 174
      src/sig/RabiClone.java
  5. 2
      src/sig/engine/Sound.java
  6. 10
      src/sig/objects/Player.java
  7. 12
      src/sig/objects/actor/PhysicsObject.java

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -83,102 +83,102 @@ public class RabiClone{
public static RenderingHints RENDERHINTS = new RenderingHints(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
public static void main(String[] args) {
Sound s = new Sound();
// System.setProperty("sun.java2d.transaccel", "True");
// System.setProperty("sun.java2d.d3d", "True");
// System.setProperty("sun.java2d.ddforcevram", "True");
// System.setProperty("sun.java2d.xrender", "True");
// RENDERHINTS.put(RenderingHints.KEY_COLOR_RENDERING,RenderingHints.VALUE_COLOR_RENDER_SPEED);
// RENDERHINTS.put(RenderingHints.KEY_DITHERING,RenderingHints.VALUE_DITHER_DISABLE);
// RENDERHINTS.put(RenderingHints.KEY_FRACTIONALMETRICS,RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
// RENDERHINTS.put(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_SPEED);
// Key.InitializeKeyConversionMap();
// f = new JFrame(PROGRAM_NAME);
// f.setResizable(false);
// f.setUndecorated(true);
// f.setSize(BASE_WIDTH, BASE_HEIGHT); // 1024x576 (64x64)
// ChooseBestRatio();
//Sound s = new Sound();
System.setProperty("sun.java2d.transaccel", "True");
System.setProperty("sun.java2d.d3d", "True");
System.setProperty("sun.java2d.ddforcevram", "True");
System.setProperty("sun.java2d.xrender", "True");
RENDERHINTS.put(RenderingHints.KEY_COLOR_RENDERING,RenderingHints.VALUE_COLOR_RENDER_SPEED);
RENDERHINTS.put(RenderingHints.KEY_DITHERING,RenderingHints.VALUE_DITHER_DISABLE);
RENDERHINTS.put(RenderingHints.KEY_FRACTIONALMETRICS,RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
RENDERHINTS.put(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_SPEED);
Key.InitializeKeyConversionMap();
f = new JFrame(PROGRAM_NAME);
f.setResizable(false);
f.setUndecorated(true);
f.setSize(BASE_WIDTH, BASE_HEIGHT); // 1024x576 (64x64)
ChooseBestRatio();
// Map.LoadMap(Maps.WORLD1);
// setupDefaultControls();
Map.LoadMap(Maps.WORLD1);
setupDefaultControls();
// p = new Panel(f);
p = new Panel(f);
// p.init();
p.init();
// f.add(p);
// f.addKeyListener(p);
// f.setLocation((int) ((Toolkit.getDefaultToolkit().getScreenSize().getWidth() - f.getWidth()) / 2),
// (int) ((Toolkit.getDefaultToolkit().getScreenSize().getHeight() - f.getHeight()) / 2));
// f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// f.setVisible(true);
// f.createBufferStrategy(2);
f.add(p);
f.addKeyListener(p);
f.setLocation((int) ((Toolkit.getDefaultToolkit().getScreenSize().getWidth() - f.getWidth()) / 2),
(int) ((Toolkit.getDefaultToolkit().getScreenSize().getHeight() - f.getHeight()) / 2));
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
f.createBufferStrategy(2);
// OBJ.add(level_renderer = new LevelRenderer(p));
// StartGame();
OBJ.add(level_renderer = new LevelRenderer(p));
StartGame();
// p.render();
p.render();
// long lastGameTime = System.nanoTime();
// long dt = 0;
long lastGameTime = System.nanoTime();
long dt = 0;
// CONTROLLERS = ControllerEnvironment.getDefaultEnvironment().getControllers();
// ConfigureControls.LoadControls();
CONTROLLERS = ControllerEnvironment.getDefaultEnvironment().getControllers();
ConfigureControls.LoadControls();
// while (true) {
// dt += System.nanoTime() - lastGameTime;
// lastGameTime = System.nanoTime();
// while (dt >= UPDATE_LOOP_NANOTIME) {
// handleGameControllers();
// KeyBind.poll();
// if ((Key.isKeyHeld(KeyEvent.VK_F5)||reloadControllerList) && System.currentTimeMillis() - lastControllerScan > 5000) {
// CONTROLLERS = ControllerEnvironment.getDefaultEnvironment().rescanControllers();
// System.out.println(Arrays.toString(CONTROLLERS));
// lastControllerScan = System.currentTimeMillis();
// if (reloadControllerList) {
// ConfigureControls.LoadControls();
// }
// reloadControllerList=false;
// }
// FRIENDLY_OBJ.clear();
// ENEMY_OBJ.clear();
// for (int i = 0; i < OBJ.size(); i++) {
// if (OBJ.get(i) instanceof RenderedObject) {
// RenderedObject r = (RenderedObject)OBJ.get(i);
// if (r.isFriendlyObject()) {
// FRIENDLY_OBJ.add((AnimatedObject)r);
// } else {
// ENEMY_OBJ.add((AnimatedObject)r);
// }
// }
// OBJ.get(i).update(UPDATE_MULT);
// if (OBJ.get(i).isMarkedForDeletion()) {
// OBJ.remove(i--);
// }
// }
// for (int i = 0; i < FRIENDLY_OBJ.size(); i++) {
// AnimatedObject f = FRIENDLY_OBJ.get(i);
// for (int j=0;j<ENEMY_OBJ.size();j++) {
// AnimatedObject e = ENEMY_OBJ.get(j);
// if (detectCollision(e,f)) {
// e.collisionEvent(f);
// f.collisionEvent(e);
// }
// }
// }
// dt -= UPDATE_LOOP_NANOTIME;
// TIME += UPDATE_LOOP_NANOTIME;
// // System.out.println(TIME);
// }
// gameUpdateLoopStabilizer(dt); //This is hackish. Removing this slows down the game by about 30%. The timer runs slower. ???
// }
while (true) {
dt += System.nanoTime() - lastGameTime;
lastGameTime = System.nanoTime();
while (dt >= UPDATE_LOOP_NANOTIME) {
handleGameControllers();
KeyBind.poll();
if ((Key.isKeyHeld(KeyEvent.VK_F5)||reloadControllerList) && System.currentTimeMillis() - lastControllerScan > 5000) {
CONTROLLERS = ControllerEnvironment.getDefaultEnvironment().rescanControllers();
System.out.println(Arrays.toString(CONTROLLERS));
lastControllerScan = System.currentTimeMillis();
if (reloadControllerList) {
ConfigureControls.LoadControls();
}
reloadControllerList=false;
}
FRIENDLY_OBJ.clear();
ENEMY_OBJ.clear();
for (int i = 0; i < OBJ.size(); i++) {
if (OBJ.get(i) instanceof RenderedObject) {
RenderedObject r = (RenderedObject)OBJ.get(i);
if (r.isFriendlyObject()) {
FRIENDLY_OBJ.add((AnimatedObject)r);
} else {
ENEMY_OBJ.add((AnimatedObject)r);
}
}
OBJ.get(i).update(UPDATE_MULT);
if (OBJ.get(i).isMarkedForDeletion()) {
OBJ.remove(i--);
}
}
for (int i = 0; i < FRIENDLY_OBJ.size(); i++) {
AnimatedObject f = FRIENDLY_OBJ.get(i);
for (int j=0;j<ENEMY_OBJ.size();j++) {
AnimatedObject e = ENEMY_OBJ.get(j);
if (detectCollision(e,f)) {
e.collisionEvent(f);
f.collisionEvent(e);
}
}
}
dt -= UPDATE_LOOP_NANOTIME;
TIME += UPDATE_LOOP_NANOTIME;
// System.out.println(TIME);
}
gameUpdateLoopStabilizer(dt); //This is hackish. Removing this slows down the game by about 30%. The timer runs slower. ???
}
}
public static void setupDefaultControls() {

@ -14,7 +14,7 @@ import javax.sound.sampled.UnsupportedAudioFileException;
public class Sound{
public Sound() {
try {
File audioFile = new File("testFile.wav");
File audioFile = new File("..","Woolookologie.wav");
AudioInputStream audioStream = AudioSystem.getAudioInputStream(audioFile);
AudioFormat format = audioStream.getFormat();
DataLine.Info info = new DataLine.Info(SourceDataLine.class,format);

@ -132,6 +132,13 @@ public class Player extends PhysicsObject{
}
break;
case JUMP:
if(KeyHeld(Action.MOVE_LEFT)){
facing_direction=LEFT;
}
if(KeyHeld(Action.MOVE_RIGHT)){
facing_direction=RIGHT;
}
if (jump_slide_fall_StartAnimationTimer == -1) {
jump_slide_fall_StartAnimationTimer = RabiClone.TIME;
setAnimatedSpr(Sprite.ERINA_JUMP_RISE1);
@ -172,7 +179,7 @@ public class Player extends PhysicsObject{
break;
case BELLYSLIDE:{
horizontal_friction = 0;
if (y_velocity>0) {
if (!groundCollision) {
bellySlideTime=RabiClone.TIME;
}
if (groundCollision&&!landedBellySlide){
@ -212,6 +219,7 @@ public class Player extends PhysicsObject{
&& state!=State.ATTACK2&&state!=State.ATTACK3&&state!=State.BELLYSLIDE) {
y_velocity = jump_velocity;
}
System.out.println(state);
}
private void handleEventCollisions() {

@ -219,7 +219,7 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
}
if (checkCollision(x+getCollisionBox().getX2()-getSprite().getWidth()/2,(getY()-getSprite().getHeight()/2+getCollisionBounds().getY2()))||
checkCollision(x+getCollisionBox().getX2()-getSprite().getWidth()/2,(getY()-getSprite().getHeight()/2+getCollisionBounds().getY()))) {
if (!(checkCollision(x+getCollisionBox().getX2()-getSprite().getWidth()/2,(getY()-getSprite().getHeight()/2+getCollisionBounds().getY2()-2))||
if (state!=State.JUMP&&!(checkCollision(x+getCollisionBox().getX2()-getSprite().getWidth()/2,(getY()-getSprite().getHeight()/2+getCollisionBounds().getY2()-2))||
checkCollision(x+getCollisionBox().getX2()-getSprite().getWidth()/2,(getY()-getSprite().getHeight()/2+getCollisionBounds().getY()-2)))) {
setY(getY()-1);
} else {
@ -230,9 +230,11 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
break;
}
} else {
if (!hitAbove&&!checkCollision(x+getCollisionBox().getX()-getSprite().getWidth()/2,(getY()-getSprite().getHeight()/2+getCollisionBounds().getY2()+1))&&
checkCollision(x+getCollisionBox().getX()-getSprite().getWidth()/2,(getY()-getSprite().getHeight()/2+getCollisionBounds().getY2()+2))) {
if (state!=State.JUMP&&!hitAbove&&!checkCollision(x+getCollisionBox().getX()-getSprite().getWidth()/2,(getY()-getSprite().getHeight()/2+getCollisionBounds().getY2()+1))&&
(checkCollision(x+getCollisionBox().getX()-getSprite().getWidth()/2-1,(getY()-getSprite().getHeight()/2+getCollisionBounds().getY2()+2))||
checkCollision(x+getCollisionBox().getX()-getSprite().getWidth()/2,(getY()-getSprite().getHeight()/2+getCollisionBounds().getY2()+2)))) {
//System.out.println("Performs check."+System.currentTimeMillis());
setY(getY()+1);
//x_velocity = ;
}
@ -246,7 +248,7 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
}
if (checkCollision((x+getCollisionBox().getX()-getSprite().getWidth()/2),getY()-getSprite().getHeight()/2+getCollisionBounds().getY2())||
checkCollision((x+getCollisionBox().getX()-getSprite().getWidth()/2),getY()-getSprite().getHeight()/2+getCollisionBounds().getY())) {
if (!(checkCollision(x+getCollisionBox().getX()-getSprite().getWidth()/2,(getY()-getSprite().getHeight()/2+getCollisionBounds().getY2()-2))||
if (state!=State.JUMP&&!(checkCollision(x+getCollisionBox().getX()-getSprite().getWidth()/2,(getY()-getSprite().getHeight()/2+getCollisionBounds().getY2()-2))||
checkCollision(x+getCollisionBox().getX()-getSprite().getWidth()/2,(getY()-getSprite().getHeight()/2+getCollisionBounds().getY()-2)))) {
setY(getY()-1);
} else {
@ -257,7 +259,7 @@ public abstract class PhysicsObject extends AnimatedObject implements PhysicsObj
break;
}
} else {
if (!hitAbove&&!checkCollision(x+getCollisionBox().getX2()-getSprite().getWidth()/2,(getY()-getSprite().getHeight()/2+getCollisionBounds().getY2()+1))&&
if (state!=State.JUMP&&!hitAbove&&!checkCollision(x+getCollisionBox().getX2()-getSprite().getWidth()/2,(getY()-getSprite().getHeight()/2+getCollisionBounds().getY2()+1))&&
checkCollision(x+getCollisionBox().getX2()-getSprite().getWidth()/2,(getY()-getSprite().getHeight()/2+getCollisionBounds().getY2()+2))) {
//System.out.println("Performs check."+System.currentTimeMillis());
setY(getY()+1);

Loading…
Cancel
Save