Added god mode
This commit is contained in:
parent
5ab2075f29
commit
93ff25c5aa
|
|
@ -5,6 +5,7 @@ import java.util.Random;
|
||||||
import javax.swing.text.html.parser.Entity;
|
import javax.swing.text.html.parser.Entity;
|
||||||
|
|
||||||
import mainloop.manager.MainloopManager;
|
import mainloop.manager.MainloopManager;
|
||||||
|
import shootergame.cheats.Cheats;
|
||||||
import shootergame.display.DisplayStatsEventHandler;
|
import shootergame.display.DisplayStatsEventHandler;
|
||||||
import shootergame.display.DisplayWindow;
|
import shootergame.display.DisplayWindow;
|
||||||
import shootergame.entity.EntityEventHandler;
|
import shootergame.entity.EntityEventHandler;
|
||||||
|
|
@ -29,6 +30,9 @@ public class Main
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
|
// Initialize the cheats
|
||||||
|
Cheats.init(args);
|
||||||
|
|
||||||
// Create the mainloop
|
// Create the mainloop
|
||||||
mainloop = new MainloopManager(MainloopEventHandler.MAINLOOP_EVENT_HANDLER);
|
mainloop = new MainloopManager(MainloopEventHandler.MAINLOOP_EVENT_HANDLER);
|
||||||
mainloop.register(MainloopEventHandler.MAINLOOP_EVENT_HANDLER);
|
mainloop.register(MainloopEventHandler.MAINLOOP_EVENT_HANDLER);
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -87,7 +87,7 @@ public class Entity implements ITransparentObject
|
||||||
|
|
||||||
public boolean moveIsLegal(Vec2d pos)
|
public boolean moveIsLegal(Vec2d pos)
|
||||||
{
|
{
|
||||||
/*// Is this entity solid
|
// Is this entity solid
|
||||||
if(isSolid)
|
if(isSolid)
|
||||||
{
|
{
|
||||||
// Get the layer
|
// Get the layer
|
||||||
|
|
@ -95,10 +95,7 @@ public class Entity implements ITransparentObject
|
||||||
|
|
||||||
// Get some tiles
|
// Get some tiles
|
||||||
Vec2i[] tiles = {
|
Vec2i[] tiles = {
|
||||||
new Vec2i(MathHelpers.floor(pos.x)+0, MathHelpers.floor(pos.y)+0),
|
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)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for(Vec2i tpos : tiles)
|
for(Vec2i tpos : tiles)
|
||||||
|
|
@ -120,7 +117,6 @@ public class Entity implements ITransparentObject
|
||||||
|
|
||||||
// Send false if the tile isn't walkable
|
// Send false if the tile isn't walkable
|
||||||
if(!t.tileWalkable) {
|
if(!t.tileWalkable) {
|
||||||
System.out.println("2");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -134,15 +130,13 @@ public class Entity implements ITransparentObject
|
||||||
tpos.y + t.tileHitbox < pos.y ||
|
tpos.y + t.tileHitbox < pos.y ||
|
||||||
tpos.y - t.tileHitbox > pos.y
|
tpos.y - t.tileHitbox > pos.y
|
||||||
) {
|
) {
|
||||||
System.out.println("3");
|
|
||||||
|
|
||||||
// Send back false
|
// Send back false
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
// Send back true if everything passes
|
// Send back true if everything passes
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package shootergame.entity.player;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import shootergame.Main;
|
import shootergame.Main;
|
||||||
|
import shootergame.cheats.Cheats;
|
||||||
import shootergame.display.Camera;
|
import shootergame.display.Camera;
|
||||||
import shootergame.entity.Entity;
|
import shootergame.entity.Entity;
|
||||||
import shootergame.entity.EntityAlive;
|
import shootergame.entity.EntityAlive;
|
||||||
|
|
@ -41,6 +42,11 @@ public class EntityPlayer extends EntityVertical implements EntityAlive
|
||||||
@Override
|
@Override
|
||||||
public void tick(Chunk chunk, Layer layer)
|
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
|
// Don't tick if the player is dead
|
||||||
if(this.getHealth() < 0) return;
|
if(this.getHealth() < 0) return;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,12 @@ package shootergame.tiles;
|
||||||
import shootergame.display.Camera;
|
import shootergame.display.Camera;
|
||||||
import shootergame.display.transparent.ITransparentObject;
|
import shootergame.display.transparent.ITransparentObject;
|
||||||
import shootergame.display.transparent.TransparentObjects;
|
import shootergame.display.transparent.TransparentObjects;
|
||||||
|
import shootergame.entity.Entity;
|
||||||
import shootergame.entity.player.EntityPlayer;
|
import shootergame.entity.player.EntityPlayer;
|
||||||
import shootergame.util.math.vec.Vec2d;
|
import shootergame.util.math.vec.Vec2d;
|
||||||
import shootergame.util.math.vec.Vec2i;
|
import shootergame.util.math.vec.Vec2i;
|
||||||
|
import shootergame.world.chunk.Chunk;
|
||||||
|
import shootergame.world.layer.Layer;
|
||||||
|
|
||||||
public class Tile implements ITransparentObject
|
public class Tile implements ITransparentObject
|
||||||
{
|
{
|
||||||
|
|
@ -42,4 +45,8 @@ public class Tile implements ITransparentObject
|
||||||
public boolean isOpaqueTile() {
|
public boolean isOpaqueTile() {
|
||||||
return this.opaqueTile;
|
return this.opaqueTile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onWalkedOn(Chunk chunk, Layer layer, Vec2i pos, Entity entity) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@ public class TileVoid extends Tile {
|
||||||
super(id);
|
super(id);
|
||||||
|
|
||||||
// Set some settings
|
// Set some settings
|
||||||
this.tileSolid = true;
|
this.tileSolid = false;
|
||||||
this.tileWalkable = false;
|
this.tileWalkable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue