更新项目说明以及清空多余素材

This commit is contained in:
2025-09-22 14:44:02 +08:00
parent 87cfe5aed6
commit 8723b1354d
27 changed files with 122 additions and 150 deletions

View File

@@ -13,6 +13,7 @@ public class Alice extends Fighter {
maxHealth = 90; // 生命值较低 maxHealth = 90; // 生命值较低
health = maxHealth; health = maxHealth;
attackPower = 12; // 攻击力中等 attackPower = 12; // 攻击力中等
name = "alice";
} }
@Override @Override
@@ -53,4 +54,8 @@ public class Alice extends Fighter {
protected boolean canAttack() { protected boolean canAttack() {
return super.canAttack() || currentAction == Action.JUMP || currentAction == Action.FALL; return super.canAttack() || currentAction == Action.JUMP || currentAction == Action.FALL;
} }
public String getName() {
return this.name;
}
} }

View File

@@ -21,6 +21,7 @@ public abstract class Fighter implements Disposable {
SPECIAL1, SPECIAL2, SPECIAL1, SPECIAL2,
DEATH DEATH
} }
protected String name;
// 动画帧间隔(秒) // 动画帧间隔(秒)
protected static final float DEFAULT_FRAME_DURATION = 0.1f; protected static final float DEFAULT_FRAME_DURATION = 0.1f;
@@ -351,6 +352,8 @@ public abstract class Fighter implements Disposable {
return attackPower; return attackPower;
} }
public String getName(){ return ""; }
@Override @Override
public void dispose() { public void dispose() {
} }

View File

@@ -0,0 +1,10 @@
package uno.mloluyu.characters;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
public class FighterList {
public static final TextureAtlas aliceAtlas = new TextureAtlas(Gdx.files.internal("src\\main\\resources\\character\\alice\\alice.atlas"));
}

View File

@@ -5,43 +5,56 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.utils.viewport.ExtendViewport;
import com.badlogic.gdx.utils.viewport.Viewport;
import uno.mloluyu.characters.Alice; import uno.mloluyu.characters.Alice;
import uno.mloluyu.characters.FighterList;
public class GameCore implements ApplicationListener { public class GameCore implements ApplicationListener {
private SpriteBatch batch; private SpriteBatch batch;
private TextureAtlas atlas; private Viewport viewport;
private Alice alice1; private Gaming gaming;
private Texture texture;
@Override @Override
public void create() { public void create() {
viewport = new ExtendViewport(Launcher.width, Launcher.width);
texture = new Texture(Gdx.files.internal("src\\main\\resources\\backgrounds\\bg.png"));
batch = new SpriteBatch(); batch = new SpriteBatch();
atlas = new TextureAtlas(Gdx.files.internal("src\\main\\resources\\character\\alice\\alice.atlas")); gaming = new Gaming(new Alice(FighterList.aliceAtlas), new Alice(FighterList.aliceAtlas));
alice1= new Alice(atlas); gaming.create();
} }
@Override @Override
public void render() { public void render() {
Gdx.gl.glClearColor(150, 150, 150, 1); Gdx.gl.glClearColor(150, 150, 150, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
viewport.apply();
alice1.update(Gdx.graphics.getDeltaTime());
batch.begin(); batch.begin();
alice1.render(batch); batch.draw(texture, 0, 0);
// alice1.update(Gdx.graphics.getDeltaTime());
// batch.begin();
// alice1.render(batch);
// batch.end();
gaming.render();
batch.end(); batch.end();
} }
@Override @Override
public void dispose() { public void dispose() {
alice1.dispose(); gaming.dispose();
} }
@Override @Override
public void resize(int width, int height) { public void resize(int width, int height) {
float screenAspectRatio = (float) width / (float) height;
float newWorldWidth = Launcher.height * screenAspectRatio;
float newWorldHeight = Launcher.width / screenAspectRatio;
// 应用新的视口设置
viewport.update((int)newWorldWidth, (int)newWorldHeight, true); // 第三个参数 true 表示相机居中
} }
@Override @Override

View File

@@ -1,5 +1,38 @@
package uno.mloluyu.desktop; package uno.mloluyu.desktop;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.viewport.ExtendViewport;
import com.badlogic.gdx.utils.viewport.Viewport;
import uno.mloluyu.characters.Fighter;
public class Gaming { public class Gaming {
private Fighter selfFighter;
private Fighter frontFighter;
private SpriteBatch batch;
public Gaming(Fighter selfFighter, Fighter frontFighter) {
this.selfFighter = selfFighter;
this.frontFighter = frontFighter;
}
public void create() {
batch = new SpriteBatch();
}
public void render() {
selfFighter.update(Gdx.graphics.getDeltaTime());
frontFighter.update(Gdx.graphics.getDeltaTime());
batch.begin();
selfFighter.render(batch);
selfFighter.render(batch);
batch.end();
}
public void dispose() {
selfFighter.dispose();
frontFighter.dispose();
}
} }

View File

@@ -1,15 +1,17 @@
package uno.mloluyu.desktop; package uno.mloluyu.desktop;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
public class Launcher { public class Launcher {
private static int width; public static final int width = 640;
private static int height; public static final int height = 480;
public static void main(String[] args) { public static void main(String[] args) {
Lwjgl3ApplicationConfiguration configuration = new Lwjgl3ApplicationConfiguration(); Lwjgl3ApplicationConfiguration configuration = new Lwjgl3ApplicationConfiguration();
configuration.setTitle("Test Game"); configuration.setTitle("Test Game");
configuration.setWindowedMode(1200, 800); configuration.setWindowedMode(width, height);
configuration.setForegroundFPS(60); configuration.setForegroundFPS(60);
configuration.useVsync(true); configuration.useVsync(true);
new Lwjgl3Application(new GameCore(), configuration); new Lwjgl3Application(new GameCore(), configuration);

View File

@@ -1,5 +1,45 @@
package uno.mloluyu.network; package uno.mloluyu.network;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Net;
import com.badlogic.gdx.net.Socket;
import uno.mloluyu.desktop.Gaming;
import java.io.InputStream;
import java.io.OutputStream;
public class ConnectServer { public class ConnectServer {
private static Socket socket;
private static String host = "";
private static int port = 10800;
public static void connectServer() {
new Thread(new Runnable() {
@Override
public void run() {
try {
socket = Gdx.net.newClientSocket(Net.Protocol.TCP, host, port, null);
OutputStream outputStream = socket.getOutputStream();//读取套接字的数据流
InputStream inputStream = socket.getInputStream();
//Gaming gaming = new Gaming(); //进入游戏界面
//gaming.render();
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
} }
});
} catch (Exception e) {
} finally {
if (socket != null) {
socket.dispose();
}
}
}
});
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

View File

@@ -1,67 +0,0 @@
innerbg.png
size:1536,1024
repeat:none
0000_00
bounds:0,0,256,256
0000_01
bounds:256,0,256,256
0000_02
bounds:512,0,256,256
0000_03
bounds:768,0,256,256
0000_04
bounds:1024,0,256,256
0000_05
bounds:1280,0,120,256
0000_06
bounds:0,256,256,256
0000_07
bounds:256,256,256,256
0000_08
bounds:512,256,256,256
0000_09
bounds:768,256,256,256
0000_10
bounds:1024,256,256,256
0000_11
bounds:1280,256,120,256
0000_12
bounds:0,512,256,256
0000_13
bounds:256,512,256,256
0000_14
bounds:512,512,256,256
0000_15
bounds:768,512,256,256
0000_16
bounds:1024,512,256,256
0000_17
bounds:1280,512,120,256
0000_18
bounds:0,768,256,256
0000_19
bounds:256,768,256,256
0000_20
bounds:512,768,256,256
0000_21
bounds:768,768,256,256
0000_22
bounds:1024,768,256,256
0000_23
bounds:1280,768,120,256
innerbg2.png
size:1536,256
repeat:none
0000_24
bounds:0,0,256,176
0000_25
bounds:256,0,256,176
0000_26
bounds:512,0,256,176
0000_27
bounds:768,0,256,176
0000_28
bounds:1024,0,256,176
0000_29
bounds:1280,0,120,176

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 249 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

View File

@@ -1,67 +0,0 @@
innerbg.png
size:1536,1024
repeat:none
0000_00
bounds:0,0,256,256
0000_01
bounds:256,0,256,256
0000_02
bounds:512,0,256,256
0000_03
bounds:768,0,256,256
0000_04
bounds:1024,0,256,256
0000_05
bounds:1280,0,120,256
0000_06
bounds:0,256,256,256
0000_07
bounds:256,256,256,256
0000_08
bounds:512,256,256,256
0000_09
bounds:768,256,256,256
0000_10
bounds:1024,256,256,256
0000_11
bounds:1280,256,120,256
0000_12
bounds:0,512,256,256
0000_13
bounds:256,512,256,256
0000_14
bounds:512,512,256,256
0000_15
bounds:768,512,256,256
0000_16
bounds:1024,512,256,256
0000_17
bounds:1280,512,120,256
0000_18
bounds:0,768,256,256
0000_19
bounds:256,768,256,256
0000_20
bounds:512,768,256,256
0000_21
bounds:768,768,256,256
0000_22
bounds:1024,768,256,256
0000_23
bounds:1280,768,120,256
innerbg2.png
size:1536,256
repeat:none
0000_24
bounds:0,0,256,176
0000_25
bounds:256,0,256,176
0000_26
bounds:512,0,256,176
0000_27
bounds:768,0,256,176
0000_28
bounds:1024,0,256,176
0000_29
bounds:1280,0,120,176

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 249 KiB