'Completed' (Not Very Completed) Work
BIN
EggSimulator.zip
Normal file
BIN
LudumDare46.jar
187
res/audio/kill.aup
Normal file
|
@ -0,0 +1,187 @@
|
|||
<?xml version="1.0" standalone="no" ?>
|
||||
<!DOCTYPE project PUBLIC "-//audacityproject-1.3.0//DTD//EN" "http://audacity.sourceforge.net/xml/audacityproject-1.3.0.dtd" >
|
||||
<project xmlns="http://audacity.sourceforge.net/xml/" projname="kill_data" version="1.3.0" audacityversion="2.3.2" sel0="0.0060584427" sel1="1.2156417761" vpos="896" h="0.0000000000" zoom="164.7836538462" rate="48000.0" snapto="off" selectionformat="hh:mm:ss + milliseconds" frequencyformat="Hz" bandwidthformat="octaves">
|
||||
<tags>
|
||||
<tag name="Software" value="Lavf58.39.101"/>
|
||||
</tags>
|
||||
<wavetrack name="Thumps" channel="0" linked="1" mute="0" solo="0" height="150" minimized="0" isSelected="1" rate="48000" gain="1.0" pan="0.0" colorindex="0">
|
||||
<waveclip offset="0.30542291" colorindex="0">
|
||||
<sequence maxsamples="262144" sampleformat="262159" numsamples="28704">
|
||||
<waveblock start="0">
|
||||
<simpleblockfile filename="e0808528.au" len="28704" min="-0.121093" max="0.116137" rms="0.025088"/>
|
||||
</waveblock>
|
||||
</sequence>
|
||||
<envelope numpoints="0"/>
|
||||
</waveclip>
|
||||
<waveclip offset="0.01214583" colorindex="0">
|
||||
<sequence maxsamples="262144" sampleformat="262159" numsamples="14077">
|
||||
<waveblock start="0">
|
||||
<simpleblockfile filename="e0808456.au" len="14077" min="-0.160284" max="0.126691" rms="0.03849"/>
|
||||
</waveblock>
|
||||
</sequence>
|
||||
<envelope numpoints="0"/>
|
||||
</waveclip>
|
||||
</wavetrack>
|
||||
<wavetrack name="Thumps" channel="1" linked="0" mute="0" solo="0" height="150" minimized="0" isSelected="1" rate="48000" gain="1.0" pan="0.0" colorindex="0">
|
||||
<waveclip offset="0.30542291" colorindex="0">
|
||||
<sequence maxsamples="262144" sampleformat="262159" numsamples="28704">
|
||||
<waveblock start="0">
|
||||
<simpleblockfile filename="e0808f95.au" len="28704" min="-0.095378" max="0.109781" rms="0.023558"/>
|
||||
</waveblock>
|
||||
</sequence>
|
||||
<envelope numpoints="0"/>
|
||||
</waveclip>
|
||||
<waveclip offset="0.01214583" colorindex="0">
|
||||
<sequence maxsamples="262144" sampleformat="262159" numsamples="14077">
|
||||
<waveblock start="0">
|
||||
<simpleblockfile filename="e08089e2.au" len="14077" min="-0.146744" max="0.173983" rms="0.037692"/>
|
||||
</waveblock>
|
||||
</sequence>
|
||||
<envelope numpoints="0"/>
|
||||
</waveclip>
|
||||
</wavetrack>
|
||||
<wavetrack name="Audio Track" channel="0" linked="1" mute="0" solo="0" height="150" minimized="0" isSelected="1" rate="48000" gain="1.0" pan="0.0" colorindex="0">
|
||||
<waveclip offset="0.01214583" colorindex="0">
|
||||
<sequence maxsamples="262144" sampleformat="262159" numsamples="43269">
|
||||
<waveblock start="0">
|
||||
<simpleblockfile filename="e0808575.au" len="43269" min="-0.236975" max="0.315122" rms="0.061892"/>
|
||||
</waveblock>
|
||||
</sequence>
|
||||
<envelope numpoints="0"/>
|
||||
</waveclip>
|
||||
</wavetrack>
|
||||
<wavetrack name="Audio Track" channel="1" linked="0" mute="0" solo="0" height="150" minimized="0" isSelected="1" rate="48000" gain="1.0" pan="0.0" colorindex="0">
|
||||
<waveclip offset="0.01214583" colorindex="0">
|
||||
<sequence maxsamples="262144" sampleformat="262159" numsamples="43269">
|
||||
<waveblock start="0">
|
||||
<simpleblockfile filename="e08083af.au" len="43269" min="-0.336931" max="0.242176" rms="0.062847"/>
|
||||
</waveblock>
|
||||
</sequence>
|
||||
<envelope numpoints="0"/>
|
||||
</waveclip>
|
||||
</wavetrack>
|
||||
<wavetrack name="Audio Track" channel="0" linked="1" mute="0" solo="0" height="150" minimized="0" isSelected="1" rate="48000" gain="1.0" pan="0.0" colorindex="0">
|
||||
<waveclip offset="0.88110950" colorindex="0">
|
||||
<sequence maxsamples="262144" sampleformat="262159" numsamples="2039">
|
||||
<waveblock start="0">
|
||||
<simpleblockfile filename="e080881a.au" len="2039" min="-0.000185" max="0.000056" rms="0.00001"/>
|
||||
</waveblock>
|
||||
</sequence>
|
||||
<envelope numpoints="0"/>
|
||||
</waveclip>
|
||||
<waveclip offset="0.92358866" colorindex="0">
|
||||
<sequence maxsamples="262144" sampleformat="262159" numsamples="1364">
|
||||
<waveblock start="0">
|
||||
<simpleblockfile filename="e080859f.au" len="1364" min="-0.000065" max="0.000184" rms="0.000006"/>
|
||||
</waveblock>
|
||||
</sequence>
|
||||
<envelope numpoints="0"/>
|
||||
</waveclip>
|
||||
<waveclip offset="0.00805475" colorindex="0">
|
||||
<sequence maxsamples="262144" sampleformat="262159" numsamples="41907">
|
||||
<waveblock start="0">
|
||||
<simpleblockfile filename="e0808923.au" len="41907" min="-1.621721" max="3.158184" rms="0.229924"/>
|
||||
</waveblock>
|
||||
</sequence>
|
||||
<envelope numpoints="0"/>
|
||||
</waveclip>
|
||||
</wavetrack>
|
||||
<wavetrack name="Audio Track" channel="1" linked="0" mute="0" solo="0" height="150" minimized="0" isSelected="1" rate="48000" gain="1.0" pan="0.0" colorindex="0">
|
||||
<waveclip offset="0.88110950" colorindex="0">
|
||||
<sequence maxsamples="262144" sampleformat="262159" numsamples="2039">
|
||||
<waveblock start="0">
|
||||
<simpleblockfile filename="e0808fdb.au" len="2039" min="-0.000185" max="0.000056" rms="0.00001"/>
|
||||
</waveblock>
|
||||
</sequence>
|
||||
<envelope numpoints="0"/>
|
||||
</waveclip>
|
||||
<waveclip offset="0.92358866" colorindex="0">
|
||||
<sequence maxsamples="262144" sampleformat="262159" numsamples="1364">
|
||||
<waveblock start="0">
|
||||
<simpleblockfile filename="e0808f6d.au" len="1364" min="-0.000065" max="0.000184" rms="0.000006"/>
|
||||
</waveblock>
|
||||
</sequence>
|
||||
<envelope numpoints="0"/>
|
||||
</waveclip>
|
||||
<waveclip offset="0.00805475" colorindex="0">
|
||||
<sequence maxsamples="262144" sampleformat="262159" numsamples="41907">
|
||||
<waveblock start="0">
|
||||
<simpleblockfile filename="e08086f9.au" len="41907" min="-1.621721" max="3.158184" rms="0.229924"/>
|
||||
</waveblock>
|
||||
</sequence>
|
||||
<envelope numpoints="0"/>
|
||||
</waveclip>
|
||||
</wavetrack>
|
||||
<wavetrack name="Audio Track" channel="0" linked="1" mute="0" solo="0" height="150" minimized="0" isSelected="1" rate="48000" gain="1.0" pan="0.0" colorindex="0">
|
||||
<waveclip offset="0.32967975" colorindex="0">
|
||||
<sequence maxsamples="262144" sampleformat="262159" numsamples="28704">
|
||||
<waveblock start="0">
|
||||
<simpleblockfile filename="e0808adf.au" len="28704" min="-0.000164" max="0.00004" rms="0.000008"/>
|
||||
</waveblock>
|
||||
</sequence>
|
||||
<envelope numpoints="0"/>
|
||||
</waveclip>
|
||||
<waveclip offset="0.92767975" colorindex="0">
|
||||
<sequence maxsamples="262144" sampleformat="262159" numsamples="1364">
|
||||
<waveblock start="0">
|
||||
<simpleblockfile filename="e0808075.au" len="1364" min="0.0" max="0.0" rms="0.0"/>
|
||||
</waveblock>
|
||||
</sequence>
|
||||
<envelope numpoints="0"/>
|
||||
</waveclip>
|
||||
<waveclip offset="0.01214583" colorindex="0">
|
||||
<sequence maxsamples="262144" sampleformat="262159" numsamples="15242">
|
||||
<waveblock start="0">
|
||||
<simpleblockfile filename="e08086f1.au" len="15242" min="-0.936817" max="1.472945" rms="0.138766"/>
|
||||
</waveblock>
|
||||
</sequence>
|
||||
<envelope numpoints="0"/>
|
||||
</waveclip>
|
||||
</wavetrack>
|
||||
<wavetrack name="Audio Track" channel="1" linked="0" mute="0" solo="0" height="150" minimized="0" isSelected="1" rate="48000" gain="1.0" pan="0.0" colorindex="0">
|
||||
<waveclip offset="0.32967975" colorindex="0">
|
||||
<sequence maxsamples="262144" sampleformat="262159" numsamples="28704">
|
||||
<waveblock start="0">
|
||||
<simpleblockfile filename="e0808471.au" len="28704" min="-0.000164" max="0.00004" rms="0.000008"/>
|
||||
</waveblock>
|
||||
</sequence>
|
||||
<envelope numpoints="0"/>
|
||||
</waveclip>
|
||||
<waveclip offset="0.92767975" colorindex="0">
|
||||
<sequence maxsamples="262144" sampleformat="262159" numsamples="1364">
|
||||
<waveblock start="0">
|
||||
<simpleblockfile filename="e0808d09.au" len="1364" min="0.0" max="0.0" rms="0.0"/>
|
||||
</waveblock>
|
||||
</sequence>
|
||||
<envelope numpoints="0"/>
|
||||
</waveclip>
|
||||
<waveclip offset="0.01214583" colorindex="0">
|
||||
<sequence maxsamples="262144" sampleformat="262159" numsamples="15242">
|
||||
<waveblock start="0">
|
||||
<simpleblockfile filename="e0808c15.au" len="15242" min="-0.936817" max="1.472945" rms="0.138766"/>
|
||||
</waveblock>
|
||||
</sequence>
|
||||
<envelope numpoints="0"/>
|
||||
</waveclip>
|
||||
</wavetrack>
|
||||
<wavetrack name="Audio Track" channel="0" linked="1" mute="0" solo="0" height="150" minimized="0" isSelected="1" rate="48000" gain="1.0" pan="0.0" colorindex="0">
|
||||
<waveclip offset="0.00605844" colorindex="0">
|
||||
<sequence maxsamples="262144" sampleformat="262159" numsamples="58060">
|
||||
<waveblock start="0">
|
||||
<simpleblockfile filename="e0808155.au" len="58060" min="-0.959439" max="0.999955" rms="0.058223"/>
|
||||
</waveblock>
|
||||
</sequence>
|
||||
<envelope numpoints="0"/>
|
||||
</waveclip>
|
||||
</wavetrack>
|
||||
<wavetrack name="Audio Track" channel="1" linked="0" mute="0" solo="0" height="150" minimized="0" isSelected="1" rate="48000" gain="1.0" pan="0.0" colorindex="0">
|
||||
<waveclip offset="0.00605844" colorindex="0">
|
||||
<sequence maxsamples="262144" sampleformat="262159" numsamples="58060">
|
||||
<waveblock start="0">
|
||||
<simpleblockfile filename="e0808391.au" len="58060" min="-0.959439" max="0.999955" rms="0.058223"/>
|
||||
</waveblock>
|
||||
</sequence>
|
||||
<envelope numpoints="0"/>
|
||||
</waveclip>
|
||||
</wavetrack>
|
||||
</project>
|
BIN
res/audio/kill.wav
Normal file
BIN
res/audio/kill_data/e08/d08/e0808155.au
Normal file
BIN
res/audio/kill_data/e08/d08/e0808391.au
Normal file
BIN
res/audio/kill_data/e08/d08/e0808528.au
Normal file
BIN
res/audio/kill_data/e08/d08/e0808f95.au
Normal file
4631
res/img/eggs.ai
BIN
res/img/eggs.png
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 10 KiB |
3051
res/img/heal.ai
Normal file
BIN
res/img/heal.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
1163
res/img/kills.ai
Normal file
BIN
res/img/kills.png
Normal file
After Width: | Height: | Size: 760 B |
1159
res/img/numbers.ai
Normal file
BIN
res/img/numbers.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
res/img/screenshot1.png
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
res/img/screenshot2.png
Normal file
After Width: | Height: | Size: 33 KiB |
2630
res/img/thumbnail.ai
Normal file
BIN
res/img/thumbnail.png
Normal file
After Width: | Height: | Size: 34 KiB |
|
@ -5,6 +5,7 @@ import com.gnarwhal.ld46.engine.shaders.Shader;
|
|||
import com.gnarwhal.ld46.engine.shaders.Shader2t;
|
||||
import com.gnarwhal.ld46.engine.texture.Texture;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector2f;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public class TexRect extends Rect {
|
||||
|
@ -23,9 +24,13 @@ public class TexRect extends Rect {
|
|||
this.texture = texture;
|
||||
}
|
||||
|
||||
private final Vector2f offset = new Vector2f(0, 0);
|
||||
private final Vector2f sub = new Vector2f(1, 1);
|
||||
|
||||
public void render() {
|
||||
texture.bind();
|
||||
shader.enable();
|
||||
shader.setSubtexture(offset, sub);
|
||||
Matrix4f cmat = gui ? camera.getProjection() : camera.getMatrix();
|
||||
shader.setMVP(cmat.translate(position.add(width * scale / 2, height * scale / 2, 0, new Vector3f())).rotateZ(rotation).scale(width * scale * direction, height * scale, 1).translate(-0.5f, -0.5f, 0));
|
||||
vao.render();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.gnarwhal.ld46.game;
|
||||
|
||||
import com.gnarwhal.ld46.engine.audio.Sound;
|
||||
import com.gnarwhal.ld46.engine.display.Camera;
|
||||
import com.gnarwhal.ld46.engine.model.Rect;
|
||||
import com.gnarwhal.ld46.engine.shaders.Shader;
|
||||
|
@ -15,6 +16,13 @@ public class Egg extends Rect {
|
|||
private static final float WIDTH = 96;
|
||||
private static final float HEIGHT = 128;
|
||||
|
||||
public static final int
|
||||
ALIVE = 0x00,
|
||||
DYING = 0x01,
|
||||
DEAD = 0x02;
|
||||
|
||||
private static final float FULL_HEALTH = 20;
|
||||
|
||||
private static Texture texture;
|
||||
private static Shader2t shader;
|
||||
|
||||
|
@ -30,10 +38,18 @@ public class Egg extends Rect {
|
|||
private float vertBounceDecay;
|
||||
private float bounceChangeTime;
|
||||
|
||||
private float health;
|
||||
private int state;
|
||||
|
||||
public Egg(Camera camera) {
|
||||
super(camera, (camera.getWidth() - WIDTH) / 2, (camera.getHeight() - HEIGHT) / 2, -0.2f, WIDTH, HEIGHT, 0, false);
|
||||
reset();
|
||||
}
|
||||
|
||||
velocity = new Vector3f(600, -600, 0);
|
||||
public void reset() {
|
||||
set((camera.getWidth() - WIDTH) / 2, (camera.getHeight() - HEIGHT) / 2, WIDTH, HEIGHT);
|
||||
|
||||
velocity = new Vector3f(0, -840, 0);
|
||||
|
||||
if (texture == null) {
|
||||
texture = new Texture("res/img/eggs.png");
|
||||
|
@ -44,6 +60,10 @@ public class Egg extends Rect {
|
|||
b = (WIDTH - HEIGHT) / 4;
|
||||
|
||||
vertBounceDecay = VERT_BOUNCE_DECAY;
|
||||
|
||||
health = FULL_HEALTH;
|
||||
|
||||
state = ALIVE;
|
||||
}
|
||||
|
||||
public void update(Platform[] platforms) {
|
||||
|
@ -65,9 +85,11 @@ public class Egg extends Rect {
|
|||
friction = -GROUNDED_DECELERATION * (velocity.x / Math.abs(velocity.x));
|
||||
}
|
||||
|
||||
float absVelocityY = Math.abs(velocity.y());
|
||||
if (absVelocityY > TERMINAL_VELOCITY) {
|
||||
velocity.y = (velocity.y / absVelocityY) * TERMINAL_VELOCITY;
|
||||
if (state == ALIVE) {
|
||||
float absVelocityY = Math.abs(velocity.y());
|
||||
if (absVelocityY > TERMINAL_VELOCITY) {
|
||||
velocity.y = (velocity.y / absVelocityY) * TERMINAL_VELOCITY;
|
||||
}
|
||||
}
|
||||
|
||||
velocity.add(acceleration.mul((float) dtime, new Vector3f()));
|
||||
|
@ -85,7 +107,7 @@ public class Egg extends Rect {
|
|||
Vector3f translation = velocity.mul((float) dtime, new Vector3f());
|
||||
Vector3f translationCopy = new Vector3f(translation);
|
||||
|
||||
if (translation.y > 0) {
|
||||
if (translation.y > 0 && state == ALIVE) {
|
||||
Vector3f bottomLeft = new Vector3f(position).add(0, height, 0);
|
||||
Vector3f bottomRight = new Vector3f(position).add(width, height, 0);
|
||||
for (int i = 0; i < platforms.length; ++i) {
|
||||
|
@ -122,24 +144,30 @@ public class Egg extends Rect {
|
|||
|
||||
position.add(translation);
|
||||
|
||||
// Check y bounds
|
||||
if (position.y + height > camera.getHeight()) {
|
||||
position.y = camera.getHeight() - height;
|
||||
velocity.y *= -vertBounceDecay;
|
||||
grounded = true;
|
||||
} else {
|
||||
if (position.y < 0) {
|
||||
position.y = 0;
|
||||
velocity.y *= -vertBounceDecay;
|
||||
if (state == DYING) {
|
||||
if (position.x + width < 0 || position.x > camera.getWidth() || position.y + height < 0 || position.y > camera.getHeight()) {
|
||||
state = DEAD;
|
||||
}
|
||||
} else {
|
||||
// Check y bounds
|
||||
if (position.y + height > camera.getHeight()) {
|
||||
position.y = camera.getHeight() - height;
|
||||
velocity.y *= -vertBounceDecay;
|
||||
grounded = true;
|
||||
} else {
|
||||
if (position.y < 0) {
|
||||
position.y = 0;
|
||||
velocity.y *= -vertBounceDecay;
|
||||
}
|
||||
}
|
||||
// Check X bounds
|
||||
if (position.x < 0) {
|
||||
position.x = 0;
|
||||
velocity.x *= -HORZ_BOUNCE_DECAY;
|
||||
} else if (position.x + width > camera.getWidth()) {
|
||||
position.x = camera.getWidth() - width;
|
||||
velocity.x *= -HORZ_BOUNCE_DECAY;
|
||||
}
|
||||
}
|
||||
// Check X bounds
|
||||
if (position.x < 0) {
|
||||
position.x = 0;
|
||||
velocity.x *= -HORZ_BOUNCE_DECAY;
|
||||
} else if (position.x + width > camera.getWidth()) {
|
||||
position.x = camera.getWidth() - width;
|
||||
velocity.x *= -HORZ_BOUNCE_DECAY;
|
||||
}
|
||||
|
||||
// --- E N D C O L L I S I O N --- //
|
||||
|
@ -150,15 +178,27 @@ public class Egg extends Rect {
|
|||
public void render() {
|
||||
texture.bind();
|
||||
shader.enable();
|
||||
shader.setSubtexture(new Vector2f(0, 0), SUBTEXTURE_DIMS);
|
||||
int sprite = 4 - Math.round(health / FULL_HEALTH * 4);
|
||||
shader.setSubtexture(new Vector2f(0.2f * sprite, 0), SUBTEXTURE_DIMS);
|
||||
shader.setMVP(camera.getMatrix().translate(position).scale(WIDTH * scale, HEIGHT * scale, 1));
|
||||
vao.render();
|
||||
}
|
||||
|
||||
public void launch(Vector3f velocity) {
|
||||
this.velocity.set(velocity);
|
||||
vertBounceDecay = HIT_BOUNCE_DECAY;
|
||||
bounceChangeTime = 0;
|
||||
public void launch(Vector3f velocity, int damage) {
|
||||
if (health > 0) {
|
||||
this.velocity.set(velocity);
|
||||
vertBounceDecay = HIT_BOUNCE_DECAY;
|
||||
bounceChangeTime = 0;
|
||||
health -= damage;
|
||||
if (health <= 0) {
|
||||
this.velocity.mul(4);
|
||||
state = DYING;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int state() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public Vector3f getOrigin() {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.gnarwhal.ld46.game;
|
|||
|
||||
import com.gnarwhal.ld46.engine.display.Camera;
|
||||
import com.gnarwhal.ld46.engine.display.Window;
|
||||
import com.gnarwhal.ld46.engine.model.TexRect;
|
||||
|
||||
public class GamePanel {
|
||||
|
||||
|
@ -13,6 +14,9 @@ public class GamePanel {
|
|||
|
||||
private Platform[] platforms;
|
||||
|
||||
private TexRect killsText;
|
||||
private KillTracker killCount;
|
||||
|
||||
public GamePanel(Window window, Camera camera) {
|
||||
this.window = window;
|
||||
this.camera = camera;
|
||||
|
@ -25,10 +29,17 @@ public class GamePanel {
|
|||
new Platform(camera, (camera.getWidth() * 3 / 4 - Platform.SEGMENT_WIDTH * 4 / 2), camera.getHeight() * 2 / 5 - Platform.HEIGHT / 2, 2),
|
||||
new Platform(camera, (camera.getWidth() / 2 - Platform.SEGMENT_WIDTH * 5 / 2), camera.getHeight() * 3 / 4 - Platform.HEIGHT / 2, 3)
|
||||
};
|
||||
|
||||
killsText = new TexRect(camera, "res/img/kills.png", 0, 0, 0, 64 * 6, 64, 0, false);
|
||||
killCount = new KillTracker(camera, 64 * 6, 0);
|
||||
}
|
||||
|
||||
public void update() {
|
||||
egg.update(platforms);
|
||||
if (egg.state() == Egg.DEAD) {
|
||||
egg.reset();
|
||||
killCount.increment();
|
||||
}
|
||||
player.update(platforms, egg);
|
||||
}
|
||||
|
||||
|
@ -38,5 +49,7 @@ public class GamePanel {
|
|||
}
|
||||
egg.render();
|
||||
player.render();
|
||||
killsText.render();
|
||||
killCount.render();
|
||||
}
|
||||
}
|
||||
|
|
65
src/com/gnarwhal/ld46/game/KillTracker.java
Normal file
|
@ -0,0 +1,65 @@
|
|||
package com.gnarwhal.ld46.game;
|
||||
|
||||
import com.gnarwhal.ld46.engine.display.Camera;
|
||||
import com.gnarwhal.ld46.engine.model.Rect;
|
||||
import com.gnarwhal.ld46.engine.shaders.Shader;
|
||||
import com.gnarwhal.ld46.engine.shaders.Shader2t;
|
||||
import com.gnarwhal.ld46.engine.texture.Texture;
|
||||
import org.joml.Vector2f;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public class KillTracker extends Rect {
|
||||
|
||||
public static final float SEGMENT_WIDTH = 64;
|
||||
public static final float HEIGHT = 64;
|
||||
|
||||
private static Texture texture;
|
||||
private static Shader2t shader;
|
||||
|
||||
private int killCount;
|
||||
|
||||
public KillTracker(Camera camera, float x, float y) {
|
||||
super(camera, x, y, -0.5f, 0, HEIGHT, 0, false);
|
||||
|
||||
if (texture == null) {
|
||||
texture = new Texture("res/img/numbers.png");
|
||||
shader = Shader.SHADER2T;
|
||||
}
|
||||
}
|
||||
|
||||
public void update() {}
|
||||
|
||||
private static final Vector2f SUBTEXTURE_DIMS = new Vector2f(0.1f, 1);
|
||||
|
||||
public void render() {
|
||||
texture.bind();
|
||||
shader.enable();
|
||||
int killCount = this.killCount;
|
||||
int offset = 0;
|
||||
while ((killCount /= 10) > 0) {
|
||||
offset += SEGMENT_WIDTH;
|
||||
}
|
||||
killCount = this.killCount;
|
||||
while (killCount > 0 || offset == 0) {
|
||||
int digit = killCount % 10;
|
||||
killCount /= 10;
|
||||
shader.setSubtexture(new Vector2f(digit * SUBTEXTURE_DIMS.x, 0), SUBTEXTURE_DIMS);
|
||||
shader.setMVP(camera.getMatrix().translate(position.add(offset, 0, 0, new Vector3f())).scale(SEGMENT_WIDTH, HEIGHT, 1));
|
||||
vao.render();
|
||||
|
||||
offset -= SEGMENT_WIDTH;
|
||||
}
|
||||
}
|
||||
|
||||
public void increment() {
|
||||
++killCount;
|
||||
}
|
||||
|
||||
public Vector3f getOrigin() {
|
||||
return new Vector3f(position.x, position.y, 0);
|
||||
}
|
||||
|
||||
public Vector3f getTranslation() {
|
||||
return new Vector3f(width, 0, 0);
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ import com.gnarwhal.ld46.engine.display.Camera;
|
|||
import com.gnarwhal.ld46.engine.display.Window;
|
||||
import com.gnarwhal.ld46.engine.model.ColRect;
|
||||
import com.gnarwhal.ld46.engine.model.Rect;
|
||||
import com.gnarwhal.ld46.engine.shaders.Shader;
|
||||
import com.gnarwhal.ld46.engine.shaders.Shader2e;
|
||||
import com.gnarwhal.ld46.engine.shaders.Shader2t;
|
||||
import com.gnarwhal.ld46.engine.texture.Texture;
|
||||
|
@ -12,9 +13,8 @@ import org.joml.Vector2f;
|
|||
import org.joml.Vector3f;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import static com.gnarwhal.ld46.engine.display.Window.BUTTON_PRESSED;
|
||||
import static com.gnarwhal.ld46.game.Egg.ALIVE;
|
||||
import static com.gnarwhal.ld46.game.Main.adtime;
|
||||
import static com.gnarwhal.ld46.game.Main.dtime;
|
||||
import static org.lwjgl.glfw.GLFW.*;
|
||||
|
@ -38,14 +38,14 @@ public class Player extends Rect {
|
|||
};
|
||||
|
||||
private static final float
|
||||
UP_ANGLE_DEVIATION = (float) Math.PI / 12.0f,
|
||||
SIDE_ANGLE_DEVIATION = (float) Math.PI / 3.0f,
|
||||
DOWN_ANGLE_DEVIATION = (float) Math.PI / 12.0f;
|
||||
UP_ANGLE_DEVIATION = (float) Math.PI * 1.0f / 12.0f,
|
||||
SIDE_ANGLE_DEVIATION = (float) Math.PI * 1.0f / 12.0f,
|
||||
DOWN_ANGLE_DEVIATION = (float) Math.PI * 1.0f / 12.0f;
|
||||
|
||||
private static final float
|
||||
UP_ANGLE_RANGE = (float) Math.PI * 2.0f / 3.0f,
|
||||
SIDE_ANGLE_RANGE = (float) Math.PI * 3.0f / 4.0f,
|
||||
DOWN_ANGLE_RANGE = (float) Math.PI * 2.0f / 3.0f;
|
||||
UP_ANGLE_RANGE = 2 * (float) Math.PI * 1.0f / 4.0f,
|
||||
SIDE_ANGLE_RANGE = 2 * (float) Math.PI * 1.0f / 4.0f,
|
||||
DOWN_ANGLE_RANGE = 2 * (float) Math.PI * 1.0f / 4.0f;
|
||||
|
||||
// sour spot power, sweet spot power
|
||||
private static final Vector2f
|
||||
|
@ -65,6 +65,7 @@ public class Player extends Rect {
|
|||
|
||||
private static Sound sweet;
|
||||
private static Sound sour;
|
||||
private static Sound kill;
|
||||
|
||||
private Vector4f scaledCollisionOffsets;
|
||||
|
||||
|
@ -121,7 +122,7 @@ public class Player extends Rect {
|
|||
offset = new Vector3f();
|
||||
idleTime = 0;
|
||||
|
||||
shader = new Shader2t();
|
||||
shader = Shader.SHADER2T;
|
||||
effectShader = new Shader2e();
|
||||
|
||||
velocity = new Vector3f();
|
||||
|
@ -138,6 +139,7 @@ public class Player extends Rect {
|
|||
if (sour == null) {
|
||||
sweet = new Sound("res/audio/sweet.wav");
|
||||
sour = new Sound("res/audio/sour.wav");
|
||||
kill = new Sound("res/audio/kill.wav");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,9 +180,9 @@ public class Player extends Rect {
|
|||
}
|
||||
}
|
||||
final float ATTACK_BEGIN = 0.05f;
|
||||
final float ATTACK_ACTIVE = 0.25f;
|
||||
final float ATTACK_HOLD = 0.3f;
|
||||
final float ATTACK_END = 0.4f;
|
||||
final float ATTACK_ACTIVE = 0.15f;
|
||||
final float ATTACK_HOLD = 0.2f;
|
||||
final float ATTACK_END = 0.3f;
|
||||
if (state != STATE_REST) {
|
||||
if (attackTimer < ATTACK_BEGIN) {
|
||||
sprite.set(0, 0.2f * state);
|
||||
|
@ -445,13 +447,18 @@ public class Player extends Rect {
|
|||
float radius = egg.getRadius(theta);
|
||||
float distance = displacement.length();
|
||||
|
||||
final float SWEET_SPOT_DIFFERENCE = 2 * (float) Math.PI / 12;
|
||||
|
||||
float launchVelocity = 0;
|
||||
float blah = distance - HITBOX_RADIUS;
|
||||
if (-SWEET_SPOT_RADIUS < blah && blah < SWEET_SPOT_RADIUS) {
|
||||
Sound hitsound = sour;
|
||||
int damage = 1;
|
||||
if (-SWEET_SPOT_RADIUS < blah && blah < SWEET_SPOT_RADIUS && difference < SWEET_SPOT_DIFFERENCE) {
|
||||
hit = true;
|
||||
launchVelocity = attackPower.y;
|
||||
sweet.play(false);
|
||||
|
||||
hitsound = sweet;
|
||||
damage = 3;
|
||||
|
||||
final float SWEET_SPOT_FREEZE_DURATION = 0.35f;
|
||||
Main.freeze(SWEET_SPOT_FREEZE_DURATION);
|
||||
|
@ -459,12 +466,16 @@ public class Player extends Rect {
|
|||
} else if (-radius < blah && blah < radius) {
|
||||
hit = true;
|
||||
launchVelocity = attackPower.x;
|
||||
sour.play(false);
|
||||
}
|
||||
if (launchVelocity != 0) {
|
||||
//rect.setColor(0, 1, 0);
|
||||
float launchAngle = (theta - attackAngle) / (float) Math.PI * 3.0f * angleDeviation + attackAngle;
|
||||
egg.launch(new Vector3f(launchVelocity * (float) Math.cos(launchAngle), launchVelocity * (float) Math.sin(launchAngle), 0));
|
||||
float launchAngle = difference / (float) Math.PI * 3.0f * angleDeviation + attackAngle;
|
||||
egg.launch(new Vector3f(launchVelocity * (float) Math.cos(launchAngle), launchVelocity * (float) Math.sin(launchAngle), 0), damage);
|
||||
if (egg.state() != ALIVE) {
|
||||
kill.play(false);
|
||||
} else {
|
||||
hitsound.play(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|