├── 2DGame
├── .gitignore
├── build.gradle
├── core
│ ├── assets
│ │ ├── 1.tmx
│ │ ├── 2.tmx
│ │ ├── 21.tmx
│ │ ├── Tileset.png
│ │ └── lastguardian_all.png
│ ├── build.gradle
│ └── src
│ │ └── com
│ │ └── mygdx
│ │ ├── game
│ │ ├── MyGdxGame.java
│ │ ├── components
│ │ │ ├── Component.java
│ │ │ ├── graphicsComponent
│ │ │ │ ├── EnemyGraphics.java
│ │ │ │ ├── GraphicsComponent.java
│ │ │ │ └── PlayerGraphics.java
│ │ │ ├── inputComponent
│ │ │ │ ├── AI.java
│ │ │ │ ├── InputComponent.java
│ │ │ │ ├── MultiplayerInput.java
│ │ │ │ └── PlayerInput.java
│ │ │ ├── physicsComponent
│ │ │ │ ├── Collide.java
│ │ │ │ └── Transform.java
│ │ │ └── statComponent
│ │ │ │ ├── EnemyStatComponent.java
│ │ │ │ ├── PlayerStatComponent.java
│ │ │ │ └── StatComponent.java
│ │ ├── entities
│ │ │ ├── Entity.java
│ │ │ ├── characters
│ │ │ │ ├── Character.java
│ │ │ │ ├── Enemy.java
│ │ │ │ └── Player.java
│ │ │ ├── games
│ │ │ │ ├── Game.java
│ │ │ │ ├── Simple2DJavaGameMultiplayer.java
│ │ │ │ └── Simple2DJavaGameSingleplayer.java
│ │ │ └── worlds
│ │ │ │ ├── TiledWorld.java
│ │ │ │ └── World.java
│ │ └── utilities
│ │ │ ├── Animator.java
│ │ │ ├── ButtonListener.java
│ │ │ ├── Command.java
│ │ │ └── InputMapper.java
│ │ └── server
│ │ └── KryonetServer.java
├── desktop
│ ├── 1.tmx
│ ├── 2.tmx
│ ├── Tileset.png
│ ├── assets
│ │ ├── 1.tmx
│ │ ├── 2.tmx
│ │ ├── Thumbs.db
│ │ └── lastguardian_all.png
│ ├── build.gradle
│ └── src
│ │ └── com
│ │ └── mygdx
│ │ └── game
│ │ └── desktop
│ │ └── DesktopLauncher.java
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
├── HOWTOBUILD
└── README.md
/2DGame/.gitignore:
--------------------------------------------------------------------------------
1 | ## Java
2 |
3 | *.class
4 | *.war
5 | *.ear
6 | hs_err_pid*
7 |
8 | ## Robovm
9 | /ios/robovm-build/
10 |
11 | ## GWT
12 | /html/war/
13 | /html/gwt-unitCache/
14 | .apt_generated/
15 | .gwt/
16 | gwt-unitCache/
17 | www-test/
18 | .gwt-tmp/
19 |
20 | ## Android Studio and Intellij and Android in general
21 | /android/libs/armeabi/
22 | /android/libs/armeabi-v7a/
23 | /android/libs/arm64-v8a/
24 | /android/libs/x86/
25 | /android/libs/x86_64/
26 | /android/gen/
27 | .idea/
28 | *.ipr
29 | *.iws
30 | *.iml
31 | /android/out/
32 | com_crashlytics_export_strings.xml
33 |
34 | ## Eclipse
35 |
36 | .classpath
37 | .project
38 | .metadata/
39 | /android/bin/
40 | /core/bin/
41 | /desktop/bin/
42 | /html/bin/
43 | /ios/bin/
44 | /ios-moe/bin/
45 | *.tmp
46 | *.bak
47 | *.swp
48 | *~.nib
49 | .settings/
50 | .loadpath
51 | .externalToolBuilders/
52 | *.launch
53 |
54 | ## NetBeans
55 |
56 | /nbproject/private/
57 | /android/nbproject/private/
58 | /core/nbproject/private/
59 | /desktop/nbproject/private/
60 | /html/nbproject/private/
61 | /ios/nbproject/private/
62 | /ios-moe/nbproject/private/
63 |
64 | /build/
65 | /android/build/
66 | /core/build/
67 | /desktop/build/
68 | /html/build/
69 | /ios/build/
70 | /ios-moe/build/
71 |
72 | /nbbuild/
73 | /android/nbbuild/
74 | /core/nbbuild/
75 | /desktop/nbbuild/
76 | /html/nbbuild/
77 | /ios/nbbuild/
78 | /ios-moe/nbbuild/
79 |
80 | /dist/
81 | /android/dist/
82 | /core/dist/
83 | /desktop/dist/
84 | /html/dist/
85 | /ios/dist/
86 | /ios-moe/dist/
87 |
88 | /nbdist/
89 | /android/nbdist/
90 | /core/nbdist/
91 | /desktop/nbdist/
92 | /html/nbdist/
93 | /ios/nbdist/
94 | /ios-moe/nbdist/
95 |
96 | nbactions.xml
97 | nb-configuration.xml
98 |
99 | ## Gradle
100 |
101 | /local.properties
102 | .gradle/
103 | gradle-app.setting
104 | /build/
105 | /android/build/
106 | /core/build/
107 | /desktop/build/
108 | /html/build/
109 | /ios/build/
110 | /ios-moe/build/
111 |
112 | ## OS Specific
113 | .DS_Store
114 | Thumbs.db
115 |
--------------------------------------------------------------------------------
/2DGame/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | mavenLocal()
4 | mavenCentral()
5 | maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
6 | jcenter()
7 | }
8 | dependencies {
9 | }
10 | }
11 |
12 | allprojects {
13 | apply plugin: "eclipse"
14 | apply plugin: "idea"
15 |
16 | version = '1.0'
17 | ext {
18 | appName = "2DGame"
19 | gdxVersion = '1.9.6'
20 | roboVMVersion = '2.3.0'
21 | box2DLightsVersion = '1.4'
22 | ashleyVersion = '1.7.0'
23 | aiVersion = '1.8.0'
24 | }
25 |
26 | repositories {
27 | mavenLocal()
28 | mavenCentral()
29 | maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
30 | maven { url "https://oss.sonatype.org/content/repositories/releases/" }
31 | maven { url "https://mvnrepository.com/artifact/"}
32 | }
33 | }
34 |
35 | project(":desktop") {
36 | apply plugin: "java"
37 |
38 |
39 | dependencies {
40 | compile project(":core")
41 | compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
42 | compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
43 | compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
44 | compile "com.badlogicgames.gdx:gdx-controllers-desktop:$gdxVersion"
45 | compile "com.badlogicgames.gdx:gdx-controllers-platform:$gdxVersion:natives-desktop"
46 |
47 | }
48 | }
49 |
50 | project(":core") {
51 | apply plugin: "java"
52 |
53 |
54 | dependencies {
55 | compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
56 | compile "com.badlogicgames.gdx:gdx:$gdxVersion"
57 | compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
58 | compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"
59 | compile "com.badlogicgames.gdx:gdx-ai:$aiVersion"
60 | compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
61 | compile "com.esotericsoftware:kryonet:2.22.0-RC1"
62 | }
63 | }
64 | tasks.eclipse.doLast {
65 | delete ".project"
66 | }
--------------------------------------------------------------------------------
/2DGame/core/assets/1.tmx:
--------------------------------------------------------------------------------
1 |
2 |
55 |
--------------------------------------------------------------------------------
/2DGame/core/assets/2.tmx:
--------------------------------------------------------------------------------
1 |
2 |
327 |
--------------------------------------------------------------------------------
/2DGame/core/assets/21.tmx:
--------------------------------------------------------------------------------
1 |
2 |
142 |
--------------------------------------------------------------------------------
/2DGame/core/assets/Tileset.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Farmerjoe12/Simple2DJavaGame/f5140a34ed9ecb67ea013b44ef6191a459364aaf/2DGame/core/assets/Tileset.png
--------------------------------------------------------------------------------
/2DGame/core/assets/lastguardian_all.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Farmerjoe12/Simple2DJavaGame/f5140a34ed9ecb67ea013b44ef6191a459364aaf/2DGame/core/assets/lastguardian_all.png
--------------------------------------------------------------------------------
/2DGame/core/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "java"
2 |
3 | sourceCompatibility = 1.6
4 | [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
5 |
6 | sourceSets.main.java.srcDirs = [ "src/" ]
7 |
8 |
9 | eclipse.project {
10 | name = appName + "-core"
11 | }
12 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/MyGdxGame.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game;
2 |
3 | import com.badlogic.gdx.ApplicationAdapter;
4 | import com.badlogic.gdx.Gdx;
5 | import com.badlogic.gdx.assets.AssetManager;
6 | import com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver;
7 | import com.badlogic.gdx.graphics.GL20;
8 | import com.badlogic.gdx.graphics.OrthographicCamera;
9 | import com.badlogic.gdx.graphics.Texture;
10 | import com.badlogic.gdx.graphics.g2d.SpriteBatch;
11 |
12 | import com.badlogic.gdx.maps.MapProperties;
13 | import com.badlogic.gdx.maps.tiled.TiledMap;
14 | import com.badlogic.gdx.maps.tiled.TmxMapLoader;
15 | import com.mygdx.game.entities.characters.Player;
16 | import com.mygdx.game.entities.games.Game;
17 | import com.mygdx.game.entities.games.Simple2DJavaGameMultiplayer;
18 | import com.mygdx.game.entities.games.Simple2DJavaGameSingleplayer;
19 | import com.mygdx.game.components.physicsComponent.Transform;
20 |
21 | import com.mygdx.game.entities.worlds.TiledWorld;
22 | import com.mygdx.game.utilities.ButtonListener;
23 |
24 | /**
25 | * This is the main class that runs the program, all rendering is currently handled through the
26 | * render method with a static call to the renderer class
27 | *
28 | * @author adamfarmelo
29 | *
30 | */
31 | public class MyGdxGame extends ApplicationAdapter {
32 |
33 | public static ButtonListener listener = new ButtonListener();
34 | static AssetManager assetManager = new AssetManager();
35 | public static Simple2DJavaGameSingleplayer simple2DJavaGameSingleplayer;
36 | public static Simple2DJavaGameMultiplayer simple2DJavaGameMultiplayer;
37 | public static Game currentGame;
38 | SpriteBatch batch;
39 | OrthographicCamera cam;
40 |
41 | @Override
42 | public void create() {
43 | loadAssets();
44 |
45 | batch = new SpriteBatch();
46 |
47 | float w = Gdx.graphics.getWidth();
48 | float h = Gdx.graphics.getHeight();
49 |
50 |
51 | simple2DJavaGameSingleplayer = new Simple2DJavaGameSingleplayer();
52 | //simple2DJavaGameMultiplayer = new Simple2DJavaGameMultiplayer();
53 |
54 |
55 |
56 | cam = new OrthographicCamera(30, 30 * (h / w));
57 |
58 | cam.setToOrtho(false, 960, 640);
59 | cam.position.set(0, 0, 0);
60 | currentGame.setCamera(cam);
61 | cam.update();
62 |
63 | Gdx.input.setInputProcessor(listener);
64 |
65 | }
66 |
67 | @Override
68 | public void render() {
69 | if(assetManager.update()) {
70 | //asset manager is done loading
71 | }
72 | else {
73 | //to-do: put a loading bar here once we have enough assets that load time is non-negligible
74 | //asset manager is loading
75 | }
76 |
77 | Gdx.gl.glClearColor(1, 0, 0, 1);
78 | Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
79 | Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
80 |
81 | currentGame.tick();
82 | currentGame.draw(batch);
83 |
84 | cam.update();
85 | }
86 |
87 | @Override
88 | public void dispose() {
89 | assetManager.dispose();
90 | //simple2DJavaGameMultiplayer.dispose();
91 | }
92 |
93 | public void loadAssets() {
94 | assetManager.load("lastguardian_all.png", Texture.class);
95 | assetManager.setLoader(TiledMap.class, new TmxMapLoader(new InternalFileHandleResolver()));
96 | assetManager.load("1.tmx", TiledMap.class);
97 | assetManager.load("2.tmx", TiledMap.class);
98 | assetManager.load("21.tmx", TiledMap.class);
99 | assetManager.finishLoading();
100 | }
101 |
102 | public static AssetManager getAssetManager(){
103 | return assetManager;
104 | }
105 |
106 | private void checkMapBorders() {
107 |
108 | Player player = MyGdxGame.currentGame.getChild(Player.class);
109 | MapProperties prop = currentGame.getChild(TiledWorld.class).getProp();
110 | // get Tiled map properties
111 | int mapWidth = prop.get("width", Integer.class);
112 | int mapHeight = prop.get("height", Integer.class);
113 | int tilePixelWidth = prop.get("tilewidth", Integer.class);
114 | int tilePixelHeight = prop.get("tileheight", Integer.class);
115 |
116 | // 'width' and 'height' supply the amount of tiles in each row/column,
117 | // so you must multiply it by the tile width in order to get the map dimensions
118 | int mapPixelWidth = mapWidth * tilePixelWidth;
119 | int mapPixelHeight = mapHeight * tilePixelHeight;
120 |
121 | // determine when the camera will reach the ends of the map
122 | float viewportMinX = cam.viewportWidth / 2;
123 | float viewportMinY = cam.viewportHeight / 2;
124 | float viewportMaxX = mapPixelWidth - viewportMinX;
125 | float viewportMaxY = mapPixelHeight - viewportMinY;
126 |
127 | float x = player.getComponent(Transform.class).getPosition().x;
128 | float y = player.getComponent(Transform.class).getPosition().y;
129 |
130 | // preventing the camera from scrolling past the edge of the map
131 | if (x < viewportMinX) {
132 | cam.position.x = viewportMinX;
133 | } else if (x > viewportMaxX) {
134 | cam.position.x = viewportMaxX;
135 | } else {
136 | cam.position.x = x;
137 | }
138 |
139 | if (y < viewportMinY) {
140 | cam.position.y = viewportMinY;
141 | } else if (y > viewportMaxY) {
142 | cam.position.y = viewportMaxY;
143 | } else {
144 | cam.position.y = y;
145 | }
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/components/Component.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.components;
2 |
3 | import com.mygdx.game.entities.Entity;
4 |
5 | /**
6 | * Created by Jacob on 3/29/2017.
7 | */
8 | public abstract class Component {
9 |
10 | Entity parent;
11 |
12 | public Entity getParent() {
13 | return parent;
14 | }
15 |
16 | public void setParent(Entity set) {
17 | parent = set;
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/components/graphicsComponent/EnemyGraphics.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.components.graphicsComponent;
2 |
3 | import com.badlogic.gdx.graphics.g2d.SpriteBatch;
4 | import com.mygdx.game.components.Component;
5 | import com.mygdx.game.components.inputComponent.AI;
6 | import com.mygdx.game.components.physicsComponent.Collide;
7 | import com.mygdx.game.components.physicsComponent.Transform;
8 | import com.mygdx.game.utilities.Animator;
9 |
10 |
11 | public class EnemyGraphics extends Component implements GraphicsComponent {
12 | private Animator[] animSet;
13 | private Animator currAnimation;
14 | private int input, lastDir;
15 |
16 | /**
17 | * EnemyGraphics is solely responsible for drawing the animations and sprites
18 | * -- as it should be
19 | */
20 | public EnemyGraphics() {
21 | // createAnimSet takes parameters for row on the spritesheet and set
22 | // of sprites, the top leftmost set is row 0, set 0 increasing
23 | // down and to the right
24 | createAnimSet(12, 0);
25 | currAnimation = null;
26 | lastDir = 1;
27 | }
28 |
29 | // draw gets the input as well as current location
30 | // then draws the animation or last frame depending on if moving or not
31 | // which is determined by input
32 | @Override
33 | public void draw(SpriteBatch batch) {
34 | float x = getParent().getComponent(Transform.class).getPosition().x;
35 | float y = getParent().getComponent(Transform.class).getPosition().y;
36 |
37 | input = getParent().getComponent(AI.class).handleInput();
38 | currAnimation = getCurrentAnimation(input);
39 |
40 | if (!getParent().getComponent(Collide.class).isBlocked(input)
41 | && currAnimation != null) {
42 | batch.draw(currAnimation.getCurrentTextureRegion(), x, y, 32, 32);
43 | } else {
44 | batch.draw(animSet[lastDir].getLastFrame(), x, y, 32, 32);
45 | }
46 |
47 | }
48 |
49 | private Animator getCurrentAnimation(int input) {
50 | if (input >= 0) {
51 | lastDir = input;
52 | return animSet[input];
53 | } else
54 | return null;
55 | }
56 |
57 | private void createAnimSet(int spriteRow, int spriteSet) {
58 | int startSprite = spriteSet * 8;
59 | int endSprite = startSprite + 1;
60 |
61 | animSet = new Animator[4];
62 | animSet[0] = new Animator(spriteRow, startSprite, endSprite); // UP
63 | animSet[1] = new Animator(spriteRow, startSprite + 2, endSprite + 2); // DOWN
64 | animSet[2] = new Animator(spriteRow, startSprite + 4, endSprite + 4); // LEFT
65 | animSet[3] = new Animator(spriteRow, startSprite + 6, endSprite + 6); // RIGHT
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/components/graphicsComponent/GraphicsComponent.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.components.graphicsComponent;
2 |
3 | import com.badlogic.gdx.graphics.g2d.SpriteBatch;
4 |
5 | /**
6 | * Created by Jacob on 3/29/2017.
7 | */
8 | public interface GraphicsComponent {
9 | void draw(SpriteBatch batch);
10 | }
11 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/components/graphicsComponent/PlayerGraphics.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.components.graphicsComponent;
2 |
3 | import com.badlogic.gdx.graphics.g2d.SpriteBatch;
4 | import com.mygdx.game.components.Component;
5 | import com.mygdx.game.components.inputComponent.PlayerInput;
6 | import com.mygdx.game.components.physicsComponent.Collide;
7 | import com.mygdx.game.components.physicsComponent.Transform;
8 | import com.mygdx.game.components.statComponent.PlayerStatComponent;
9 | import com.mygdx.game.utilities.Animator;
10 |
11 | /**
12 | * Created by Jacob on 3/29/2017.
13 | */
14 | public class PlayerGraphics extends Component implements GraphicsComponent {
15 | private Animator[] animSet;
16 | private Animator currAnimation = null;
17 | private int input;
18 | private int lastDir;
19 |
20 | public PlayerGraphics() {
21 | // createAnimSet takes parameters for row on the spritesheet and set
22 | // of sprites, the top leftmost set is row 0, set 0 increasing
23 | // down and to the right
24 | createAnimSet(22, 0);
25 |
26 | }
27 |
28 | @Override
29 | public void draw(SpriteBatch batch) {
30 | input = getParent().getComponent(PlayerInput.class).handleInput();
31 | float x = getParent().getComponent(Transform.class).getPosition().x;
32 | float y = getParent().getComponent(Transform.class).getPosition().y;
33 | currAnimation = getCurrentAnimation(input);
34 | if (!(currAnimation == null)) {
35 | batch.draw(currAnimation.getCurrentTextureRegion(), x, y, 32, 32);
36 | } else {
37 | batch.draw(animSet[lastDir].getLastFrame(), x, y, 32, 32);
38 | }
39 | }
40 |
41 |
42 | private Animator getCurrentAnimation(int input) {
43 | if (input >= 0) {
44 | lastDir = input;
45 | return animSet[input];
46 | } else
47 | return null;
48 | }
49 |
50 | private void createAnimSet(int spriteRow, int spriteSet) {
51 |
52 | int startSprite = spriteSet * 8;
53 | int endSprite = startSprite + 1;
54 |
55 | animSet = new Animator[4];
56 | animSet[0] = new Animator(spriteRow, startSprite, endSprite);
57 | animSet[1] = new Animator(spriteRow, startSprite + 2, endSprite + 2); // DOWN
58 | animSet[2] = new Animator(spriteRow, startSprite + 4, endSprite + 4); // LEFT
59 | animSet[3] = new Animator(spriteRow, startSprite + 6, endSprite + 6); // RIGHT
60 | }
61 |
62 |
63 | public int getCurrentCol()
64 | {
65 | input = getParent().getComponent(PlayerInput.class).getCurrentDirection();
66 | currAnimation = getCurrentAnimation(input);
67 | if (!(currAnimation == null)) {
68 | return currAnimation.getColumn();
69 | } else {
70 | return animSet[lastDir].getColumn();
71 | }
72 | }
73 |
74 | public int getInput() {
75 | return input;
76 | }
77 |
78 | public void setInput(int input) {
79 | this.input = input;
80 | }
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/components/inputComponent/AI.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.components.inputComponent;
2 |
3 | import java.util.Random;
4 |
5 | import com.badlogic.gdx.math.Vector2;
6 | import com.badlogic.gdx.utils.TimeUtils;
7 | import com.mygdx.game.MyGdxGame;
8 | import com.mygdx.game.components.Component;
9 | import com.mygdx.game.components.physicsComponent.Collide;
10 | import com.mygdx.game.components.physicsComponent.Transform;
11 | import com.mygdx.game.components.statComponent.EnemyStatComponent;
12 | import com.mygdx.game.entities.characters.Player;
13 |
14 | public class AI extends Component implements InputComponent {
15 |
16 | // input varies based on state; idle or chasing
17 | // if enemy is idle but player comes into range,
18 | // enemy will chase
19 | private boolean idle = true;
20 | private int input;
21 | private float num;
22 | private Random rand;
23 | private int sightRange, attackRange;
24 | private Vector2 playerPos;
25 | private int playerXTile, playerYTile;
26 | private Vector2 myPos;
27 | private int npcXTile, npcYTile;
28 | private int deltaX, deltaY;
29 | boolean moveFlag = false;
30 | private long lastTime;
31 |
32 |
33 | public AI() {
34 | rand = new Random();
35 | lastTime = TimeUtils.millis();
36 | sightRange = 250;
37 | attackRange = 32;
38 | }
39 |
40 | @Override
41 | public int handleInput() {
42 | playerPos = MyGdxGame.currentGame.getChild(Player.class).getComponent(Transform.class).getPosition();
43 | myPos = getParent().getComponent(Transform.class).getPosition();
44 |
45 | // checking if player is within range of enemy,
46 | // if search then player is found
47 | // if found, chase
48 | // else if player is lost, return to idle
49 | if (search(myPos, playerPos)) {
50 | idle = false;
51 | input = chase(myPos, playerPos);
52 | } else {
53 | idle = true;
54 | }
55 |
56 | // player alternates between wandering and standing every
57 | // **two** seconds while player is not found (idle)
58 | if (TimeUtils.timeSinceMillis(lastTime) > 1500 && idle){
59 | moveFlag = !moveFlag;
60 | lastTime = TimeUtils.millis();
61 | input = wander();
62 | }
63 |
64 | // move if !blocked && !idle (chasing)
65 | // or move if !blocked && moveFlag && idle (not chasing)
66 | // if player !moving (idle || blocked || !moveFlag) return -1
67 | if ((!getParent().getComponent(Collide.class).isBlocked(input) && !idle)
68 | || (moveFlag && idle && !getParent().getComponent(Collide.class).isBlocked(input))) {
69 | move(input);
70 | } else input = -1;
71 |
72 | return input;
73 | }
74 |
75 | // search returns true if player is within range
76 | private boolean search(Vector2 myPos, Vector2 playerPos) {
77 | if ((Math.abs(myPos.x-playerPos.x) < sightRange) &&
78 | (Math.abs(myPos.y-playerPos.y) < sightRange)) {
79 | return true;
80 | }
81 | return false;
82 | }
83 |
84 | // wander generates random numbers to simulate enemy wandering about
85 | private int wander() {
86 | num = rand.nextFloat();
87 | if (num < .25) {
88 | input = 0;
89 | } else if (num >= .25 && num < .5) {
90 | input = 1;
91 | } else if (num >= .5 && num < .75) {
92 | input = 2;
93 | } else if (num >= .75) {
94 | input = 3;}
95 |
96 | return input;
97 | }
98 |
99 | // every .5 seconds calculate playerPos and change direction
100 | private int chase(Vector2 myPos, Vector2 playerPos) {
101 | npcXTile = (int)myPos.x / 32;
102 | npcYTile = (int)myPos.y / 32;
103 |
104 | playerXTile = (int)playerPos.x / 32;
105 | playerYTile = (int)playerPos.y / 32;
106 |
107 | deltaY = npcYTile-playerYTile;
108 | deltaX = npcXTile-playerXTile;
109 |
110 | boolean chasing = false;
111 | boolean attacking = false;
112 |
113 | // check if player is within attack range
114 | // if so, stop chasing/moving and attack
115 | if (Math.abs(myPos.x-playerPos.x) < attackRange &&
116 | Math.abs(myPos.y-playerPos.y) < attackRange) {
117 | chasing = false;
118 | attacking = true;
119 | attack();
120 | input = -1;
121 | }
122 |
123 | // check if enemy is not chasing and not attacking
124 | // if true, get new input
125 | // chasing is reset every *arbitrary unit of seconds*
126 | // to allow for direction change and simulated intelligence
127 | if (!chasing && !attacking) {
128 | lastTime = TimeUtils.millis();
129 | if (Math.abs(deltaY) > Math.abs(deltaX)) {
130 | if (deltaY < 0) { // if deltaY is negative, player is higher
131 | input = 0; // move up
132 | } else input = 1; // else move down
133 | } else {
134 | if (deltaX < 0) { // if deltaX is negative, player is righter
135 | input = 3; // move right
136 | } else input = 2; // else move left
137 | }
138 | chasing = true;
139 | } else if (chasing){
140 | if (TimeUtils.timeSinceMillis(lastTime) > 2000) {
141 | lastTime = TimeUtils.millis();
142 | chasing = false;
143 | }
144 | }
145 | return input;
146 | }
147 |
148 | // clearly lackluster attack method
149 | private void attack() {
150 | System.out.println("Attacking!");
151 |
152 | }
153 |
154 | // basic move method, handled now by input instead of graphics
155 | private void move(int input)
156 | {
157 | float delta = getParent().getComponent(EnemyStatComponent.class).getMoveSpeed();
158 | switch (input) {
159 | case -1:
160 | break;
161 | case 0: getParent().getComponent(Transform.class).deltaY(delta);
162 | break;
163 | case 1: getParent().getComponent(Transform.class).deltaY(-delta);
164 | break;
165 | case 2: getParent().getComponent(Transform.class).deltaX(-delta);
166 | break;
167 | case 3: getParent().getComponent(Transform.class).deltaX(delta);
168 | break;
169 | default:
170 | break;
171 | }
172 | }
173 | }
174 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/components/inputComponent/InputComponent.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.components.inputComponent;
2 |
3 |
4 | /**
5 | * Created by Jacob on 3/29/2017.
6 | */
7 | public interface InputComponent {
8 | int handleInput();
9 | }
10 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/components/inputComponent/MultiplayerInput.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.components.inputComponent;
2 |
3 | import com.badlogic.gdx.Input;
4 | import com.mygdx.game.MyGdxGame;
5 | import com.mygdx.game.components.Component;
6 | import com.mygdx.game.entities.games.Simple2DJavaGameMultiplayer;
7 | import com.mygdx.game.utilities.Command;
8 | import com.mygdx.game.utilities.InputMapper;
9 | import java.util.ArrayList;
10 |
11 | /**
12 | * Created by Jacob on 4/7/2017.
13 | */
14 | public class MultiplayerInput extends Component implements InputComponent {
15 |
16 | InputMapper mapper;
17 | Simple2DJavaGameMultiplayer parent;
18 |
19 | public MultiplayerInput(){
20 | mapper = new InputMapper();
21 |
22 | mapper.mapCommand(new Integer[]{Input.Keys.UP},new Command() {
23 | @Override
24 | public String executeCommand() {
25 | parent = ((Simple2DJavaGameMultiplayer)getParent());
26 | ArrayList buttonsList = MyGdxGame.listener.getKeysPressed();
27 | Integer[] buttons = new Integer[buttonsList.size()];
28 | for(int i = 0; i < buttons.length; i++){
29 | buttons[i] = buttonsList.get(i);
30 | }
31 | parent.getClient().sendTCP(combine(new Integer[]{parent.getClientID()},buttons));
32 | return "sent to server : walk up";
33 | }
34 | });
35 | mapper.mapCommand(new Integer[]{Input.Keys.LEFT},new Command() {
36 | @Override
37 | public String executeCommand() {
38 | parent = ((Simple2DJavaGameMultiplayer)getParent());
39 | ArrayList buttonsList = MyGdxGame.listener.getKeysPressed();
40 | Integer[] buttons = new Integer[buttonsList.size()];
41 | for(int i = 0; i < buttons.length; i++){
42 | buttons[i] = buttonsList.get(i);
43 | }
44 | parent.getClient().sendTCP(combine(new Integer[]{parent.getClientID()},buttons));
45 | return "sent to server : walk left";
46 | }
47 | });
48 | mapper.mapCommand(new Integer[]{Input.Keys.RIGHT},new Command() {
49 | @Override
50 | public String executeCommand() {
51 | parent = ((Simple2DJavaGameMultiplayer)getParent());
52 | ArrayList buttonsList = MyGdxGame.listener.getKeysPressed();
53 | Integer[] buttons = new Integer[buttonsList.size()];
54 | for(int i = 0; i < buttons.length; i++){
55 | buttons[i] = buttonsList.get(i);
56 | }
57 | parent.getClient().sendTCP(combine(new Integer[]{parent.getClientID()},buttons));
58 | return "sent to server : walk right";
59 | }
60 | });
61 | mapper.mapCommand(new Integer[]{Input.Keys.DOWN},new Command() {
62 | @Override
63 | public String executeCommand() {
64 | parent = ((Simple2DJavaGameMultiplayer)getParent());
65 | ArrayList buttonsList = MyGdxGame.listener.getKeysPressed();
66 | Integer[] buttons = new Integer[buttonsList.size()];
67 | for(int i = 0; i < buttons.length; i++){
68 | buttons[i] = buttonsList.get(i);
69 | }
70 | parent.getClient().sendTCP(combine(new Integer[]{parent.getClientID()},buttons));
71 | return "sent to server : walk down";
72 | }
73 | });
74 | }
75 |
76 | @Override
77 | public int handleInput() {
78 |
79 | ArrayList buttonsList = MyGdxGame.listener.getKeysPressed();
80 | if(mapper.containsCommand(buttonsList)){
81 | mapper.getCommand(buttonsList).executeCommand();
82 | }
83 | return 0;
84 | }
85 |
86 | private Integer[] combine(Integer[] a, Integer[] b){
87 | Integer[] toRet = new Integer[a.length+b.length];
88 | for(int i = 0; i < a.length; i++) {
89 | toRet[i] = a[i];
90 | }
91 | for(int i = a.length; i < toRet.length; i++) {
92 | toRet[i] = b[i-a.length];
93 | }
94 | return toRet;
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/components/inputComponent/PlayerInput.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.components.inputComponent;
2 |
3 |
4 | import com.badlogic.gdx.Gdx;
5 |
6 |
7 | import com.badlogic.gdx.Input;
8 | import com.mygdx.game.MyGdxGame;
9 | import com.mygdx.game.components.Component;
10 |
11 | import com.mygdx.game.components.physicsComponent.Collide;
12 | import com.mygdx.game.components.physicsComponent.Transform;
13 | import com.mygdx.game.components.statComponent.PlayerStatComponent;
14 | import com.mygdx.game.utilities.InputMapper;
15 | import com.mygdx.game.utilities.Command;
16 | import java.util.ArrayList;
17 |
18 |
19 | /**
20 | * Created by Jacob on 3/29/2017.
21 | */
22 | public class PlayerInput extends Component implements InputComponent {
23 |
24 | InputMapper mapper;
25 | // @param deltaVal controls the amount that the player moves every frame
26 | // while recieving input
27 | public static final int UP = 0;
28 | public static final int DOWN = 1;
29 | public static final int LEFT = 2;
30 | public static final int RIGHT = 3;
31 |
32 | int currentDirection = 0;
33 |
34 | public PlayerInput() {
35 |
36 | mapper = new InputMapper();
37 | mapper.mapCommand(new Integer[]{Input.Keys.UP},new Command() {
38 | @Override
39 | public String executeCommand() {
40 | float deltaVal = getParent().getComponent(PlayerStatComponent.class).getMoveSpeed();
41 | currentDirection = UP;
42 | if(!getParent().getComponent(Collide.class).isBlocked(currentDirection)){
43 | getParent().getComponent(Transform.class).deltaY(deltaVal);
44 | }
45 |
46 | return "walk-up";
47 | }
48 | });
49 | mapper.mapCommand(new Integer[]{Input.Keys.LEFT},new Command() {
50 | @Override
51 | public String executeCommand() {
52 | float deltaVal = getParent().getComponent(PlayerStatComponent.class).getMoveSpeed();
53 | currentDirection = LEFT;
54 | if(!getParent().getComponent(Collide.class).isBlocked(currentDirection)){
55 | getParent().getComponent(Transform.class).deltaX(-deltaVal);
56 | }
57 |
58 | return "walk-left";
59 | }
60 | });
61 | mapper.mapCommand(new Integer[]{Input.Keys.RIGHT},new Command() {
62 | @Override
63 | public String executeCommand() {
64 | float deltaVal = getParent().getComponent(PlayerStatComponent.class).getMoveSpeed();
65 | currentDirection = RIGHT;
66 | if(!getParent().getComponent(Collide.class).isBlocked(currentDirection)){
67 | getParent().getComponent(Transform.class).deltaX(deltaVal);
68 | }
69 |
70 | return "walk-right";
71 | }
72 | });
73 | mapper.mapCommand(new Integer[]{Input.Keys.DOWN},new Command() {
74 | @Override
75 | public String executeCommand() {
76 | float deltaVal = getParent().getComponent(PlayerStatComponent.class).getMoveSpeed();
77 | currentDirection = DOWN;
78 | if(!getParent().getComponent(Collide.class).isBlocked(currentDirection)){
79 | getParent().getComponent(Transform.class).deltaY(-deltaVal);
80 | }
81 |
82 | return "walk-down";
83 | }
84 | });
85 | mapper.mapCommand(new Integer[]{Input.Keys.UP,Input.Keys.SHIFT_LEFT},new Command() {
86 | @Override
87 | public String executeCommand() {
88 | float deltaVal = getParent().getComponent(PlayerStatComponent.class).getMoveSpeed();
89 | currentDirection = UP;
90 | if(!getParent().getComponent(Collide.class).isBlocked(currentDirection)){
91 | getParent().getComponent(Transform.class).deltaY(2*deltaVal);
92 | }
93 |
94 | return "walk-up";
95 | }
96 | });
97 | mapper.mapCommand(new Integer[]{Input.Keys.LEFT,Input.Keys.SHIFT_LEFT},new Command() {
98 | @Override
99 | public String executeCommand() {
100 | float deltaVal = getParent().getComponent(PlayerStatComponent.class).getMoveSpeed();
101 | currentDirection = LEFT;
102 | if(!getParent().getComponent(Collide.class).isBlocked(currentDirection)){
103 | getParent().getComponent(Transform.class).deltaX(-2*deltaVal);
104 | }
105 |
106 | return "walk-left";
107 | }
108 | });
109 | mapper.mapCommand(new Integer[]{Input.Keys.RIGHT,Input.Keys.SHIFT_LEFT},new Command() {
110 | @Override
111 | public String executeCommand() {
112 | float deltaVal = getParent().getComponent(PlayerStatComponent.class).getMoveSpeed();
113 | currentDirection = RIGHT;
114 | if(!getParent().getComponent(Collide.class).isBlocked(currentDirection)){
115 | getParent().getComponent(Transform.class).deltaX(2*deltaVal);
116 | }
117 |
118 | return "walk-right";
119 | }
120 | });
121 | mapper.mapCommand(new Integer[]{Input.Keys.DOWN,Input.Keys.SHIFT_LEFT},new Command() {
122 | @Override
123 | public String executeCommand() {
124 | float deltaVal = getParent().getComponent(PlayerStatComponent.class).getMoveSpeed();
125 | currentDirection = DOWN;
126 | if(!getParent().getComponent(Collide.class).isBlocked(currentDirection)){
127 | getParent().getComponent(Transform.class).deltaY(-2*deltaVal);
128 | }
129 |
130 | return "walk-down";
131 | }
132 | });
133 | }
134 |
135 | @Override
136 | public int handleInput() {
137 | ArrayList buttonsList = MyGdxGame.listener.getKeysPressed();
138 | if(mapper.containsCommand(buttonsList)){
139 | mapper.getCommand(buttonsList).executeCommand();
140 | return currentDirection;
141 | } else {
142 | //To-Do : check to see if there is a subsection of buttons pressed that is a relevant command
143 | // and check from context what attempted command is most probable
144 | }
145 | return -1;
146 | }
147 |
148 | public InputMapper getMapper(){
149 | return mapper;
150 | }
151 |
152 | public int getCurrentDirection() {
153 | return currentDirection;
154 | }
155 |
156 | }
157 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/components/physicsComponent/Collide.java:
--------------------------------------------------------------------------------
1 |
2 | package com.mygdx.game.components.physicsComponent;
3 |
4 | import com.badlogic.gdx.maps.MapProperties;
5 | import com.badlogic.gdx.maps.tiled.TiledMap;
6 | import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;
7 | import com.badlogic.gdx.math.Vector2;
8 | import com.mygdx.game.MyGdxGame;
9 | import com.mygdx.game.components.Component;
10 | import com.mygdx.game.entities.worlds.TiledWorld;
11 |
12 | /**
13 | *
14 | * Ideally this component should be implemented by the worldMap entity. Then,
15 | * within handleInput() of PlayerInput before transform is called, the Collide
16 | * compponent should be called and utilized so that the player's position is not updated
17 | * until the tile in the desired direction of travel is verified to be clear
18 | * @author adamfarmelo
19 | *
20 | */
21 | public class Collide extends Component{
22 | private Vector2 position;
23 | private TiledMap tiledMap;
24 | private MapProperties prop;
25 | private int mapWidth;
26 | private int mapHeight;
27 | private int tilePixelWidth;
28 | private int tilePixelHeight;
29 |
30 | // m supply the amount of tiles in each row/column,
31 | // so you must multiply it by the tile width in order to get the map dimensions
32 | int mapPixelWidth;
33 | int mapPixelHeight;
34 |
35 | private boolean bottomLeft, bottomRight, topRight, topLeft;
36 |
37 | public Collide()
38 | {
39 | tiledMap = MyGdxGame.currentGame.getChild(TiledWorld.class).tiledMap;
40 | prop = tiledMap.getProperties();
41 | mapWidth = prop.get("width", Integer.class);
42 | mapHeight = prop.get("height", Integer.class);
43 | tilePixelWidth = prop.get("tilewidth", Integer.class);
44 | tilePixelHeight = prop.get("tileheight", Integer.class);
45 | mapPixelWidth = mapWidth * tilePixelWidth;
46 | mapPixelHeight = mapHeight * tilePixelHeight;
47 | }
48 |
49 |
50 | /** isBlocked() is based on the individual properties of the tiles within the cells of
51 | * the tiledMap
52 | *
53 | */
54 | public boolean isBlocked(int facing)
55 | {
56 | position = getParent().getComponent(Transform.class).position;
57 |
58 | /**
59 | * baseX&Y and adjX&Y are used to get the corners of the sprite, since
60 | * the sprites position is based off of the bottom left corner, adjusted
61 | * values are needed for the other three corners
62 | */
63 | float baseX = position.x;
64 | float baseY = position.y;
65 | float adjX = position.x + 31;
66 | float adjY = position.y + 15;
67 |
68 | // TMTL is storing the collidable layer from 2.tmx
69 | TiledMapTileLayer collidableLayer = (TiledMapTileLayer)tiledMap.getLayers().get("collidable");
70 |
71 | // Values tweaked to prevent texture overlap
72 |
73 | // UP
74 | // If facing up, checks top left and right pixels for collision and also top map bounds
75 | if (facing == 0) {
76 | adjY += 1;
77 | topLeft = collidableLayer.getCell((int)(baseX/32), (int)(adjY/32)) != null;
78 | topRight = collidableLayer.getCell((int)(adjX/32), (int)(adjY/32)) != null;
79 | return ((topLeft || topRight) ) || position.y + 32 > mapHeight*tilePixelHeight;
80 | }
81 | // DOWN
82 | // If facing down, checks bottom left and right pixels for collision and also bottom map bounds
83 | if (facing == 1) {
84 | baseY -= 1;
85 | bottomLeft = collidableLayer.getCell((int)(baseX/32), (int)(baseY/32)) != null;
86 | bottomRight = collidableLayer.getCell((int)(adjX/32), (int)(baseY/32)) != null;
87 | return ((bottomLeft) || (bottomRight)) || position.y < 0;
88 | }
89 | // LEFT
90 | // If facing left, checks bottom and top left pixels for collision and also left map bounds
91 | if (facing == 2) {
92 | baseX -= 1;
93 | bottomLeft = collidableLayer.getCell((int)(baseX/32), (int)(baseY/32)) != null;
94 | topLeft = collidableLayer.getCell((int)(baseX/32), (int)(adjY/32)) != null;
95 | return ((bottomLeft) || (topLeft)) || position.x < 0;
96 | }
97 | // RIGHT
98 | // If facing right, checks bottom and top right pixels for collision and also right map bounds
99 | if (facing == 3) {
100 | adjX += 1;
101 | bottomRight = collidableLayer.getCell((int)(adjX/32), (int)(baseY/32)) != null;
102 | topRight = collidableLayer.getCell((int)(adjX/32), (int)(adjY/32)) != null;
103 | return ((bottomRight) || (topRight)) || position.x + 32 > mapWidth*tilePixelWidth;
104 | }
105 | return false;
106 | }
107 | }
108 |
109 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/components/physicsComponent/Transform.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.components.physicsComponent;
2 |
3 | import com.badlogic.gdx.math.Vector2;
4 | import com.mygdx.game.components.Component;
5 |
6 | /**
7 | * Created by Jacob on 3/23/2017.
8 | */
9 | public class Transform extends Component {
10 | public float rotation = 0f;
11 | public float scale = 1f;
12 | Vector2 position = new Vector2();
13 | Vector2 velocity = new Vector2(0, 0);
14 | Vector2 acceleration = new Vector2(0, 0);
15 |
16 | public Transform(Vector2 position) {
17 | this.position = position;
18 | }
19 |
20 | public Transform(float x, float y) {
21 | position = new Vector2(x, y);
22 | }
23 |
24 | // deltaX and deltaY are the actual movement methods
25 | public void deltaX(float dx) {
26 | position.x += dx;
27 | }
28 |
29 | public void deltaY(float dy) {
30 | position.y += dy;
31 | }
32 |
33 | // Getters and setters
34 | public float getRotation() {
35 | return rotation;
36 | }
37 |
38 | public void setRotation(float rotation) {
39 | this.rotation = rotation;
40 | }
41 |
42 | public float getScale() {
43 | return scale;
44 | }
45 |
46 | public void setScale(float scale) {
47 | this.scale = scale;
48 | }
49 |
50 | public Vector2 getPosition() {
51 | return position;
52 | }
53 |
54 | public void setPosition(Vector2 position) {
55 | this.position = position;
56 | }
57 |
58 | public void setX(float x) {
59 | this.position.x = x;
60 | }
61 |
62 | public void setY(float y) {
63 | this.position.y = y;
64 | }
65 |
66 | public Vector2 getVelocity() {
67 | return velocity;
68 | }
69 |
70 | public void setVelocity(Vector2 velocity) {
71 | this.velocity = velocity;
72 | }
73 |
74 | public Vector2 getAcceleration() {
75 | return acceleration;
76 | }
77 |
78 | public void setAcceleration(Vector2 acceleration) {
79 | this.acceleration = acceleration;
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/components/statComponent/EnemyStatComponent.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.components.statComponent;
2 |
3 | public class EnemyStatComponent extends StatComponent{
4 |
5 | }
6 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/components/statComponent/PlayerStatComponent.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.components.statComponent;
2 |
3 |
4 | public class PlayerStatComponent extends StatComponent{
5 |
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/components/statComponent/StatComponent.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.components.statComponent;
2 |
3 | import com.mygdx.game.components.Component;
4 |
5 | public abstract class StatComponent extends Component{
6 |
7 | int health = 100;
8 | int armor = 10;
9 | int strength = 5;
10 | int abilityPoints = 50;
11 | int level = 1;
12 | float experience = 100;
13 | float moveSpeed = 1f;
14 | float carryWeight = strength * 5; // some arbitrary value will be calculated based off of strength
15 |
16 | // getters
17 | public int getHealth() {return health;}
18 | public int getArmor() {return armor;}
19 | public int getStrength() {return strength;}
20 | public int getAP() {return abilityPoints;}
21 | public int getLevel() {return level;}
22 | public float getEXP() {return experience;}
23 | public float getMoveSpeed() {return moveSpeed;}
24 | // setters
25 | public int addHealth(int toAdd) {return health += toAdd;}
26 | public int addArmor(int toAdd) {return armor += toAdd;}
27 | public int addStrength(int toAdd) {return armor += toAdd;}
28 | public int setAP(int toAdd) {return abilityPoints += toAdd;}
29 | public int levelUP() {return level++;}
30 | public float addEXP(float toAdd) {return experience += toAdd;}
31 | public float setMoveSpeed(float newSpd) {return moveSpeed = newSpd;}
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/entities/Entity.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.entities;
2 |
3 | import com.badlogic.gdx.graphics.g2d.SpriteBatch;
4 | import com.mygdx.game.components.Component;
5 | import java.util.ArrayList;
6 |
7 | /**
8 | * Created by Jacob on 3/29/2017.
9 | */
10 | public abstract class Entity {
11 | private int id = (int)(Math.random()*Integer.MAX_VALUE);
12 | private final int MAX_COMPONENTS = 10;
13 | private ArrayList components = new ArrayList();
14 | private ArrayList children = new ArrayList();
15 | private Entity parent;
16 |
17 | public void tick() {
18 |
19 | }
20 |
21 | public abstract void draw(SpriteBatch b);
22 |
23 | public T getComponent(Class toGet) {
24 | for (Component c : components) {
25 | if (toGet.isInstance(c)) {
26 | return toGet.cast(c);
27 | }
28 | }
29 | return null;
30 | }
31 |
32 | public T getChild(Class toGet) {
33 | for (Entity e : children) {
34 | if (toGet.isInstance(e)) {
35 | return toGet.cast(e);
36 | }
37 | }
38 | return null;
39 | }
40 |
41 | public void addComponent(Component c) {
42 | if (components.size() < MAX_COMPONENTS) {
43 | components.add(c);
44 | c.setParent(this);
45 | }
46 | }
47 |
48 | public void removeComponent(Component c) {
49 | components.remove(c);
50 | }
51 |
52 | public Entity getParent() {
53 | return parent;
54 | }
55 |
56 | public void setParent(Entity parent) {
57 | if (this.parent == null) {
58 | this.parent = parent;
59 | } else {
60 | this.parent.removeChild(this);
61 | this.parent = parent;
62 | }
63 | }
64 |
65 | public ArrayList getChildren() {
66 | return children;
67 | }
68 |
69 | public void addChild(Entity e) {
70 | children.add(e);
71 | e.setParent(this);
72 | }
73 |
74 | public void removeChild(Entity e) {
75 | children.remove(e);
76 | }
77 |
78 | public int getId() {
79 | return id;
80 | }
81 |
82 | public void setId(int id) {
83 | this.id = id;
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/entities/characters/Character.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.entities.characters;
2 |
3 | import com.mygdx.game.entities.Entity;
4 |
5 | /**
6 | * Created by Jacob on 3/29/2017.
7 | */
8 | public abstract class Character extends Entity {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/entities/characters/Enemy.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.entities.characters;
2 |
3 | import com.badlogic.gdx.graphics.g2d.SpriteBatch;
4 | import com.mygdx.game.components.graphicsComponent.EnemyGraphics;
5 | import com.mygdx.game.components.inputComponent.AI;
6 | import com.mygdx.game.components.physicsComponent.Collide;
7 | import com.mygdx.game.components.physicsComponent.Transform;
8 | import com.mygdx.game.components.statComponent.EnemyStatComponent;
9 |
10 | public class Enemy extends Character {
11 |
12 | // location of char is passed at creation of transform
13 | public Enemy() /** Number 1 **/ {
14 | addComponent(new Transform(900, 900));
15 | addComponent(new EnemyStatComponent());
16 | addComponent(new EnemyGraphics());
17 | addComponent(new AI());
18 | addComponent(new Collide());
19 | }
20 | @Override
21 | public void draw(SpriteBatch b) {
22 | // TODO Auto-generated method stub
23 | getComponent(EnemyGraphics.class).draw(b);
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/entities/characters/Player.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.entities.characters;
2 |
3 | import com.badlogic.gdx.graphics.g2d.SpriteBatch;
4 | import com.mygdx.game.MyGdxGame;
5 | import com.mygdx.game.components.graphicsComponent.PlayerGraphics;
6 | import com.mygdx.game.components.inputComponent.PlayerInput;
7 | import com.mygdx.game.components.physicsComponent.Collide;
8 | import com.mygdx.game.components.physicsComponent.Transform;
9 | import com.mygdx.game.components.statComponent.PlayerStatComponent;
10 |
11 | /**
12 | * Created by Jacob on 3/29/2017.
13 | */
14 | public class Player extends Character {
15 |
16 | public Player() {
17 | Transform transform = new Transform(900, 900);
18 | addComponent(transform);
19 | addComponent(new PlayerStatComponent());
20 | addComponent(new PlayerGraphics());
21 | addComponent(new PlayerInput());
22 | addComponent(new Collide());
23 | }
24 |
25 | @Override
26 | public void draw(SpriteBatch b) {
27 | b.setProjectionMatrix(MyGdxGame.currentGame.getCamera().combined);
28 | getComponent(PlayerGraphics.class).draw(b);
29 | }
30 |
31 |
32 | @Override
33 | public void tick() {
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/entities/games/Game.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.entities.games;
2 |
3 | import com.badlogic.gdx.assets.AssetManager;
4 | import com.badlogic.gdx.graphics.OrthographicCamera;
5 |
6 | import com.badlogic.gdx.graphics.g2d.SpriteBatch;
7 | import com.badlogic.gdx.maps.MapProperties;
8 | import com.mygdx.game.MyGdxGame;
9 | import com.mygdx.game.components.physicsComponent.Transform;
10 | import com.mygdx.game.entities.Entity;
11 | import com.mygdx.game.entities.characters.Player;
12 | import com.mygdx.game.entities.worlds.TiledWorld;
13 |
14 |
15 | /**
16 | * Created by Jacob on 3/29/2017.
17 | */
18 | public abstract class Game extends Entity {
19 |
20 | private OrthographicCamera camera;
21 |
22 | public void setCamera(OrthographicCamera camera) {
23 | this.camera = camera;
24 | }
25 |
26 | public OrthographicCamera getCamera() {
27 | return camera;
28 | }
29 |
30 | public abstract void draw(SpriteBatch batch);
31 |
32 | public void updateCamera() {
33 |
34 | float x = getChild(Player.class).getComponent(Transform.class).getPosition().x + 16;
35 | float y = getChild(Player.class).getComponent(Transform.class).getPosition().y + 16;
36 | camera.position.set(x, y, 0);
37 | checkMapBorders();
38 | camera.update();
39 |
40 | }
41 |
42 | protected void checkMapBorders() {
43 | Player player = MyGdxGame.currentGame.getChild(Player.class);
44 | MapProperties prop = getChild(TiledWorld.class).getProp();
45 | // get Tiled map properties
46 | int mapWidth = prop.get("width", Integer.class);
47 | int mapHeight = prop.get("height", Integer.class);
48 | int tilePixelWidth = prop.get("tilewidth", Integer.class);
49 | int tilePixelHeight = prop.get("tileheight", Integer.class);
50 |
51 | // 'width' and 'height' supply the amount of tiles in each row/column,
52 | // so you must multiply it by the tile width in order to get the map dimensions
53 | int mapPixelWidth = mapWidth * tilePixelWidth;
54 | int mapPixelHeight = mapHeight * tilePixelHeight;
55 |
56 | // determine when the camera will reach the ends of the map
57 | float viewportMinX = camera.viewportWidth / 2;
58 | float viewportMinY = camera.viewportHeight / 2;
59 | float viewportMaxX = mapPixelWidth - viewportMinX;
60 | float viewportMaxY = mapPixelHeight - viewportMinY;
61 |
62 | float x = player.getComponent(Transform.class).getPosition().x;
63 | float y = player.getComponent(Transform.class).getPosition().y;
64 |
65 | // preventing the camera from scrolling past the edge of the map
66 | if (x < viewportMinX) {
67 | camera.position.x = viewportMinX;
68 | } else if (x > viewportMaxX) {
69 | camera.position.x = viewportMaxX;
70 | } else {
71 | camera.position.x = x;
72 | }
73 |
74 | if (y < viewportMinY) {
75 | camera.position.y = viewportMinY;
76 | } else if (y > viewportMaxY) {
77 | camera.position.y = viewportMaxY;
78 | } else {
79 | camera.position.y = y;
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/entities/games/Simple2DJavaGameMultiplayer.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.entities.games;
2 |
3 | import com.badlogic.gdx.graphics.Texture;
4 | import com.badlogic.gdx.graphics.g2d.SpriteBatch;
5 | import com.badlogic.gdx.graphics.g2d.TextureRegion;
6 | import com.badlogic.gdx.maps.MapProperties;
7 | import com.esotericsoftware.kryo.Kryo;
8 | import com.esotericsoftware.kryonet.Client;
9 | import com.esotericsoftware.kryonet.Connection;
10 | import com.esotericsoftware.kryonet.KryoSerialization;
11 | import com.esotericsoftware.kryonet.Listener;
12 | import com.mygdx.game.MyGdxGame;
13 | import com.mygdx.game.components.inputComponent.MultiplayerInput;
14 | import com.mygdx.game.entities.worlds.TiledWorld;
15 | import com.mygdx.server.KryonetServer;
16 | import java.io.IOException;
17 | import java.util.ArrayList;
18 |
19 | /**
20 | * Created by Jacob on 4/3/2017.
21 | */
22 | public class Simple2DJavaGameMultiplayer extends Game {
23 |
24 | Client client;
25 | ArrayList drawables = new ArrayList();
26 |
27 |
28 | int clientID;
29 | String[] player;
30 |
31 | public Simple2DJavaGameMultiplayer() {
32 | MyGdxGame.currentGame = this;
33 | new KryonetServer();
34 | TiledWorld tiledWorld = new TiledWorld();
35 | addChild(tiledWorld);
36 |
37 | Kryo kryo = new Kryo();
38 | kryo.setReferences(true);
39 | KryoSerialization serialization = new KryoSerialization(kryo);
40 |
41 | client = new Client(1024,256,serialization);
42 | kryo = client.getKryo();
43 | kryo.register(String.class);
44 | kryo.register(String[].class);
45 | kryo.register(Integer.class);
46 | kryo.register(Integer[].class);
47 | client.start();
48 | try {
49 | client.connect(5000, "127.0.0.1", 51197, 54777);
50 | clientID = client.getID();
51 | } catch (IOException e) {
52 | e.printStackTrace();
53 | }
54 |
55 |
56 | client.addListener(new Listener() {
57 | public void received (Connection connection, Object object) {
58 | if (object instanceof String[]) {
59 | String[] in = (String[])object;
60 | //System.out.println("client got message:");
61 | for(int i = 0; i < in.length; i++) {
62 | //System.out.println("\t"+in[i]);
63 | }
64 | if(in[0].equals("drawable")) {
65 | addDrawable(in);
66 | if(Integer.parseInt(in[1]) == client.getID()){
67 | player = in;
68 | }
69 | }
70 | }
71 | }
72 | });
73 |
74 |
75 | addComponent(new MultiplayerInput());
76 |
77 |
78 | }
79 |
80 | public Client getClient() {
81 | return client;
82 | }
83 |
84 | public void addDrawable(String[] toAdd) {
85 | if(Integer.parseInt(toAdd[1]) == clientID){
86 | player = toAdd;
87 | }
88 | boolean contained = false;
89 | for(String[] s : drawables) {
90 | if(s[1].equals(toAdd[1])) {
91 | s[2] = toAdd[2];//texture (in this case the sprite map)
92 | s[3] = toAdd[3];//x position in float
93 | s[4] = toAdd[4];//y position in float
94 | s[5] = toAdd[5];//row in int
95 | s[6] = toAdd[6];//col in int
96 | contained = true;
97 | break;
98 | }
99 | }
100 | if(!contained) {
101 | drawables.add(toAdd);
102 | }
103 | }
104 |
105 | @Override
106 | public void updateCamera() {
107 | float x = Float.parseFloat(player[3]) + 16;
108 | float y = Float.parseFloat(player[4]) + 16;
109 | //System.out.println(x+","+y);
110 | getCamera().position.set(x, y, 0);
111 | checkMapBorders();
112 | getCamera().update();
113 | //System.out.println(getCamera().position.x+","+ getCamera().position.y);
114 | }
115 |
116 | public void dispose() {
117 | try {
118 | client.dispose();
119 | } catch (IOException e) {
120 | e.printStackTrace();
121 | }
122 | }
123 |
124 | @Override
125 | public void checkMapBorders() {
126 | MapProperties prop = getChild(TiledWorld.class).getProp();
127 | // get Tiled map properties
128 | int mapWidth = prop.get("width", Integer.class);
129 | int mapHeight = prop.get("height", Integer.class);
130 | int tilePixelWidth = prop.get("tilewidth", Integer.class);
131 | int tilePixelHeight = prop.get("tileheight", Integer.class);
132 |
133 | // 'width' and 'height' supply the amount of tiles in each row/column,
134 | // so you must multiply it by the tile width in order to get the map dimensions
135 | int mapPixelWidth = mapWidth * tilePixelWidth;
136 | int mapPixelHeight = mapHeight * tilePixelHeight;
137 |
138 | // determine when the camera will reach the ends of the map
139 | float viewportMinX = getCamera().viewportWidth / 2;
140 | float viewportMinY = getCamera().viewportHeight / 2;
141 | float viewportMaxX = mapPixelWidth - viewportMinX;
142 | float viewportMaxY = mapPixelHeight - viewportMinY;
143 |
144 | float x = Float.parseFloat(player[3]);
145 | float y = Float.parseFloat(player[4]);
146 |
147 | // preventing the camera from scrolling past the edge of the map
148 | if (x < viewportMinX) {
149 | getCamera().position.x = viewportMinX;
150 | } else if (x > viewportMaxX) {
151 | getCamera().position.x = viewportMaxX;
152 | } else {
153 | getCamera().position.x = x;
154 | }
155 |
156 | if (y < viewportMinY) {
157 | getCamera().position.y = viewportMinY;
158 | } else if (y > viewportMaxY) {
159 | getCamera().position.y = viewportMaxY;
160 | } else {
161 | getCamera().position.y = y;
162 | }
163 | }
164 |
165 | public void tick() {
166 | getComponent(MultiplayerInput.class).handleInput();
167 | if(player!=null){
168 | updateCamera();
169 | }
170 |
171 | }
172 |
173 | public int getClientID(){
174 | return clientID;
175 | }
176 |
177 | @Override
178 | public void draw(SpriteBatch batch) {
179 |
180 | //getChild(TiledWorld.class).draw(batch);
181 |
182 | getChild(TiledWorld.class).drawBackground(batch);
183 | TextureRegion[][] tmp;
184 | batch.setProjectionMatrix(getCamera().combined);
185 | for(String[] s : drawables) {
186 | final int FRAME_COLS = 32, FRAME_ROWS = 23;
187 | Texture walkSheet = MyGdxGame.getAssetManager().get("assets/lastguardian_all.png");
188 | tmp = TextureRegion.split(walkSheet, walkSheet.getWidth() / FRAME_COLS,
189 | walkSheet.getHeight() / FRAME_ROWS);
190 | batch.begin();
191 | batch.draw(tmp[Integer.parseInt(s[5])][Integer.parseInt(s[6])],Float.parseFloat(s[3]),Float.parseFloat(s[4]));
192 | batch.end();
193 | getChild(TiledWorld.class).drawForeground(batch);
194 | }
195 |
196 | }
197 |
198 | }
199 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/entities/games/Simple2DJavaGameSingleplayer.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.entities.games;
2 |
3 | import com.badlogic.gdx.graphics.g2d.SpriteBatch;
4 | import com.badlogic.gdx.math.Vector2;
5 | import com.mygdx.game.MyGdxGame;
6 | import com.mygdx.game.components.physicsComponent.Transform;
7 | import com.mygdx.game.entities.characters.Enemy;
8 | import com.mygdx.game.entities.characters.Player;
9 | import com.mygdx.game.entities.worlds.TiledWorld;
10 |
11 | /**
12 | * Created by Jacob on 3/29/2017.
13 | */
14 | public class Simple2DJavaGameSingleplayer extends Game {
15 |
16 | public Simple2DJavaGameSingleplayer() {
17 | MyGdxGame.currentGame = this;
18 | TiledWorld tiledWorld = new TiledWorld();
19 | addChild(tiledWorld);
20 | Player player = new Player();
21 | Enemy enemy = new Enemy();
22 | addChild(enemy);
23 | player.getComponent(Transform.class).setPosition(new Vector2(450f, 900f));
24 |
25 | addChild(player);
26 |
27 | }
28 |
29 | public void tick() {
30 | getChild(TiledWorld.class).tick();
31 | getChild(Player.class).tick();
32 | updateCamera();
33 | }
34 |
35 | public void draw(SpriteBatch batch) {
36 | batch.setProjectionMatrix(getCamera().combined);
37 | getChild(TiledWorld.class).drawBackground(batch);
38 | batch.begin();
39 | getChild(Player.class).draw(batch);
40 | getChild(Enemy.class).draw(batch);
41 | batch.end();
42 | getChild(TiledWorld.class).drawForeground(batch);
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/entities/worlds/TiledWorld.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.entities.worlds;
2 |
3 | import com.badlogic.gdx.graphics.g2d.SpriteBatch;
4 | import com.badlogic.gdx.maps.MapProperties;
5 | import com.badlogic.gdx.maps.tiled.TiledMap;
6 | import com.badlogic.gdx.maps.tiled.TiledMapRenderer;
7 | import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
8 | import com.mygdx.game.MyGdxGame;
9 |
10 | /**
11 | * Created by Jacob on 3/29/2017.
12 | */
13 | public class TiledWorld extends World {
14 | public TiledMap tiledMap;
15 | TiledMapRenderer tiledMapRenderer;
16 | public MapProperties prop;
17 |
18 | int[] backgroundLayers = {0, 1};
19 | int[] foregroundLayers = {2};
20 |
21 | public TiledWorld() {
22 | // loading in Tiled map, initializing the renderer
23 | tiledMap = MyGdxGame.getAssetManager().get("2.tmx");
24 | tiledMapRenderer = new OrthogonalTiledMapRenderer(tiledMap);
25 | prop = tiledMap.getProperties();
26 | }
27 |
28 | public void draw(SpriteBatch batch) {
29 | tiledMapRenderer.setView(MyGdxGame.currentGame.getCamera());
30 | tiledMapRenderer.render();
31 | }
32 |
33 | public void drawBackground(SpriteBatch batch) {
34 | tiledMapRenderer.setView(MyGdxGame.currentGame.getCamera());
35 | tiledMapRenderer.render(backgroundLayers);
36 |
37 | }
38 |
39 | public void drawForeground(SpriteBatch batch) {
40 | tiledMapRenderer.setView(MyGdxGame.currentGame.getCamera());
41 | tiledMapRenderer.render(foregroundLayers);
42 | }
43 | public MapProperties getProp() {
44 | return prop;
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/entities/worlds/World.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.entities.worlds;
2 |
3 | import com.mygdx.game.entities.Entity;
4 |
5 | /**
6 | * Created by Jacob on 3/29/2017.
7 | */
8 | public abstract class World extends Entity {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/utilities/Animator.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.utilities;
2 |
3 | import com.badlogic.gdx.Gdx;
4 | import com.badlogic.gdx.graphics.Texture;
5 | import com.badlogic.gdx.graphics.g2d.Animation;
6 | import com.badlogic.gdx.graphics.g2d.Animation.PlayMode;
7 | import com.badlogic.gdx.graphics.g2d.SpriteBatch;
8 | import com.badlogic.gdx.graphics.g2d.TextureRegion;
9 | import com.mygdx.game.MyGdxGame;
10 |
11 | /**
12 | * Animator is used to provide the animations for the sprites
13 | *
14 | * @author adamfarmelo
15 | *
16 | */
17 | public class Animator {
18 |
19 | // Cols and rows come from the lastguardian_all.png
20 | // they represent the number of sprites on the sheet
21 | private static final int FRAME_COLS = 32, FRAME_ROWS = 23;
22 |
23 | private Animation walkAnimation;
24 | private TextureRegion[] walkFrames;
25 | private static Texture walkSheet;
26 | private static SpriteBatch spriteBatch;
27 | private float stateTime;
28 | private float frameTime;
29 | private int startIndex;
30 |
31 |
32 | public Animator(int row, int startSprite, int endSprite) {
33 |
34 | // frameTime controls the speed of the animation, lower is faster
35 | startIndex = startSprite;
36 | frameTime = 0.2f;
37 |
38 | walkSheet = MyGdxGame.getAssetManager().get("lastguardian_all.png");
39 |
40 | // this array is populated with individual indexes of sprites from the
41 | // sprite sheet to make them easily accessible
42 | TextureRegion[][] tmp = TextureRegion.split(walkSheet, walkSheet.getWidth() / FRAME_COLS,
43 | walkSheet.getHeight() / FRAME_ROWS);
44 |
45 | // walkFrames is used to hold the frames or sprites that will be cycled
46 | // by an animation
47 | walkFrames = new TextureRegion[2];
48 |
49 | walkFrames[0] = tmp[row][startSprite];
50 | walkFrames[1] = tmp[row][endSprite];
51 |
52 | walkAnimation = new Animation(frameTime, walkFrames);
53 | walkAnimation.setPlayMode(PlayMode.LOOP);
54 |
55 | stateTime = 0f;
56 | }
57 |
58 | public TextureRegion getCurrentTextureRegion() {
59 | stateTime += Gdx.graphics.getDeltaTime();
60 |
61 | return walkAnimation.getKeyFrame(stateTime, true);
62 | }
63 |
64 | public static void dispose() {
65 | walkSheet.dispose();
66 | }
67 |
68 | public TextureRegion getLastFrame() {
69 | return walkFrames[1];
70 | }
71 |
72 | public int getColumn() {
73 | stateTime += Gdx.graphics.getDeltaTime();
74 | return startIndex + walkAnimation.getKeyFrameIndex(stateTime);
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/utilities/ButtonListener.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.utilities;
2 |
3 | import com.badlogic.gdx.InputProcessor;
4 | import java.util.ArrayList;
5 | import java.util.Collections;
6 |
7 | /**
8 | * Created by Jacob on 4/7/2017.
9 | */
10 | public class ButtonListener implements InputProcessor {
11 |
12 | ArrayList keysPressed = new ArrayList();
13 |
14 | @Override
15 | public boolean keyDown(int keycode) {
16 | keysPressed.add(keycode);
17 | return false;
18 | }
19 |
20 | @Override
21 | public boolean keyUp(int keycode) {
22 | keysPressed.remove(new Integer(keycode));
23 | return false;
24 | }
25 |
26 | @Override
27 | public boolean keyTyped(char character) {
28 | return false;
29 | }
30 |
31 | @Override
32 | public boolean touchDown(int screenX, int screenY, int pointer, int button) {
33 | return false;
34 | }
35 |
36 | @Override
37 | public boolean touchUp(int screenX, int screenY, int pointer, int button) {
38 | return false;
39 | }
40 |
41 | @Override
42 | public boolean touchDragged(int screenX, int screenY, int pointer) {
43 | return false;
44 | }
45 |
46 | @Override
47 | public boolean mouseMoved(int screenX, int screenY) {
48 | return false;
49 | }
50 |
51 | @Override
52 | public boolean scrolled(int amount) {
53 | return false;
54 | }
55 |
56 | public ArrayList getKeysPressed(){
57 | Collections.sort(keysPressed);
58 | return keysPressed;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/utilities/Command.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.utilities;
2 |
3 | /**
4 | * Created by Jacob on 4/7/2017.
5 | */
6 | public interface Command {
7 | String executeCommand();
8 | }
9 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/game/utilities/InputMapper.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.utilities;
2 |
3 | import java.util.ArrayList;
4 | import java.util.HashMap;
5 | import java.util.List;
6 |
7 | /**
8 | * Created by Jacob on 4/7/2017.
9 | */
10 | public class InputMapper {
11 | private HashMap,Command> commands;
12 |
13 | public InputMapper() {
14 | commands = new HashMap,Command>();
15 | }
16 |
17 | public Command getCommand(List s){
18 | return commands.get(s);
19 | }
20 |
21 | public boolean containsCommand(List s){
22 | return commands.containsKey(s);
23 | }
24 |
25 | public void mapCommand(Integer[] s, Command c){
26 | ArrayList keys = new ArrayList();
27 | for(int i = 0; i < s.length; i++){
28 | keys.add(s[i]);
29 | }
30 | commands.put(keys,c);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/2DGame/core/src/com/mygdx/server/KryonetServer.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.server;
2 |
3 | /**
4 | * Created by Jacob on 4/1/2017.
5 | */
6 |
7 | import com.badlogic.gdx.assets.AssetManager;
8 | import com.badlogic.gdx.assets.loaders.TextureLoader;
9 | import com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver;
10 | import com.badlogic.gdx.graphics.Texture;
11 | import com.badlogic.gdx.maps.tiled.TiledMap;
12 | import com.badlogic.gdx.maps.tiled.TmxMapLoader;
13 | import com.esotericsoftware.kryo.Kryo;
14 | import com.esotericsoftware.kryonet.Connection;
15 | import com.esotericsoftware.kryonet.KryoSerialization;
16 | import com.esotericsoftware.kryonet.Listener;
17 | import com.esotericsoftware.kryonet.Server;
18 | import com.mygdx.game.MyGdxGame;
19 | import com.mygdx.game.components.graphicsComponent.PlayerGraphics;
20 | import com.mygdx.game.components.inputComponent.InputComponent;
21 | import com.mygdx.game.components.inputComponent.PlayerInput;
22 | import com.mygdx.game.components.physicsComponent.Transform;
23 | import com.mygdx.game.entities.characters.Player;
24 | import com.mygdx.game.utilities.InputMapper;
25 | import java.io.IOException;
26 | import java.util.ArrayList;
27 |
28 | public class KryonetServer
29 | {
30 |
31 | Server server;
32 | String tiledWorld = "1.tmx";
33 | ArrayList players = new ArrayList();
34 |
35 | public KryonetServer() {
36 | Kryo kryo = new Kryo();
37 | kryo.setReferences(true);
38 | KryoSerialization serialization = new KryoSerialization(kryo);
39 |
40 | server = new Server(1024,256,serialization);
41 | kryo = server.getKryo();
42 | kryo.register(String.class);
43 | kryo.register(String[].class);
44 | kryo.register(Integer.class);
45 | kryo.register(Integer[].class);
46 | server.start();
47 | try {
48 | server.bind(51197, 54777);
49 | } catch (IOException e) {
50 | e.printStackTrace();
51 | }
52 |
53 | server.addListener(new Listener() {
54 | public void received (Connection connection, Object object) {
55 | if (object instanceof Integer[]) {
56 | Integer[] in = (Integer[])object;
57 | Player player = getPlayerByID(in[0]);
58 | ArrayList keys = new ArrayList();
59 | for(int i = 1; i < in.length; i++){
60 | keys.add(in[i]);
61 | }
62 | InputMapper mapper = player.getComponent(PlayerInput.class).getMapper();
63 | if(mapper.containsCommand(keys)){
64 | mapper.getCommand(keys).executeCommand();
65 | server.sendToAllTCP(new String[]{
66 | "drawable",
67 | in[0]+"",
68 | tiledWorld,
69 | player.getComponent(Transform.class).getPosition().x+"",
70 | player.getComponent(Transform.class).getPosition().y+"",
71 | "0",
72 | player.getComponent(PlayerGraphics.class).getCurrentCol()+""
73 | });
74 | }
75 |
76 |
77 | //System.out.println("got message: ");
78 | for(int i = 0; i < in.length; i++)
79 | {
80 | //System.out.println("\t"+in[i]);
81 | }
82 | }
83 | }
84 | });
85 |
86 | server.addListener(new Listener() {
87 | @Override
88 | public void connected(Connection connection) {
89 | super.connected(connection);
90 | System.out.println(connection.getRemoteAddressTCP());
91 | Player player = new Player();
92 | player.setId(connection.getID());
93 | players.add(player);
94 | server.sendToAllTCP(new String[]{
95 | "drawable",
96 | connection.getID()+"",
97 | "lastguardian_all.png",
98 | player.getComponent(Transform.class).getPosition().x+"",
99 | player.getComponent(Transform.class).getPosition().y+"",
100 | "0",
101 | player.getComponent(PlayerGraphics.class).getCurrentCol()+""
102 | });
103 | }
104 | });
105 |
106 |
107 | }
108 |
109 | public void dispose(){
110 | server.close();
111 | try {
112 | server.dispose();
113 | } catch (IOException e) {
114 | e.printStackTrace();
115 | }
116 | }
117 |
118 | public Player getPlayerByID(int id){
119 | //System.out.println("searching for player with id "+ id);
120 | for(Player p : players){
121 | if(p.getId() == id){
122 | //System.out.println("Player found");
123 | return p;
124 |
125 | }
126 | }
127 | System.out.println("player not found");
128 | return new Player();
129 | }
130 |
131 |
132 | }
133 |
--------------------------------------------------------------------------------
/2DGame/desktop/1.tmx:
--------------------------------------------------------------------------------
1 |
2 |
55 |
--------------------------------------------------------------------------------
/2DGame/desktop/2.tmx:
--------------------------------------------------------------------------------
1 |
2 |
327 |
--------------------------------------------------------------------------------
/2DGame/desktop/Tileset.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Farmerjoe12/Simple2DJavaGame/f5140a34ed9ecb67ea013b44ef6191a459364aaf/2DGame/desktop/Tileset.png
--------------------------------------------------------------------------------
/2DGame/desktop/assets/1.tmx:
--------------------------------------------------------------------------------
1 |
2 |
55 |
--------------------------------------------------------------------------------
/2DGame/desktop/assets/2.tmx:
--------------------------------------------------------------------------------
1 |
2 |
146 |
--------------------------------------------------------------------------------
/2DGame/desktop/assets/Thumbs.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Farmerjoe12/Simple2DJavaGame/f5140a34ed9ecb67ea013b44ef6191a459364aaf/2DGame/desktop/assets/Thumbs.db
--------------------------------------------------------------------------------
/2DGame/desktop/assets/lastguardian_all.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Farmerjoe12/Simple2DJavaGame/f5140a34ed9ecb67ea013b44ef6191a459364aaf/2DGame/desktop/assets/lastguardian_all.png
--------------------------------------------------------------------------------
/2DGame/desktop/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "java"
2 |
3 | sourceCompatibility = 1.6
4 | sourceSets.main.java.srcDirs = [ "src/" ]
5 |
6 | project.ext.mainClassName = "com.mygdx.game.desktop.DesktopLauncher"
7 | project.ext.assetsDir = new File("../core/assets");
8 |
9 | task run(dependsOn: classes, type: JavaExec) {
10 | main = project.mainClassName
11 | classpath = sourceSets.main.runtimeClasspath
12 | standardInput = System.in
13 | workingDir = project.assetsDir
14 | ignoreExitValue = true
15 | }
16 |
17 | task debug(dependsOn: classes, type: JavaExec) {
18 | main = project.mainClassName
19 | classpath = sourceSets.main.runtimeClasspath
20 | standardInput = System.in
21 | workingDir = project.assetsDir
22 | ignoreExitValue = true
23 | debug = true
24 | }
25 |
26 | task dist(type: Jar) {
27 | from files(sourceSets.main.output.classesDir)
28 | from files(sourceSets.main.output.resourcesDir)
29 | from {configurations.compile.collect {zipTree(it)}}
30 | from files(project.assetsDir);
31 |
32 | manifest {
33 | attributes 'Main-Class': project.mainClassName
34 | }
35 | }
36 |
37 | dist.dependsOn classes
38 |
39 | eclipse {
40 | project {
41 | name = appName + "-desktop"
42 | linkedResource name: 'assets', type: '2', location: 'PARENT-1-PROJECT_LOC/core/assets'
43 | }
44 | }
45 |
46 | task afterEclipseImport(description: "Post processing after project generation", group: "IDE") {
47 | doLast {
48 | def classpath = new XmlParser().parse(file(".classpath"))
49 | new Node(classpath, "classpathentry", [ kind: 'src', path: 'assets' ]);
50 | def writer = new FileWriter(file(".classpath"))
51 | def printer = new XmlNodePrinter(new PrintWriter(writer))
52 | printer.setPreserveWhitespace(true)
53 | printer.print(classpath)
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/2DGame/desktop/src/com/mygdx/game/desktop/DesktopLauncher.java:
--------------------------------------------------------------------------------
1 | package com.mygdx.game.desktop;
2 |
3 | import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
4 | import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
5 | import com.mygdx.game.MyGdxGame;
6 | import com.mygdx.server.KryonetServer;
7 |
8 | public class DesktopLauncher {
9 | public static void main(String[] arg) {
10 | LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
11 | config.title = "2D Java Game";
12 | config.width = 960;
13 | config.height = 640;
14 | new LwjglApplication(new MyGdxGame(), config);
15 |
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/2DGame/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.daemon=true
2 | org.gradle.jvmargs=-Xms128m -Xmx1500m
3 | org.gradle.configureondemand=true
4 |
--------------------------------------------------------------------------------
/2DGame/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Farmerjoe12/Simple2DJavaGame/f5140a34ed9ecb67ea013b44ef6191a459364aaf/2DGame/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/2DGame/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Sep 21 13:08:26 CEST 2013
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
7 |
--------------------------------------------------------------------------------
/2DGame/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/2DGame/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/2DGame/settings.gradle:
--------------------------------------------------------------------------------
1 | include 'desktop', 'core'
--------------------------------------------------------------------------------
/HOWTOBUILD:
--------------------------------------------------------------------------------
1 | MUST HAVE NEWEST VERSION OF ECLPISE AND GRADLE AS OF 03/20/2017
2 |
3 | 1. Download the zip source folder and extract the master folder.
4 | 2. Open eclipse (preferably in a new workspace)
5 | 3. File -> Import -> Gradle (STS) -> Gradle (STS) Project
6 | 4. Browse to the "Simple2DJavaGame-master" folder
7 | 5. Select the "2DGame" folder as the root directory
8 | 6. Click Build Model next to the Browse... button
9 | 7. Wait
10 | 8. Click the check box next to the "2DGame" main directory and make sure to check Auto-select subprojects
11 | 9. Click finish
12 | 10. Files should be imported into the workspace and you can now navigate to 2DGame-core to start working on the project!
13 |
14 | Run the game through 2DGame-desktop/src/com.mygdx.game.desktop/DesktopLauncher.java
15 | Be sure to run as a Java Application!
16 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Simple 2D Java Game
2 |
3 | ***
4 |
5 | ## Introduction
6 |
7 | This game is a work in progress, using Java, LibGDX, and gradle. As of right now, 03/19, the game
8 | is only being developed for desktop environments. This github repo for anyone who is interested in game
9 | development or wants to get started making games with Java. I decided on Java for this game because it's super easy to pick up, but very powerful if you can use it right. LibGDX is the same way, albeit with a little steeper learning curve.
10 |
11 | ***
12 |
13 | ## Build
14 |
15 | The source code for all of the classes are in [src/com/mygdx/game](https://github.com/Farmerjoe12/Simple2DJavaGame/tree/master/2DGame/core/src/com/mygdx/game)
16 | and all of the images and textures are in the assets folder.
17 |
18 | The project is under development using the latest version of eclipse and gradle, so you'll need the same to configure your IDE.
19 |
20 | The master repository is being built in Eclipse so that's what the HOWTOBUILD file assumes of you.
21 |
22 | If you prefer a different IDE, then by all means, configure this project to work in that IDE and then add your steps to the HOWTOBUILD file.
23 |
24 | **We are not trying to constrain you to our way of development in any way. You can contribute in any way you feel comfortable. This game is being developed for beginners and by beginners, and we're all learning here.**
25 |
26 | ***
27 |
28 | ## Notes/Remarks
29 |
30 | Github is still partially a foreign language to me, but I'm learning more and more every day.
31 |
32 | Even if you think you don't know git, there's hundreds of videos and thousands more blog posts and questions on StackExchange where someone had the same exact question as you. You're not alone in the quest to understand the intricasies of version control, so don't hesitate to make yourself known on this repository or on our [Discord Server](https://discord.gg/5gXN8yW).
33 |
34 | Thanks for checking us out!
35 |
36 | ***
37 |
--------------------------------------------------------------------------------