Added god mode

This commit is contained in:
josua 2019-08-25 15:45:40 +10:00
parent 5ab2075f29
commit 93ff25c5aa
6 changed files with 38 additions and 11 deletions

View File

@ -5,6 +5,7 @@ import java.util.Random;
import javax.swing.text.html.parser.Entity;
import mainloop.manager.MainloopManager;
import shootergame.cheats.Cheats;
import shootergame.display.DisplayStatsEventHandler;
import shootergame.display.DisplayWindow;
import shootergame.entity.EntityEventHandler;
@ -29,6 +30,9 @@ public class Main
public static void main(String[] args)
{
// Initialize the cheats
Cheats.init(args);
// Create the mainloop
mainloop = new MainloopManager(MainloopEventHandler.MAINLOOP_EVENT_HANDLER);
mainloop.register(MainloopEventHandler.MAINLOOP_EVENT_HANDLER);

View File

@ -0,0 +1,16 @@
package shootergame.cheats;
public class Cheats
{
public static boolean god_mode = false;
public static void init(String[] args)
{
for(String arg : args)
{
// God mode
if(arg.matches("--cheat-god-mode"))
god_mode = true;
}
}
}

View File

@ -87,7 +87,7 @@ public class Entity implements ITransparentObject
public boolean moveIsLegal(Vec2d pos)
{
/*// Is this entity solid
// Is this entity solid
if(isSolid)
{
// Get the layer
@ -95,10 +95,7 @@ public class Entity implements ITransparentObject
// Get some tiles
Vec2i[] tiles = {
new Vec2i(MathHelpers.floor(pos.x)+0, MathHelpers.floor(pos.y)+0),
new Vec2i(MathHelpers.floor(pos.x)+1, MathHelpers.floor(pos.y)+0),
new Vec2i(MathHelpers.floor(pos.x)+1, MathHelpers.floor(pos.y)+1),
new Vec2i(MathHelpers.floor(pos.x)+0, MathHelpers.floor(pos.y)+1)
new Vec2i(MathHelpers.floor(pos.x)+0, MathHelpers.floor(pos.y)+0)
};
for(Vec2i tpos : tiles)
@ -120,7 +117,6 @@ public class Entity implements ITransparentObject
// Send false if the tile isn't walkable
if(!t.tileWalkable) {
System.out.println("2");
return false;
}
@ -134,15 +130,13 @@ public class Entity implements ITransparentObject
tpos.y + t.tileHitbox < pos.y ||
tpos.y - t.tileHitbox > pos.y
) {
System.out.println("3");
// Send back false
return false;
}
}
}
}
}*/
}
// Send back true if everything passes
return true;

View File

@ -3,6 +3,7 @@ package shootergame.entity.player;
import java.util.Random;
import shootergame.Main;
import shootergame.cheats.Cheats;
import shootergame.display.Camera;
import shootergame.entity.Entity;
import shootergame.entity.EntityAlive;
@ -41,6 +42,11 @@ public class EntityPlayer extends EntityVertical implements EntityAlive
@Override
public void tick(Chunk chunk, Layer layer)
{
// Reset the health if god mode is active
if(Cheats.god_mode) {
this.resetHealth();
}
// Don't tick if the player is dead
if(this.getHealth() < 0) return;

View File

@ -3,9 +3,12 @@ package shootergame.tiles;
import shootergame.display.Camera;
import shootergame.display.transparent.ITransparentObject;
import shootergame.display.transparent.TransparentObjects;
import shootergame.entity.Entity;
import shootergame.entity.player.EntityPlayer;
import shootergame.util.math.vec.Vec2d;
import shootergame.util.math.vec.Vec2i;
import shootergame.world.chunk.Chunk;
import shootergame.world.layer.Layer;
public class Tile implements ITransparentObject
{
@ -42,4 +45,8 @@ public class Tile implements ITransparentObject
public boolean isOpaqueTile() {
return this.opaqueTile;
}
public void onWalkedOn(Chunk chunk, Layer layer, Vec2i pos, Entity entity) {
}
}

View File

@ -6,8 +6,8 @@ public class TileVoid extends Tile {
super(id);
// Set some settings
this.tileSolid = true;
this.tileWalkable = false;
this.tileSolid = false;
this.tileWalkable = true;
}
}