更新项目说明以及清空多余素材
@@ -13,6 +13,7 @@ public class Alice extends Fighter {
|
||||
maxHealth = 90; // 生命值较低
|
||||
health = maxHealth;
|
||||
attackPower = 12; // 攻击力中等
|
||||
name = "alice";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,4 +54,8 @@ public class Alice extends Fighter {
|
||||
protected boolean canAttack() {
|
||||
return super.canAttack() || currentAction == Action.JUMP || currentAction == Action.FALL;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ public abstract class Fighter implements Disposable {
|
||||
SPECIAL1, SPECIAL2,
|
||||
DEATH
|
||||
}
|
||||
protected String name;
|
||||
|
||||
// 动画帧间隔(秒)
|
||||
protected static final float DEFAULT_FRAME_DURATION = 0.1f;
|
||||
@@ -351,6 +352,8 @@ public abstract class Fighter implements Disposable {
|
||||
return attackPower;
|
||||
}
|
||||
|
||||
public String getName(){ return ""; }
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
10
src/main/java/uno/mloluyu/characters/FighterList.java
Normal 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"));
|
||||
|
||||
}
|
||||
@@ -5,43 +5,56 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
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.FighterList;
|
||||
|
||||
public class GameCore implements ApplicationListener {
|
||||
private SpriteBatch batch;
|
||||
private TextureAtlas atlas;
|
||||
private Alice alice1;
|
||||
|
||||
private Viewport viewport;
|
||||
private Gaming gaming;
|
||||
private Texture texture;
|
||||
|
||||
@Override
|
||||
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();
|
||||
atlas = new TextureAtlas(Gdx.files.internal("src\\main\\resources\\character\\alice\\alice.atlas"));
|
||||
alice1= new Alice(atlas);
|
||||
|
||||
gaming = new Gaming(new Alice(FighterList.aliceAtlas), new Alice(FighterList.aliceAtlas));
|
||||
gaming.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
Gdx.gl.glClearColor(150, 150, 150, 1);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
|
||||
alice1.update(Gdx.graphics.getDeltaTime());
|
||||
viewport.apply();
|
||||
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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
alice1.dispose();
|
||||
gaming.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
|
||||
@@ -1,5 +1,38 @@
|
||||
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 {
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
package uno.mloluyu.desktop;
|
||||
|
||||
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
|
||||
|
||||
|
||||
public class Launcher {
|
||||
private static int width;
|
||||
private static int height;
|
||||
public static final int width = 640;
|
||||
public static final int height = 480;
|
||||
public static void main(String[] args) {
|
||||
Lwjgl3ApplicationConfiguration configuration = new Lwjgl3ApplicationConfiguration();
|
||||
configuration.setTitle("Test Game");
|
||||
configuration.setWindowedMode(1200, 800);
|
||||
configuration.setWindowedMode(width, height);
|
||||
configuration.setForegroundFPS(60);
|
||||
configuration.useVsync(true);
|
||||
new Lwjgl3Application(new GameCore(), configuration);
|
||||
|
||||
@@ -1,5 +1,45 @@
|
||||
package uno.mloluyu.network;
|
||||
|
||||
public class ConnectServer {
|
||||
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 {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 7.1 MiB |
|
Before Width: | Height: | Size: 1.2 MiB |
@@ -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
|
||||
|
Before Width: | Height: | Size: 2.8 MiB |
|
Before Width: | Height: | Size: 249 KiB |
|
Before Width: | Height: | Size: 7.1 MiB |
|
Before Width: | Height: | Size: 1.2 MiB |
@@ -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
|
||||
|
Before Width: | Height: | Size: 2.8 MiB |
|
Before Width: | Height: | Size: 249 KiB |