Newer
Older
AlgebraicDataflowArchitectureModel / GameEngine / src / main / java / gameEngine / entites / gameComponents / MoveImage.java
NoranekoFelician on 5 Nov 4 KB ・ボタン用画像追加。
package gameEngine.entites.gameComponents;
import gameEngine.entites.Entity;
import gameEngine.entites.GameObject;
import gameEngine.input.*;
import gameEngine.views.Window;

import java.awt.*;

import static org.lwjgl.glfw.GLFW.*;
import static org.lwjgl.opengl.GL11.*;


public class MoveImage extends GameComponent{

    private Entity entity;

    public MoveImage(Entity entity){
        this.entity = entity;
    }
    @Override
    public GameComponent copy() {
        return this;
    }

    public void update() {

        if(Input.GetKey(GLFW_KEY_O)){
            GameObject gameObject = (GameObject) entity;
            TextMesh textmesh = gameObject.getComponent(TextMesh.class);
            textmesh.setTextSize(textmesh.textSize+1);
        }
        if(Input.GetKey(GLFW_KEY_P)){
            GameObject gameObject = (GameObject) entity;
            TextMesh textmesh = gameObject.getComponent(TextMesh.class);
            textmesh.setTextSize(textmesh.textSize-1);
        }
        if(Input.GetKeyDown(GLFW_KEY_I)){
            GameObject gameObject = (GameObject) entity;
            TextMesh textmesh = gameObject.getComponent(TextMesh.class);
            textmesh.setText("popopo");
        }
        if(Input.GetKeyDown(GLFW_KEY_U)){
            GameObject gameObject = (GameObject) entity;
            TextMesh textmesh = gameObject.getComponent(TextMesh.class);
            textmesh.setColor(Color.RED);
        }

        if (Input.GetKey(GLFW_KEY_W)) {
            float y =  entity.transform.position.y;
            entity.transform.setPosition(entity.transform.position.x, y - 1, entity.transform.position.z);
        }
        if (Input.GetKey(GLFW_KEY_A)) {
            float x =  entity.transform.position.x;
            entity.transform.setPosition(x - 1, entity.transform.position.y, entity.transform.position.z);
        }
        if (Input.GetKey(GLFW_KEY_S)) {
            float y =  entity.transform.position.y;
            entity.transform.setPosition(entity.transform.position.x, y + 1, entity.transform.position.z);
        }
        if (Input.GetKey(GLFW_KEY_D)) {
            float x =  entity.transform.position.x;
            entity.transform.setPosition(x + 1,  entity.transform.position.y, entity.transform.position.z);
        }
        if (Input.GetKey(GLFW_KEY_Q)) {
            float z =  entity.transform.position.z;
            entity.transform.setPosition(entity.transform.position.x,  entity.transform.position.y, z - 1);
        }
        if (Input.GetKey(GLFW_KEY_E)) {
            float z =  entity.transform.position.z;
            entity.transform.setPosition(entity.transform.position.x,  entity.transform.position.y, z + 1);
        }
        if (Input.GetKey(GLFW_KEY_Z)) {
            float rotation = entity.transform.rotation.x;
            rotation -= 1;
            if (rotation < 0) rotation += 360;

            entity.transform.setRotation(rotation, entity.transform.rotation.y, entity.transform.rotation.z);  // 左回転
        }
        if (Input.GetKey(GLFW_KEY_C)) {
            float rotation = entity.transform.rotation.x;
            rotation += 1;
            if (rotation >= 360) rotation -= 360;
            entity.transform.setRotation(rotation ,entity.transform.rotation.y, entity.transform.rotation.z);  // 右回転
        }
        if (Input.GetKey(GLFW_KEY_UP)) {
            float rotation = entity.transform.rotation.y;
            rotation -= 1;
            if (rotation < 0) rotation += 360;

            entity.transform.setRotation(entity.transform.rotation.x, rotation, entity.transform.rotation.z);  // 左回転
        }
        if (Input.GetKey(GLFW_KEY_DOWN)) {
            float rotation = entity.transform.rotation.y;
            rotation += 1;
            if (rotation >= 360) rotation -= 360;
            entity.transform.setRotation(entity.transform.rotation.x, rotation, entity.transform.rotation.z);  // 右回転
        }
        if (Input.GetKey(GLFW_KEY_LEFT)) {
            float rotation = entity.transform.rotation.z;
            rotation -= 1;
            if (rotation < 0) rotation += 360;

            entity.transform.setRotation(entity.transform.rotation.x, entity.transform.rotation.y, rotation);  // 左回転
        }
        if (Input.GetKey(GLFW_KEY_RIGHT)) {
            float rotation = entity.transform.rotation.z;
            rotation += 1;
            if (rotation >= 360) rotation -= 360;
            entity.transform.setRotation(entity.transform.rotation.x, entity.transform.rotation.y, rotation);  // 右回転
        }
    }
}