diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..c10a6f7 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..b26911b --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_joml_joml_1_9_24.xml b/.idea/libraries/Maven__org_joml_joml_1_9_24.xml new file mode 100644 index 0000000..6f5840d --- /dev/null +++ b/.idea/libraries/Maven__org_joml_joml_1_9_24.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_lwjgl_lwjgl_3_2_3.xml b/.idea/libraries/Maven__org_lwjgl_lwjgl_3_2_3.xml new file mode 100644 index 0000000..d151ac8 --- /dev/null +++ b/.idea/libraries/Maven__org_lwjgl_lwjgl_3_2_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_lwjgl_lwjgl_assimp_3_2_3.xml b/.idea/libraries/Maven__org_lwjgl_lwjgl_assimp_3_2_3.xml new file mode 100644 index 0000000..64acbdf --- /dev/null +++ b/.idea/libraries/Maven__org_lwjgl_lwjgl_assimp_3_2_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_lwjgl_lwjgl_assimp_natives_windows_3_2_3.xml b/.idea/libraries/Maven__org_lwjgl_lwjgl_assimp_natives_windows_3_2_3.xml new file mode 100644 index 0000000..a4e7d4f --- /dev/null +++ b/.idea/libraries/Maven__org_lwjgl_lwjgl_assimp_natives_windows_3_2_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_lwjgl_lwjgl_glfw_3_2_3.xml b/.idea/libraries/Maven__org_lwjgl_lwjgl_glfw_3_2_3.xml new file mode 100644 index 0000000..a0c9717 --- /dev/null +++ b/.idea/libraries/Maven__org_lwjgl_lwjgl_glfw_3_2_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_lwjgl_lwjgl_glfw_natives_windows_3_2_3.xml b/.idea/libraries/Maven__org_lwjgl_lwjgl_glfw_natives_windows_3_2_3.xml new file mode 100644 index 0000000..3b5ec8f --- /dev/null +++ b/.idea/libraries/Maven__org_lwjgl_lwjgl_glfw_natives_windows_3_2_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_lwjgl_lwjgl_natives_windows_3_2_3.xml b/.idea/libraries/Maven__org_lwjgl_lwjgl_natives_windows_3_2_3.xml new file mode 100644 index 0000000..8c47f48 --- /dev/null +++ b/.idea/libraries/Maven__org_lwjgl_lwjgl_natives_windows_3_2_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_lwjgl_lwjgl_openal_3_2_3.xml b/.idea/libraries/Maven__org_lwjgl_lwjgl_openal_3_2_3.xml new file mode 100644 index 0000000..16cafc0 --- /dev/null +++ b/.idea/libraries/Maven__org_lwjgl_lwjgl_openal_3_2_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_lwjgl_lwjgl_openal_natives_windows_3_2_3.xml b/.idea/libraries/Maven__org_lwjgl_lwjgl_openal_natives_windows_3_2_3.xml new file mode 100644 index 0000000..567dc3a --- /dev/null +++ b/.idea/libraries/Maven__org_lwjgl_lwjgl_openal_natives_windows_3_2_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_lwjgl_lwjgl_opengl_3_2_3.xml b/.idea/libraries/Maven__org_lwjgl_lwjgl_opengl_3_2_3.xml new file mode 100644 index 0000000..c07061e --- /dev/null +++ b/.idea/libraries/Maven__org_lwjgl_lwjgl_opengl_3_2_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_lwjgl_lwjgl_opengl_natives_windows_3_2_3.xml b/.idea/libraries/Maven__org_lwjgl_lwjgl_opengl_natives_windows_3_2_3.xml new file mode 100644 index 0000000..4cd60f7 --- /dev/null +++ b/.idea/libraries/Maven__org_lwjgl_lwjgl_opengl_natives_windows_3_2_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_lwjgl_lwjgl_stb_3_2_3.xml b/.idea/libraries/Maven__org_lwjgl_lwjgl_stb_3_2_3.xml new file mode 100644 index 0000000..679c690 --- /dev/null +++ b/.idea/libraries/Maven__org_lwjgl_lwjgl_stb_3_2_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_lwjgl_lwjgl_stb_natives_windows_3_2_3.xml b/.idea/libraries/Maven__org_lwjgl_lwjgl_stb_natives_windows_3_2_3.xml new file mode 100644 index 0000000..7ede507 --- /dev/null +++ b/.idea/libraries/Maven__org_lwjgl_lwjgl_stb_natives_windows_3_2_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..71bba8c --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..06a4dda --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 734b005..e2ab130 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -JumpGame +resources.JumpGame =============== diff --git a/jumpGame.iml b/jumpGame.iml new file mode 100644 index 0000000..13770d9 --- /dev/null +++ b/jumpGame.iml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..e461d95 --- /dev/null +++ b/pom.xml @@ -0,0 +1,105 @@ + + + 4.0.0 + + jumpGame + jumpGame + 1.0-SNAPSHOT + + + 3.2.3 + 1.9.24 + natives-windows + UTF-8 + 1.8 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 11.0 + 11.0 + + + + + + + + + org.lwjgl + lwjgl-bom + ${lwjgl.version} + import + pom + + + + + + + org.lwjgl + lwjgl + + + org.lwjgl + lwjgl-assimp + + + org.lwjgl + lwjgl-glfw + + + org.lwjgl + lwjgl-openal + + + org.lwjgl + lwjgl-opengl + + + org.lwjgl + lwjgl-stb + + + org.lwjgl + lwjgl + ${lwjgl.natives} + + + org.lwjgl + lwjgl-assimp + ${lwjgl.natives} + + + org.lwjgl + lwjgl-glfw + ${lwjgl.natives} + + + org.lwjgl + lwjgl-openal + ${lwjgl.natives} + + + org.lwjgl + lwjgl-opengl + ${lwjgl.natives} + + + org.lwjgl + lwjgl-stb + ${lwjgl.natives} + + + org.joml + joml + ${joml.version} + + + \ No newline at end of file diff --git a/src/Acceleration.java b/src/Acceleration.java deleted file mode 100644 index 3bccc68..0000000 --- a/src/Acceleration.java +++ /dev/null @@ -1,25 +0,0 @@ -import java.util.*; - -public class Acceleration { - private double mass; - private Map.Entry force; - private Velocity velocity; - private Onground onground; - private Map.Entry acceleration; - public void updateMass(double mass) { - this.mass = mass; - acceleration = (this.onground.getOnground() ? new AbstractMap.SimpleEntry<>((force.getKey()/mass), 0.0) : new AbstractMap.SimpleEntry<>((force.getKey()/mass), (force.getValue()/mass))); - velocity.updateAcceleration(acceleration); - } - public void updateForce(Map.Entry force) { - this.force = force; - acceleration = (this.onground.getOnground() ? new AbstractMap.SimpleEntry<>((force.getKey()/mass), 0.0) : new AbstractMap.SimpleEntry<>((force.getKey()/mass), (force.getValue()/mass))); - velocity.updateAcceleration(acceleration); - } - public Acceleration(Velocity velocity, Onground onground) { - this.onground = onground; - } - public Map.Entry getAcceleration() { - return acceleration; - } -} \ No newline at end of file diff --git a/src/Clear.java b/src/Clear.java deleted file mode 100644 index 5936436..0000000 --- a/src/Clear.java +++ /dev/null @@ -1,11 +0,0 @@ -import java.util.*; - -public class Clear { - private Position position; - public Clear(Position position) { - this.position = position; - } - public boolean getClear() { - return ((this.position.getPosition().getKey()>100.0) ? true : false); - } -} \ No newline at end of file diff --git a/src/Force.java b/src/Force.java deleted file mode 100644 index e379404..0000000 --- a/src/Force.java +++ /dev/null @@ -1,16 +0,0 @@ -import java.util.*; - -public class Force { - private Acceleration acceleration; - private Map.Entry force; - public Force(Acceleration acceleration) { - this.acceleration = acceleration; - } - public void gravity(double y) { - this.force = new AbstractMap.SimpleEntry<>(0.0, y); - acceleration.updateForce(force); - } - public Map.Entry getForce() { - return force; - } -} \ No newline at end of file diff --git a/src/Gameover.java b/src/Gameover.java deleted file mode 100644 index e0bef2f..0000000 --- a/src/Gameover.java +++ /dev/null @@ -1,11 +0,0 @@ -import java.util.*; - -public class Gameover { - private Position position; - public Gameover(Position position) { - this.position = position; - } - public boolean getGameover() { - return ((this.position.getPosition().getValue()<-(1.0)) ? true : false); - } -} \ No newline at end of file diff --git a/src/Ground.java b/src/Ground.java deleted file mode 100644 index 6a1763e..0000000 --- a/src/Ground.java +++ /dev/null @@ -1,12 +0,0 @@ -import java.util.*; - -public class Ground { - private Position position; - private boolean ground; - public Ground(Position position) { - this.position = position; - } - public boolean getGround() { - return ground; - } -} \ No newline at end of file diff --git a/src/JumpGame.java b/src/JumpGame.java deleted file mode 100644 index 9aca478..0000000 --- a/src/JumpGame.java +++ /dev/null @@ -1,61 +0,0 @@ -import java.util.*; - -public class JumpGame { - private Time time = new Time(); - private Position position = new Position(); - private Gameover gameover = new Gameover(position); - private Ground ground = new Ground(position); - private Onground onground = new Onground(ground,position); - private Velocity velocity = new Velocity(position,onground); - private Clear clear = new Clear(position); - private Move move = new Move(velocity); - private Acceleration acceleration = new Acceleration(velocity,onground); - private Force force = new Force(acceleration); - private Mass mass = new Mass(acceleration); - public void gravity(double y) { - this.force.gravity(y); - this.time.gravity(y); - } - public void moveY(double y) { - this.move.moveY(y); - } - public void moveX(double x) { - this.move.moveX(x); - } - public void setMass(double x) { - this.mass.setMass(x); - } - public Map.Entry getAcceleration() { - return acceleration.getAcceleration(); - } - public Map.Entry getMove() { - return move.getMove(); - } - public double getMass() { - return mass.getMass(); - } - public boolean getClear() { - return clear.getClear(); - } - public boolean getGround() { - return ground.getGround(); - } - public Map.Entry getForce() { - return force.getForce(); - } - public Map.Entry getVelocity() { - return velocity.getVelocity(); - } - public Map.Entry getPosition() { - return position.getPosition(); - } - public boolean getOnground() { - return onground.getOnground(); - } - public double getTime() { - return time.getTime(); - } - public boolean getGameover() { - return gameover.getGameover(); - } -} \ No newline at end of file diff --git a/src/Mass.java b/src/Mass.java deleted file mode 100644 index c381628..0000000 --- a/src/Mass.java +++ /dev/null @@ -1,16 +0,0 @@ -import java.util.*; - -public class Mass { - private Acceleration acceleration; - private double mass; - public Mass(Acceleration acceleration) { - this.acceleration = acceleration; - } - public void setMass(double x) { - this.mass = x; - acceleration.updateMass(mass); - } - public double getMass() { - return mass; - } -} \ No newline at end of file diff --git a/src/Move.java b/src/Move.java deleted file mode 100644 index ab8511b..0000000 --- a/src/Move.java +++ /dev/null @@ -1,19 +0,0 @@ -import java.util.*; - -public class Move { - private Velocity velocity; - private Map.Entry move; - public Move(Velocity velocity) { - this.velocity = velocity; - } - public void moveY(double y) { - this.move = new AbstractMap.SimpleEntry<>(this.move.getKey(), y); - velocity.updateMove(move); - } - public void moveX(double x) { - this.move = new AbstractMap.SimpleEntry<>(x, this.move.getValue()); - } - public Map.Entry getMove() { - return move; - } -} \ No newline at end of file diff --git a/src/Onground.java b/src/Onground.java deleted file mode 100644 index 694d757..0000000 --- a/src/Onground.java +++ /dev/null @@ -1,13 +0,0 @@ -import java.util.*; - -public class Onground { - private Ground ground; - private Position position; - public Onground(Ground ground, Position position) { - this.ground = ground; - this.position = position; - } - public boolean getOnground() { - return ((this.ground.getGround()==true)&&(this.position.getPosition().getValue()<=0.0)); - } -} \ No newline at end of file diff --git a/src/Position.java b/src/Position.java deleted file mode 100644 index 0ecaa4f..0000000 --- a/src/Position.java +++ /dev/null @@ -1,18 +0,0 @@ -import java.util.*; - -public class Position { - private Map.Entry velocity; - private boolean ground; - private Map.Entry position; - public void updateVelocity(Map.Entry velocity) { - this.velocity = velocity; - position = (((ground==true)&&((this.position.getValue()+(0.01*velocity.getValue()))<0.0)) ? new AbstractMap.SimpleEntry<>((this.position.getKey()+(0.01*velocity.getKey())), 0.0) : new AbstractMap.SimpleEntry<>((this.position.getKey()+(0.01*velocity.getKey())), (this.position.getValue()+(0.01*velocity.getValue())))); - } - public void updateGround(boolean ground) { - this.ground = ground; - position = (((ground==true)&&((this.position.getValue()+(0.01*velocity.getValue()))<0.0)) ? new AbstractMap.SimpleEntry<>((this.position.getKey()+(0.01*velocity.getKey())), 0.0) : new AbstractMap.SimpleEntry<>((this.position.getKey()+(0.01*velocity.getKey())), (this.position.getValue()+(0.01*velocity.getValue())))); - } - public Map.Entry getPosition() { - return position; - } -} \ No newline at end of file diff --git a/src/Time.java b/src/Time.java deleted file mode 100644 index cf5540a..0000000 --- a/src/Time.java +++ /dev/null @@ -1,11 +0,0 @@ -import java.util.*; - -public class Time { - private double time; - public void gravity(double y) { - this.time = (this.time+0.01); - } - public double getTime() { - return time; - } -} \ No newline at end of file diff --git a/src/Velocity.java b/src/Velocity.java deleted file mode 100644 index 4f20c7b..0000000 --- a/src/Velocity.java +++ /dev/null @@ -1,25 +0,0 @@ -import java.util.*; - -public class Velocity { - private Map.Entry acceleration; - private Map.Entry move; - private Position position; - private Onground onground; - private Map.Entry velocity; - public void updateAcceleration(Map.Entry acceleration) { - this.acceleration = acceleration; - velocity = ((this.onground.getOnground()&&(this.velocity.getValue()<0.0)) ? new AbstractMap.SimpleEntry<>((this.velocity.getKey()+(0.01*acceleration.getKey())), 0.0) : new AbstractMap.SimpleEntry<>((this.velocity.getKey()+(0.01*acceleration.getKey())), (this.velocity.getValue()+(0.01*acceleration.getValue())))); - position.updateVelocity(velocity); - } - public void updateMove(Map.Entry move) { - this.move = move; - velocity = ((this.onground.getOnground()&&(move.getValue()>=0.0)) ? move : this.velocity); - position.updateVelocity(velocity); - } - public Velocity(Position position, Onground onground) { - this.onground = onground; - } - public Map.Entry getVelocity() { - return velocity; - } -} \ No newline at end of file diff --git a/src/main/java/Main.java b/src/main/java/Main.java new file mode 100644 index 0000000..c6d48d4 --- /dev/null +++ b/src/main/java/Main.java @@ -0,0 +1,110 @@ +import org.lwjgl.glfw.*; +import org.lwjgl.opengl.*; + +import org.lwjgl.Version; +import static org.lwjgl.glfw.Callbacks.*; + +import static org.lwjgl.glfw.GLFW.*; +import static org.lwjgl.opengl.GL11.*; +import static org.lwjgl.system.MemoryUtil.*; + +public class Main { + + // The window handle + private long window; + + public void run() { + System.out.println("Hello LWJGL " + Version.getVersion() + "!"); + + try { + init(); + loop(); + + // Release window and window callbacks + glfwFreeCallbacks(window); + glfwDestroyWindow(window); + } finally { + // Terminate GLFW and release the GLFWerrorfun + glfwTerminate(); + glfwSetErrorCallback(null).free(); + } + } + + private void init() { + // Setup an error callback. The default implementation + // will print the error message in System.err. + GLFWErrorCallback.createPrint(System.err).set(); + + // Initialize GLFW. Most GLFW functions will not work before doing this. + if (!glfwInit()) { + throw new IllegalStateException("Unable to initialize GLFW"); + } + + // Configure our window + glfwDefaultWindowHints(); // optional, the current window hints are already the default + glfwWindowHint(GLFW_VISIBLE, GL_FALSE); // the window will stay hidden after creation + glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); // the window will be resizable + + int WIDTH = 300; + int HEIGHT = 300; + + // Create the window + window = glfwCreateWindow(WIDTH, HEIGHT, "Hello World!", NULL, NULL); + if (window == NULL) { + throw new RuntimeException("Failed to create the GLFW window"); + } + + // Setup a key callback. It will be called every time a key is pressed, repeated or released. + glfwSetKeyCallback(window, (window, key, scancode, action, mods) -> { + if (key == GLFW_KEY_ESCAPE && action == GLFW_RELEASE) { + glfwSetWindowShouldClose(window, true); // We will detect this in the rendering loop + } + }); + + // Get the resolution of the primary monitor + GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor()); + // Center our window + glfwSetWindowPos( + window, + (vidmode.width() - WIDTH) / 2, + (vidmode.height() - HEIGHT) / 2 + ); + + // Make the OpenGL context current + glfwMakeContextCurrent(window); + // Enable v-sync + glfwSwapInterval(1); + + // Make the window visible + glfwShowWindow(window); + } + + private void loop() { + // This line is critical for LWJGL's interoperation with GLFW's + // OpenGL context, or any context that is managed externally. + // LWJGL detects the context that is current in the current thread, + // creates the ContextCapabilities instance and makes the OpenGL + // bindings available for use. + GL.createCapabilities(); + + // Set the clear color + glClearColor(1.0f, 0.0f, 0.0f, 0.0f); + + // Run the rendering loop until the user has attempted to close + // the window or has pressed the ESCAPE key. + while (!glfwWindowShouldClose(window)) { + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // clear the framebuffer + + glfwSwapBuffers(window); // swap the color buffers + + // Poll for window events. The key callback above will only be + // invoked during this call. + glfwPollEvents(); + } + } + + public static void main(String[] args) { + new Main().run(); + } + +} \ No newline at end of file diff --git a/src/main/java/resources/Acceleration.java b/src/main/java/resources/Acceleration.java new file mode 100644 index 0000000..f7d33d4 --- /dev/null +++ b/src/main/java/resources/Acceleration.java @@ -0,0 +1,42 @@ +package resources; + +public class Acceleration { + private double massValue; + private Vector2 forceValue; + private Velocity velocity; + private Onground onground; + private Vector2 value; + + public void updateByMass(double mass) { + this.massValue = mass; + Vector2 temp_l0; + if (this.onground.getOnground()) { + temp_l0 = new Vector2((forceValue.getX() / mass), 0.0); + } else { + temp_l0 = new Vector2((forceValue.getX() / mass), (forceValue.getY() / mass)); + } + value = temp_l0; + velocity.updateByAcceleration(value); + } + + public void updateByForce(Vector2 force) { + this.forceValue = force; + Vector2 temp_l1; + if (this.onground.getOnground()) { + temp_l1 = new Vector2((force.getX() / massValue), 0.0); + } else { + temp_l1 = new Vector2((force.getX() / massValue), (force.getY() / massValue)); + } + value = temp_l1; + velocity.updateByAcceleration(value); + } + + public Acceleration(Velocity velocity, Onground onground) { + this.velocity = velocity; + this.onground = onground; + } + + public Vector2 getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/resources/Clear.java b/src/main/java/resources/Clear.java new file mode 100644 index 0000000..8076814 --- /dev/null +++ b/src/main/java/resources/Clear.java @@ -0,0 +1,19 @@ +package resources; + +public class Clear { + private Position position; + + public Clear(Position position) { + this.position = position; + } + + public boolean getClear() { + boolean temp_l4; + if ((this.position.getValue().getX() > 100.0)) { + temp_l4 = true; + } else { + temp_l4 = false; + } + return temp_l4; + } +} \ No newline at end of file diff --git a/src/main/java/resources/Force.java b/src/main/java/resources/Force.java new file mode 100644 index 0000000..5ee523e --- /dev/null +++ b/src/main/java/resources/Force.java @@ -0,0 +1,19 @@ +package resources; + +public class Force { + private Acceleration acceleration; + private Vector2 value; + + public Force(Acceleration acceleration) { + this.acceleration = acceleration; + } + + public void gravity(double y) { + this.value = new Vector2(0.0, y); + acceleration.updateByForce(value); + } + + public Vector2 getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/resources/Gameover.java b/src/main/java/resources/Gameover.java new file mode 100644 index 0000000..9f95b01 --- /dev/null +++ b/src/main/java/resources/Gameover.java @@ -0,0 +1,19 @@ +package resources; + +public class Gameover { + private Position position; + + public Gameover(Position position) { + this.position = position; + } + + public boolean getGameover() { + boolean temp_l6; + if ((this.position.getValue().getY() < -(1.0))) { + temp_l6 = true; + } else { + temp_l6 = false; + } + return temp_l6; + } +} \ No newline at end of file diff --git a/src/main/java/resources/Ground.java b/src/main/java/resources/Ground.java new file mode 100644 index 0000000..2df0f2f --- /dev/null +++ b/src/main/java/resources/Ground.java @@ -0,0 +1,9 @@ +package resources; + +public class Ground { + private boolean value; + + public boolean getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/resources/JumpGame.java b/src/main/java/resources/JumpGame.java new file mode 100644 index 0000000..6689e0e --- /dev/null +++ b/src/main/java/resources/JumpGame.java @@ -0,0 +1,76 @@ +package resources; + +public class JumpGame { + private Time time = new Time(); + private Ground ground = new Ground(); + private Position position = new Position(ground); + private Gameover gameover = new Gameover(position); + private Onground onground = new Onground(ground, position); + private Velocity velocity = new Velocity(position, onground); + private Clear clear = new Clear(position); + private Move move = new Move(velocity); + private Acceleration acceleration = new Acceleration(velocity, onground); + private Force force = new Force(acceleration); + private Mass mass = new Mass(acceleration); + + public void gravity(double y) { + this.force.gravity(y); + this.time.gravity(y); + } + + public void moveX(double x) { + this.move.moveX(x); + } + + public void moveY(double y) { + this.move.moveY(y); + } + + public void setMass(double x) { + this.mass.setValue(x); + } + + public Vector2 getAcceleration() { + return acceleration.getValue(); + } + + public Vector2 getMove() { + return move.getValue(); + } + + public double getMass() { + return mass.getValue(); + } + + public boolean getClear() { + return clear.getClear(); + } + + public boolean getGround() { + return ground.getValue(); + } + + public Vector2 getForce() { + return force.getValue(); + } + + public Vector2 getVelocity() { + return velocity.getValue(); + } + + public Vector2 getPosition() { + return position.getValue(); + } + + public boolean getOnground() { + return onground.getOnground(); + } + + public double getTime() { + return time.getValue(); + } + + public boolean getGameover() { + return gameover.getGameover(); + } +} \ No newline at end of file diff --git a/src/main/java/resources/Mass.java b/src/main/java/resources/Mass.java new file mode 100644 index 0000000..c0acc82 --- /dev/null +++ b/src/main/java/resources/Mass.java @@ -0,0 +1,19 @@ +package resources; + +public class Mass { + private Acceleration acceleration; + private double value; + + public Mass(Acceleration acceleration) { + this.acceleration = acceleration; + } + + public void setValue(double x) { + this.value = x; + acceleration.updateByMass(value); + } + + public double getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/resources/Move.java b/src/main/java/resources/Move.java new file mode 100644 index 0000000..20be320 --- /dev/null +++ b/src/main/java/resources/Move.java @@ -0,0 +1,23 @@ +package resources; + +public class Move { + private Velocity velocity; + private Vector2 value; + + public Move(Velocity velocity) { + this.velocity = velocity; + } + + public void moveX(double x) { + this.value = new Vector2(x, this.value.getY()); + velocity.updateByMove(value); + } + + public void moveY(double y) { + this.value = new Vector2(this.value.getX(), y); + } + + public Vector2 getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/resources/Onground.java b/src/main/java/resources/Onground.java new file mode 100644 index 0000000..de8ece5 --- /dev/null +++ b/src/main/java/resources/Onground.java @@ -0,0 +1,14 @@ +package resources; + +public class Onground { + private Ground ground; + private Position position; + + public Onground(Ground ground, Position position) { + this.ground = ground; + this.position = position; + } + + public boolean getOnground() { + return ((this.ground.getValue() == true) && (this.position.getValue().getY() <= 0.0)); } +} \ No newline at end of file diff --git a/src/main/java/resources/Position.java b/src/main/java/resources/Position.java new file mode 100644 index 0000000..d890660 --- /dev/null +++ b/src/main/java/resources/Position.java @@ -0,0 +1,24 @@ +package resources; + +public class Position { + private Ground ground; + private Vector2 value; + + public void updateByVelocity(Vector2 velocity) { + Vector2 temp_l3; + if (((this.ground.getValue() == true) && ((this.value.getY() + (0.01 * velocity.getY())) < 0.0))) { + temp_l3 = new Vector2((this.value.getX() + (0.01 * velocity.getX())), 0.0); + } else { + temp_l3 = new Vector2((this.value.getX() + (0.01 * velocity.getX())), (this.value.getY() + (0.01 * velocity.getY()))); + } + value = temp_l3; + } + + public Position(Ground ground) { + this.ground = ground; + } + + public Vector2 getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/resources/Time.java b/src/main/java/resources/Time.java new file mode 100644 index 0000000..3ba6de2 --- /dev/null +++ b/src/main/java/resources/Time.java @@ -0,0 +1,13 @@ +package resources; + +public class Time { + private double value; + + public void gravity(double y) { + this.value = (this.value + 0.01); + } + + public double getValue() { + return value; + } +} \ No newline at end of file diff --git a/src/main/java/resources/Vector2.java b/src/main/java/resources/Vector2.java new file mode 100644 index 0000000..8b97696 --- /dev/null +++ b/src/main/java/resources/Vector2.java @@ -0,0 +1,19 @@ +package resources; + +public class Vector2 { + private double x; + private double y; + + public Vector2(double x, double y) { + this.x = x; + this.y = y; + } + + public double getX() { + return this.x; + } + + public double getY() { + return this.y; + } +} diff --git a/src/main/java/resources/Velocity.java b/src/main/java/resources/Velocity.java new file mode 100644 index 0000000..fcae09b --- /dev/null +++ b/src/main/java/resources/Velocity.java @@ -0,0 +1,42 @@ +package resources; + +public class Velocity { + private Vector2 moveValue; + private Vector2 accelerationValue; + private Position position; + private Onground onground; + private Vector2 value; + + public void updateByMove(Vector2 move) { + this.moveValue = move; + Vector2 temp_l2; + if ((this.onground.getOnground() && (move.getY() >= 0.0))) { + temp_l2 = move; + } else { + temp_l2 = this.value; + } + value = temp_l2; + position.updateByVelocity(value); + } + + public void updateByAcceleration(Vector2 acceleration) { + this.accelerationValue = acceleration; + Vector2 temp_l5; + if ((this.onground.getOnground() && (this.value.getY() < 0.0))) { + temp_l5 = new Vector2((this.value.getX() + (0.01 * acceleration.getX())), 0.0); + } else { + temp_l5 = new Vector2((this.value.getX() + (0.01 * acceleration.getX())), (this.value.getY() + (0.01 * acceleration.getY()))); + } + value = temp_l5; + position.updateByVelocity(value); + } + + public Velocity(Position position, Onground onground) { + this.position = position; + this.onground = onground; + } + + public Vector2 getValue() { + return value; + } +} \ No newline at end of file