diff --git a/GameEngine/src/main/java/org/example/ColorController.java b/GameEngine/src/main/java/org/example/ColorController.java index 7949bda..52cd4cb 100644 --- a/GameEngine/src/main/java/org/example/ColorController.java +++ b/GameEngine/src/main/java/org/example/ColorController.java @@ -1,47 +1,78 @@ package org.example; -import static org.lwjgl.glfw.GLFW.*; -import static org.lwjgl.opengl.GL11.glClearColor; +import org.lwjgl.opengl.GL11; public class ColorController implements IGameComponent { + private float red; + private float green; + private float blue; + private int customKeyInput; + private static int customKeyCode; + private int customColor; - private float red, green, blue; - - @Override - public void init() { - setColor(0.0f,0.0f,0.0f); + public ColorController() { } - @Override - public void update() { + public void init() { + this.setColor(0.0F, 0.0F, 0.0F); + } - if (KeyInput.KeyDown(GLFW_KEY_R)) { - setColor(1.0f, 0.0f, 0.0f); // Rキーが押された瞬間 + public void update() { + if (KeyInput.KeyDown(82)) { + this.setColor(1.0F, 0.0F, 0.0F); System.out.println("R"); } - if (KeyInput.KeyPress(GLFW_KEY_G)) { - setColor(0.0f, 1.0f, 0.0f); // Gキーが押され続けている間 + + if (KeyInput.KeyPress(71)) { + this.setColor(0.0F, 1.0F, 0.0F); System.out.println("G"); } - if (KeyInput.KeyUp(GLFW_KEY_B)) { - setColor(0.0f, 0.0f, 1.0f); // Bキーが離された瞬間 + + if (KeyInput.KeyUp(66)) { + this.setColor(0.0F, 0.0F, 1.0F); System.out.println("B"); } - if (KeyInput.KeyUp(GLFW_KEY_Y)) { - setColor(1.0f, 1.0f, 0.0f); + + if (KeyInput.KeyUp(89)) { + this.setColor(1.0F, 1.0F, 0.0F); System.out.println("Y"); } - glClearColor(getRed(), getGreen(), getBlue(), 0.0f); + if (KeyInput.KeyPress(customKeyCode)) { + this.setColor(0.0F, 1.0F, 1.0F); + System.out.println("Custom"); + } + + GL11.glClearColor(this.getRed(), this.getGreen(), this.getBlue(), 0.0F); } - public float getRed() { return red; } - public float getGreen() { return green; } - public float getBlue() { return blue; } - - public void setColor(float r, float g, float b){ - red = r; - green = g; - blue = b; + public float getRed() { + return this.red; } -} \ No newline at end of file + + public float getGreen() { + return this.green; + } + + public float getBlue() { + return this.blue; + } + + public void setColor(float r, float g, float b) { + this.red = r; + this.green = g; + this.blue = b; + } + + public void setCustomKeyInput(int value) { + this.customKeyInput = value; + } + + public static void setCustomKeyCode(int value) { + customKeyCode = value; + } + + public void setCustomColor(int value) { + this.customColor = value; + } +}