master
王宇洋 3 years ago
parent c76c5ce1fe
commit b00ee488f1

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.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,177 @@
package Scene.Objects;
import Scene.Scene;
import Scene.base.SceneObject;
import base.GraphicsObjects.Point4f;
import base.GraphicsObjects.Vector4f;
import base.objects3D.DisplayListTexCube;
import base.objects3D.DisplayListTexSphere;
import org.lwjgl.input.Keyboard;
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/12/13-12:39
* @Project: Assignment3
* @Package: Scene.Objects
* @Description:
**/
public class Balloon extends SceneObject {
DisplayListTexCube cube = new DisplayListTexCube();
DisplayListTexSphere sphere = new DisplayListTexSphere(1f, 16, 16, getTextures().get("wool_pink"));
private Boolean openDoor = false;
public Balloon(Point4f origin, Point4f position, Vector4f scale) {
super(origin, position, scale);
}
public Balloon(Point4f origin, Point4f position, Vector4f scale, HashMap<String, Texture> textures) {
super(origin, position, scale, textures);
}
public Balloon(Point4f origin, Point4f position, Vector4f scale, Vector4f rotation, HashMap<String, Texture> textures) {
super(origin, position, scale, rotation, textures);
}
@Override
public void draw(Integer delta) {
if (Keyboard.isKeyDown(Keyboard.KEY_RETURN) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
if (!Scene.player.getJumping()) {
setPosition(new Point4f(
0,
Scene.player.getPosition().y / 10,
0,
0
));
setShadowOffset(new Vector4f(
-Scene.player.getPosition().y * 900,
0,
-Scene.player.getPosition().y * 900,
0
));
}
}
float distance = getWorldPosition().MinusPoint(Scene.player.getWorldPosition()).length();
if (distance > 2375 && distance < 2500) {
openDoor = true;
} else {
openDoor = false;
}
Color.white.bind();
GL11.glBindTexture(GL_TEXTURE_2D, 0);
GL11.glTexParameteri(
GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T,
GL11.GL_CLAMP);
GL11.glTexParameteri(
GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S,
GL11.GL_CLAMP);
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);
glDisable(GL_CULL_FACE);
getTextures().get("earthspace").bind();
sphere.DrawTexSphere();
getTextures().get("default_dirt").bind();
glPushMatrix();
{
glTranslatef(0, -2.75f, 0);
glScalef(0.3f, 0.01f, 0.3f);
cube.DrawTexCube();
}
glPopMatrix();
glPushMatrix();
{
glTranslatef(0.3f, 0, 0);
glTranslatef(0, -2.65f, 0);
glRotatef(90, 0, 0, 1f);
glScalef(0.1f, 0.01f, 0.3f);
cube.DrawTexCube();
}
glPopMatrix();
glPushMatrix();
{
glTranslatef(-0.3f, 0, 0);
glTranslatef(0, -2.65f, 0);
glRotatef(90, 0, 0, 1f);
glScalef(0.1f, 0.01f, 0.3f);
cube.DrawTexCube();
}
glPopMatrix();
glPushMatrix();
{
glTranslatef(0f, -0f, 0.3f);
glTranslatef(0, -2.65f, 0);
glRotatef(90, 0, 0, 1f);
glRotatef(90, 1, 0, 0f);
glScalef(0.1f, 0.01f, 0.3f);
cube.DrawTexCube();
}
glPopMatrix();
glPushMatrix();
{
glTranslatef(0f, -0f, -0.3f);
glTranslatef(0, -2.65f, 0);
glRotatef(90, 0, 0, 1f);
glRotatef(90, 1, 0, 0f);
glScalef(0.1f, 0.01f, 0.3f);
if (!openDoor)
cube.DrawTexCube();
}
glPopMatrix();
GL11.glBindTexture(GL_TEXTURE_2D, 0);
getTextures().get("default_cobble").bind();
glPushMatrix();
{
glTranslatef(0.35f, 0f, 0.62f);
glTranslatef(0, -1.19f, 0);
glRotatef(20, 1, 1, 0f);
glScalef(0.01f, 1.4f, 0.01f);
cube.DrawTexCube();
}
glPopMatrix();
glPushMatrix();
{
glRotatef(90, 0, 1, 0f);
glTranslatef(0.35f, 0f, 0.62f);
glTranslatef(0, -1.19f, 0);
glRotatef(20, 1, 1, 0f);
glScalef(0.01f, 1.4f, 0.01f);
cube.DrawTexCube();
}
glPopMatrix();
glPushMatrix();
{
glRotatef(180, 0, 1, 0f);
glTranslatef(0.35f, 0f, 0.62f);
glTranslatef(0, -1.19f, 0);
glRotatef(20, 1, 1, 0f);
glScalef(0.01f, 1.4f, 0.01f);
cube.DrawTexCube();
}
glPopMatrix();
glPushMatrix();
{
glRotatef(270, 0, 1, 0f);
glTranslatef(0.35f, 0f, 0.62f);
glTranslatef(0, -1.19f, 0);
glRotatef(20, 1, 1, 0f);
glScalef(0.01f, 1.4f, 0.01f);
cube.DrawTexCube();
}
glPopMatrix();
GL11.glBindTexture(GL_TEXTURE_2D, 0);
glEnable(GL_CULL_FACE);
Color.white.bind();
}
}

@ -138,7 +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;
Camera.position.y = jump_height * 90 + getPosition().y * 90;
setShadowOffset(new Vector4f(
-jump_height * 90,
0,
@ -742,7 +742,7 @@ 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)){
if (Keyboard.isKeyDown(Keyboard.KEY_8)) {
player.jump(5000);
}
// System.out.println(move);
@ -759,8 +759,10 @@ public class Player extends SceneObject {
return move;
}
// @Override
public Boolean getJumping() {
return isJumping;
}
// @Override
// public void drawShadow() {
//
// }

@ -596,6 +596,14 @@ public class Scene {
new Vector4f(0, 1, 0, 90),
textures
));
sceneManager.addSceneObject(new Balloon(
new Point4f(-1800, 2500, 1800, 0),
new Point4f(0, 0, 0, 0),
new Vector4f(900, 900, 900, 0),
new Vector4f(0, 0, 0, 0),
textures
));
//
//
@ -721,10 +729,9 @@ 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 ) {
if (SuperJumpPaddle.height <= 10) {
SuperJumpPaddle.height += +1f;
}
else{
} else {
SuperJumpPaddle.height = -10;
}
// rightParticleEmitter.update();

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

Loading…
Cancel
Save