add-SuperJumpPaddle

master
王宇洋 3 years ago
parent 81375cc9a8
commit b24c34e7a9

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

@ -138,6 +138,7 @@ public class Player extends SceneObject {
t = (current_time - start_time) / 10;
h = (speed * t - 0.5 * g * t * t) / 10000;
jump_height = (float) h;
Camera.position.y = jump_height * 90;
setShadowOffset(new Vector4f(
-jump_height * 90,
0,
@ -741,6 +742,9 @@ public class Player extends SceneObject {
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
move = move.PlusVector(new Vector4f(0, speedY, 0, 0));
}
if(Keyboard.isKeyDown(Keyboard.KEY_8)){
player.jump(5000);
}
// System.out.println(move);
player.move(move);
// human.setPosition(new Point4f(posn_x * 3.0f, 0.0f, posn_y * 3.0f, 0));

@ -0,0 +1,80 @@
package Scene.Objects;
import Scene.Scene;
import Scene.base.SceneObject;
import base.GraphicsObjects.Point4f;
import base.GraphicsObjects.Vector4f;
import base.objects3D.DisplayListTexCube;
import org.lwjgl.opengl.GL11;
import org.newdawn.slick.Color;
import org.newdawn.slick.opengl.Texture;
import java.util.HashMap;
import static org.lwjgl.opengl.GL11.*;
/**
* @Author: WangYuyang
* @Date: 2021/11/25-16:33
* @Project: Assignment3
* @Package: Scene.Objects
* @Description:
**/
public class SuperJumpPaddle extends SceneObject {
public static float height = 0;
private final DisplayListTexCube cube = new DisplayListTexCube();
public SuperJumpPaddle(Point4f origin, Point4f position, Vector4f scale) {
super(origin, position, scale);
}
public SuperJumpPaddle(Point4f origin, Point4f position, Vector4f scale, HashMap<String, Texture> textures) {
super(origin, position, scale, textures);
}
public SuperJumpPaddle(Point4f origin, Point4f position, Vector4f scale, Vector4f rotation, HashMap<String, Texture> textures) {
super(origin, position, scale, rotation, textures);
}
@Override
public void draw(Integer delta) {
glDisable(GL_CULL_FACE);
GL11.glTexParameteri(
GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T,
GL11.GL_REPEAT);
GL11.glTexParameteri(
GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S,
GL11.GL_REPEAT);
Color.white.bind();
// Color.black.bind();
//bind texture
getTextures().get("piston_top").bind();
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL_NEAREST);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
// oval.DrawOval();
glScalef(1, height/2, 1);
getShadowOffset().x = height;
getShadowOffset().z = height;
cube.DrawTexCube();
glEnable(GL_CULL_FACE);
Color.white.bind();
}
@Override
public Boolean isHit(SceneObject other) {
Point4f o1 = getWorldPosition();
Point4f o2 = other.getWorldPosition();
Point4f o3 = new Point4f(o1.x, 0, o1.z, 0);
Point4f o4 = new Point4f(o2.x, 0, o2.z, 0);
if (o3.MinusPoint(o4).length() - this.getScale().x - other.getScale().x < 0) {
// float speed = Player.frame_delta / 1.6f;
// height += 0.01;
// Scene.player.move(new Vector4f(0,height,0,0));
// Camera.position.y += height * 90;
Scene.player.jump(4000);
}
return false;
}
}

@ -649,6 +649,36 @@ public class Scene {
}
}).start();
sceneManager.addSceneObject(new SuperJumpPaddle(
new Point4f(0f, 0f, -3700, 0),
new Point4f(0, 0, 0, 0),
new Vector4f(190, 10f + SuperJumpPaddle.height, 190, 0),
new Vector4f(0, 1, 0, 90),
textures
));
sceneManager.addSceneObject(new SuperJumpPaddle(
new Point4f(-3700, 0f, 0, 0),
new Point4f(0, 0, 0, 0),
new Vector4f(190, 10f + SuperJumpPaddle.height, 190, 0),
new Vector4f(0, 1, 0, 90),
textures
));
sceneManager.addSceneObject(new SuperJumpPaddle(
new Point4f(3700, 0f, 0, 0),
new Point4f(0, 0, 0, 0),
new Vector4f(190, 10f + SuperJumpPaddle.height, 190, 0),
new Vector4f(0, 1, 0, 90),
textures
));
sceneManager.addSceneObject(new SuperJumpPaddle(
new Point4f(0, 0f, 3700, 0),
new Point4f(0, 0, 0, 0),
new Vector4f(190, 10f + SuperJumpPaddle.height, 190, 0),
new Vector4f(0, 1, 0, 90),
textures
));
}
public static void initBackground(SceneManager backgroundManager, HashMap textures) {
@ -691,6 +721,12 @@ public class Scene {
bookParticleEmitter.update();
bookParticleEmitter.colorVec = new Vector3f(random.nextFloat() + 0.5f, random.nextFloat() + 0.5f, random.nextFloat() + 0.5f);
if (SuperJumpPaddle.height <= 10 ) {
SuperJumpPaddle.height += +1f;
}
else{
SuperJumpPaddle.height = -10;
}
// rightParticleEmitter.update();
// leftParticleEmitter.update();
// backParticleEmitter.update();

@ -246,7 +246,7 @@ public class Main {
}
};
new Thread(cameraRunnable).start();
// new Thread(cameraRunnable).start();
// new Thread(light_anmi).start();
while (!Display.isCloseRequested()) {

@ -45,6 +45,8 @@ public class TextureLoader {
loadTexture("new_face1.png");
loadTexture("new_face2.png");
loadTexture("new_face3.png");
loadTexture("iron_trapdoor.png");
loadTexture("piston_top.png");
//sky box
loadTexture("skybox/back.png");

Loading…
Cancel
Save