diff --git a/src/main/java/JumpGame.java b/src/main/java/JumpGame.java index bfbf201..4a7b5ca 100644 --- a/src/main/java/JumpGame.java +++ b/src/main/java/JumpGame.java @@ -1,16 +1,12 @@ import models.IModel; import models.JumpGameModel; -import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFWKeyCallback; import views.BackgroundRenderer; import views.IView; import views.PlayerRenderer; import views.TileMapRenderer; -import static org.lwjgl.glfw.Callbacks.glfwFreeCallbacks; import static org.lwjgl.glfw.GLFW.*; -import static org.lwjgl.opengl.GL11.*; -import static org.lwjgl.system.MemoryUtil.NULL; import java.util.ArrayList; @@ -26,7 +22,7 @@ // public void gravity(double y) { JumpGameModel jumpGameModel = (JumpGameModel) model; - jumpGameModel.updateGravity(y); //重力の更新 + jumpGameModel.gravity(y); //重力の更新 jumpGameModel.updateGroundFlag();//地面の判定切り替え } diff --git a/src/main/java/entities/Acceleration.java b/src/main/java/entities/Acceleration.java index 0d80c79..930cd85 100644 --- a/src/main/java/entities/Acceleration.java +++ b/src/main/java/entities/Acceleration.java @@ -1,5 +1,7 @@ package entities; +import java.util.*; + public class Acceleration { private double massValue = 1.0; private Pair forceValue = new Pair<>(0d, 0d); @@ -13,8 +15,11 @@ this.massValue = mass; Pair temp_l0; - if (this.onground.getOnground()) temp_l0 = new Pair((forceValue.getFirst() / mass), 0.0); - else temp_l0 = new Pair((forceValue.getFirst() / mass), (forceValue.getSecond() / mass)); + if (this.onground.getOnground()) { + temp_l0 = new Pair((forceValue.getFirst() / mass), 0.0); + } else { + temp_l0 = new Pair((forceValue.getFirst() / mass), (forceValue.getSecond() / mass)); + } this.value = temp_l0; velocity.updateByAcceleration(value); @@ -26,9 +31,11 @@ this.forceValue = force; Pair temp_l1; - if (this.onground.getOnground()) temp_l1 = new Pair((force.getFirst() / massValue), 0.0); - temp_l1 = new Pair((force.getFirst() / massValue), (force.getSecond() / massValue)); - + if (this.onground.getOnground()) { + temp_l1 = new Pair((force.getFirst() / massValue), 0.0); + } else { + temp_l1 = new Pair((force.getFirst() / massValue), (force.getSecond() / massValue)); + } value = temp_l1; velocity.updateByAcceleration(value); } diff --git a/src/main/java/entities/Clear.java b/src/main/java/entities/Clear.java index 3f33d64..abdcc20 100644 --- a/src/main/java/entities/Clear.java +++ b/src/main/java/entities/Clear.java @@ -1,5 +1,7 @@ package entities; +import java.util.*; + public class Clear { private Position position; diff --git a/src/main/java/entities/Force.java b/src/main/java/entities/Force.java index 5a544e0..c5cb410 100644 --- a/src/main/java/entities/Force.java +++ b/src/main/java/entities/Force.java @@ -1,5 +1,7 @@ package entities; +import java.util.*; + public class Force { private Acceleration acceleration; private Pair value = new Pair<>(-1.0d, 0.0d); diff --git a/src/main/java/entities/Gameover.java b/src/main/java/entities/Gameover.java index 751be25..c84d3a0 100644 --- a/src/main/java/entities/Gameover.java +++ b/src/main/java/entities/Gameover.java @@ -1,5 +1,7 @@ package entities; +import java.util.*; + public class Gameover { private Position position; diff --git a/src/main/java/entities/Ground.java b/src/main/java/entities/Ground.java index 3fc328f..7f755ba 100644 --- a/src/main/java/entities/Ground.java +++ b/src/main/java/entities/Ground.java @@ -1,5 +1,7 @@ package entities; +import java.util.*; + public class Ground { private boolean value = true; diff --git a/src/main/java/entities/Mass.java b/src/main/java/entities/Mass.java index f7d4012..73cddd7 100644 --- a/src/main/java/entities/Mass.java +++ b/src/main/java/entities/Mass.java @@ -1,5 +1,7 @@ package entities; +import java.util.*; + public class Mass { private Acceleration acceleration; private double value; diff --git a/src/main/java/entities/Move.java b/src/main/java/entities/Move.java index a966f75..7de2f12 100644 --- a/src/main/java/entities/Move.java +++ b/src/main/java/entities/Move.java @@ -1,5 +1,7 @@ package entities; +import java.util.*; + public class Move { private Velocity velocity; private Pair value = new Pair<>(1d, 256d); diff --git a/src/main/java/entities/Onground.java b/src/main/java/entities/Onground.java index 6b58b90..117f49d 100644 --- a/src/main/java/entities/Onground.java +++ b/src/main/java/entities/Onground.java @@ -1,5 +1,7 @@ package entities; +import java.util.*; + public class Onground { private Ground ground; private Position position; @@ -10,5 +12,6 @@ } public boolean getOnground() { - return ((this.ground.getValue() == true) && (this.position.getValue().getSecond() <= 0.0)); } + return ((this.ground.getValue() == true) && (this.position.getValue().getSecond() <= 0.0)); + } } \ No newline at end of file diff --git a/src/main/java/entities/Pair.java b/src/main/java/entities/Pair.java index 4f17624..6a62008 100644 --- a/src/main/java/entities/Pair.java +++ b/src/main/java/entities/Pair.java @@ -1,5 +1,7 @@ package entities; +import java.util.*; + public class Pair { private T first; private T second; diff --git a/src/main/java/entities/Position.java b/src/main/java/entities/Position.java index 20fa323..a84e966 100644 --- a/src/main/java/entities/Position.java +++ b/src/main/java/entities/Position.java @@ -1,7 +1,6 @@ package entities; -import entities.Ground; -import entities.Pair; +import java.util.*; //--------------------------------------------------------------- // @@ -30,13 +29,6 @@ } //--------------------------------------------------------------- - // - public Position(Pair value, Ground ground) { - this.value = value; - this.ground = ground; - } - - //--------------------------------------------------------------- //--------------------------------------------------------------- // getter public Pair getValue() { diff --git a/src/main/java/entities/Time.java b/src/main/java/entities/Time.java index 0b96add..16381eb 100644 --- a/src/main/java/entities/Time.java +++ b/src/main/java/entities/Time.java @@ -1,5 +1,7 @@ package entities; +import java.util.*; + public class Time { private double value; diff --git a/src/main/java/entities/Velocity.java b/src/main/java/entities/Velocity.java index 4e7c568..c1c1c0a 100644 --- a/src/main/java/entities/Velocity.java +++ b/src/main/java/entities/Velocity.java @@ -1,5 +1,6 @@ package entities; +import java.util.*; public class Velocity { private Pair moveValue = new Pair<>(0d, 0d); @@ -44,13 +45,6 @@ } //--------------------------------------------------------------- - public Velocity(Pair value,Position position, Onground onground) { - this.value = value; - this.position = position; - this.onground = onground; - } - - //--------------------------------------------------------------- //--------------------------------------------------------------- public Pair getValue() { return value; diff --git a/src/main/java/models/JumpGameModel.java b/src/main/java/models/JumpGameModel.java index 9e6d387..97880b9 100644 --- a/src/main/java/models/JumpGameModel.java +++ b/src/main/java/models/JumpGameModel.java @@ -1,5 +1,7 @@ package models; +import java.util.*; + import entities.*; import entities.modelExtentions.Stage; @@ -14,20 +16,15 @@ private Position position; private Velocity velocity; private Onground onground; - - //--------------------------------------------------------------- private Time time; private Gameover gameover; private Clear clear; - - //--------------------------------------------------------------- private Ground ground; //--------------------------------------------------------------- + private Stage stage; private double jumpPower = 256; - //--------------------------------------------------------------- - private Stage stage; //--------------------------------------------------------------- //--------------------------------------------------------------- @@ -36,7 +33,7 @@ ground = new Ground(); position = new Position(ground); onground = new Onground(ground, position); - velocity = new Velocity(new Pair<>(1d, 0d), position, onground); + velocity = new Velocity(position, onground); acceleration = new Acceleration(velocity, onground); force = new Force(acceleration); mass = new Mass(acceleration); @@ -119,9 +116,9 @@ //--------------------------------------------------------------- // マイフレーム更新処理 - public void updateGravity(double gravity) { - this.time.gravity(gravity); - this.force.gravity(gravity); + public void gravity(double y) { + this.time.gravity(y); + this.force.gravity(y); // System.out.println("swapWindow Gravity"); } @@ -133,22 +130,11 @@ if (stage.isOpenFlag(x)) ground.openHole(); if (stage.isCloseFlag(x)) ground.closeHole(); - System.out.print("x: " + x + "/"); - System.out.println("Ground: " + ground.getValue() + "/"); +// System.out.print("x: " + x + "/"); +// System.out.println("Ground: " + ground.getValue() + "/"); // System.out.print("Clear: " + clear.getClear() + "/"); // System.out.println("GameOver: " + gameover.getGameover()); } - - //--------------------------------------------------------------- - // - - //--------------------------------------------------------------- - // - private void init() { - - } - - //--------------------------------------------------------------- }