Compare commits
4 Commits
a1d07210a0
...
7c26fd7ce6
| Author | SHA1 | Date | |
|---|---|---|---|
| 7c26fd7ce6 | |||
| 3dcb067a3d | |||
| 3362cacc72 | |||
| 8723b1354d |
@@ -23,6 +23,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;
|
||||||
@@ -374,6 +375,8 @@ public abstract class Fighter implements Disposable {
|
|||||||
return attackPower;
|
return attackPower;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getName(){ return ""; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
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"));
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,44 +3,57 @@ package uno.mloluyu.desktop;
|
|||||||
import com.badlogic.gdx.ApplicationListener;
|
import com.badlogic.gdx.ApplicationListener;
|
||||||
import com.badlogic.gdx.Gdx;
|
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.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
import uno.mloluyu.Controller.FighterController;
|
|
||||||
|
import com.badlogic.gdx.utils.Scaling;
|
||||||
|
import com.badlogic.gdx.utils.viewport.ExtendViewport;
|
||||||
|
import com.badlogic.gdx.utils.viewport.ScalingViewport;
|
||||||
|
import com.badlogic.gdx.utils.viewport.ScreenViewport;
|
||||||
|
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 Alice alice1;
|
private Viewport viewport;
|
||||||
private FighterController controller;
|
private Gaming gaming;
|
||||||
|
private Texture texture;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
|
viewport = new ScalingViewport(Scaling.none, Launcher.width, Launcher.width);
|
||||||
|
texture = new Texture(Gdx.files.internal("src\\main\\resources\\backgrounds\\bg.png"));
|
||||||
batch = new SpriteBatch();
|
batch = new SpriteBatch();
|
||||||
alice1= new Alice();
|
gaming = new Gaming(new Alice(), new Alice());
|
||||||
controller = new FighterController(alice1);
|
gaming.create();
|
||||||
Gdx.input.setInputProcessor(controller);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@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());
|
|
||||||
controller.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) {
|
||||||
|
|
||||||
|
// 应用新的视口设置
|
||||||
|
viewport.update(width, height, true); // 第三个参数 true 表示相机居中
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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(2600,1600);
|
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);
|
||||||
|
|||||||
@@ -1,5 +1,45 @@
|
|||||||
package uno.mloluyu.network;
|
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 |