Added ammo
This commit is contained in:
parent
a30a3f0566
commit
bb13aaa09f
|
|
@ -21,15 +21,18 @@ public class DisplayRenderUI
|
||||||
// Disable some opengl options
|
// Disable some opengl options
|
||||||
GlHelpers.disableDepthTest();
|
GlHelpers.disableDepthTest();
|
||||||
|
|
||||||
|
// Get some text settings
|
||||||
|
Vec2d text_size = new Vec2d(0.5, 0.2);
|
||||||
|
|
||||||
// Render the fps and the position
|
// Render the fps and the position
|
||||||
GlHelpers.pushMatrix();
|
GlHelpers.pushMatrix();
|
||||||
GlHelpers.translate(-9.5, 9.5, 0);
|
GlHelpers.translate(-9.5, 9.5, 0);
|
||||||
GlHelpers.color3(1, 1, 0);
|
GlHelpers.color3(1, 1, 0);
|
||||||
Text.render("FPS: " + DisplayStatsEventHandler.fps, new Vec2d(0.5, 0.2));
|
Text.render("FPS: " + DisplayStatsEventHandler.fps, text_size);
|
||||||
GlHelpers.translate(0, -0.5, 0);
|
GlHelpers.translate(0, -0.5, 0);
|
||||||
Text.render("x: " + (int) player.pos.x + ", y: " + (int) player.pos.y, new Vec2d(0.5, 0.2));
|
Text.render("x: " + (int) player.pos.x + ", y: " + (int) player.pos.y, text_size);
|
||||||
GlHelpers.translate(0, -0.5, 0);
|
GlHelpers.translate(0, -0.5, 0);
|
||||||
Text.render("AL Sound Source: "+AudioSources.upto, new Vec2d(0.5, 0.2));
|
Text.render("AL Sound Source: "+AudioSources.upto, text_size);
|
||||||
GlHelpers.color3(1, 1, 1);
|
GlHelpers.color3(1, 1, 1);
|
||||||
GlHelpers.popMatrix();
|
GlHelpers.popMatrix();
|
||||||
|
|
||||||
|
|
@ -51,5 +54,11 @@ public class DisplayRenderUI
|
||||||
health_fg.texCoord(1-a, 0); GlHelpers.vertex2(2.5-a*5, -9.0);
|
health_fg.texCoord(1-a, 0); GlHelpers.vertex2(2.5-a*5, -9.0);
|
||||||
|
|
||||||
GlHelpers.end();
|
GlHelpers.end();
|
||||||
|
|
||||||
|
// Display the amount of ammo left
|
||||||
|
GlHelpers.pushMatrix();
|
||||||
|
GlHelpers.translate(-9.5, -9.5, 0);
|
||||||
|
Text.render("Ammo: "+player.ammo, text_size);
|
||||||
|
GlHelpers.popMatrix();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
package shootergame.entity;
|
||||||
|
|
||||||
|
public interface EntityInventory {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -39,6 +39,8 @@ public class EntityPlayer extends EntityVertical implements EntityAlive
|
||||||
public boolean dead = false;
|
public boolean dead = false;
|
||||||
public boolean in_animation = false;
|
public boolean in_animation = false;
|
||||||
|
|
||||||
|
public int ammo = 1000;
|
||||||
|
|
||||||
public EntityPlayer() {
|
public EntityPlayer() {
|
||||||
this.angle = 45;
|
this.angle = 45;
|
||||||
rand = new Random();
|
rand = new Random();
|
||||||
|
|
@ -154,11 +156,14 @@ public class EntityPlayer extends EntityVertical implements EntityAlive
|
||||||
bullet_frequency += 1;
|
bullet_frequency += 1;
|
||||||
bullet_frequency %= 10;
|
bullet_frequency %= 10;
|
||||||
|
|
||||||
if(bullet_frequency == 0)
|
// Is there enough ammo and are the bullets at the right frequency
|
||||||
|
if(bullet_frequency == 0 && ammo > 0)
|
||||||
{
|
{
|
||||||
|
// Remove some ammo
|
||||||
|
ammo -= 1;
|
||||||
|
|
||||||
// Summon bullets at this angle relative to the player
|
// Summon bullets at this angle relative to the player
|
||||||
Main.world.getLayer().spawnEntity(new EntityBullet(rand, pos.copy(), this, angle + this.angle));
|
Main.world.getLayer().spawnEntity(new EntityBullet(rand, pos.copy(), this, angle + this.angle));
|
||||||
//throwTnt(angle);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue