Hitbox added
This commit is contained in:
parent
ed2f49ad0e
commit
7439137e4d
13
shaders/StylishShaders/HitboxFrag.glsl
Normal file
13
shaders/StylishShaders/HitboxFrag.glsl
Normal file
@ -0,0 +1,13 @@
|
||||
#version 410
|
||||
|
||||
in vec3 color;
|
||||
in vec3 fragCoord;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform float time;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = vec4(color, 0.4f);
|
||||
}
|
@ -3,6 +3,7 @@ package engine;
|
||||
import engine.gui.UIElementText;
|
||||
import engine.input.*;
|
||||
import engine.math.Vector3f;
|
||||
import engine.object.Hitbox;
|
||||
import engine.object.ObjectGl;
|
||||
import engine.object.Sprite;
|
||||
import engine.sound.*;
|
||||
@ -59,6 +60,9 @@ public class TestEngine {
|
||||
zangief2.translate(new Vector3f(1000.0f, 200.0f, 0.0f));
|
||||
zangief2.flipTextureWrapH();
|
||||
|
||||
Hitbox hitboxTest = new Hitbox(35.0f, 100.0f, 50.0f, 10.0f, new Vector3f(1.0f, 0.0f, 0.0f));
|
||||
engine.add_objectGl(hitboxTest);
|
||||
|
||||
engine.setCameraTrackingSF3ThirdStrike(zangief, zangief2);
|
||||
|
||||
//Create background
|
||||
|
@ -4,6 +4,6 @@ import engine.math.Vector3f;
|
||||
|
||||
public interface TrackingDummy {
|
||||
|
||||
public Vector3f getViewVector();
|
||||
Vector3f getViewVector();
|
||||
|
||||
}
|
||||
|
@ -29,8 +29,6 @@ public class TrackingSF3ThirdStrick implements TrackingDummy {
|
||||
ObjectGl left = obj1.getXPos() >= obj2.getXPos() ? obj2 : obj1;
|
||||
ObjectGl right = obj1.getXPos() < obj2.getXPos() ? obj2 : obj1;
|
||||
|
||||
System.out.println(viewXPos);
|
||||
|
||||
if ((right.getXPos() + right.getWidth() * right.getScalingFactor()) > viewXPos + dimension){
|
||||
vec.x = - Math.abs((right.getXPos() + right.getWidth() * right.getScalingFactor()) - (viewXPos + dimension));
|
||||
} else if (left.getXPos() < viewXPos - dimension){
|
||||
@ -38,6 +36,5 @@ public class TrackingSF3ThirdStrick implements TrackingDummy {
|
||||
}
|
||||
|
||||
return vec;
|
||||
|
||||
}
|
||||
}
|
||||
|
21
src/engine/object/Hitbox.java
Normal file
21
src/engine/object/Hitbox.java
Normal file
@ -0,0 +1,21 @@
|
||||
package engine.object;
|
||||
|
||||
import engine.math.Vector3f;
|
||||
|
||||
public class Hitbox extends ObjectGl{
|
||||
|
||||
|
||||
/**
|
||||
* Create a rectangle shape, use setTextureWrap to correctly align the texture with the model
|
||||
*
|
||||
* @param z depth of your model the larger it is the more it will be "close" to the camera
|
||||
* @param w height of the rectangle
|
||||
* @param h width of the rectangle
|
||||
* @param size scaling factor of the rectangle, the model could not show up because this value is too small or too large, a good compromise is between 2 and 15
|
||||
* @param color set to null if you don't want a Color on your model
|
||||
*/
|
||||
public Hitbox(float z, float w, float h, float size, Vector3f color) {
|
||||
super(z, w, h, size, null, color);
|
||||
this.setShader("shaders/ObjectGlColor/vert.glsl", "shaders/StylishShaders/HitboxFrag.glsl");
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user