mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-28 13:47:32 +07:00
Added fullscreen, player outlines, better weapon display
This commit is contained in:
@ -3,6 +3,7 @@ package io.anuke.mindustry;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.io.BlockLoader;
|
||||
import io.anuke.mindustry.io.BundleLoader;
|
||||
import io.anuke.mindustry.io.Platform;
|
||||
import io.anuke.ucore.modules.ModuleCore;
|
||||
import io.anuke.ucore.util.Log;
|
||||
|
||||
@ -12,6 +13,8 @@ public class Mindustry extends ModuleCore {
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
debug = Platform.instance.isDebug();
|
||||
|
||||
Log.setUseColors(false);
|
||||
BundleLoader.load();
|
||||
BlockLoader.load();
|
||||
|
@ -146,6 +146,7 @@ public class Control extends Module{
|
||||
});
|
||||
|
||||
Events.on(ResetEvent.class, () -> {
|
||||
upgrades.reset();
|
||||
player.weaponLeft = player.weaponRight = Weapon.blaster;
|
||||
|
||||
player.add();
|
||||
|
@ -304,6 +304,20 @@ public class NetClient extends Module {
|
||||
}
|
||||
}
|
||||
|
||||
//TODO remove.
|
||||
public void test(){
|
||||
gotData = false;
|
||||
connecting = true;
|
||||
}
|
||||
|
||||
public boolean hasData(){
|
||||
return gotData;
|
||||
}
|
||||
|
||||
public boolean isConnecting(){
|
||||
return connecting;
|
||||
}
|
||||
|
||||
private void finishConnecting(){
|
||||
Net.send(new ConnectConfirmPacket(), SendMode.tcp);
|
||||
state.set(State.playing);
|
||||
|
@ -68,7 +68,7 @@ public class NetServer extends Module{
|
||||
data.stream = new ByteArrayInputStream(stream.toByteArray());
|
||||
Net.sendStream(id, data);
|
||||
|
||||
Log.info("Sending custom map: Packed {0}uncompressed bytes of MAP data.", stream.size());
|
||||
Log.info("Sending custom map: Packed {0} uncompressed bytes of MAP data.", stream.size());
|
||||
}else{
|
||||
//hack-- simulate the map ack packet recieved to send the world data to the client.
|
||||
Net.handleServerReceived(id, new MapAckPacket());
|
||||
|
@ -177,14 +177,17 @@ public class Renderer extends RendererModule{
|
||||
|
||||
Graphics.shader(Shaders.outline, false);
|
||||
Entities.draw(enemyGroup);
|
||||
Entities.draw(playerGroup, p -> !p.isAndroid);
|
||||
Graphics.shader();
|
||||
|
||||
Entities.draw(playerGroup, p -> !p.isAndroid);
|
||||
Entities.draw(Entities.defaultGroup());
|
||||
|
||||
blocks.drawBlocks(true);
|
||||
|
||||
Graphics.shader(Shaders.outline, false);
|
||||
Entities.draw(playerGroup, p -> p.isAndroid);
|
||||
Graphics.shader();
|
||||
|
||||
Entities.draw(bulletGroup);
|
||||
|
||||
drawShield();
|
||||
@ -208,6 +211,10 @@ public class Renderer extends RendererModule{
|
||||
super.resize(width, height);
|
||||
control.input().resetCursor();
|
||||
camera.position.set(player.x, player.y, 0);
|
||||
|
||||
int scale = Settings.getBool("pixelate") ? Core.cameraScale : 1;
|
||||
Graphics.getEffects1().setScale(scale);
|
||||
Graphics.getEffects2().setScale(scale);
|
||||
}
|
||||
|
||||
public void clearTiles(){
|
||||
@ -224,7 +231,7 @@ public class Renderer extends RendererModule{
|
||||
Draw.color(0f, 0f, 0f, 0.3f);
|
||||
Draw.rect("blank", player.x, player.y + 8 - layout.height/2, layout.width + 2, layout.height + 2);
|
||||
Draw.color();
|
||||
Draw.tcolor(NetCommon.colorArray[player.id % NetCommon.colorArray.length]);
|
||||
Draw.tcolor(player.getColor());
|
||||
Draw.text(player.name, player.x, player.y + 8);
|
||||
Draw.tcolor();
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import io.anuke.mindustry.core.NetCommon;
|
||||
import io.anuke.mindustry.graphics.Fx;
|
||||
import io.anuke.mindustry.graphics.Shaders;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.NetEvents;
|
||||
import io.anuke.mindustry.resource.Mech;
|
||||
import io.anuke.mindustry.resource.Weapon;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.Blocks;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Inputs;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.core.*;
|
||||
import io.anuke.ucore.entities.SolidEntity;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
@ -108,25 +108,33 @@ public class Player extends SyncEntity{
|
||||
boolean snap = snapCamera && Settings.getBool("smoothcam") && Settings.getBool("pixelate") && isLocal;
|
||||
|
||||
String part = isAndroid ? "ship" : "mech";
|
||||
|
||||
|
||||
Shaders.outline.color.set(getColor());
|
||||
Shaders.outline.lighten = 0f;
|
||||
Shaders.outline.region = Draw.region(part + "-" + mech.name);
|
||||
|
||||
Shaders.outline.apply();
|
||||
|
||||
if(!isAndroid) {
|
||||
for (int i : Mathf.signs) {
|
||||
Weapon weapon = i < 0 ? weaponLeft : weaponRight;
|
||||
Angles.vector.set(3 * i, 2).rotate(angle - 90);
|
||||
float w = i > 0 ? -8 : 8;
|
||||
if(snap){
|
||||
Draw.rect(weapon.name + "-equip", (int)x + Angles.x(), (int)y + Angles.y(), w, 8, angle - 90);
|
||||
}else{
|
||||
Draw.rect(weapon.name + "-equip", x + Angles.x(), y + Angles.y(), w, 8, angle - 90);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(snap){
|
||||
Draw.rect(part + "-" + mech.name, (int)x, (int)y, angle-90);
|
||||
}else{
|
||||
Draw.rect(part + "-" + mech.name, x, y, angle-90);
|
||||
}
|
||||
|
||||
if(!isAndroid) {
|
||||
for (boolean b : new boolean[]{true, false}) {
|
||||
Weapon weapon = b ? weaponLeft : weaponRight;
|
||||
Angles.translation(angle + Mathf.sign(b) * -50f, 3.5f);
|
||||
float s = 5f;
|
||||
if(snap){
|
||||
Draw.rect(weapon.name, (int)x + Angles.x(), (int)y + Angles.y(), s, s, angle- 90);
|
||||
}else{
|
||||
Draw.rect(weapon.name, x + Angles.x(), y + Angles.y(), s, s, angle - 90);
|
||||
}
|
||||
}
|
||||
}
|
||||
Graphics.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -250,4 +258,8 @@ public class Player extends SyncEntity{
|
||||
y = Mathf.lerpDelta(y, i.target.y, 0.4f);
|
||||
angle = Mathf.lerpAngDelta(angle, i.targetrot, 0.6f);
|
||||
}
|
||||
|
||||
public Color getColor(){
|
||||
return NetCommon.colorArray[id % NetCommon.colorArray.length];
|
||||
}
|
||||
}
|
||||
|
@ -26,4 +26,5 @@ public abstract class Platform {
|
||||
public boolean canJoinGame(){
|
||||
return true;
|
||||
}
|
||||
public boolean isDebug(){return false;}
|
||||
}
|
||||
|
@ -5,11 +5,13 @@ import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.IntMap;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||
import io.anuke.mindustry.io.Platform;
|
||||
import io.anuke.mindustry.net.Packet.ImportantPacket;
|
||||
import io.anuke.mindustry.net.Packets.KickReason;
|
||||
import io.anuke.mindustry.net.Streamable.StreamBegin;
|
||||
import io.anuke.mindustry.net.Streamable.StreamBuilder;
|
||||
import io.anuke.mindustry.net.Streamable.StreamChunk;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.function.BiConsumer;
|
||||
import io.anuke.ucore.function.Consumer;
|
||||
import io.anuke.ucore.util.Log;
|
||||
@ -51,6 +53,8 @@ public class Net{
|
||||
clientProvider.connect(ip, port);
|
||||
active = true;
|
||||
server = false;
|
||||
|
||||
Timers.runTask(60f, Platform.instance::updateRPC);
|
||||
}
|
||||
|
||||
/**Host a server at an address*/
|
||||
@ -58,6 +62,8 @@ public class Net{
|
||||
serverProvider.host(port);
|
||||
active = true;
|
||||
server = true;
|
||||
|
||||
Timers.runTask(60f, Platform.instance::updateRPC);
|
||||
}
|
||||
|
||||
/**Closes the server.*/
|
||||
|
@ -22,6 +22,7 @@ public class NetworkIO {
|
||||
|
||||
public static void writeMap(Map map, OutputStream os){
|
||||
try(DataOutputStream stream = new DataOutputStream(os)){
|
||||
stream.writeUTF(map.name);
|
||||
stream.writeBoolean(map.oreGen);
|
||||
|
||||
stream.writeShort(map.getWidth());
|
||||
@ -65,6 +66,7 @@ public class NetworkIO {
|
||||
|
||||
public static Map loadMap(InputStream is){
|
||||
try(DataInputStream stream = new DataInputStream(is)){
|
||||
String name = stream.readUTF();
|
||||
boolean ores = stream.readBoolean();
|
||||
|
||||
short width = stream.readShort();
|
||||
@ -85,11 +87,11 @@ public class NetworkIO {
|
||||
}
|
||||
|
||||
Map map = new Map();
|
||||
map.name = name;
|
||||
map.oreGen = ores;
|
||||
map.custom = true;
|
||||
map.pixmap = pixmap;
|
||||
map.visible = false;
|
||||
map.name = "network map";
|
||||
map.id = -1;
|
||||
|
||||
return map;
|
||||
|
@ -20,6 +20,7 @@ public class Weapon extends Upgrade{
|
||||
blaster = new Weapon("blaster", 12, BulletType.shot){
|
||||
{
|
||||
effect = Fx.laserShoot;
|
||||
length = 2f;
|
||||
}
|
||||
},
|
||||
triblaster = new Weapon("triblaster", 16, BulletType.spread){
|
||||
@ -63,6 +64,7 @@ public class Weapon extends Upgrade{
|
||||
roundrobin = true;
|
||||
shots = 7;
|
||||
inaccuracy = 15f;
|
||||
length = 3.5f;
|
||||
}
|
||||
};
|
||||
/**weapon reload in frames*/
|
||||
@ -81,6 +83,8 @@ public class Weapon extends Upgrade{
|
||||
float shake = 0f;
|
||||
/**effect displayed when shooting*/
|
||||
Effect effect;
|
||||
/**shoot barrel length*/
|
||||
float length = 3f;
|
||||
/**whether to shoot the weapons in different arms one after another, rather an all at once*/
|
||||
boolean roundrobin = false;
|
||||
|
||||
@ -96,7 +100,7 @@ public class Weapon extends Upgrade{
|
||||
Timers.reset(p, "reload" + !left, reload/2f);
|
||||
}
|
||||
float ang = Angles.mouseAngle(p.x, p.y);
|
||||
Angles.translation(ang + Mathf.sign(left) * -60f, 3f);
|
||||
Angles.vector.set(3f * Mathf.sign(left), length).rotate(ang - 90);
|
||||
shoot(p, p.x + Angles.x(), p.y + Angles.y(), Angles.mouseAngle(p.x + Angles.x(), p.y + Angles.y()));
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.function.Consumer;
|
||||
import io.anuke.ucore.scene.ui.Image;
|
||||
@ -114,6 +115,13 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
|
||||
graphics.checkPref("fps", false);
|
||||
graphics.checkPref("vsync", true, b -> Gdx.graphics.setVSync(b));
|
||||
graphics.checkPref("fullscreen", false, b -> {
|
||||
if(b){
|
||||
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
|
||||
}else{
|
||||
Gdx.graphics.setWindowedMode(600, 480);
|
||||
}
|
||||
});
|
||||
graphics.checkPref("lasers", true);
|
||||
graphics.checkPref("indicators", true);
|
||||
graphics.checkPref("healthbars", true);
|
||||
@ -122,14 +130,21 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
renderer.pixelSurface.setScale(Core.cameraScale);
|
||||
renderer.shadowSurface.setScale(Core.cameraScale);
|
||||
renderer.shieldSurface.setScale(Core.cameraScale);
|
||||
Graphics.getEffects1().setScale(Core.cameraScale);
|
||||
Graphics.getEffects2().setScale(Core.cameraScale);
|
||||
}else{
|
||||
renderer.shadowSurface.setScale(1);
|
||||
renderer.shieldSurface.setScale(1);
|
||||
Graphics.getEffects1().setScale(1);
|
||||
Graphics.getEffects2().setScale(1);
|
||||
}
|
||||
renderer.setPixelate(b);
|
||||
});
|
||||
|
||||
Gdx.graphics.setVSync(Settings.getBool("vsync"));
|
||||
if(!gwt && Settings.getBool("fullscreen")){
|
||||
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
|
||||
}
|
||||
}
|
||||
|
||||
private void back(){
|
||||
|
@ -57,6 +57,8 @@ public class DebugFragment implements Fragment {
|
||||
row();
|
||||
new button("spawn", () -> new Enemy(EnemyTypes.standard).set(player.x, player.y).add());
|
||||
row();
|
||||
new button("stuff", () -> netClient.test());
|
||||
row();
|
||||
}}.end();
|
||||
|
||||
row();
|
||||
@ -102,16 +104,23 @@ public class DebugFragment implements Fragment {
|
||||
}}.end();
|
||||
}
|
||||
|
||||
public static void printDebugInfo(){
|
||||
Gdx.app.error("Minudstry Info Dump", debugInfo());
|
||||
}
|
||||
|
||||
public static String debugInfo(){
|
||||
return join(
|
||||
"net.active: " + Net.active(),
|
||||
"net.server: " + Net.server(),
|
||||
Net.client() ? "chat.open: " + ui.chatfrag.chatOpen() : "",
|
||||
Net.client() ? "chat.messages: " + ui.chatfrag.getMessagesSize() : "",
|
||||
Net.client() ?
|
||||
"chat.open: " + ui.chatfrag.chatOpen() + "\n" +
|
||||
"chat.messages: " + ui.chatfrag.getMessagesSize() + "\n" +
|
||||
"client.connecting: " + netClient.isConnecting() + "\n" +
|
||||
"client.hasdata: " + netClient.hasData() : "",
|
||||
"players: " + playerGroup.size(),
|
||||
"enemies: " + enemyGroup.size(),
|
||||
"tiles: " + tileGroup.size(),
|
||||
world.getCore() != null ? "core.health: " + world.getCore().entity.health : "",
|
||||
world.getCore() != null && world.getCore().entity != null ? "core.health: " + world.getCore().entity.health : "",
|
||||
"",
|
||||
!Net.server() ? clientDebug.getOut() : serverDebug.getOut()
|
||||
);
|
||||
|
@ -63,6 +63,7 @@ public class HudFragment implements Fragment{
|
||||
}).get();
|
||||
|
||||
new imagebutton("icon-pause", isize, () -> {
|
||||
if(android) DebugFragment.printDebugInfo();
|
||||
if (Net.active() && android) {
|
||||
ui.listfrag.visible = !ui.listfrag.visible;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user