├── Breakout
    ├── .gitignore
    ├── build.gradle
    ├── core
    │   ├── assets
    │   │   ├── ball.png
    │   │   └── block.png
    │   ├── build.gradle
    │   └── src
    │   │   ├── MyGdxGame.gwt.xml
    │   │   └── net
    │   │       └── sekao
    │   │           └── breakout
    │   │               ├── MainScreen.java
    │   │               └── MyGdxGame.java
    ├── desktop
    │   ├── build.gradle
    │   └── src
    │   │   └── net
    │   │       └── sekao
    │   │           └── breakout
    │   │               └── desktop
    │   │                   └── DesktopLauncher.java
    ├── gradle.properties
    ├── gradle
    │   └── wrapper
    │   │   ├── gradle-wrapper.jar
    │   │   └── gradle-wrapper.properties
    ├── gradlew
    ├── gradlew.bat
    ├── html
    │   ├── build.gradle
    │   ├── src
    │   │   └── net
    │   │   │   └── sekao
    │   │   │       └── breakout
    │   │   │           ├── GdxDefinition.gwt.xml
    │   │   │           ├── GdxDefinitionSuperdev.gwt.xml
    │   │   │           └── client
    │   │   │               └── HtmlLauncher.java
    │   └── webapp
    │   │   ├── WEB-INF
    │   │       └── web.xml
    │   │   ├── index.html
    │   │   ├── refresh.png
    │   │   ├── soundmanager2-jsmin.js
    │   │   ├── soundmanager2-setup.js
    │   │   └── styles.css
    └── settings.gradle
├── DungeonCrawler
    ├── .gitignore
    ├── build.gradle
    ├── core
    │   ├── assets
    │   │   ├── 64x64.png
    │   │   ├── brick.png
    │   │   ├── brick1.png
    │   │   ├── brick2.png
    │   │   ├── brick3.png
    │   │   ├── brick4.png
    │   │   ├── brick5.png
    │   │   ├── brick6.png
    │   │   ├── catacomb.png
    │   │   ├── characters
    │   │   │   ├── dragon.png
    │   │   │   ├── elemental.png
    │   │   │   ├── goblin.png
    │   │   │   ├── magician.png
    │   │   │   ├── male_base.png
    │   │   │   ├── male_heavy.png
    │   │   │   ├── male_light.png
    │   │   │   ├── male_longbow.png
    │   │   │   ├── male_longsword.png
    │   │   │   ├── male_shield.png
    │   │   │   ├── male_staff.png
    │   │   │   ├── male_unarmored.png
    │   │   │   ├── ogre.png
    │   │   │   ├── skeleton.png
    │   │   │   ├── slime.png
    │   │   │   ├── werewolf.png
    │   │   │   └── zombie.png
    │   │   ├── cocutos.png
    │   │   ├── crypt.png
    │   │   ├── death.wav
    │   │   ├── dwarven_gauntlet.png
    │   │   ├── gallery.png
    │   │   ├── gehena.png
    │   │   ├── hive.png
    │   │   ├── lair.png
    │   │   ├── lapis.png
    │   │   ├── level1.tmx
    │   │   ├── level2.tmx
    │   │   ├── level3.tmx
    │   │   ├── monsterhurt.wav
    │   │   ├── moss.png
    │   │   ├── mucus.png
    │   │   ├── normal.png
    │   │   ├── pandem1.png
    │   │   ├── pandem2.png
    │   │   ├── pandem3.png
    │   │   ├── pandem4.png
    │   │   ├── pandem6.png
    │   │   ├── playerhurt.wav
    │   │   ├── rock.png
    │   │   └── tunnel.png
    │   ├── build.gradle
    │   └── src
    │   │   ├── MyGdxGame.gwt.xml
    │   │   └── net
    │   │       └── sekao
    │   │           └── dungeoncrawler
    │   │               ├── EndScreen.java
    │   │               ├── Entities.java
    │   │               ├── Entity.java
    │   │               ├── Level.java
    │   │               ├── Levels.java
    │   │               ├── MainScreen.java
    │   │               ├── MyGdxGame.java
    │   │               ├── Overlay.java
    │   │               ├── Overlays.java
    │   │               ├── Room.java
    │   │               ├── Rooms.java
    │   │               └── Utils.java
    ├── desktop
    │   ├── build.gradle
    │   └── src
    │   │   └── net
    │   │       └── sekao
    │   │           └── dungeoncrawler
    │   │               └── desktop
    │   │                   └── DesktopLauncher.java
    ├── gradle.properties
    ├── gradle
    │   └── wrapper
    │   │   ├── gradle-wrapper.jar
    │   │   └── gradle-wrapper.properties
    ├── gradlew
    ├── gradlew.bat
    ├── html
    │   ├── build.gradle
    │   ├── src
    │   │   └── net
    │   │   │   └── sekao
    │   │   │       └── dungeoncrawler
    │   │   │           ├── GdxDefinition.gwt.xml
    │   │   │           ├── GdxDefinitionSuperdev.gwt.xml
    │   │   │           └── client
    │   │   │               └── HtmlLauncher.java
    │   └── webapp
    │   │   ├── WEB-INF
    │   │       └── web.xml
    │   │   ├── index.html
    │   │   ├── refresh.png
    │   │   ├── soundmanager2-jsmin.js
    │   │   ├── soundmanager2-setup.js
    │   │   └── styles.css
    └── settings.gradle
├── Minicraft
    ├── .gitignore
    ├── build.gradle
    ├── core
    │   ├── assets
    │   │   ├── bossdeath.wav
    │   │   ├── craft.wav
    │   │   ├── death.wav
    │   │   ├── icons.png
    │   │   ├── icons2.png
    │   │   ├── level1.tmx
    │   │   ├── monsterhurt.wav
    │   │   ├── pickup.wav
    │   │   ├── playerhurt.wav
    │   │   ├── test.wav
    │   │   └── tiles.png
    │   ├── build.gradle
    │   └── src
    │   │   ├── MyGdxGame.gwt.xml
    │   │   └── net
    │   │       └── sekao
    │   │           └── minicraft
    │   │               ├── Entities.java
    │   │               ├── Entity.java
    │   │               ├── MainScreen.java
    │   │               ├── MyGdxGame.java
    │   │               └── Utils.java
    ├── desktop
    │   ├── build.gradle
    │   └── src
    │   │   └── net
    │   │       └── sekao
    │   │           └── minicraft
    │   │               └── desktop
    │   │                   └── DesktopLauncher.java
    ├── gradle.properties
    ├── gradle
    │   └── wrapper
    │   │   ├── gradle-wrapper.jar
    │   │   └── gradle-wrapper.properties
    ├── gradlew
    ├── gradlew.bat
    ├── html
    │   ├── build.gradle
    │   ├── src
    │   │   └── net
    │   │   │   └── sekao
    │   │   │       └── minicraft
    │   │   │           ├── GdxDefinition.gwt.xml
    │   │   │           ├── GdxDefinitionSuperdev.gwt.xml
    │   │   │           └── client
    │   │   │               └── HtmlLauncher.java
    │   └── webapp
    │   │   ├── WEB-INF
    │   │       └── web.xml
    │   │   ├── index.html
    │   │   ├── refresh.png
    │   │   ├── soundmanager2-jsmin.js
    │   │   ├── soundmanager2-setup.js
    │   │   └── styles.css
    └── settings.gradle
├── README.md
├── SuperKoalio
    ├── .gitignore
    ├── build.gradle
    ├── core
    │   ├── assets
    │   │   ├── koalio.png
    │   │   ├── level1.tmx
    │   │   └── tileSet.png
    │   ├── build.gradle
    │   └── src
    │   │   ├── MyGdxGame.gwt.xml
    │   │   └── net
    │   │       └── sekao
    │   │           └── superkoalio
    │   │               ├── Koala.java
    │   │               ├── MainScreen.java
    │   │               └── MyGdxGame.java
    ├── desktop
    │   ├── build.gradle
    │   └── src
    │   │   └── net
    │   │       └── sekao
    │   │           └── superkoalio
    │   │               └── desktop
    │   │                   └── DesktopLauncher.java
    ├── gradle.properties
    ├── gradle
    │   └── wrapper
    │   │   ├── gradle-wrapper.jar
    │   │   └── gradle-wrapper.properties
    ├── gradlew
    ├── gradlew.bat
    ├── html
    │   ├── build.gradle
    │   ├── src
    │   │   └── net
    │   │   │   └── sekao
    │   │   │       └── superkoalio
    │   │   │           ├── GdxDefinition.gwt.xml
    │   │   │           ├── GdxDefinitionSuperdev.gwt.xml
    │   │   │           └── client
    │   │   │               └── HtmlLauncher.java
    │   └── webapp
    │   │   ├── WEB-INF
    │   │       └── web.xml
    │   │   ├── index.html
    │   │   ├── refresh.png
    │   │   ├── soundmanager2-jsmin.js
    │   │   ├── soundmanager2-setup.js
    │   │   └── styles.css
    └── settings.gradle
├── Tetris
    ├── .gitignore
    ├── build.gradle
    ├── core
    │   ├── assets
    │   │   └── shapes.png
    │   ├── build.gradle
    │   └── src
    │   │   ├── MyGdxGame.gwt.xml
    │   │   └── net
    │   │       └── sekao
    │   │           └── tetris
    │   │               ├── MainScreen.java
    │   │               └── MyGdxGame.java
    ├── desktop
    │   ├── build.gradle
    │   └── src
    │   │   └── net
    │   │       └── sekao
    │   │           └── tetris
    │   │               └── desktop
    │   │                   └── DesktopLauncher.java
    ├── gradle.properties
    ├── gradle
    │   └── wrapper
    │   │   ├── gradle-wrapper.jar
    │   │   └── gradle-wrapper.properties
    ├── gradlew
    ├── gradlew.bat
    ├── html
    │   ├── build.gradle
    │   ├── src
    │   │   └── net
    │   │   │   └── sekao
    │   │   │       └── tetris
    │   │   │           ├── GdxDefinition.gwt.xml
    │   │   │           ├── GdxDefinitionSuperdev.gwt.xml
    │   │   │           └── client
    │   │   │               └── HtmlLauncher.java
    │   └── webapp
    │   │   ├── WEB-INF
    │   │       └── web.xml
    │   │   ├── index.html
    │   │   ├── refresh.png
    │   │   ├── soundmanager2-jsmin.js
    │   │   ├── soundmanager2-setup.js
    │   │   └── styles.css
    └── settings.gradle
└── UNLICENSE
/Breakout/.gitignore:
--------------------------------------------------------------------------------
 1 | ## Java
 2 | 
 3 | *.class
 4 | *.war
 5 | *.ear
 6 | hs_err_pid*
 7 | 
 8 | ## Robovm
 9 | robovm-build/
10 | 
11 | ## GWT
12 | war/
13 | html/war/gwt_bree/
14 | html/gwt-unitCache/
15 | .apt_generated/
16 | html/war/WEB-INF/deploy/
17 | html/war/WEB-INF/classes/
18 | .gwt/
19 | gwt-unitCache/
20 | www-test/
21 | .gwt-tmp/
22 | 
23 | ## Android Studio and Intellij and Android in general
24 | android/libs/armeabi/
25 | android/libs/armeabi-v7a/
26 | android/libs/arm64-v8a/
27 | android/libs/x86/
28 | android/libs/x86_64/
29 | android/gen/
30 | .idea/
31 | *.ipr
32 | *.iws
33 | *.iml
34 | out/
35 | com_crashlytics_export_strings.xml
36 | 
37 | ## Eclipse
38 | .classpath
39 | .project
40 | .metadata
41 | **/bin/
42 | tmp/
43 | *.tmp
44 | *.bak
45 | *.swp
46 | *~.nib
47 | local.properties
48 | .settings/
49 | .loadpath
50 | .externalToolBuilders/
51 | *.launch
52 | 
53 | ## NetBeans
54 | **/nbproject/private/
55 | build/
56 | nbbuild/
57 | dist/
58 | nbdist/
59 | nbactions.xml
60 | nb-configuration.xml
61 | 
62 | ## Gradle
63 | 
64 | .gradle
65 | gradle-app.setting
66 | build/
67 | 
68 | ## OS Specific
69 | .DS_Store
70 | Thumbs.db
71 | 
--------------------------------------------------------------------------------
/Breakout/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 |         classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
10 |     }
11 | }
12 | 
13 | allprojects {
14 |     apply plugin: "eclipse"
15 |     apply plugin: "idea"
16 | 
17 |     version = '1.1'
18 |     ext {
19 |         appName = "Breakout"
20 |         gdxVersion = '1.9.3'
21 |         roboVMVersion = '2.1.0'
22 |         box2DLightsVersion = '1.4'
23 |         ashleyVersion = '1.7.0'
24 |         aiVersion = '1.8.0'
25 |     }
26 | 
27 |     repositories {
28 |         mavenLocal()
29 |         mavenCentral()
30 |         maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
31 |         maven { url "https://oss.sonatype.org/content/repositories/releases/" }
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 |     }
45 | }
46 | 
47 | project(":html") {
48 |     apply plugin: "gwt"
49 |     apply plugin: "war"
50 | 
51 | 
52 |     dependencies {
53 |         compile project(":core")
54 |         compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
55 |         compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
56 |         compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
57 |         //compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion:sources"
58 |         compile "com.badlogicgames.gdx:gdx-box2d-gwt:$gdxVersion:sources"
59 |     }
60 | }
61 | 
62 | project(":core") {
63 |     apply plugin: "java"
64 | 
65 | 
66 |     dependencies {
67 |         compile "com.badlogicgames.gdx:gdx:$gdxVersion"
68 |         compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
69 |     }
70 | }
71 | 
72 | tasks.eclipse.doLast {
73 |     delete ".project"
74 | }
--------------------------------------------------------------------------------
/Breakout/core/assets/ball.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/Breakout/core/assets/ball.png
--------------------------------------------------------------------------------
/Breakout/core/assets/block.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/Breakout/core/assets/block.png
--------------------------------------------------------------------------------
/Breakout/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 | 
--------------------------------------------------------------------------------
/Breakout/core/src/MyGdxGame.gwt.xml:
--------------------------------------------------------------------------------
1 | 
2 | 
3 | 
4 | 	
5 | 
--------------------------------------------------------------------------------
/Breakout/core/src/net/sekao/breakout/MainScreen.java:
--------------------------------------------------------------------------------
  1 | package net.sekao.breakout;
  2 | 
  3 | import com.badlogic.gdx.*;
  4 | import com.badlogic.gdx.graphics.*;
  5 | import com.badlogic.gdx.math.*;
  6 | import com.badlogic.gdx.physics.box2d.*;
  7 | import com.badlogic.gdx.scenes.scene2d.*;
  8 | import com.badlogic.gdx.scenes.scene2d.ui.*;
  9 | import java.util.*;
 10 | 
 11 | public class MainScreen implements Screen {
 12 |     Stage stage;
 13 |     World world;
 14 |     Image ball, paddle;
 15 |     Body ballBody, wallBody, floorBody, paddleBody;
 16 |     HashMap blocks;
 17 |     final int scale = 32;
 18 | 
 19 |     public void show() {
 20 |         stage = new Stage();
 21 |         blocks = new HashMap();
 22 | 
 23 |         Texture ballTexture = new Texture("ball.png");
 24 |         Texture blockTexture = new Texture("block.png");
 25 | 
 26 |         ball = new Image(ballTexture);
 27 |         stage.addActor(ball);
 28 |         paddle = new Image(blockTexture);
 29 |         stage.addActor(paddle);
 30 | 
 31 |         final float screenWidth = Gdx.graphics.getWidth();
 32 |         final float screenHeight = Gdx.graphics.getHeight();
 33 |         final float blockWidth = blockTexture.getWidth();
 34 |         final float blockHeight = blockTexture.getHeight();
 35 | 
 36 |         world = new World(new Vector2(0, 0), true);
 37 | 
 38 |         float col = screenWidth / blockWidth;
 39 |         while (col > 0) {
 40 |             col--;
 41 | 
 42 |             float row = screenHeight / blockHeight / 2;
 43 |             while (row > 0) {
 44 |                 row--;
 45 | 
 46 |                 float x = col * blockWidth;
 47 |                 float y = row * blockHeight + screenHeight / 2;
 48 | 
 49 |                 Image block = new Image(blockTexture);
 50 |                 block.setPosition(x, y);
 51 |                 stage.addActor(block);
 52 |                 Body blockBody = createRectBody(x, y, blockWidth, blockHeight);
 53 |                 blocks.put(blockBody, block);
 54 |             }
 55 |         }
 56 | 
 57 |         ballBody = createBallBody(100, 100, ballTexture.getWidth()/2);
 58 |         ballBody.setLinearVelocity(10, 10);
 59 | 
 60 |         wallBody = createRectBody(0, 0, screenWidth, screenHeight);
 61 |         floorBody = createRectBody(0, 0, screenWidth, 1);
 62 |         paddleBody = createRectBody(0, 0, blockWidth, blockHeight);
 63 | 
 64 |         Gdx.input.setInputProcessor(stage);
 65 |         stage.addListener(new InputListener() {
 66 |             public boolean handle(Event e) {
 67 |                 float x = Gdx.input.getX() - blockWidth / 2;
 68 |                 moveBody(paddleBody, x, 0);
 69 |                 return true;
 70 |             }
 71 |         });
 72 | 
 73 |         world.setContactListener(new ContactListener() {
 74 |             public void beginContact(Contact c) {
 75 |                 Body b = c.getFixtureA().getBody();
 76 |                 Image i = (Image) blocks.get(b);
 77 |                 if (i != null) {
 78 |                     i.remove();
 79 |                 } else if (b == floorBody) {
 80 |                     show();
 81 |                 }
 82 |             }
 83 |             public void endContact(Contact c) {}
 84 |             public void postSolve(Contact c, ContactImpulse ci) {}
 85 |             public void preSolve(Contact c, Manifold m) {}
 86 |         });
 87 |     }
 88 | 
 89 |     public void render(float delta) {
 90 |         Gdx.gl.glClearColor(0, 0, 0, 0);
 91 |         Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
 92 | 
 93 |         world.step(delta, 10, 10);
 94 |         paddle.setPosition(paddleBody.getPosition().x*scale, paddleBody.getPosition().y*scale);
 95 |         ball.setPosition(ballBody.getPosition().x*scale, ballBody.getPosition().y*scale);
 96 | 
 97 |         Iterator iter = blocks.keySet().iterator();
 98 |         while (iter.hasNext()) {
 99 |             Body b = (Body) iter.next();
100 |             Image i = (Image) blocks.get(b);
101 |             if (i.hasParent() == false) {
102 |                 world.destroyBody(b);
103 |                 iter.remove();
104 |             }
105 |         }
106 | 
107 |         stage.act(delta);
108 |         stage.draw();
109 |     }
110 | 
111 |     public void dispose() {
112 |     }
113 | 
114 |     public void hide() {
115 |     }
116 | 
117 |     public void pause() {
118 |     }
119 | 
120 |     public void resize(int width, int height) {
121 |     }
122 | 
123 |     public void resume() {
124 |     }
125 | 
126 |     public Body createBallBody(float x, float y, float radius) {
127 |         x = x/scale;
128 |         y = y/scale;
129 |         radius = radius/scale;
130 | 
131 |         BodyDef def = new BodyDef();
132 |         def.type = BodyDef.BodyType.DynamicBody;
133 |         def.position.set(x, y);
134 |         Body body = world.createBody(def);
135 | 
136 |         CircleShape shape = new CircleShape();
137 |         shape.setRadius(radius);
138 |         shape.setPosition(new Vector2(radius, radius));
139 |         Fixture fixture = body.createFixture(shape, 1);
140 |         fixture.setFriction(0);
141 |         fixture.setRestitution(1);
142 |         shape.dispose();
143 | 
144 |         return body;
145 |     }
146 | 
147 |     public Body createRectBody(float x, float y, float width, float height) {
148 |         x = x/scale;
149 |         y = y/scale;
150 |         width = width/scale;
151 |         height = height/scale;
152 | 
153 |         BodyDef def = new BodyDef();
154 |         def.type = BodyDef.BodyType.StaticBody;
155 |         def.position.set(x, y);
156 |         Body body = world.createBody(def);
157 | 
158 |         ChainShape shape = new ChainShape();
159 |         float[] vertices = {
160 |                 0, 0,
161 |                 0, height,
162 |                 width, height,
163 |                 width, 0,
164 |                 0, 0
165 |         };
166 |         shape.createChain(vertices);
167 |         body.createFixture(shape, 1);
168 |         shape.dispose();
169 | 
170 |         return body;
171 |     }
172 | 
173 |     public void moveBody(Body body, float x, float y) {
174 |         x = x/scale;
175 |         y = y/scale;
176 | 
177 |         body.setTransform(x, y, 0);
178 |     }
179 | }
180 | 
--------------------------------------------------------------------------------
/Breakout/core/src/net/sekao/breakout/MyGdxGame.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.breakout;
 2 | 
 3 | import com.badlogic.gdx.Game;
 4 | import net.sekao.breakout.MainScreen;
 5 | 
 6 | public class MyGdxGame extends Game {
 7 | 	public void create() {
 8 | 		this.setScreen(new MainScreen());
 9 | 	}
10 | }
11 | 
--------------------------------------------------------------------------------
/Breakout/desktop/build.gradle:
--------------------------------------------------------------------------------
 1 | apply plugin: "java"
 2 | 
 3 | sourceCompatibility = 1.6
 4 | sourceSets.main.java.srcDirs = [ "src/" ]
 5 | 
 6 | project.ext.mainClassName = "net.sekao.breakout.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 dist(type: Jar) {
18 |     from files(sourceSets.main.output.classesDir)
19 |     from files(sourceSets.main.output.resourcesDir)
20 |     from {configurations.compile.collect {zipTree(it)}}
21 |     from files(project.assetsDir);
22 |  
23 |     manifest {
24 |         attributes 'Main-Class': project.mainClassName
25 |     }
26 | }
27 | 
28 | dist.dependsOn classes
29 | 
30 | eclipse {
31 |     project {
32 |         name = appName + "-desktop"
33 |         linkedResource name: 'assets', type: '2', location: 'PARENT-1-PROJECT_LOC/core/assets'
34 |     }
35 | }
36 | 
37 | task afterEclipseImport(description: "Post processing after project generation", group: "IDE") {
38 |   doLast {
39 |     def classpath = new XmlParser().parse(file(".classpath"))
40 |     new Node(classpath, "classpathentry", [ kind: 'src', path: 'assets' ]);
41 |     def writer = new FileWriter(file(".classpath"))
42 |     def printer = new XmlNodePrinter(new PrintWriter(writer))
43 |     printer.setPreserveWhitespace(true)
44 |     printer.print(classpath)
45 |   }
46 | }
--------------------------------------------------------------------------------
/Breakout/desktop/src/net/sekao/breakout/desktop/DesktopLauncher.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.breakout.desktop;
 2 | 
 3 | import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
 4 | import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
 5 | import net.sekao.breakout.MyGdxGame;
 6 | 
 7 | public class DesktopLauncher {
 8 | 	public static void main (String[] arg) {
 9 | 		LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
10 | 		new LwjglApplication(new MyGdxGame(), config);
11 | 	}
12 | }
13 | 
--------------------------------------------------------------------------------
/Breakout/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.daemon=true
2 | org.gradle.jvmargs=-Xms128m -Xmx1500m
3 | org.gradle.configureondemand=true
4 | 
--------------------------------------------------------------------------------
/Breakout/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/Breakout/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Breakout/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=http\://services.gradle.org/distributions/gradle-2.10-all.zip
7 | 
--------------------------------------------------------------------------------
/Breakout/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 | 
--------------------------------------------------------------------------------
/Breakout/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 | 
--------------------------------------------------------------------------------
/Breakout/html/build.gradle:
--------------------------------------------------------------------------------
 1 | apply plugin: "java"
 2 | apply plugin: "jetty"
 3 | 
 4 | gwt {
 5 |     gwtVersion='2.6.0' // Should match the gwt version used for building the gwt backend
 6 |     maxHeapSize="1G" // Default 256m is not enough for gwt compiler. GWT is HUNGRY
 7 |     minHeapSize="1G"
 8 | 
 9 |     src = files(file("src/")) // Needs to be in front of "modules" below.
10 |     modules 'net.sekao.breakout.GdxDefinition'
11 |     devModules 'net.sekao.breakout.GdxDefinitionSuperdev'
12 |     project.webAppDirName = 'webapp'
13 | 
14 |     compiler {
15 |         strict = true;
16 |         enableClosureCompiler = true;
17 |         disableCastChecking = true;
18 |     }
19 | }
20 | 
21 | task draftRun(type: JettyRunWar) {
22 |     dependsOn draftWar
23 |     dependsOn.remove('war')
24 |     webApp=draftWar.archivePath
25 |     daemon=true
26 | }
27 | 
28 | task superDev(type: de.richsource.gradle.plugins.gwt.GwtSuperDev) {
29 |     dependsOn draftRun
30 |     doFirst {
31 |     	gwt.modules = gwt.devModules
32 |     }
33 | }
34 | 
35 | task dist(dependsOn: [clean, compileGwt]) {
36 |     doLast {
37 |         file("build/dist").mkdirs()
38 |         copy {
39 |             from "build/gwt/out"
40 |             into "build/dist"
41 |         }
42 |         copy {
43 |             from "webapp"
44 |             into "build/dist"
45 |             }
46 |         copy {
47 |             from "war"
48 |             into "build/dist"
49 |         }
50 |     }
51 | }
52 | 
53 | draftWar {
54 |    from "war"
55 | }
56 | 
57 | task addSource << {
58 | 	sourceSets.main.compileClasspath += files(project(':core').sourceSets.main.allJava.srcDirs)
59 | }
60 | 
61 | tasks.compileGwt.dependsOn(addSource)
62 | tasks.draftCompileGwt.dependsOn(addSource)
63 | 
64 | sourceCompatibility = 1.6
65 | sourceSets.main.java.srcDirs = [ "src/" ]
66 | 
67 | 
68 | eclipse.project {
69 |     name = appName + "-html"
70 | }
71 | 
--------------------------------------------------------------------------------
/Breakout/html/src/net/sekao/breakout/GdxDefinition.gwt.xml:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 | 
 4 | 	
 5 | 	
 6 | 
 7 | 	
 8 | 	
 9 | 	
10 | 	
11 | 
12 | 
--------------------------------------------------------------------------------
/Breakout/html/src/net/sekao/breakout/GdxDefinitionSuperdev.gwt.xml:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 | 
 4 | 	
 5 | 	
 6 | 
 7 |     
 8 |     
 9 |     
10 |     
11 | 		
12 | 	
13 | 		
14 | 
15 | 
--------------------------------------------------------------------------------
/Breakout/html/src/net/sekao/breakout/client/HtmlLauncher.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.breakout.client;
 2 | 
 3 | import com.badlogic.gdx.ApplicationListener;
 4 | import com.badlogic.gdx.backends.gwt.GwtApplication;
 5 | import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
 6 | import net.sekao.breakout.MyGdxGame;
 7 | 
 8 | public class HtmlLauncher extends GwtApplication {
 9 | 
10 |         @Override
11 |         public GwtApplicationConfiguration getConfig () {
12 |                 return new GwtApplicationConfiguration(800, 600);
13 |         }
14 | 
15 |         @Override
16 |         public ApplicationListener createApplicationListener () {
17 |                 return new MyGdxGame();
18 |         }
19 | }
20 | 
--------------------------------------------------------------------------------
/Breakout/html/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 | 
2 | 
3 | 
--------------------------------------------------------------------------------
/Breakout/html/webapp/index.html:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 |        
 4 |               Breakout
 5 |               
 6 |               
 7 |               
 8 |   			  
 9 |        
10 | 
11 |        
12 |               ↻
13 |               
14 |               
15 |        
16 | 
17 |        
32 | 
33 | 
--------------------------------------------------------------------------------
/Breakout/html/webapp/refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/Breakout/html/webapp/refresh.png
--------------------------------------------------------------------------------
/Breakout/html/webapp/soundmanager2-setup.js:
--------------------------------------------------------------------------------
1 | window.SM2_DEFER = true;
--------------------------------------------------------------------------------
/Breakout/html/webapp/styles.css:
--------------------------------------------------------------------------------
 1 | canvas {
 2 |     cursor: default;
 3 |     outline: none;
 4 | }
 5 | 
 6 | body {
 7 |     background-color: #222222;
 8 | }
 9 | 
10 | .superdev {
11 |     color: rgb(37,37,37);
12 |     text-shadow: 0px 1px 1px rgba(250,250,250,0.1);
13 |     font-size: 50pt;
14 |     display: block;
15 |     position: relative;
16 |     text-decoration: none;
17 |     background-color: rgb(83,87,93);
18 |     box-shadow: 0px 3px 0px 0px rgb(34,34,34),
19 |                 0px 7px 10px 0px rgb(17,17,17),
20 |                 inset 0px 1px 1px 0px rgba(250, 250, 250, .2),
21 |                 inset 0px -12px 35px 0px rgba(0, 0, 0, .5);
22 |     width: 70px;
23 |     height: 70px;
24 |     border: 0;
25 |     border-radius: 35px;
26 |     text-align: center;
27 |     line-height: 68px;
28 | }
29 | 
30 | .superdev:active {
31 |     box-shadow: 0px 0px 0px 0px rgb(34,34,34),
32 |                 0px 3px 7px 0px rgb(17,17,17),
33 |                 inset 0px 1px 1px 0px rgba(250, 250, 250, .2),
34 |                 inset 0px -10px 35px 5px rgba(0, 0, 0, .5);
35 |     background-color: rgb(83,87,93);
36 |     top: 3px;
37 |     color: #fff;
38 |     text-shadow: 0px 0px 3px rgb(250,250,250);
39 | }
40 | 
41 | .superdev:hover {
42 |     background-color: rgb(100,100,100);
43 | }
44 | 
--------------------------------------------------------------------------------
/Breakout/settings.gradle:
--------------------------------------------------------------------------------
1 | include 'desktop', 'html', 'core'
--------------------------------------------------------------------------------
/DungeonCrawler/.gitignore:
--------------------------------------------------------------------------------
 1 | ## Java
 2 | 
 3 | *.class
 4 | *.war
 5 | *.ear
 6 | hs_err_pid*
 7 | 
 8 | ## Robovm
 9 | robovm-build/
10 | 
11 | ## GWT
12 | war/
13 | html/war/gwt_bree/
14 | html/gwt-unitCache/
15 | .apt_generated/
16 | html/war/WEB-INF/deploy/
17 | html/war/WEB-INF/classes/
18 | .gwt/
19 | gwt-unitCache/
20 | www-test/
21 | .gwt-tmp/
22 | 
23 | ## Android Studio and Intellij and Android in general
24 | android/libs/armeabi/
25 | android/libs/armeabi-v7a/
26 | android/libs/arm64-v8a/
27 | android/libs/x86/
28 | android/libs/x86_64/
29 | android/gen/
30 | .idea/
31 | *.ipr
32 | *.iws
33 | *.iml
34 | out/
35 | com_crashlytics_export_strings.xml
36 | 
37 | ## Eclipse
38 | .classpath
39 | .project
40 | .metadata
41 | **/bin/
42 | tmp/
43 | *.tmp
44 | *.bak
45 | *.swp
46 | *~.nib
47 | local.properties
48 | .settings/
49 | .loadpath
50 | .externalToolBuilders/
51 | *.launch
52 | 
53 | ## NetBeans
54 | **/nbproject/private/
55 | build/
56 | nbbuild/
57 | dist/
58 | nbdist/
59 | nbactions.xml
60 | nb-configuration.xml
61 | 
62 | ## Gradle
63 | 
64 | .gradle
65 | gradle-app.setting
66 | build/
67 | 
68 | ## OS Specific
69 | .DS_Store
70 | Thumbs.db
71 | 
--------------------------------------------------------------------------------
/DungeonCrawler/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 |         classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
10 |     }
11 | }
12 | 
13 | allprojects {
14 |     apply plugin: "eclipse"
15 |     apply plugin: "idea"
16 | 
17 |     version = '1.1'
18 |     ext {
19 |         appName = "DungeonCrawler"
20 |         gdxVersion = '1.9.3'
21 |         roboVMVersion = '2.1.0'
22 |         box2DLightsVersion = '1.4'
23 |         ashleyVersion = '1.7.0'
24 |         aiVersion = '1.8.0'
25 |     }
26 | 
27 |     repositories {
28 |         mavenLocal()
29 |         mavenCentral()
30 |         maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
31 |         maven { url "https://oss.sonatype.org/content/repositories/releases/" }
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 |     }
44 | }
45 | 
46 | project(":html") {
47 |     apply plugin: "gwt"
48 |     apply plugin: "war"
49 | 
50 | 
51 |     dependencies {
52 |         compile project(":core")
53 |         compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
54 |         compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
55 |         compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
56 |     }
57 | }
58 | 
59 | project(":core") {
60 |     apply plugin: "java"
61 | 
62 | 
63 |     dependencies {
64 |         compile "com.badlogicgames.gdx:gdx:$gdxVersion"
65 |     }
66 | }
67 | 
68 | tasks.eclipse.doLast {
69 |     delete ".project"
70 | }
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/64x64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/64x64.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/brick.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/brick.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/brick1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/brick1.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/brick2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/brick2.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/brick3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/brick3.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/brick4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/brick4.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/brick5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/brick5.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/brick6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/brick6.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/catacomb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/catacomb.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/characters/dragon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/characters/dragon.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/characters/elemental.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/characters/elemental.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/characters/goblin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/characters/goblin.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/characters/magician.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/characters/magician.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/characters/male_base.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/characters/male_base.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/characters/male_heavy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/characters/male_heavy.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/characters/male_light.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/characters/male_light.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/characters/male_longbow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/characters/male_longbow.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/characters/male_longsword.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/characters/male_longsword.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/characters/male_shield.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/characters/male_shield.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/characters/male_staff.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/characters/male_staff.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/characters/male_unarmored.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/characters/male_unarmored.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/characters/ogre.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/characters/ogre.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/characters/skeleton.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/characters/skeleton.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/characters/slime.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/characters/slime.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/characters/werewolf.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/characters/werewolf.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/characters/zombie.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/characters/zombie.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/cocutos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/cocutos.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/crypt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/crypt.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/death.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/death.wav
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/dwarven_gauntlet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/dwarven_gauntlet.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/gallery.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/gallery.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/gehena.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/gehena.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/hive.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/hive.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/lair.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/lair.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/lapis.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/lapis.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/level1.tmx:
--------------------------------------------------------------------------------
 1 | 
 2 | 
12 | 
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/level2.tmx:
--------------------------------------------------------------------------------
 1 | 
 2 | 
12 | 
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/level3.tmx:
--------------------------------------------------------------------------------
 1 | 
 2 | 
12 | 
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/monsterhurt.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/monsterhurt.wav
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/moss.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/moss.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/mucus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/mucus.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/normal.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/pandem1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/pandem1.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/pandem2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/pandem2.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/pandem3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/pandem3.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/pandem4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/pandem4.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/pandem6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/pandem6.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/playerhurt.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/playerhurt.wav
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/rock.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/rock.png
--------------------------------------------------------------------------------
/DungeonCrawler/core/assets/tunnel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/core/assets/tunnel.png
--------------------------------------------------------------------------------
/DungeonCrawler/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 | 
--------------------------------------------------------------------------------
/DungeonCrawler/core/src/MyGdxGame.gwt.xml:
--------------------------------------------------------------------------------
1 | 
2 | 
3 | 
4 | 	
5 | 
--------------------------------------------------------------------------------
/DungeonCrawler/core/src/net/sekao/dungeoncrawler/EndScreen.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.dungeoncrawler;
 2 | 
 3 | import com.badlogic.gdx.*;
 4 | import com.badlogic.gdx.graphics.*;
 5 | import com.badlogic.gdx.graphics.g2d.*;
 6 | import com.badlogic.gdx.graphics.glutils.*;
 7 | import com.badlogic.gdx.maps.tiled.*;
 8 | import com.badlogic.gdx.maps.tiled.renderers.*;
 9 | import com.badlogic.gdx.math.*;
10 | import com.badlogic.gdx.scenes.scene2d.*;
11 | import com.badlogic.gdx.scenes.scene2d.ui.*;
12 | import com.badlogic.gdx.utils.*;
13 | import java.util.*;
14 | 
15 | public class EndScreen extends ScreenAdapter {
16 | 	Stage stage;
17 | 	Label label;
18 | 	
19 | 	public void show() {
20 | 		stage = new Stage();
21 | 		Label.LabelStyle style = new Label.LabelStyle(new BitmapFont(), Color.WHITE);
22 | 		label = new Label("You have won!", style);
23 | 		label.setWrap(true);
24 | 		label.setAlignment(Align.center);
25 | 		label.setFontScale(3);
26 | 		stage.addActor(label);
27 | 	}
28 | 
29 | 	public void render(float delta) {
30 | 		Gdx.gl.glClearColor(0, 0, 0, 0);
31 | 		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
32 | 		stage.draw();
33 | 	}
34 | 
35 | 	public void resize(int width, int height) {
36 | 		label.setSize(width, height);
37 | 	}
38 | }
39 | 
--------------------------------------------------------------------------------
/DungeonCrawler/core/src/net/sekao/dungeoncrawler/Entity.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.dungeoncrawler;
 2 | 
 3 | import com.badlogic.gdx.*;
 4 | import com.badlogic.gdx.graphics.*;
 5 | import com.badlogic.gdx.graphics.g2d.*;
 6 | import com.badlogic.gdx.maps.tiled.*;
 7 | import com.badlogic.gdx.maps.tiled.renderers.*;
 8 | import java.util.*;
 9 | 
10 | public class Entity implements Comparable {
11 | 	float x, y;
12 | 	float width, height;
13 | 	float xFeet, yFeet;
14 | 	float xChange, yChange;
15 | 	float xVelocity, yVelocity, maxVelocity;
16 | 	boolean isMe, isNPC, isStaircase, isBoss;
17 | 	float lastAttack, attackInterval = 1;
18 | 	float health = 10, wounds = 0, damage = 2;
19 | 	TiledMapTileLayer layer;
20 | 	
21 | 	enum Direction {
22 | 		W, NW, N, NE, E, SE, S, SW
23 | 	};
24 | 	Direction lastDirection = Direction.S;
25 | 
26 | 	ArrayList overlays = new ArrayList();
27 | 	Overlay drop;
28 | 	
29 | 	public int compareTo(Object o) {
30 | 		Entity e = (Entity) o;
31 | 		if (health == 0 && e.health > 0) {
32 | 			return -1;
33 | 		} else if (health > 0 && e.health == 0) {
34 | 			return 1;
35 | 		} else if (y > e.y) {
36 | 			return -1;
37 | 		} else if (e.y > y) {
38 | 			return 1;
39 | 		}
40 | 		return 0;
41 | 	}
42 | }
43 | 
--------------------------------------------------------------------------------
/DungeonCrawler/core/src/net/sekao/dungeoncrawler/Level.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.dungeoncrawler;
 2 | 
 3 | import com.badlogic.gdx.*;
 4 | import com.badlogic.gdx.graphics.*;
 5 | import com.badlogic.gdx.graphics.g2d.*;
 6 | import com.badlogic.gdx.graphics.glutils.*;
 7 | import com.badlogic.gdx.maps.tiled.*;
 8 | import com.badlogic.gdx.maps.tiled.renderers.*;
 9 | import com.badlogic.gdx.math.*;
10 | import com.badlogic.gdx.scenes.scene2d.*;
11 | import com.badlogic.gdx.scenes.scene2d.ui.*;
12 | import com.badlogic.gdx.utils.Timer;
13 | import java.util.*;
14 | 
15 | public class Level {
16 | 	TiledMap map;
17 | 	ArrayList entities;
18 | 	Room startRoom, endRoom;
19 | 	Entity staircase;
20 | }
21 | 
--------------------------------------------------------------------------------
/DungeonCrawler/core/src/net/sekao/dungeoncrawler/Levels.java:
--------------------------------------------------------------------------------
  1 | package net.sekao.dungeoncrawler;
  2 | 
  3 | import com.badlogic.gdx.*;
  4 | import com.badlogic.gdx.graphics.*;
  5 | import com.badlogic.gdx.graphics.g2d.*;
  6 | import com.badlogic.gdx.graphics.glutils.*;
  7 | import com.badlogic.gdx.maps.tiled.*;
  8 | import com.badlogic.gdx.maps.tiled.renderers.*;
  9 | import com.badlogic.gdx.math.*;
 10 | import com.badlogic.gdx.scenes.scene2d.*;
 11 | import com.badlogic.gdx.scenes.scene2d.ui.*;
 12 | import com.badlogic.gdx.utils.Timer;
 13 | import java.util.*;
 14 | 
 15 | public class Levels {
 16 | 	public static void connectRooms(Level l) {
 17 | 		int startX = new Random().nextInt(Rooms.COLS);
 18 | 		int startY = new Random().nextInt(Rooms.ROWS);
 19 | 		
 20 | 		ArrayList rooms = new ArrayList();
 21 | 		for (int x = 0; x < Rooms.COLS; x++) {
 22 | 			for (int y = 0; y < Rooms.ROWS; y++) {
 23 | 				Room room = new Room(x, y);
 24 | 				if (x == startX && y == startY) {
 25 | 					l.startRoom = room;
 26 | 				}
 27 | 				rooms.add(room);
 28 | 			}
 29 | 		}
 30 | 
 31 | 		ArrayList deadEnds = new ArrayList();
 32 | 		Rooms.connectRooms(l.map, rooms, l.startRoom, deadEnds);
 33 | 		l.endRoom = deadEnds.get(0);
 34 | 	}
 35 | 
 36 | 	public static Level createLevel(Entity player, int num) {
 37 | 		if (num == 1) {
 38 | 			return createLevel1(player);
 39 | 		} else if (num == 2) {
 40 | 			return createLevel2(player);
 41 | 		} else if (num == 3) {
 42 | 			return createLevel3(player);
 43 | 		}
 44 | 
 45 | 		return null;
 46 | 	}
 47 | 	
 48 | 	private static Level createLevel1(Entity player) {
 49 | 		Level l = new Level();
 50 | 		
 51 | 		l.map = new TmxMapLoader().load("level1.tmx");
 52 | 
 53 | 		Levels.connectRooms(l);
 54 | 		Entities.putInRoom(player, l.startRoom);
 55 | 
 56 | 		l.entities = new ArrayList();
 57 | 		l.entities.addAll(Entities.createOgres(256, 20));
 58 | 		l.entities.addAll(Entities.createMagicians(128, 20));
 59 | 		Entities.initNPCs(l.map, player, l.entities);
 60 | 		
 61 | 		l.entities.add(player);
 62 | 		
 63 | 		l.staircase = Entities.createStaircase(l.endRoom);
 64 | 		l.entities.add(l.staircase);
 65 | 		
 66 | 		l.entities.addAll(Utils.splitLayer(l.map, "walls"));
 67 | 		
 68 | 		return l;
 69 | 	}
 70 | 	
 71 | 	private static Level createLevel2(Entity player) {
 72 | 		Level l = new Level();
 73 | 		
 74 | 		l.map = new TmxMapLoader().load("level2.tmx");
 75 | 
 76 | 		Levels.connectRooms(l);
 77 | 		Entities.putInRoom(player, l.startRoom);
 78 | 
 79 | 		l.entities = new ArrayList();
 80 | 		l.entities.addAll(Entities.createOgres(256, 20));
 81 | 		l.entities.addAll(Entities.createElementals(256, 20));
 82 | 		Entities.initNPCs(l.map, player, l.entities);
 83 | 		
 84 | 		l.entities.add(player);
 85 | 		
 86 | 		l.staircase = Entities.createStaircase(l.endRoom);
 87 | 		l.entities.add(l.staircase);
 88 | 		
 89 | 		l.entities.addAll(Utils.splitLayer(l.map, "walls"));
 90 | 		
 91 | 		return l;
 92 | 	}
 93 | 	
 94 | 	private static Level createLevel3(Entity player) {
 95 | 		Level l = new Level();
 96 | 		
 97 | 		l.map = new TmxMapLoader().load("level3.tmx");
 98 | 
 99 | 		player.x = 18;
100 | 		player.y = 2;
101 | 		Utils.mapToScreen(player);
102 | 
103 | 		l.entities = new ArrayList();
104 | 		l.entities.add(Entities.createDragon(10, 10));
105 | 		l.entities.add(player);
106 | 		
107 | 		l.entities.addAll(Utils.splitLayer(l.map, "walls"));
108 | 		
109 | 		return l;
110 | 	}
111 | }
112 | 
--------------------------------------------------------------------------------
/DungeonCrawler/core/src/net/sekao/dungeoncrawler/MainScreen.java:
--------------------------------------------------------------------------------
  1 | package net.sekao.dungeoncrawler;
  2 | 
  3 | import com.badlogic.gdx.*;
  4 | import com.badlogic.gdx.graphics.*;
  5 | import com.badlogic.gdx.graphics.g2d.*;
  6 | import com.badlogic.gdx.graphics.glutils.*;
  7 | import com.badlogic.gdx.maps.tiled.*;
  8 | import com.badlogic.gdx.maps.tiled.renderers.*;
  9 | import com.badlogic.gdx.math.*;
 10 | import com.badlogic.gdx.scenes.scene2d.*;
 11 | import com.badlogic.gdx.scenes.scene2d.ui.*;
 12 | import com.badlogic.gdx.utils.Timer;
 13 | import java.util.*;
 14 | 
 15 | public class MainScreen implements Screen {
 16 | 	Level level;
 17 | 	int levelNum = 1;
 18 | 	
 19 | 	IsometricTiledMapRenderer renderer;
 20 | 	OrthographicCamera camera;
 21 | 	Entity player, cursorEntity;
 22 | 	float time;
 23 | 	Pixmap attackCursor;
 24 | 	Timer resetTimer;
 25 | 	
 26 | 	ShapeRenderer healthPlayer, healthNpc;
 27 | 	final float BAR_X = 5, BAR_Y = 5;
 28 | 	final float BAR_WIDTH = 20, BAR_HEIGHT = 80, NPC_BAR_HEIGHT = 0.1f;
 29 | 
 30 | 	Stage stage;
 31 | 	Label dropLabel;
 32 | 
 33 | 	public MainScreen(Game game) {
 34 | 		Utils.game = game;
 35 | 	}
 36 | 
 37 | 	public void drawNPCInfo() {
 38 | 		float percent = player.health / (player.health + player.wounds);
 39 | 		healthPlayer.begin(ShapeRenderer.ShapeType.Filled);
 40 | 		healthPlayer.setColor(Color.RED);
 41 | 		healthPlayer.rect(BAR_X, BAR_Y, BAR_WIDTH, BAR_HEIGHT);
 42 | 		healthPlayer.setColor(Color.GREEN);
 43 | 		healthPlayer.rect(BAR_X, BAR_Y, BAR_WIDTH, BAR_HEIGHT * percent);
 44 | 		healthPlayer.end();
 45 | 
 46 | 		dropLabel.setVisible(false);
 47 | 		if (cursorEntity != null && cursorEntity.isNPC == true) {
 48 | 			if (cursorEntity.health > 0) {
 49 | 				percent = cursorEntity.health / (cursorEntity.health + cursorEntity.wounds);
 50 | 				healthNpc.setProjectionMatrix(camera.combined);
 51 | 				healthNpc.begin(ShapeRenderer.ShapeType.Filled);
 52 | 				healthNpc.setColor(Color.RED);
 53 | 				healthNpc.rect(cursorEntity.x, cursorEntity.y + cursorEntity.height, cursorEntity.width, NPC_BAR_HEIGHT);
 54 | 				healthNpc.setColor(Color.GREEN);
 55 | 				healthNpc.rect(cursorEntity.x, cursorEntity.y + cursorEntity.height, cursorEntity.width * percent, NPC_BAR_HEIGHT);
 56 | 				healthNpc.end();
 57 | 			} else if (cursorEntity.drop != null) {
 58 | 				dropLabel.setVisible(true);
 59 | 				dropLabel.setText(cursorEntity.drop.name);
 60 | 
 61 | 				Vector3 v = new Vector3(cursorEntity.x, cursorEntity.y, 0);
 62 | 				camera.project(v);
 63 | 				dropLabel.setPosition(v.x, v.y);
 64 | 			}
 65 | 		}
 66 | 
 67 | 		stage.draw();
 68 | 	}
 69 | 	
 70 | 	public void show() {
 71 | 		time = 0;
 72 | 		
 73 | 		attackCursor = new Pixmap(Gdx.files.internal("dwarven_gauntlet.png"));
 74 | 		healthPlayer = new ShapeRenderer();
 75 | 		healthNpc = new ShapeRenderer();
 76 | 		
 77 | 		Utils.playerHurt = Gdx.audio.newSound(Gdx.files.internal("playerhurt.wav"));
 78 | 		Utils.monsterHurt = Gdx.audio.newSound(Gdx.files.internal("monsterhurt.wav"));
 79 | 		Utils.death = Gdx.audio.newSound(Gdx.files.internal("death.wav"));
 80 | 
 81 | 		player = Entities.createPlayer();
 82 | 		level = Levels.createLevel(player, levelNum);
 83 | 		
 84 | 		renderer = new IsometricTiledMapRenderer(level.map, 1 / Utils.PIXELS_PER_TILE);
 85 | 		camera = new OrthographicCamera();
 86 | 		
 87 | 		stage = new Stage();
 88 | 		Label.LabelStyle style = new Label.LabelStyle(new BitmapFont(), Color.WHITE);
 89 | 		dropLabel = new Label("", style);
 90 | 		dropLabel.setVisible(false);
 91 | 		stage.addActor(dropLabel);
 92 | 
 93 | 		Gdx.input.setInputProcessor(new InputAdapter() {
 94 | 			public boolean touchDown(int screenX, int screenY, int pointer, int button) {
 95 | 				Entity target = Utils.getEntityAtCursor(camera, level.entities, screenX, screenY);
 96 | 				
 97 | 				if (button == Input.Buttons.LEFT) {
 98 | 					if (target != null) {
 99 | 						if (target.health == 0 && target.drop != null) {
100 | 							Overlays.add(player, target.drop);
101 | 							target.drop = null;
102 | 						} else if (target.isStaircase == true) {
103 | 							levelNum += 1;
104 | 							level = Levels.createLevel(player, levelNum);
105 | 						}
106 | 					}
107 | 				} else {
108 | 					if (!Utils.canAttack(player, target)) {
109 | 						target = null;
110 | 					}
111 | 					Entities.attack(player, target);
112 | 				}
113 | 				
114 | 				return true;
115 | 			}
116 | 
117 | 			public boolean mouseMoved(int screenX, int screenY) {
118 | 				cursorEntity = Utils.getEntityAtCursor(camera, level.entities, screenX, screenY);
119 |                 Cursor customCursor;
120 | 				if (cursorEntity != null) {
121 |                     customCursor = Gdx.graphics.newCursor(attackCursor, 0, 0);
122 | 				} else {
123 |                     customCursor = Gdx.graphics.newCursor(null, 0, 0);
124 | 				}
125 | 				Gdx.graphics.setCursor(customCursor);
126 | 				return true;
127 | 			}
128 | 		});
129 | 	}
130 | 	
131 | 	public void render(float delta) {
132 | 		time += delta;
133 | 		
134 | 		Gdx.gl.glClearColor(0, 0, 0, 0);
135 | 		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
136 | 
137 | 		camera.position.x = player.x;
138 | 		camera.position.y = player.y;
139 | 		camera.update();
140 | 
141 | 		renderer.setView(camera);
142 | 
143 | 		Collections.sort(level.entities);
144 | 
145 | 		SpriteBatch batch = (SpriteBatch) renderer.getBatch();
146 | 		batch.begin();
147 | 		for (Entity e : level.entities) {
148 | 			if (e.layer != null) {
149 | 				renderer.renderTileLayer(e.layer);
150 | 			} else {
151 | 				if (e.isMe == true || e.isNPC == true) {
152 | 					if (Entities.move(e, player, delta)) {
153 | 						Entities.animate(e, time);
154 | 						Entities.preventMove(e, level.entities, level.map);
155 | 					} else {
156 | 						Entities.recover(e);
157 | 						if (Utils.canAttack(e, player)) {
158 | 							Entities.attack(e, player);
159 | 						}
160 | 					}
161 | 				}
162 | 				for (Overlay o : e.overlays) {
163 | 					batch.draw(o.image, e.x, e.y, e.width, e.height);
164 | 				}
165 | 			}
166 | 		}
167 | 		batch.end();
168 | 
169 | 		drawNPCInfo();
170 | 
171 | 		if (resetTimer == null) {
172 | 			if (player.health == 0) {
173 | 				resetTimer = new Timer();
174 | 				resetTimer.scheduleTask(new Timer.Task() {
175 | 					public void run() {
176 | 						MainScreen screen = new MainScreen(Utils.game);
177 | 						screen.levelNum = levelNum;
178 | 						Utils.game.setScreen(screen);
179 | 					}
180 | 				}, 2);
181 | 			} else if (level != null) {
182 | 				for (Entity e : level.entities) {
183 | 					if (e.isBoss == true && e.health == 0) {
184 | 						resetTimer = new Timer();
185 | 						resetTimer.scheduleTask(new Timer.Task() {
186 | 							public void run() {
187 | 								EndScreen screen = new EndScreen();
188 | 								Utils.game.setScreen(screen);
189 | 							}
190 | 						}, 2);
191 | 					}
192 | 				}
193 | 			}
194 | 		}
195 | 	}
196 | 	
197 | 	public void dispose() {
198 | 	}
199 | 	
200 | 	public void hide() {
201 | 	}
202 | 	
203 | 	public void pause() {
204 | 	}
205 | 
206 | 	public void resize(int width, int height) {
207 | 		camera.setToOrtho(false, Utils.CAMERA_HEIGHT * width / height, Utils.CAMERA_HEIGHT);
208 | 	}
209 | 
210 | 	public void resume() {
211 | 	}
212 | }
213 | 
--------------------------------------------------------------------------------
/DungeonCrawler/core/src/net/sekao/dungeoncrawler/MyGdxGame.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.dungeoncrawler;
 2 | 
 3 | import com.badlogic.gdx.Game;
 4 | import com.badlogic.gdx.graphics.Texture;
 5 | 
 6 | public class MyGdxGame extends Game {
 7 | 	public void create() {
 8 | 		this.setScreen(new MainScreen(this));
 9 | 	}
10 | }
11 | 
--------------------------------------------------------------------------------
/DungeonCrawler/core/src/net/sekao/dungeoncrawler/Overlay.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.dungeoncrawler;
 2 | 
 3 | import com.badlogic.gdx.*;
 4 | import com.badlogic.gdx.graphics.*;
 5 | import com.badlogic.gdx.graphics.g2d.*;
 6 | import com.badlogic.gdx.maps.tiled.*;
 7 | import com.badlogic.gdx.maps.tiled.renderers.*;
 8 | import java.util.*;
 9 | 
10 | public class Overlay implements Comparable {
11 | 	Animation[] move;
12 | 	TextureRegion[] attack, special, hit, dead;
13 | 	TextureRegion image;
14 | 
15 | 	int zIndex;
16 | 	float health, damage;
17 | 	String name;
18 | 
19 | 	public int compareTo(Object o) {
20 | 		Overlay overlay = (Overlay) o;
21 | 		int diff = zIndex - overlay.zIndex;
22 | 		return (int) Math.signum(diff);
23 | 	}
24 | }
25 | 
--------------------------------------------------------------------------------
/DungeonCrawler/core/src/net/sekao/dungeoncrawler/Overlays.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.dungeoncrawler;
 2 | 
 3 | import com.badlogic.gdx.*;
 4 | import com.badlogic.gdx.graphics.*;
 5 | import com.badlogic.gdx.graphics.g2d.*;
 6 | import com.badlogic.gdx.maps.tiled.*;
 7 | import com.badlogic.gdx.maps.tiled.renderers.*;
 8 | import java.util.*;
 9 | 
10 | public class Overlays {
11 | 	public static Overlay create(TextureRegion[][] grid, float interval) {
12 | 		Overlay o = new Overlay();
13 | 		
14 | 		int row = grid.length;
15 | 		
16 | 		o.move = new Animation[row];
17 | 		o.attack = new TextureRegion[row];
18 | 		o.special = new TextureRegion[row];
19 | 		o.hit = new TextureRegion[row];
20 | 		o.dead = new TextureRegion[row];
21 | 		
22 | 		while (row > 0) {
23 | 			row--;
24 | 			o.move[row] = new Animation(interval, grid[row][0], grid[row][1], grid[row][2], grid[row][3]);
25 | 			o.attack[row] = grid[row][4];
26 | 			o.special[row] = grid[row][5];
27 | 			o.hit[row] = grid[row][6];
28 | 			o.dead[row] = grid[row][7];
29 | 		}
30 | 
31 | 		int south = Entity.Direction.S.ordinal();
32 | 		o.image = grid[south][0];
33 | 
34 | 		return o;
35 | 	}
36 | 
37 | 	public static Overlay create(String path, int maskSize, float interval) {
38 | 		TextureRegion[][] grid = Utils.splitTexture(path, Utils.GRID_TILE_SIZE, maskSize);
39 | 
40 | 		return create(grid, interval);
41 | 	}
42 | 
43 | 	public static ArrayList createItems() {
44 | 		ArrayList items = new ArrayList();
45 | 
46 | 		Overlay armor = create("characters/male_heavy.png", 128, 0.1f);
47 | 		armor.health = 80;
48 | 		armor.name = "Heavy Armor";
49 | 		armor.zIndex = 1;
50 | 		items.add(armor);
51 | 
52 | 		Overlay sword = create("characters/male_longsword.png", 128, 0.1f);
53 | 		sword.damage = 4;
54 | 		sword.name = "Sword";
55 | 		sword.zIndex = 2;
56 | 		items.add(sword);
57 | 		
58 | 		Overlay shield = create("characters/male_shield.png", 128, 0.1f);
59 | 		shield.health = 20;
60 | 		shield.name = "Shield";
61 | 		shield.zIndex = 2;
62 | 		items.add(shield);
63 | 
64 | 		return items;
65 | 	}
66 | 
67 | 	public static void add(Entity e, Overlay o) {
68 | 		if (!e.overlays.contains(o)) {
69 | 			e.overlays.add(o);
70 | 			Collections.sort(e.overlays);
71 | 			e.damage += o.damage;
72 | 			e.health += o.health;
73 | 		}
74 | 	}
75 | }
76 | 
--------------------------------------------------------------------------------
/DungeonCrawler/core/src/net/sekao/dungeoncrawler/Room.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.dungeoncrawler;
 2 | 
 3 | public class Room {
 4 | 	int x, y;
 5 | 	boolean visited = false;
 6 | 
 7 | 	public Room(int x, int y) {
 8 | 		this.x = x;
 9 | 		this.y = y;
10 | 	}
11 | }
12 | 
--------------------------------------------------------------------------------
/DungeonCrawler/core/src/net/sekao/dungeoncrawler/Rooms.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.dungeoncrawler;
 2 | 
 3 | import com.badlogic.gdx.*;
 4 | import com.badlogic.gdx.graphics.*;
 5 | import com.badlogic.gdx.graphics.g2d.*;
 6 | import com.badlogic.gdx.maps.*;
 7 | import com.badlogic.gdx.maps.tiled.*;
 8 | import com.badlogic.gdx.maps.tiled.renderers.*;
 9 | import com.badlogic.gdx.utils.*;
10 | import java.util.*;
11 | 
12 | public class Rooms {
13 | 	public static final int COLS = 4;
14 | 	public static final int ROWS = 4;
15 | 	public static final int SIZE = 10;
16 | 
17 | 	public static Room getRandomNeighbor(ArrayList rooms, Room room) {
18 | 		ArrayList neighbors = new ArrayList();
19 | 		neighbors.add(new Room(room.x - 1, room.y));
20 | 		neighbors.add(new Room(room.x, room.y - 1));
21 | 		neighbors.add(new Room(room.x + 1, room.y));
22 | 		neighbors.add(new Room(room.x, room.y + 1));
23 | 
24 | 		Utils.shuffle(rooms);
25 | 		Utils.shuffle(neighbors);
26 | 
27 | 		for (Room r : rooms) {
28 | 			for (Room n : neighbors) {
29 | 				if (r.x == n.x && r.y == n.y && r.visited == false) {
30 | 					return r;
31 | 				}
32 | 			}
33 | 		}
34 | 		
35 | 		return null;
36 | 	}
37 | 
38 | 	public static void connectRoom(TiledMap map, Room r1, Room r2) {
39 | 		int randomSpot = new Random().nextInt(SIZE - 3) + 1;
40 | 		int x = r1.x * SIZE + randomSpot;
41 | 		int y = r1.y * SIZE + randomSpot;
42 | 		int xDiff = r2.x - r1.x;
43 | 		int yDiff = r2.y - r1.y;
44 | 		
45 | 		int step = 0;
46 | 		while (step < SIZE) {
47 | 			x = x + xDiff;
48 | 			y = y + yDiff;
49 | 			Utils.clearTile(map, "walls", x, y);
50 | 			Utils.clearTile(map, "walls", x + 1, y);
51 | 			Utils.clearTile(map, "walls", x, y + 1);
52 | 			Utils.clearTile(map, "walls", x + 1, y + 1);
53 | 			step++;
54 | 		}
55 | 	}
56 | 
57 | 	public static boolean connectRooms(TiledMap map, ArrayList rooms, Room room, ArrayList deadEnds) {
58 | 		room.visited = true;
59 | 		
60 | 		Room nextRoom = getRandomNeighbor(rooms, room);
61 | 		if (nextRoom == null) {
62 | 			deadEnds.add(room);
63 | 			return false;
64 | 		}
65 | 
66 | 		connectRoom(map, room, nextRoom);
67 | 		
68 | 		while (connectRooms(map, rooms, nextRoom, deadEnds)) {}
69 | 
70 | 		return true;
71 | 	}
72 | }
73 | 
--------------------------------------------------------------------------------
/DungeonCrawler/core/src/net/sekao/dungeoncrawler/Utils.java:
--------------------------------------------------------------------------------
  1 | package net.sekao.dungeoncrawler;
  2 | 
  3 | import com.badlogic.gdx.*;
  4 | import com.badlogic.gdx.audio.*;
  5 | import com.badlogic.gdx.graphics.*;
  6 | import com.badlogic.gdx.graphics.g2d.*;
  7 | import com.badlogic.gdx.maps.tiled.*;
  8 | import com.badlogic.gdx.maps.tiled.renderers.*;
  9 | import com.badlogic.gdx.math.*;
 10 | import java.util.*;
 11 | 
 12 | public class Utils {
 13 | 	public static final float PIXELS_PER_TILE = 64;
 14 | 	public static final float CAMERA_HEIGHT = 4;
 15 | 	public static final float HALF_TILE_WIDTH = 0.5f;
 16 | 	public static final float HALF_TILE_HEIGHT = 0.25f;
 17 | 	public static final int MAP_WIDTH = 40;
 18 | 	public static final int MAP_HEIGHT = 40;
 19 | 	public static final int GRID_TILE_SIZE = 256;
 20 | 	public static final float AGGRO_DISTANCE = 2;
 21 | 	public static final float ATTACK_DISTANCE = 0.25f;
 22 | 	public static Sound playerHurt, monsterHurt, death;
 23 | 	public static Game game;
 24 | 
 25 | 	public static void clearTile(TiledMap map, String layerName, int x, int y) {
 26 | 		TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(layerName);
 27 | 		layer.setCell(x, y, null);
 28 | 	}
 29 | 
 30 | 	public static float decelerate(float velocity) {
 31 | 		float deceleration = 0.9f;
 32 | 		velocity = velocity * deceleration;
 33 | 		if (Math.abs(velocity) < 0.5f) {
 34 | 			velocity = 0;
 35 | 		}
 36 | 		return velocity;
 37 | 	}
 38 | 
 39 | 	public static void screenToMap(Entity e) {
 40 | 		float x = e.x, y = e.y;
 41 | 		e.x = (x / HALF_TILE_WIDTH - y / HALF_TILE_HEIGHT) / 2;
 42 | 		e.y = (y / HALF_TILE_HEIGHT + (x / HALF_TILE_WIDTH)) / 2;
 43 | 	}
 44 | 
 45 | 	public static void mapToScreen(Entity e) {
 46 | 		float x = e.x, y = e.y;
 47 | 		e.x = x * HALF_TILE_WIDTH + y * HALF_TILE_WIDTH;
 48 | 		e.y = -1 * x * HALF_TILE_HEIGHT + y * HALF_TILE_HEIGHT;
 49 | 	}
 50 | 
 51 | 	public static boolean isOnLayer(Entity e, TiledMap map, String layerName) {
 52 | 		TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(layerName);
 53 | 
 54 | 		screenToMap(e);
 55 | 		
 56 | 		float endX = e.x + e.width;
 57 | 		float endY = e.y + e.height;
 58 | 		
 59 | 		int x = (int) e.x;
 60 | 		while (x < endX) {
 61 | 			
 62 | 			int y = (int) e.y;
 63 | 			while (y < endY) {
 64 | 				if (layer.getCell(x, y) != null) {
 65 | 					mapToScreen(e);
 66 | 					return true;
 67 | 				}
 68 | 				y = y + 1;
 69 | 			}
 70 | 			x = x + 1;
 71 | 		}
 72 | 
 73 | 		mapToScreen(e);
 74 | 		return false;
 75 | 	}
 76 | 
 77 | 	public static Rectangle getRectangle(Entity e, float minDistance) {
 78 | 		float x = e.x + e.xFeet - minDistance / 4;
 79 | 		float y = e.y + e.yFeet - minDistance / 4;
 80 | 		float width = e.width + minDistance / 2 - e.xFeet * 2;
 81 | 		float height = e.height + minDistance / 2 - e.yFeet * 2;
 82 | 		return new Rectangle(x, y, width, height);
 83 | 	}
 84 | 	
 85 | 	public static boolean isNearEntity(Entity e, Entity e2, float minDistance) {
 86 | 		if (e == e2 || e2.layer != null || e2.health == 0) {
 87 | 			return false;
 88 | 		}
 89 | 		
 90 | 		Rectangle r1 = getRectangle(e, minDistance);
 91 | 		Rectangle r2 = getRectangle(e2, minDistance);
 92 | 		
 93 | 		return r1.overlaps(r2);
 94 | 	}
 95 | 
 96 | 	public static boolean isNearEntity(Entity e, ArrayList entities, float minDistance) {
 97 | 		for (Entity e2 : entities) {
 98 | 			if (isNearEntity(e, e2, minDistance)) {
 99 | 				return true;
100 | 			}
101 | 		}
102 | 
103 | 		return false;
104 | 	}
105 | 
106 | 	public static boolean isInvalidLocation(Entity e, ArrayList entities, TiledMap map) {
107 | 		return isNearEntity(e, entities, 0) || isOnLayer(e, map, "walls");
108 | 	}
109 | 
110 | 	public static int random() {
111 | 		return (int) Math.round(Math.random() * 2 - 1);
112 | 	}
113 | 
114 | 	public static TextureRegion[][] splitTexture(String path, int size, int maskSize) {
115 | 		Texture sheet = new Texture(path);
116 | 		TextureRegion[][] grid = TextureRegion.split(sheet, size, size);
117 | 		int start = (size - maskSize) / 2;
118 | 
119 | 		for (TextureRegion[] row : grid) {
120 | 			for (TextureRegion t : row) {
121 | 				t.setRegion(t, start, start, maskSize, maskSize);
122 | 			}
123 | 		}
124 | 
125 | 		return grid;
126 | 	}
127 | 
128 | 	public static Entity.Direction getDirection(float xVelocity, float yVelocity) {
129 | 		// W, NW, N, NE, E, SE, S, SW
130 | 		float[] xDirection = {
131 | 			-1, -1, 0, 1, 1, 1, 0, -1
132 | 		};
133 | 		float[] yDirection = {
134 | 			0, 1, 1, 1, 0, -1, -1, -1
135 | 		};
136 | 
137 | 		for (Entity.Direction d : Entity.Direction.values()) {
138 | 			float x = xDirection[d.ordinal()];
139 | 			float y = yDirection[d.ordinal()];
140 | 			if (x == Math.signum(xVelocity) && y == Math.signum(yVelocity)) {
141 | 				return d;
142 | 			}
143 | 		}
144 | 
145 | 		return null;
146 | 	}
147 | 
148 | 	public static Entity.Direction getDirection(Entity e) {
149 | 		return getDirection(e.xVelocity, e.yVelocity);
150 | 	}
151 | 
152 | 	public static ArrayList splitLayer(TiledMap map, String layerName) {
153 | 		TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(layerName);
154 | 		ArrayList rows = new ArrayList();
155 | 
156 | 		for (int x = layer.getWidth() - 1; x >= 0; x--) {
157 | 			for (int y = layer.getHeight() - 1; y >= 0; y--) {
158 | 				Entity e = new Entity();
159 | 				e.x = x;
160 | 				e.y = y;
161 | 				mapToScreen(e);
162 | 
163 | 				for (Entity r : rows) {
164 | 					if (e.y == r.y) {
165 | 						e = r;
166 | 						break;
167 | 					}
168 | 				}
169 | 				
170 | 				if (e.layer == null) {
171 | 					e.layer = new TiledMapTileLayer(layer.getWidth(), layer.getHeight(), (int) layer.getTileWidth(), (int) layer.getTileHeight());
172 | 					rows.add(e);
173 | 				}
174 | 
175 | 				e.layer.setCell(x, y, layer.getCell(x, y));
176 | 			}
177 | 		}
178 | 
179 | 		return rows;
180 | 	}
181 | 
182 | 	public static ArrayList getLocationOptions(float width, float height, int mapWidth, int mapHeight) {
183 | 		ArrayList options = new ArrayList();
184 | 
185 | 		int endX = mapWidth - (int) width;
186 | 		int endY = mapHeight - (int) height;
187 | 
188 | 		int x = 0;
189 | 		while (x < endX) {
190 | 			
191 | 			int y = 0;
192 | 			while (y < endY) {
193 | 				Entity option = new Entity();
194 | 				option.x = x;
195 | 				option.y = y;
196 | 				option.width = width;
197 | 				option.height = height;
198 | 				mapToScreen(option);
199 | 				options.add(option);
200 | 				
201 | 				y = y + 1;
202 | 			}
203 | 			x = x + 1;
204 | 		}
205 | 
206 | 		return options;
207 | 	}
208 | 
209 | 	public static void randomizeLocations(TiledMap map, Entity player, ArrayList entities) {
210 | 		for (Entity e : entities) {
211 | 			ArrayList options = getLocationOptions(e.width, e.height, MAP_WIDTH, MAP_HEIGHT);
212 | 			Utils.shuffle(options);
213 | 			for (Entity option : options) {
214 | 				if (!isOnLayer(option, map, "walls") &&
215 | 				    !isNearEntity(option, entities, 2) &&
216 | 				    !isNearEntity(option, player, 5)) {
217 | 					e.x = option.x;
218 | 					e.y = option.y;
219 | 					break;
220 | 				}
221 | 			}
222 | 		}
223 | 	}
224 | 
225 | 	public static boolean canAttack(Entity e, Entity e2) {
226 | 		if (e2 == null || e.isNPC == e2.isNPC || e.health == 0) {
227 | 			return false;
228 | 		}
229 | 
230 | 		return e.lastAttack >= e.attackInterval && Utils.isNearEntity(e, e2, ATTACK_DISTANCE);
231 | 	}
232 | 
233 | 	public static Entity getEntityAtCursor(Camera camera, ArrayList entities, float x, float y) {
234 | 		Vector3 v = new Vector3(x, y, 0);
235 | 		camera.unproject(v);
236 | 		
237 | 		Rectangle r = new Rectangle();
238 | 		for (Entity e : entities) {
239 | 			if ((e.isNPC != true && e.isStaircase != true) || (e.health == 0 && e.drop == null)) {
240 | 				continue;
241 | 			}
242 | 			r.set(e.x, e.y, e.width, e.height);
243 | 			if (r.contains(v.x, v.y)) {
244 | 				return e;
245 | 			}
246 | 		}
247 | 
248 | 		return null;
249 | 	}
250 | 	
251 | 	private static void swap(ArrayList list, int idx1, int idx2) {
252 |         Object o1 = list.get(idx1);
253 |         list.set(idx1, list.get(idx2));
254 |         list.set(idx2, o1);
255 | 	}
256 | 
257 | 	public static void shuffle(ArrayList objects) {
258 | 	    for(int i = objects.size(); i > 1; i--) {
259 | 	    	swap(objects, i - 1, new Random().nextInt(i));
260 | 	    }
261 | 	}
262 | }
263 | 
--------------------------------------------------------------------------------
/DungeonCrawler/desktop/build.gradle:
--------------------------------------------------------------------------------
 1 | apply plugin: "java"
 2 | 
 3 | sourceCompatibility = 1.6
 4 | sourceSets.main.java.srcDirs = [ "src/" ]
 5 | 
 6 | project.ext.mainClassName = "net.sekao.dungeoncrawler.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 dist(type: Jar) {
18 |     from files(sourceSets.main.output.classesDir)
19 |     from files(sourceSets.main.output.resourcesDir)
20 |     from {configurations.compile.collect {zipTree(it)}}
21 |     from files(project.assetsDir);
22 |  
23 |     manifest {
24 |         attributes 'Main-Class': project.mainClassName
25 |     }
26 | }
27 | 
28 | dist.dependsOn classes
29 | 
30 | eclipse {
31 |     project {
32 |         name = appName + "-desktop"
33 |         linkedResource name: 'assets', type: '2', location: 'PARENT-1-PROJECT_LOC/core/assets'
34 |     }
35 | }
36 | 
37 | task afterEclipseImport(description: "Post processing after project generation", group: "IDE") {
38 |   doLast {
39 |     def classpath = new XmlParser().parse(file(".classpath"))
40 |     new Node(classpath, "classpathentry", [ kind: 'src', path: 'assets' ]);
41 |     def writer = new FileWriter(file(".classpath"))
42 |     def printer = new XmlNodePrinter(new PrintWriter(writer))
43 |     printer.setPreserveWhitespace(true)
44 |     printer.print(classpath)
45 |   }
46 | }
--------------------------------------------------------------------------------
/DungeonCrawler/desktop/src/net/sekao/dungeoncrawler/desktop/DesktopLauncher.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.dungeoncrawler.desktop;
 2 | 
 3 | import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
 4 | import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
 5 | import net.sekao.dungeoncrawler.MyGdxGame;
 6 | 
 7 | public class DesktopLauncher {
 8 | 	public static void main (String[] arg) {
 9 | 		LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
10 | 		new LwjglApplication(new MyGdxGame(), config);
11 | 	}
12 | }
13 | 
--------------------------------------------------------------------------------
/DungeonCrawler/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.daemon=true
2 | org.gradle.jvmargs=-Xms128m -Xmx1500m
3 | org.gradle.configureondemand=true
4 | 
--------------------------------------------------------------------------------
/DungeonCrawler/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/DungeonCrawler/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=http\://services.gradle.org/distributions/gradle-2.10-all.zip
7 | 
--------------------------------------------------------------------------------
/DungeonCrawler/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 | 
--------------------------------------------------------------------------------
/DungeonCrawler/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 | 
--------------------------------------------------------------------------------
/DungeonCrawler/html/build.gradle:
--------------------------------------------------------------------------------
 1 | apply plugin: "java"
 2 | apply plugin: "jetty"
 3 | 
 4 | gwt {
 5 |     gwtVersion='2.6.0' // Should match the gwt version used for building the gwt backend
 6 |     maxHeapSize="1G" // Default 256m is not enough for gwt compiler. GWT is HUNGRY
 7 |     minHeapSize="1G"
 8 | 
 9 |     src = files(file("src/")) // Needs to be in front of "modules" below.
10 |     modules 'net.sekao.dungeoncrawler.GdxDefinition'
11 |     devModules 'net.sekao.dungeoncrawler.GdxDefinitionSuperdev'
12 |     project.webAppDirName = 'webapp'
13 | 
14 |     compiler {
15 |         strict = true;
16 |         enableClosureCompiler = true;
17 |         disableCastChecking = true;
18 |     }
19 | }
20 | 
21 | task draftRun(type: JettyRunWar) {
22 |     dependsOn draftWar
23 |     dependsOn.remove('war')
24 |     webApp=draftWar.archivePath
25 |     daemon=true
26 | }
27 | 
28 | task superDev(type: de.richsource.gradle.plugins.gwt.GwtSuperDev) {
29 |     dependsOn draftRun
30 |     doFirst {
31 |     	gwt.modules = gwt.devModules
32 |     }
33 | }
34 | 
35 | task dist(dependsOn: [clean, compileGwt]) {
36 |     doLast {
37 |         file("build/dist").mkdirs()
38 |         copy {
39 |             from "build/gwt/out"
40 |             into "build/dist"
41 |         }
42 |         copy {
43 |             from "webapp"
44 |             into "build/dist"
45 |             }
46 |         copy {
47 |             from "war"
48 |             into "build/dist"
49 |         }
50 |     }
51 | }
52 | 
53 | draftWar {
54 |    from "war"
55 | }
56 | 
57 | task addSource << {
58 | 	sourceSets.main.compileClasspath += files(project(':core').sourceSets.main.allJava.srcDirs)
59 | }
60 | 
61 | tasks.compileGwt.dependsOn(addSource)
62 | tasks.draftCompileGwt.dependsOn(addSource)
63 | 
64 | sourceCompatibility = 1.6
65 | sourceSets.main.java.srcDirs = [ "src/" ]
66 | 
67 | 
68 | eclipse.project {
69 |     name = appName + "-html"
70 | }
71 | 
--------------------------------------------------------------------------------
/DungeonCrawler/html/src/net/sekao/dungeoncrawler/GdxDefinition.gwt.xml:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 | 
 4 | 	
 5 | 
 6 | 	
 7 | 	
 8 | 	
 9 | 	
10 | 
11 | 
--------------------------------------------------------------------------------
/DungeonCrawler/html/src/net/sekao/dungeoncrawler/GdxDefinitionSuperdev.gwt.xml:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 | 
 4 | 	
 5 | 
 6 |     
 7 |     
 8 |     
 9 |     
10 | 		
11 | 	
12 | 		
13 | 
14 | 
--------------------------------------------------------------------------------
/DungeonCrawler/html/src/net/sekao/dungeoncrawler/client/HtmlLauncher.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.dungeoncrawler.client;
 2 | 
 3 | import com.badlogic.gdx.ApplicationListener;
 4 | import com.badlogic.gdx.backends.gwt.GwtApplication;
 5 | import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
 6 | import net.sekao.dungeoncrawler.MyGdxGame;
 7 | 
 8 | public class HtmlLauncher extends GwtApplication {
 9 | 
10 |         @Override
11 |         public GwtApplicationConfiguration getConfig () {
12 |                 return new GwtApplicationConfiguration(800, 600);
13 |         }
14 | 
15 |         @Override
16 |         public ApplicationListener createApplicationListener () {
17 |                 return new MyGdxGame();
18 |         }
19 | }
20 | 
--------------------------------------------------------------------------------
/DungeonCrawler/html/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 | 
2 | 
3 | 
--------------------------------------------------------------------------------
/DungeonCrawler/html/webapp/index.html:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 |        
 4 |               DungeonCrawler
 5 |               
 6 |               
 7 |               
 8 |   			  
 9 |        
10 | 
11 |        
12 |               ↻
13 |               
14 |               
15 |        
16 | 
17 |        
32 | 
33 | 
--------------------------------------------------------------------------------
/DungeonCrawler/html/webapp/refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/DungeonCrawler/html/webapp/refresh.png
--------------------------------------------------------------------------------
/DungeonCrawler/html/webapp/soundmanager2-setup.js:
--------------------------------------------------------------------------------
1 | window.SM2_DEFER = true;
--------------------------------------------------------------------------------
/DungeonCrawler/html/webapp/styles.css:
--------------------------------------------------------------------------------
 1 | canvas {
 2 |     cursor: default;
 3 |     outline: none;
 4 | }
 5 | 
 6 | body {
 7 |     background-color: #222222;
 8 | }
 9 | 
10 | .superdev {
11 |     color: rgb(37,37,37);
12 |     text-shadow: 0px 1px 1px rgba(250,250,250,0.1);
13 |     font-size: 50pt;
14 |     display: block;
15 |     position: relative;
16 |     text-decoration: none;
17 |     background-color: rgb(83,87,93);
18 |     box-shadow: 0px 3px 0px 0px rgb(34,34,34),
19 |                 0px 7px 10px 0px rgb(17,17,17),
20 |                 inset 0px 1px 1px 0px rgba(250, 250, 250, .2),
21 |                 inset 0px -12px 35px 0px rgba(0, 0, 0, .5);
22 |     width: 70px;
23 |     height: 70px;
24 |     border: 0;
25 |     border-radius: 35px;
26 |     text-align: center;
27 |     line-height: 68px;
28 | }
29 | 
30 | .superdev:active {
31 |     box-shadow: 0px 0px 0px 0px rgb(34,34,34),
32 |                 0px 3px 7px 0px rgb(17,17,17),
33 |                 inset 0px 1px 1px 0px rgba(250, 250, 250, .2),
34 |                 inset 0px -10px 35px 5px rgba(0, 0, 0, .5);
35 |     background-color: rgb(83,87,93);
36 |     top: 3px;
37 |     color: #fff;
38 |     text-shadow: 0px 0px 3px rgb(250,250,250);
39 | }
40 | 
41 | .superdev:hover {
42 |     background-color: rgb(100,100,100);
43 | }
44 | 
--------------------------------------------------------------------------------
/DungeonCrawler/settings.gradle:
--------------------------------------------------------------------------------
1 | include 'desktop', 'html', 'core'
--------------------------------------------------------------------------------
/Minicraft/.gitignore:
--------------------------------------------------------------------------------
 1 | ## Java
 2 | 
 3 | *.class
 4 | *.war
 5 | *.ear
 6 | hs_err_pid*
 7 | 
 8 | ## Robovm
 9 | robovm-build/
10 | 
11 | ## GWT
12 | war/
13 | html/war/gwt_bree/
14 | html/gwt-unitCache/
15 | .apt_generated/
16 | html/war/WEB-INF/deploy/
17 | html/war/WEB-INF/classes/
18 | .gwt/
19 | gwt-unitCache/
20 | www-test/
21 | .gwt-tmp/
22 | 
23 | ## Android Studio and Intellij and Android in general
24 | android/libs/armeabi/
25 | android/libs/armeabi-v7a/
26 | android/libs/arm64-v8a/
27 | android/libs/x86/
28 | android/libs/x86_64/
29 | android/gen/
30 | .idea/
31 | *.ipr
32 | *.iws
33 | *.iml
34 | out/
35 | com_crashlytics_export_strings.xml
36 | 
37 | ## Eclipse
38 | .classpath
39 | .project
40 | .metadata
41 | **/bin/
42 | tmp/
43 | *.tmp
44 | *.bak
45 | *.swp
46 | *~.nib
47 | local.properties
48 | .settings/
49 | .loadpath
50 | .externalToolBuilders/
51 | *.launch
52 | 
53 | ## NetBeans
54 | **/nbproject/private/
55 | build/
56 | nbbuild/
57 | dist/
58 | nbdist/
59 | nbactions.xml
60 | nb-configuration.xml
61 | 
62 | ## Gradle
63 | 
64 | .gradle
65 | gradle-app.setting
66 | build/
67 | 
68 | ## OS Specific
69 | .DS_Store
70 | Thumbs.db
71 | 
--------------------------------------------------------------------------------
/Minicraft/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 |         classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
10 |     }
11 | }
12 | 
13 | allprojects {
14 |     apply plugin: "eclipse"
15 |     apply plugin: "idea"
16 | 
17 |     version = '1.1'
18 |     ext {
19 |         appName = "Minicraft"
20 |         gdxVersion = '1.9.3'
21 |         roboVMVersion = '2.1.0'
22 |         box2DLightsVersion = '1.4'
23 |         ashleyVersion = '1.7.0'
24 |         aiVersion = '1.8.0'
25 |     }
26 | 
27 |     repositories {
28 |         mavenLocal()
29 |         mavenCentral()
30 |         maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
31 |         maven { url "https://oss.sonatype.org/content/repositories/releases/" }
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 |     }
44 | }
45 | 
46 | project(":html") {
47 |     apply plugin: "gwt"
48 |     apply plugin: "war"
49 | 
50 | 
51 |     dependencies {
52 |         compile project(":core")
53 |         compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
54 |         compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
55 |         compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
56 |     }
57 | }
58 | 
59 | project(":core") {
60 |     apply plugin: "java"
61 | 
62 | 
63 |     dependencies {
64 |         compile "com.badlogicgames.gdx:gdx:$gdxVersion"
65 |     }
66 | }
67 | 
68 | tasks.eclipse.doLast {
69 |     delete ".project"
70 | }
--------------------------------------------------------------------------------
/Minicraft/core/assets/bossdeath.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/Minicraft/core/assets/bossdeath.wav
--------------------------------------------------------------------------------
/Minicraft/core/assets/craft.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/Minicraft/core/assets/craft.wav
--------------------------------------------------------------------------------
/Minicraft/core/assets/death.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/Minicraft/core/assets/death.wav
--------------------------------------------------------------------------------
/Minicraft/core/assets/icons.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/Minicraft/core/assets/icons.png
--------------------------------------------------------------------------------
/Minicraft/core/assets/icons2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/Minicraft/core/assets/icons2.png
--------------------------------------------------------------------------------
/Minicraft/core/assets/monsterhurt.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/Minicraft/core/assets/monsterhurt.wav
--------------------------------------------------------------------------------
/Minicraft/core/assets/pickup.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/Minicraft/core/assets/pickup.wav
--------------------------------------------------------------------------------
/Minicraft/core/assets/playerhurt.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/Minicraft/core/assets/playerhurt.wav
--------------------------------------------------------------------------------
/Minicraft/core/assets/test.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/Minicraft/core/assets/test.wav
--------------------------------------------------------------------------------
/Minicraft/core/assets/tiles.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/Minicraft/core/assets/tiles.png
--------------------------------------------------------------------------------
/Minicraft/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 | 
--------------------------------------------------------------------------------
/Minicraft/core/src/MyGdxGame.gwt.xml:
--------------------------------------------------------------------------------
1 | 
2 | 
3 | 
4 | 	
5 | 
--------------------------------------------------------------------------------
/Minicraft/core/src/net/sekao/minicraft/Entities.java:
--------------------------------------------------------------------------------
  1 | package net.sekao.minicraft;
  2 | 
  3 | import com.badlogic.gdx.*;
  4 | import com.badlogic.gdx.graphics.*;
  5 | import com.badlogic.gdx.graphics.g2d.*;
  6 | import com.badlogic.gdx.maps.tiled.*;
  7 | import com.badlogic.gdx.maps.tiled.renderers.*;
  8 | import java.util.*;
  9 | 
 10 | public class Entities {
 11 | 	public static Entity create(String startLayer, TextureRegion down, TextureRegion up, TextureRegion standRight, TextureRegion walkRight) {
 12 | 		Entity player = new Entity();
 13 | 		player.width = 2;
 14 | 		player.height = 2;
 15 | 		player.xVelocity = 0;
 16 | 		player.yVelocity = 0;
 17 | 		player.minDistance = 5;
 18 | 		player.startLayer = startLayer;
 19 | 
 20 | 		float duration = 0.2f;
 21 | 		player.down = new Animation(duration, down, Utils.flipX(down));
 22 | 		player.up = new Animation(duration, up, Utils.flipX(up));
 23 | 		player.right = new Animation(duration, standRight, walkRight);
 24 | 		player.left = new Animation(duration, Utils.flipX(standRight), Utils.flipX(walkRight));
 25 | 
 26 | 		player.image = down;
 27 | 
 28 | 		return player;
 29 | 	}
 30 | 	
 31 | 	public static Entity create(String startLayer, TextureRegion down, TextureRegion up) {
 32 | 		Entity player = new Entity();
 33 | 		player.width = 2;
 34 | 		player.height = 2;
 35 | 		player.xVelocity = 0;
 36 | 		player.yVelocity = 0;
 37 | 		player.minDistance = 5;
 38 | 		player.startLayer = startLayer;
 39 | 
 40 | 		float duration = 0.2f;
 41 | 		Animation anim = new Animation(duration, down, up);
 42 | 		player.down = anim;
 43 | 		player.up = anim;
 44 | 		player.right = anim;
 45 | 		player.left = anim;
 46 | 
 47 | 		player.image = down;
 48 | 
 49 | 		return player;
 50 | 	}
 51 | 
 52 | 	public static Entity create(String startLayer, TextureRegion img) {
 53 | 		Entity player = new Entity();
 54 | 		player.width = 2;
 55 | 		player.height = 2;
 56 | 		player.xVelocity = 0;
 57 | 		player.yVelocity = 0;
 58 | 		player.startLayer = startLayer;
 59 | 		player.image = img;
 60 | 
 61 | 		return player;
 62 | 	}
 63 | 
 64 | 	public static boolean move(Entity e, Entity player, float delta) {
 65 | 		float maxVelocity = 5;
 66 | 		float maxNpcVelocity = 3;
 67 | 		
 68 | 		if (e.isMe == true) {
 69 | 			e.attackTime = Math.max(0, e.attackTime - delta);
 70 | 			
 71 | 			boolean downTouched = Gdx.input.isTouched() && Gdx.input.getY() > Gdx.graphics.getHeight() * 2 / 3;
 72 | 			if (Gdx.input.isKeyPressed(Input.Keys.DOWN) || downTouched) {
 73 | 				e.yVelocity = -1 * maxVelocity;
 74 | 			}
 75 | 			
 76 | 			boolean upTouched = Gdx.input.isTouched() && Gdx.input.getY() < Gdx.graphics.getHeight() / 3;
 77 | 			if (Gdx.input.isKeyPressed(Input.Keys.UP) || upTouched) {
 78 | 				e.yVelocity = maxVelocity;
 79 | 			}
 80 | 			
 81 | 			boolean leftTouched = Gdx.input.isTouched() && Gdx.input.getX() < Gdx.graphics.getWidth() / 3;
 82 | 			if (Gdx.input.isKeyPressed(Input.Keys.LEFT) || leftTouched) {
 83 | 				e.xVelocity = -1 * maxVelocity;
 84 | 			}
 85 | 			
 86 | 			boolean rightTouched = Gdx.input.isTouched() && Gdx.input.getX() > Gdx.graphics.getWidth() * 2 / 3;
 87 | 			if (Gdx.input.isKeyPressed(Input.Keys.RIGHT) || rightTouched) {
 88 | 				e.xVelocity = maxVelocity;
 89 | 			}
 90 | 		} else if (e.isNpc == true) {
 91 | 			if (e.attackTime == 0) {
 92 | 				e.attackTime = 1;
 93 | 			}
 94 | 			
 95 | 			e.attackTime = Math.max(0, e.attackTime - delta);
 96 | 			
 97 | 			if (Utils.isNearEntity(e, player, 6)) {
 98 | 				float xDiff = e.x - player.x;
 99 | 				float yDiff = e.y - player.y;
100 | 				float closeEnough = 1.5f;
101 | 				
102 | 				if (xDiff > closeEnough) {
103 | 					e.xVelocity = -1 * maxNpcVelocity;
104 | 				} else if (xDiff < -1 * closeEnough) {
105 | 					e.xVelocity = maxNpcVelocity;
106 | 				}
107 | 
108 | 				if (yDiff > closeEnough) {
109 | 					e.yVelocity = -1 * maxNpcVelocity;
110 | 				} else if (yDiff < -1 * closeEnough) {
111 | 					e.yVelocity = maxNpcVelocity;
112 | 				}
113 | 			} else if (e.attackTime == 0) {
114 | 				e.xVelocity = maxNpcVelocity * Utils.random();
115 | 				e.yVelocity = maxNpcVelocity * Utils.random();
116 | 			}
117 | 		}
118 | 
119 | 		e.xChange = e.xVelocity * delta;
120 | 		e.yChange = e.yVelocity * delta;
121 | 
122 | 		e.x = e.x + e.xChange;
123 | 		e.y = e.y + e.yChange;
124 | 
125 | 		e.xVelocity = Utils.decelerate(e.xVelocity);
126 | 		e.yVelocity = Utils.decelerate(e.yVelocity);
127 | 
128 | 		return e.xChange != 0 || e.yChange != 0;
129 | 	}
130 | 	
131 | 	public static void animate(Entity e, float time, TiledMap map) {
132 | 		Animation anim = null;
133 | 		if (e.yVelocity != 0) {
134 | 			if (e.yVelocity > 0) {
135 | 				anim = e.up;
136 | 				e.lastDirection = Entity.Direction.UP;
137 | 			} else {
138 | 				anim = e.down;
139 | 				e.lastDirection = Entity.Direction.DOWN;
140 | 			}
141 | 		} else if (e.xVelocity != 0) {
142 | 			if (e.xVelocity > 0) {
143 | 				anim = e.right;
144 | 				e.lastDirection = Entity.Direction.RIGHT;
145 | 			} else {
146 | 				anim = e.left;
147 | 				e.lastDirection = Entity.Direction.LEFT;
148 | 			}
149 | 		}
150 | 		
151 | 		if (anim != null) {
152 | 			e.image = anim.getKeyFrame(time, true);
153 | 		}
154 | 		
155 | 		if (Utils.isOnLayer(e, map, "water")) {
156 | 			e.image = new TextureRegion(e.image);
157 | 			e.image.setRegionHeight((int) Utils.pixelsPerTile);
158 | 		}
159 | 
160 | 		e.width = e.image.getRegionWidth() / Utils.pixelsPerTile;
161 | 		e.height = e.image.getRegionHeight() / Utils.pixelsPerTile;
162 | 	}
163 | 
164 | 	public static void preventMove(Entity e, ArrayList entities) {
165 | 		if (Utils.isNearEntity(e, entities, 1) || !Utils.isOnMap(e)) {
166 | 			e.x = e.x - e.xChange;
167 | 			e.y = e.y - e.yChange;
168 | 			e.xVelocity = 0;
169 | 			e.yVelocity = 0;
170 | 		}
171 | 	}
172 | 
173 | 	public static void attack(Entity e, ArrayList entities, Entity swipe, Entity hit, TiledMap map) {
174 | 		if (Utils.isOnLayer(e, map, "water")) {
175 | 			return;
176 | 		}
177 | 		
178 | 		Entity victim = null;
179 | 		for (Entity e2 : entities) {
180 | 			if (Utils.canAttack(e, e2)) {
181 | 				boolean xIsGood = false, yIsGood = false;
182 | 				switch (e.lastDirection) {
183 | 					case DOWN:
184 | 						xIsGood = true;
185 | 						yIsGood = e.y - e2.y > 0;
186 | 						break;
187 | 					case UP:
188 | 						xIsGood = true;
189 | 						yIsGood = e.y - e2.y < 0;
190 | 						break;
191 | 					case RIGHT:
192 | 						xIsGood = e.x - e2.x < 0;
193 | 						yIsGood = true;
194 | 						break;
195 | 					case LEFT:
196 | 						xIsGood = e.x - e2.x > 0;
197 | 						yIsGood = true;
198 | 						break;
199 | 				}
200 | 				if (xIsGood && yIsGood) {
201 | 					victim = e2;
202 | 					break;
203 | 				}
204 | 			}
205 | 		}
206 | 		
207 | 		if (e.isMe && e.health > 0) {
208 | 			swipe.related = e;
209 | 			swipe.drawTime = 0.2f;
210 | 		}
211 | 
212 | 		hit.related = victim;
213 | 		if (victim != null) {
214 | 			hit.drawTime = 0.2f;
215 | 			victim.health = Math.max(0, victim.health - e.damage);
216 | 			
217 | 			e.attackTime = Math.min(e.stamina, e.attackTime + 1);
218 | 			
219 | 			if (victim.isMe == true) {
220 | 				Utils.playerHurt.play();
221 | 				if (victim.health == 0) {
222 | 					Utils.death.play();
223 | 				}
224 | 			} else {
225 | 				Utils.monsterHurt.play();
226 | 			}
227 | 		}
228 | 	}
229 | 
230 | 	public static void animateSwipe(Entity swipe) {
231 | 		if (swipe.related == null) {
232 | 			return;
233 | 		}
234 | 		
235 | 		switch (swipe.related.lastDirection) {
236 | 			case DOWN:
237 | 				swipe.x = swipe.related.x;
238 | 				swipe.y = swipe.related.y - 1;
239 | 				swipe.image = swipe.down.getKeyFrame(0, true);
240 | 				break;
241 | 			case UP:
242 | 				swipe.x = swipe.related.x;
243 | 				swipe.y = swipe.related.y + 1;
244 | 				swipe.image = swipe.up.getKeyFrame(0, true);
245 | 				break;
246 | 			case RIGHT:
247 | 				swipe.x = swipe.related.x + 1;
248 | 				swipe.y = swipe.related.y;
249 | 				swipe.image = swipe.right.getKeyFrame(0, true);
250 | 				break;
251 | 			case LEFT:
252 | 				swipe.x = swipe.related.x - 1;
253 | 				swipe.y = swipe.related.y;
254 | 				swipe.image = swipe.left.getKeyFrame(0, true);
255 | 				break;
256 | 		}
257 | 	}
258 | 
259 | 	public static void animateHit(Entity hit) {
260 | 		if (hit.related == null) {
261 | 			return;
262 | 		}
263 | 		
264 | 		hit.x = hit.related.x;
265 | 		hit.y = hit.related.y - 0.1f;
266 | 	}
267 | }
268 | 
--------------------------------------------------------------------------------
/Minicraft/core/src/net/sekao/minicraft/Entity.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.minicraft;
 2 | 
 3 | import com.badlogic.gdx.*;
 4 | import com.badlogic.gdx.graphics.*;
 5 | import com.badlogic.gdx.graphics.g2d.*;
 6 | import java.util.*;
 7 | 
 8 | public class Entity implements Comparable {
 9 | 	float x, y;
10 | 	float xChange, yChange;
11 | 	float width, height;
12 | 	float xVelocity, yVelocity;
13 | 	TextureRegion image;
14 | 	Animation down, up, left, right;
15 | 	boolean isMe, isNpc;
16 | 	int minDistance = 2;
17 | 	String startLayer;
18 | 	float drawTime = -1;
19 | 	float attackTime = 0, stamina = 1;
20 | 	Entity related;
21 | 	int health, damage;
22 | 
23 | 	public int compareTo(Object o) {
24 | 		Entity e = (Entity) o;
25 | 		if (y > e.y) {
26 | 			return -1;
27 | 		}
28 | 		return 1;
29 | 	}
30 | 
31 | 	enum Direction {
32 | 		DOWN, UP, LEFT, RIGHT
33 | 	};
34 | 	Direction lastDirection = Direction.DOWN;
35 | }
36 | 
--------------------------------------------------------------------------------
/Minicraft/core/src/net/sekao/minicraft/MainScreen.java:
--------------------------------------------------------------------------------
  1 | package net.sekao.minicraft;
  2 | 
  3 | import com.badlogic.gdx.*;
  4 | import com.badlogic.gdx.graphics.*;
  5 | import com.badlogic.gdx.graphics.g2d.*;
  6 | import com.badlogic.gdx.math.*;
  7 | import com.badlogic.gdx.scenes.scene2d.*;
  8 | import com.badlogic.gdx.scenes.scene2d.ui.*;
  9 | import com.badlogic.gdx.maps.tiled.*;
 10 | import com.badlogic.gdx.maps.tiled.renderers.*;
 11 | import com.badlogic.gdx.utils.*;
 12 | import com.badlogic.gdx.utils.viewport.*;
 13 | import java.util.*;
 14 | 
 15 | public class MainScreen implements Screen {
 16 | 	TiledMap map;
 17 | 	Stage stage;
 18 | 	OrthogonalTiledMapRenderer renderer;
 19 | 	OrthographicCamera camera;
 20 | 	ArrayList entities;
 21 | 	Entity player, swipe, hit;
 22 | 	float time;
 23 | 	ArrayList hearts, bolts;
 24 | 	
 25 | 	public void show() {
 26 | 		time = 0;
 27 | 		
 28 | 		map = new TmxMapLoader().load("level1.tmx");
 29 | 		renderer = new OrthogonalTiledMapRenderer(map, 1 / Utils.pixelsPerTile);
 30 | 		
 31 | 		camera = new OrthographicCamera();
 32 | 
 33 | 		Utils.start = Gdx.audio.newSound(Gdx.files.internal("test.wav"));
 34 | 		Utils.playerHurt = Gdx.audio.newSound(Gdx.files.internal("playerhurt.wav"));
 35 | 		Utils.monsterHurt = Gdx.audio.newSound(Gdx.files.internal("monsterhurt.wav"));
 36 | 		Utils.death = Gdx.audio.newSound(Gdx.files.internal("death.wav"));
 37 | 		
 38 | 		Texture tiles = new Texture("tiles.png");
 39 | 		TextureRegion[][] grid = TextureRegion.split(tiles, 16, 16);
 40 | 		TextureRegion treeTexture = new TextureRegion(tiles, 0, 8, 16, 16);
 41 | 		TextureRegion cactusTexture = new TextureRegion(tiles, 16, 8, 16, 16);
 42 | 		TextureRegion attackDownTexture = new TextureRegion(tiles, 48, 0, 16, 8);
 43 | 		TextureRegion attackRightTexture = new TextureRegion(tiles, 32, 8, 8, 16);
 44 | 		TextureRegion hitTexture = new TextureRegion(tiles, 40, 8, 16, 16);
 45 | 		TextureRegion heartOffTexture = new TextureRegion(tiles, 64, 0, 8, 8);
 46 | 		TextureRegion boltOffTexture = new TextureRegion(tiles, 72, 0, 8, 8);
 47 | 		TextureRegion heartOnTexture = new TextureRegion(tiles, 80, 0, 8, 8);
 48 | 		TextureRegion boltOnTexture = new TextureRegion(tiles, 88, 0, 8, 8);
 49 | 		TextureRegion blackTexture = new TextureRegion(tiles, 0, 18, 1, 1);
 50 | 		
 51 | 		player = Entities.create("grass", grid[6][0], grid[6][1], grid[6][2], grid[6][3]);
 52 | 		player.isMe = true;
 53 | 		player.health = 10;
 54 | 		player.stamina = 5;
 55 | 		player.damage = 4;
 56 | 		
 57 | 		entities = new ArrayList();
 58 | 		entities.add(player);
 59 | 
 60 | 		swipe = Entities.create("grass", attackDownTexture, Utils.flipY(attackDownTexture), attackRightTexture, attackRightTexture);
 61 | 		swipe.drawTime = 0;
 62 | 		entities.add(swipe);
 63 | 		
 64 | 		hit = Entities.create("grass", hitTexture);
 65 | 		hit.drawTime = 0;
 66 | 		entities.add(hit);
 67 | 		
 68 | 		int zombieCount = 5;
 69 | 		while (zombieCount > 0) {
 70 | 			Entity zombie = Entities.create("grass", grid[6][4], grid[6][5], grid[6][6], grid[6][7]);
 71 | 			zombie.isNpc = true;
 72 | 			zombie.health = 10;
 73 | 			zombie.damage = 3;
 74 | 			entities.add(zombie);
 75 | 			zombieCount = zombieCount - 1;
 76 | 		}
 77 | 		
 78 | 		int slimeCount = 5;
 79 | 		while (slimeCount > 0) {
 80 | 			Entity slime = Entities.create("grass", grid[7][4], grid[7][5]);
 81 | 			slime.isNpc = true;
 82 | 			slime.health = 10;
 83 | 			slime.damage = 2;
 84 | 			entities.add(slime);
 85 | 			slimeCount = slimeCount - 1;
 86 | 		}
 87 | 
 88 | 		int treeCount = 100;
 89 | 		while (treeCount > 0) {
 90 | 			Entity tree = Entities.create("grass", treeTexture);
 91 | 			tree.health = 12;
 92 | 			entities.add(tree);
 93 | 			treeCount = treeCount - 1;
 94 | 		}
 95 | 
 96 | 		int cactusCount = 10;
 97 | 		while (cactusCount > 0) {
 98 | 			Entity cactus = Entities.create("desert", cactusTexture);
 99 | 			cactus.damage = 3;
100 | 			cactus.health = 12;
101 | 			entities.add(cactus);
102 | 			cactusCount = cactusCount - 1;
103 | 		}
104 | 		
105 | 		for (Entity e : entities) {
106 | 			ArrayList options = Utils.getLocationOptions(e.width, e.height, Utils.mapWidth, Utils.mapHeight);
107 | 			Utils.shuffle(options);
108 | 			for (Entity option : options) {
109 | 				if (Utils.isOnlyOnLayer(option, map, e.startLayer) && !Utils.isNearEntity(option, entities, e.minDistance)) {
110 | 					e.x = option.x;
111 | 					e.y = option.y;
112 | 					break;
113 | 				}
114 | 			}
115 | 		}
116 | 
117 | 		Gdx.input.setInputProcessor(new InputAdapter() {
118 | 			public boolean keyDown(int keycode) {
119 | 				if (keycode == Input.Keys.SPACE) {
120 | 					Entities.attack(player, entities, swipe, hit, map);
121 | 					return true;
122 | 				}
123 | 				return false;
124 | 			}
125 | 			
126 | 			public boolean touchDown(int screenX, int screenY, int pointer, int button) {
127 | 				int width = Gdx.graphics.getWidth();
128 | 				int height = Gdx.graphics.getHeight();
129 | 				int minX = width / 3, maxX = width * 2 / 3;
130 | 				int minY = height / 3, maxY = height * 2 / 3;
131 | 				if (screenX > minX && screenX < maxX && screenY > minY && screenY < maxY) {
132 | 					Entities.attack(player, entities, swipe, hit, map);
133 | 					return true;
134 | 				}
135 | 				return false;
136 | 			}
137 | 		});
138 | 		
139 | 		stage = new Stage();
140 | 		
141 | 		Image bar = Utils.createImage(stage, blackTexture, 0, 0);
142 | 		bar.setSize(Utils.stageWidth, Utils.pixelsPerTile * 2);
143 | 		
144 | 		hearts = new ArrayList();
145 | 		bolts = new ArrayList();
146 | 		
147 | 		int count = 0;
148 | 		while (count < player.health) {
149 | 			float x = count * Utils.pixelsPerTile;
150 | 			
151 | 			Utils.createImage(stage, heartOffTexture, x, Utils.pixelsPerTile);
152 | 			hearts.add(Utils.createImage(stage, heartOnTexture, x, Utils.pixelsPerTile));
153 | 			Utils.createImage(stage, boltOffTexture, x, 0);
154 | 			bolts.add(Utils.createImage(stage, boltOnTexture, x, 0));
155 | 			
156 | 			count++;
157 | 		}
158 | 
159 | 		Utils.start.play();
160 | 	}
161 | 	
162 | 	public void render(float delta) {
163 | 		time += delta;
164 | 		
165 | 		Gdx.gl.glClearColor(0, 0, 0, 0);
166 | 		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
167 | 		
168 | 		camera.position.x = player.x;
169 | 		camera.position.y = player.y;
170 | 		camera.update();
171 | 		
172 | 		renderer.setView(camera);
173 | 		renderer.render();
174 | 
175 | 		Collections.sort(entities);
176 | 
177 | 		Entities.animateSwipe(swipe);
178 | 		Entities.animateHit(hit);
179 | 
180 | 		Utils.updateImages(hearts, ((float) player.health) / 10);
181 | 		Utils.updateImages(bolts, (player.stamina - player.attackTime) / player.stamina);
182 | 		
183 | 		SpriteBatch batch = (SpriteBatch) renderer.getBatch();
184 | 		batch.begin();
185 | 		for (Entity e : entities) {
186 | 			if (e.drawTime > 0) {
187 | 				e.drawTime = Math.max(0, e.drawTime - delta);
188 | 			} else if (e.drawTime == 0 || e.health == 0) {
189 | 				continue;
190 | 			}
191 | 			if (Entities.move(e, player, delta)) {
192 | 				Entities.animate(e, time, map);
193 | 				Entities.preventMove(e, entities);
194 | 			}
195 | 			if (e.isNpc && Utils.canAttack(e, player)) {
196 | 				Entities.attack(e, entities, swipe, hit, map);
197 | 			}
198 | 			batch.draw(e.image, e.x, e.y, e.width, e.height);
199 | 		}
200 | 		batch.end();
201 | 
202 | 		//stage.draw();
203 | 	}
204 | 	
205 | 	public void dispose() {
206 | 	}
207 | 	
208 | 	public void hide() {
209 | 	}
210 | 	
211 | 	public void pause() {
212 | 	}
213 | 
214 | 	public void resize(int width, int height) {
215 | 		camera.setToOrtho(false, Utils.cameraHeight * width / height, Utils.cameraHeight);
216 | 		//stage.setViewport(Utils.stageWidth, Utils.stageWidth * height / width);
217 | 	}
218 | 
219 | 	public void resume() {
220 | 	}
221 | }
222 | 
--------------------------------------------------------------------------------
/Minicraft/core/src/net/sekao/minicraft/MyGdxGame.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.minicraft;
 2 | 
 3 | import com.badlogic.gdx.Game;
 4 | 
 5 | public class MyGdxGame extends Game {
 6 | 	public void create() {
 7 | 		this.setScreen(new MainScreen());
 8 | 	}
 9 | }
10 | 
11 | 
--------------------------------------------------------------------------------
/Minicraft/core/src/net/sekao/minicraft/Utils.java:
--------------------------------------------------------------------------------
  1 | package net.sekao.minicraft;
  2 | 
  3 | import com.badlogic.gdx.*;
  4 | import com.badlogic.gdx.audio.*;
  5 | import com.badlogic.gdx.graphics.*;
  6 | import com.badlogic.gdx.graphics.g2d.*;
  7 | import com.badlogic.gdx.maps.*;
  8 | import com.badlogic.gdx.maps.tiled.*;
  9 | import com.badlogic.gdx.maps.tiled.renderers.*;
 10 | import com.badlogic.gdx.scenes.scene2d.*;
 11 | import com.badlogic.gdx.scenes.scene2d.ui.*;
 12 | import java.util.*;
 13 | 
 14 | public class Utils {
 15 | 	public static float pixelsPerTile = 8;
 16 | 	public static int mapWidth = 50;
 17 | 	public static int mapHeight = 50;
 18 | 	public static float cameraHeight = 20;
 19 | 	public static float stageWidth = 150;
 20 | 	public static Sound start, playerHurt, monsterHurt, death;
 21 | 	
 22 | 	public static float decelerate(float velocity) {
 23 | 		float deceleration = 0.9f;
 24 | 		velocity = velocity * deceleration;
 25 | 		if (Math.abs(velocity) < 0.5f) {
 26 | 			velocity = 0;
 27 | 		}
 28 | 		return velocity;
 29 | 	}
 30 | 
 31 | 	public static TextureRegion flipX(TextureRegion t) {
 32 | 		TextureRegion t2 = new TextureRegion(t);
 33 | 		t2.flip(true, false);
 34 | 		return t2;
 35 | 	}
 36 | 
 37 | 	public static TextureRegion flipY(TextureRegion t) {
 38 | 		TextureRegion t2 = new TextureRegion(t);
 39 | 		t2.flip(false, true);
 40 | 		return t2;
 41 | 	}
 42 | 
 43 | 	public static boolean isOnLayer(Entity e, TiledMap map, String layerName) {
 44 | 		TiledMapTileLayer layer = (TiledMapTileLayer) map.getLayers().get(layerName);
 45 | 		
 46 | 		float endX = e.x + e.width;
 47 | 		float endY = e.y + e.height;
 48 | 		
 49 | 		int x = (int) e.x;
 50 | 		while (x < endX) {
 51 | 			
 52 | 			int y = (int) e.y;
 53 | 			while (y < endY) {
 54 | 				if (layer.getCell(x, y) == null) {
 55 | 					return false;
 56 | 				}
 57 | 				y = y + 1;
 58 | 			}
 59 | 			x = x + 1;
 60 | 		}
 61 | 		
 62 | 		return true;
 63 | 	}
 64 | 
 65 | 	public static boolean isOnlyOnLayer(Entity e, TiledMap map, String layerName) {
 66 | 		int count = map.getLayers().getCount();
 67 | 		while (count > 0) {
 68 | 			count = count - 1;
 69 | 			
 70 | 			String name = map.getLayers().get(count).getName();
 71 | 			if (name.equals("grass")) {
 72 | 				continue;
 73 | 			}
 74 | 
 75 | 			boolean isRequired = layerName.equals(name);
 76 | 			if (isOnLayer(e, map, name) != isRequired) {
 77 | 				return false;
 78 | 			}
 79 | 		}
 80 | 
 81 | 		return true;
 82 | 	}
 83 | 
 84 | 	public static boolean isNearEntity(Entity e, Entity e2, int minDistance) {
 85 | 		if (e == e2 || e2.drawTime != -1 || e.health == 0 || e2.health == 0) {
 86 | 			return false;
 87 | 		}
 88 | 		
 89 | 		float xDiff = Math.abs(e.x - e2.x);
 90 | 		float yDiff = Math.abs(e.y - e2.y);
 91 | 		
 92 | 		return xDiff < minDistance && yDiff < minDistance;
 93 | 	}
 94 | 
 95 | 	public static boolean isNearEntity(Entity e, ArrayList entities, int minDistance) {
 96 | 		for (Entity e2 : entities) {
 97 | 			if (isNearEntity(e, e2, minDistance)) {
 98 | 				return true;
 99 | 			}
100 | 		}
101 | 
102 | 		return false;
103 | 	}
104 | 
105 | 	public static ArrayList getLocationOptions(float width, float height, int mapWidth, int mapHeight) {
106 | 		ArrayList options = new ArrayList();
107 | 
108 | 		int endX = mapWidth - (int) width;
109 | 		int endY = mapHeight - (int) height;
110 | 
111 | 		int x = 0;
112 | 		while (x < endX) {
113 | 			
114 | 			int y = 0;
115 | 			while (y < endY) {
116 | 				Entity option = new Entity();
117 | 				option.x = x;
118 | 				option.y = y;
119 | 				option.width = width;
120 | 				option.height = height;
121 | 				options.add(option);
122 | 				
123 | 				y = y + 1;
124 | 			}
125 | 			x = x + 1;
126 | 		}
127 | 
128 | 		return options;
129 | 	}
130 | 
131 | 	public static boolean isOnMap(Entity e) {
132 | 		return e.x >= 0 && e.x < mapWidth - 1 && e.y >= 0 && e.y < mapHeight - 1;
133 | 	}
134 | 
135 | 	public static int random() {
136 | 		return (int) Math.round(Math.random() * 2 - 1);
137 | 	}
138 | 
139 | 	public static Image createImage(Stage s, TextureRegion t, float x, float y) {
140 | 		Image image = new Image(t);
141 | 		image.setPosition(x, y);
142 | 		s.addActor(image);
143 | 		return image;
144 | 	}
145 | 
146 | 	public static boolean canAttack(Entity e, Entity e2) {
147 | 		if (e.isNpc == true && e2.isMe != true) {
148 | 			return false;
149 | 		}
150 | 
151 | 		return e.stamina - e.attackTime >= 1 && Utils.isNearEntity(e, e2, 2);
152 | 	}
153 | 
154 | 	public static void updateImages(ArrayList images, float percent) {
155 | 		float num = images.size() * percent;
156 | 		for (Image i : images) {
157 | 			i.setVisible(num >= 1);
158 | 			num--;
159 | 		}
160 | 	}
161 | 	
162 | 	private static void swap(ArrayList list, int idx1, int idx2) {
163 |         Object o1 = list.get(idx1);
164 |         list.set(idx1, list.get(idx2));
165 |         list.set(idx2, o1);
166 | 	}
167 | 	
168 | 	public static void shuffle(ArrayList objects) {
169 | 	    for(int i = objects.size(); i > 1; i--) {
170 | 	    	swap(objects, i - 1, new Random().nextInt(i));
171 | 	    }
172 | 	}
173 | }
174 | 
--------------------------------------------------------------------------------
/Minicraft/desktop/build.gradle:
--------------------------------------------------------------------------------
 1 | apply plugin: "java"
 2 | 
 3 | sourceCompatibility = 1.6
 4 | sourceSets.main.java.srcDirs = [ "src/" ]
 5 | 
 6 | project.ext.mainClassName = "net.sekao.minicraft.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 dist(type: Jar) {
18 |     from files(sourceSets.main.output.classesDir)
19 |     from files(sourceSets.main.output.resourcesDir)
20 |     from {configurations.compile.collect {zipTree(it)}}
21 |     from files(project.assetsDir);
22 |  
23 |     manifest {
24 |         attributes 'Main-Class': project.mainClassName
25 |     }
26 | }
27 | 
28 | dist.dependsOn classes
29 | 
30 | eclipse {
31 |     project {
32 |         name = appName + "-desktop"
33 |         linkedResource name: 'assets', type: '2', location: 'PARENT-1-PROJECT_LOC/core/assets'
34 |     }
35 | }
36 | 
37 | task afterEclipseImport(description: "Post processing after project generation", group: "IDE") {
38 |   doLast {
39 |     def classpath = new XmlParser().parse(file(".classpath"))
40 |     new Node(classpath, "classpathentry", [ kind: 'src', path: 'assets' ]);
41 |     def writer = new FileWriter(file(".classpath"))
42 |     def printer = new XmlNodePrinter(new PrintWriter(writer))
43 |     printer.setPreserveWhitespace(true)
44 |     printer.print(classpath)
45 |   }
46 | }
--------------------------------------------------------------------------------
/Minicraft/desktop/src/net/sekao/minicraft/desktop/DesktopLauncher.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.minicraft.desktop;
 2 | 
 3 | import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
 4 | import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
 5 | import net.sekao.minicraft.MyGdxGame;
 6 | 
 7 | public class DesktopLauncher {
 8 | 	public static void main (String[] arg) {
 9 | 		LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
10 | 		new LwjglApplication(new MyGdxGame(), config);
11 | 	}
12 | }
13 | 
--------------------------------------------------------------------------------
/Minicraft/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.daemon=true
2 | org.gradle.jvmargs=-Xms128m -Xmx1500m
3 | org.gradle.configureondemand=true
4 | 
--------------------------------------------------------------------------------
/Minicraft/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/Minicraft/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Minicraft/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=http\://services.gradle.org/distributions/gradle-2.10-all.zip
7 | 
--------------------------------------------------------------------------------
/Minicraft/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 | 
--------------------------------------------------------------------------------
/Minicraft/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 | 
--------------------------------------------------------------------------------
/Minicraft/html/build.gradle:
--------------------------------------------------------------------------------
 1 | apply plugin: "java"
 2 | apply plugin: "jetty"
 3 | 
 4 | gwt {
 5 |     gwtVersion='2.6.0' // Should match the gwt version used for building the gwt backend
 6 |     maxHeapSize="1G" // Default 256m is not enough for gwt compiler. GWT is HUNGRY
 7 |     minHeapSize="1G"
 8 | 
 9 |     src = files(file("src/")) // Needs to be in front of "modules" below.
10 |     modules 'net.sekao.minicraft.GdxDefinition'
11 |     devModules 'net.sekao.minicraft.GdxDefinitionSuperdev'
12 |     project.webAppDirName = 'webapp'
13 | 
14 |     compiler {
15 |         strict = true;
16 |         enableClosureCompiler = true;
17 |         disableCastChecking = true;
18 |     }
19 | }
20 | 
21 | task draftRun(type: JettyRunWar) {
22 |     dependsOn draftWar
23 |     dependsOn.remove('war')
24 |     webApp=draftWar.archivePath
25 |     daemon=true
26 | }
27 | 
28 | task superDev(type: de.richsource.gradle.plugins.gwt.GwtSuperDev) {
29 |     dependsOn draftRun
30 |     doFirst {
31 |     	gwt.modules = gwt.devModules
32 |     }
33 | }
34 | 
35 | task dist(dependsOn: [clean, compileGwt]) {
36 |     doLast {
37 |         file("build/dist").mkdirs()
38 |         copy {
39 |             from "build/gwt/out"
40 |             into "build/dist"
41 |         }
42 |         copy {
43 |             from "webapp"
44 |             into "build/dist"
45 |             }
46 |         copy {
47 |             from "war"
48 |             into "build/dist"
49 |         }
50 |     }
51 | }
52 | 
53 | draftWar {
54 |    from "war"
55 | }
56 | 
57 | task addSource << {
58 | 	sourceSets.main.compileClasspath += files(project(':core').sourceSets.main.allJava.srcDirs)
59 | }
60 | 
61 | tasks.compileGwt.dependsOn(addSource)
62 | tasks.draftCompileGwt.dependsOn(addSource)
63 | 
64 | sourceCompatibility = 1.6
65 | sourceSets.main.java.srcDirs = [ "src/" ]
66 | 
67 | 
68 | eclipse.project {
69 |     name = appName + "-html"
70 | }
71 | 
--------------------------------------------------------------------------------
/Minicraft/html/src/net/sekao/minicraft/GdxDefinition.gwt.xml:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 | 
 4 | 	
 5 | 
 6 | 	
 7 | 	
 8 | 	
 9 | 	
10 | 
11 | 
--------------------------------------------------------------------------------
/Minicraft/html/src/net/sekao/minicraft/GdxDefinitionSuperdev.gwt.xml:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 | 
 4 | 	
 5 | 
 6 |     
 7 |     
 8 |     
 9 |     
10 | 		
11 | 	
12 | 		
13 | 
14 | 
--------------------------------------------------------------------------------
/Minicraft/html/src/net/sekao/minicraft/client/HtmlLauncher.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.minicraft.client;
 2 | 
 3 | import com.badlogic.gdx.ApplicationListener;
 4 | import com.badlogic.gdx.backends.gwt.GwtApplication;
 5 | import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
 6 | import net.sekao.minicraft.MyGdxGame;
 7 | 
 8 | public class HtmlLauncher extends GwtApplication {
 9 | 
10 |         @Override
11 |         public GwtApplicationConfiguration getConfig () {
12 |                 return new GwtApplicationConfiguration(800, 600);
13 |         }
14 | 
15 |         @Override
16 |         public ApplicationListener createApplicationListener () {
17 |                 return new MyGdxGame();
18 |         }
19 | }
20 | 
--------------------------------------------------------------------------------
/Minicraft/html/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 | 
2 | 
3 | 
--------------------------------------------------------------------------------
/Minicraft/html/webapp/index.html:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 |        
 4 |               Minicraft
 5 |               
 6 |               
 7 |               
 8 |   			  
 9 |        
10 | 
11 |        
12 |               ↻
13 |               
14 |               
15 |        
16 | 
17 |        
32 | 
33 | 
--------------------------------------------------------------------------------
/Minicraft/html/webapp/refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/Minicraft/html/webapp/refresh.png
--------------------------------------------------------------------------------
/Minicraft/html/webapp/soundmanager2-setup.js:
--------------------------------------------------------------------------------
1 | window.SM2_DEFER = true;
--------------------------------------------------------------------------------
/Minicraft/html/webapp/styles.css:
--------------------------------------------------------------------------------
 1 | canvas {
 2 |     cursor: default;
 3 |     outline: none;
 4 | }
 5 | 
 6 | body {
 7 |     background-color: #222222;
 8 | }
 9 | 
10 | .superdev {
11 |     color: rgb(37,37,37);
12 |     text-shadow: 0px 1px 1px rgba(250,250,250,0.1);
13 |     font-size: 50pt;
14 |     display: block;
15 |     position: relative;
16 |     text-decoration: none;
17 |     background-color: rgb(83,87,93);
18 |     box-shadow: 0px 3px 0px 0px rgb(34,34,34),
19 |                 0px 7px 10px 0px rgb(17,17,17),
20 |                 inset 0px 1px 1px 0px rgba(250, 250, 250, .2),
21 |                 inset 0px -12px 35px 0px rgba(0, 0, 0, .5);
22 |     width: 70px;
23 |     height: 70px;
24 |     border: 0;
25 |     border-radius: 35px;
26 |     text-align: center;
27 |     line-height: 68px;
28 | }
29 | 
30 | .superdev:active {
31 |     box-shadow: 0px 0px 0px 0px rgb(34,34,34),
32 |                 0px 3px 7px 0px rgb(17,17,17),
33 |                 inset 0px 1px 1px 0px rgba(250, 250, 250, .2),
34 |                 inset 0px -10px 35px 5px rgba(0, 0, 0, .5);
35 |     background-color: rgb(83,87,93);
36 |     top: 3px;
37 |     color: #fff;
38 |     text-shadow: 0px 0px 3px rgb(250,250,250);
39 | }
40 | 
41 | .superdev:hover {
42 |     background-color: rgb(100,100,100);
43 | }
44 | 
--------------------------------------------------------------------------------
/Minicraft/settings.gradle:
--------------------------------------------------------------------------------
1 | include 'desktop', 'html', 'core'
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
 1 | Here are a few libGDX games I made in Java. You can run them in your browser or download JAR files that you can run locally. None of them are finished, but they might help those who are interested in learning libGDX. They are basically the Java equivalents of some of the games in [play-clj-examples](https://github.com/oakes/play-clj-examples). All files that originate from this project are dedicated to the public domain.
 2 | 
 3 | * Breakout - [HTML5](http://oakes.github.io/libgdx-examples/breakout/) or [JAR](https://github.com/oakes/libgdx-examples/releases/download/1.1/breakout.jar)
 4 | * Dungeon Crawler - [HTML5](http://oakes.github.io/libgdx-examples/dungeon-crawler) or [JAR](https://github.com/oakes/libgdx-examples/releases/download/1.1/dungeon-crawler.jar)
 5 | * Minicraft - [HTML5](http://oakes.github.io/libgdx-examples/minicraft/) or [JAR](https://github.com/oakes/libgdx-examples/releases/download/1.1/minicraft.jar) [1]
 6 | * Super Koalio - [HTML5](http://oakes.github.io/libgdx-examples/super-koalio/) or [JAR](https://github.com/oakes/libgdx-examples/releases/download/1.1/super-koalio.jar) [2]
 7 | * Tetris - [JAR](https://github.com/oakes/libgdx-examples/releases/download/1.1/tetris.jar) [3]
 8 | 
 9 | [1] Based on Notch's [Ludum Dare entry](http://www.ludumdare.com/compo/ludum-dare-22/?action=preview&uid=398)
10 | 
11 | [2] Based on a libGDX [test game](https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests/src/com/badlogic/gdx/tests/superkoalio/SuperKoalio.java)
12 | 
13 | [3] I used a bizarre technique in the tetris game, using a low-level libGDX feature to count the pixels on the screen. As a result, I was unable to compile an HTML5 version.
14 | 
--------------------------------------------------------------------------------
/SuperKoalio/.gitignore:
--------------------------------------------------------------------------------
 1 | ## Java
 2 | 
 3 | *.class
 4 | *.war
 5 | *.ear
 6 | hs_err_pid*
 7 | 
 8 | ## Robovm
 9 | robovm-build/
10 | 
11 | ## GWT
12 | war/
13 | html/war/gwt_bree/
14 | html/gwt-unitCache/
15 | .apt_generated/
16 | html/war/WEB-INF/deploy/
17 | html/war/WEB-INF/classes/
18 | .gwt/
19 | gwt-unitCache/
20 | www-test/
21 | .gwt-tmp/
22 | 
23 | ## Android Studio and Intellij and Android in general
24 | android/libs/armeabi/
25 | android/libs/armeabi-v7a/
26 | android/libs/arm64-v8a/
27 | android/libs/x86/
28 | android/libs/x86_64/
29 | android/gen/
30 | .idea/
31 | *.ipr
32 | *.iws
33 | *.iml
34 | out/
35 | com_crashlytics_export_strings.xml
36 | 
37 | ## Eclipse
38 | .classpath
39 | .project
40 | .metadata
41 | **/bin/
42 | tmp/
43 | *.tmp
44 | *.bak
45 | *.swp
46 | *~.nib
47 | local.properties
48 | .settings/
49 | .loadpath
50 | .externalToolBuilders/
51 | *.launch
52 | 
53 | ## NetBeans
54 | **/nbproject/private/
55 | build/
56 | nbbuild/
57 | dist/
58 | nbdist/
59 | nbactions.xml
60 | nb-configuration.xml
61 | 
62 | ## Gradle
63 | 
64 | .gradle
65 | gradle-app.setting
66 | build/
67 | 
68 | ## OS Specific
69 | .DS_Store
70 | Thumbs.db
71 | 
--------------------------------------------------------------------------------
/SuperKoalio/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 |         classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
10 |     }
11 | }
12 | 
13 | allprojects {
14 |     apply plugin: "eclipse"
15 |     apply plugin: "idea"
16 | 
17 |     version = '1.1'
18 |     ext {
19 |         appName = "SuperKoalio"
20 |         gdxVersion = '1.9.3'
21 |         roboVMVersion = '2.1.0'
22 |         box2DLightsVersion = '1.4'
23 |         ashleyVersion = '1.7.0'
24 |         aiVersion = '1.8.0'
25 |     }
26 | 
27 |     repositories {
28 |         mavenLocal()
29 |         mavenCentral()
30 |         maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
31 |         maven { url "https://oss.sonatype.org/content/repositories/releases/" }
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 |     }
44 | }
45 | 
46 | project(":html") {
47 |     apply plugin: "gwt"
48 |     apply plugin: "war"
49 | 
50 | 
51 |     dependencies {
52 |         compile project(":core")
53 |         compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
54 |         compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
55 |         compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
56 |     }
57 | }
58 | 
59 | project(":core") {
60 |     apply plugin: "java"
61 | 
62 | 
63 |     dependencies {
64 |         compile "com.badlogicgames.gdx:gdx:$gdxVersion"
65 |     }
66 | }
67 | 
68 | tasks.eclipse.doLast {
69 |     delete ".project"
70 | }
71 | 
--------------------------------------------------------------------------------
/SuperKoalio/core/assets/koalio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/SuperKoalio/core/assets/koalio.png
--------------------------------------------------------------------------------
/SuperKoalio/core/assets/tileSet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/SuperKoalio/core/assets/tileSet.png
--------------------------------------------------------------------------------
/SuperKoalio/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 | 
--------------------------------------------------------------------------------
/SuperKoalio/core/src/MyGdxGame.gwt.xml:
--------------------------------------------------------------------------------
1 | 
2 | 
3 | 
4 | 	
5 | 
--------------------------------------------------------------------------------
/SuperKoalio/core/src/net/sekao/superkoalio/Koala.java:
--------------------------------------------------------------------------------
  1 | package net.sekao.superkoalio;
  2 | 
  3 | import com.badlogic.gdx.*;
  4 | import com.badlogic.gdx.graphics.*;
  5 | import com.badlogic.gdx.graphics.g2d.*;
  6 | import com.badlogic.gdx.maps.tiled.*;
  7 | import com.badlogic.gdx.scenes.scene2d.ui.*;
  8 | 
  9 | public class Koala extends Image {
 10 |     TextureRegion stand, jump;
 11 |     Animation walk;
 12 | 
 13 |     float time = 0;
 14 |     float xVelocity = 0;
 15 |     float yVelocity = 0;
 16 |     boolean canJump = false;
 17 |     boolean isFacingRight = true;
 18 |     TiledMapTileLayer layer;
 19 | 
 20 |     final float GRAVITY = -2.5f;
 21 |     final float MAX_VELOCITY = 10f;
 22 |     final float DAMPING = 0.87f;
 23 | 
 24 |     public Koala() {
 25 |         final float width = 18;
 26 |         final float height = 26;
 27 |         this.setSize(1, height / width);
 28 | 
 29 |         Texture koalaTexture = new Texture("koalio.png");
 30 |         TextureRegion[][] grid = TextureRegion.split(koalaTexture, (int) width, (int) height);
 31 | 
 32 |         stand = grid[0][0];
 33 |         jump = grid[0][1];
 34 |         walk = new Animation(0.15f, grid[0][2], grid[0][3], grid[0][4]);
 35 |         walk.setPlayMode(Animation.PlayMode.LOOP_PINGPONG);
 36 |     }
 37 | 
 38 |     public void act(float delta) {
 39 |         time = time + delta;
 40 | 
 41 |         boolean upTouched = Gdx.input.isTouched() && Gdx.input.getY() < Gdx.graphics.getHeight() / 2;
 42 |         if (Gdx.input.isKeyPressed(Input.Keys.UP) || upTouched) {
 43 |             if (canJump) {
 44 |                 yVelocity = yVelocity + MAX_VELOCITY * 4;
 45 |             }
 46 |             canJump = false;
 47 |         }
 48 | 
 49 |         boolean leftTouched = Gdx.input.isTouched() && Gdx.input.getX() < Gdx.graphics.getWidth() / 3;
 50 |         if (Gdx.input.isKeyPressed(Input.Keys.LEFT) || leftTouched) {
 51 |             xVelocity = -1 * MAX_VELOCITY;
 52 |             isFacingRight = false;
 53 |         }
 54 | 
 55 |         boolean rightTouched = Gdx.input.isTouched() && Gdx.input.getX() > Gdx.graphics.getWidth() * 2 / 3;
 56 |         if (Gdx.input.isKeyPressed(Input.Keys.RIGHT) || rightTouched) {
 57 |             xVelocity = MAX_VELOCITY;
 58 |             isFacingRight = true;
 59 |         }
 60 | 
 61 |         yVelocity = yVelocity + GRAVITY;
 62 | 
 63 |         float x = this.getX();
 64 |         float y = this.getY();
 65 |         float xChange = xVelocity * delta;
 66 |         float yChange = yVelocity * delta;
 67 | 
 68 |         if (canMoveTo(x + xChange, y, false) == false) {
 69 |             xVelocity = xChange = 0;
 70 |         }
 71 | 
 72 |         if (canMoveTo(x, y + yChange, yVelocity > 0) == false) {
 73 |             canJump = yVelocity < 0;
 74 |             yVelocity = yChange = 0;
 75 |         }
 76 | 
 77 |         this.setPosition(x + xChange, y + yChange);
 78 | 
 79 |         xVelocity = xVelocity * DAMPING;
 80 |         if (Math.abs(xVelocity) < 0.5f) {
 81 |             xVelocity = 0;
 82 |         }
 83 |     }
 84 | 
 85 |     public void draw(Batch batch, float parentAlpha) {
 86 |         TextureRegion frame;
 87 | 
 88 |         if (yVelocity != 0) {
 89 |             frame = jump;
 90 |         } else if (xVelocity != 0) {
 91 |             frame = walk.getKeyFrame(time);
 92 |         } else {
 93 |             frame = stand;
 94 |         }
 95 | 
 96 |         if (isFacingRight) {
 97 |             batch.draw(frame, this.getX(), this.getY(), this.getWidth(), this.getHeight());
 98 |         } else {
 99 |             batch.draw(frame, this.getX() + this.getWidth(), this.getY(), -1 * this.getWidth(), this.getHeight());
100 |         }
101 |     }
102 | 
103 |     private boolean canMoveTo(float startX, float startY, boolean shouldDestroy) {
104 |         float endX = startX + this.getWidth();
105 |         float endY = startY + this.getHeight();
106 | 
107 |         int x = (int) startX;
108 |         while (x < endX) {
109 | 
110 |             int y = (int) startY;
111 |             while (y < endY) {
112 |                 if (layer.getCell(x, y) != null) {
113 |                     if (shouldDestroy) {
114 |                         layer.setCell(x, y, null);
115 |                     }
116 |                     return false;
117 |                 }
118 |                 y = y + 1;
119 |             }
120 |             x = x + 1;
121 |         }
122 | 
123 |         return true;
124 |     }
125 | }
126 | 
--------------------------------------------------------------------------------
/SuperKoalio/core/src/net/sekao/superkoalio/MainScreen.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.superkoalio;
 2 | 
 3 | import com.badlogic.gdx.*;
 4 | import com.badlogic.gdx.graphics.*;
 5 | import com.badlogic.gdx.maps.tiled.*;
 6 | import com.badlogic.gdx.maps.tiled.renderers.*;
 7 | import com.badlogic.gdx.scenes.scene2d.*;
 8 | 
 9 | public class MainScreen implements Screen {
10 |     Stage stage;
11 |     TiledMap map;
12 |     OrthogonalTiledMapRenderer renderer;
13 |     OrthographicCamera camera;
14 |     Koala koala;
15 | 
16 |     public void show() {
17 |         map = new TmxMapLoader().load("level1.tmx");
18 |         final float pixelsPerTile = 16;
19 |         renderer = new OrthogonalTiledMapRenderer(map, 1 / pixelsPerTile);
20 |         camera = new OrthographicCamera();
21 | 
22 |         stage = new Stage();
23 |         stage.getViewport().setCamera(camera);
24 | 
25 |         koala = new Koala();
26 |         koala.layer = (TiledMapTileLayer) map.getLayers().get("walls");
27 |         koala.setPosition(20, 10);
28 |         stage.addActor(koala);
29 |     }
30 | 
31 |     public void render(float delta) {
32 |         Gdx.gl.glClearColor(0.5f, 0.5f, 1, 1);
33 |         Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
34 | 
35 |         camera.position.x = koala.getX();
36 |         camera.update();
37 | 
38 |         renderer.setView(camera);
39 |         renderer.render();
40 | 
41 |         stage.act(delta);
42 |         stage.draw();
43 |     }
44 | 
45 |     public void dispose() {
46 |     }
47 | 
48 |     public void hide() {
49 |     }
50 | 
51 |     public void pause() {
52 |     }
53 | 
54 |     public void resize(int width, int height) {
55 |         camera.setToOrtho(false, 20 * width / height, 20);
56 |     }
57 | 
58 |     public void resume() {
59 |     }
60 | }
61 | 
--------------------------------------------------------------------------------
/SuperKoalio/core/src/net/sekao/superkoalio/MyGdxGame.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.superkoalio;
 2 | 
 3 | import com.badlogic.gdx.Game;
 4 | import net.sekao.superkoalio.MainScreen;
 5 | 
 6 | public class MyGdxGame extends Game {
 7 | 	public void create() {
 8 | 		this.setScreen(new MainScreen());
 9 | 	}
10 | }
11 | 
--------------------------------------------------------------------------------
/SuperKoalio/desktop/build.gradle:
--------------------------------------------------------------------------------
 1 | apply plugin: "java"
 2 | 
 3 | sourceCompatibility = 1.6
 4 | sourceSets.main.java.srcDirs = [ "src/" ]
 5 | 
 6 | project.ext.mainClassName = "net.sekao.superkoalio.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 dist(type: Jar) {
18 |     from files(sourceSets.main.output.classesDir)
19 |     from files(sourceSets.main.output.resourcesDir)
20 |     from {configurations.compile.collect {zipTree(it)}}
21 |     from files(project.assetsDir);
22 |  
23 |     manifest {
24 |         attributes 'Main-Class': project.mainClassName
25 |     }
26 | }
27 | 
28 | dist.dependsOn classes
29 | 
30 | eclipse {
31 |     project {
32 |         name = appName + "-desktop"
33 |         linkedResource name: 'assets', type: '2', location: 'PARENT-1-PROJECT_LOC/core/assets'
34 |     }
35 | }
36 | 
37 | task afterEclipseImport(description: "Post processing after project generation", group: "IDE") {
38 |   doLast {
39 |     def classpath = new XmlParser().parse(file(".classpath"))
40 |     new Node(classpath, "classpathentry", [ kind: 'src', path: 'assets' ]);
41 |     def writer = new FileWriter(file(".classpath"))
42 |     def printer = new XmlNodePrinter(new PrintWriter(writer))
43 |     printer.setPreserveWhitespace(true)
44 |     printer.print(classpath)
45 |   }
46 | }
--------------------------------------------------------------------------------
/SuperKoalio/desktop/src/net/sekao/superkoalio/desktop/DesktopLauncher.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.superkoalio.desktop;
 2 | 
 3 | import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
 4 | import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
 5 | import net.sekao.superkoalio.MyGdxGame;
 6 | 
 7 | public class DesktopLauncher {
 8 | 	public static void main (String[] arg) {
 9 | 		LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
10 | 		new LwjglApplication(new MyGdxGame(), config);
11 | 	}
12 | }
13 | 
--------------------------------------------------------------------------------
/SuperKoalio/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.daemon=true
2 | org.gradle.jvmargs=-Xms128m -Xmx1500m
3 | org.gradle.configureondemand=true
4 | 
--------------------------------------------------------------------------------
/SuperKoalio/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/SuperKoalio/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/SuperKoalio/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=http\://services.gradle.org/distributions/gradle-2.10-all.zip
7 | 
--------------------------------------------------------------------------------
/SuperKoalio/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 | 
--------------------------------------------------------------------------------
/SuperKoalio/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 | 
--------------------------------------------------------------------------------
/SuperKoalio/html/build.gradle:
--------------------------------------------------------------------------------
 1 | apply plugin: "java"
 2 | apply plugin: "jetty"
 3 | 
 4 | gwt {
 5 |     gwtVersion='2.6.0' // Should match the gwt version used for building the gwt backend
 6 |     maxHeapSize="1G" // Default 256m is not enough for gwt compiler. GWT is HUNGRY
 7 |     minHeapSize="1G"
 8 | 
 9 |     src = files(file("src/")) // Needs to be in front of "modules" below.
10 |     modules 'net.sekao.superkoalio.GdxDefinition'
11 |     devModules 'net.sekao.superkoalio.GdxDefinitionSuperdev'
12 |     project.webAppDirName = 'webapp'
13 | 
14 |     compiler {
15 |         strict = true;
16 |         enableClosureCompiler = true;
17 |         disableCastChecking = true;
18 |     }
19 | }
20 | 
21 | task draftRun(type: JettyRunWar) {
22 |     dependsOn draftWar
23 |     dependsOn.remove('war')
24 |     webApp=draftWar.archivePath
25 |     daemon=true
26 | }
27 | 
28 | task superDev(type: de.richsource.gradle.plugins.gwt.GwtSuperDev) {
29 |     dependsOn draftRun
30 |     doFirst {
31 |     	gwt.modules = gwt.devModules
32 |     }
33 | }
34 | 
35 | task dist(dependsOn: [clean, compileGwt]) {
36 |     doLast {
37 |         file("build/dist").mkdirs()
38 |         copy {
39 |             from "build/gwt/out"
40 |             into "build/dist"
41 |         }
42 |         copy {
43 |             from "webapp"
44 |             into "build/dist"
45 |             }
46 |         copy {
47 |             from "war"
48 |             into "build/dist"
49 |         }
50 |     }
51 | }
52 | 
53 | draftWar {
54 |    from "war"
55 | }
56 | 
57 | task addSource << {
58 | 	sourceSets.main.compileClasspath += files(project(':core').sourceSets.main.allJava.srcDirs)
59 | }
60 | 
61 | tasks.compileGwt.dependsOn(addSource)
62 | tasks.draftCompileGwt.dependsOn(addSource)
63 | 
64 | sourceCompatibility = 1.6
65 | sourceSets.main.java.srcDirs = [ "src/" ]
66 | 
67 | 
68 | eclipse.project {
69 |     name = appName + "-html"
70 | }
71 | 
--------------------------------------------------------------------------------
/SuperKoalio/html/src/net/sekao/superkoalio/GdxDefinition.gwt.xml:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 | 
 4 | 	
 5 | 
 6 | 	
 7 | 	
 8 | 	
 9 | 	
10 | 
11 | 
--------------------------------------------------------------------------------
/SuperKoalio/html/src/net/sekao/superkoalio/GdxDefinitionSuperdev.gwt.xml:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 | 
 4 | 	
 5 | 
 6 |     
 7 |     
 8 |     
 9 |     
10 | 		
11 | 	
12 | 		
13 | 
14 | 
--------------------------------------------------------------------------------
/SuperKoalio/html/src/net/sekao/superkoalio/client/HtmlLauncher.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.superkoalio.client;
 2 | 
 3 | import com.badlogic.gdx.ApplicationListener;
 4 | import com.badlogic.gdx.backends.gwt.GwtApplication;
 5 | import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
 6 | import net.sekao.superkoalio.MyGdxGame;
 7 | 
 8 | public class HtmlLauncher extends GwtApplication {
 9 | 
10 |         @Override
11 |         public GwtApplicationConfiguration getConfig () {
12 |                 return new GwtApplicationConfiguration(800, 600);
13 |         }
14 | 
15 |         @Override
16 |         public ApplicationListener createApplicationListener () {
17 |                 return new MyGdxGame();
18 |         }
19 | }
20 | 
--------------------------------------------------------------------------------
/SuperKoalio/html/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 | 
2 | 
3 | 
--------------------------------------------------------------------------------
/SuperKoalio/html/webapp/index.html:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 |        
 4 |               SuperKoalio
 5 |               
 6 |               
 7 |               
 8 |   			  
 9 |        
10 | 
11 |        
12 |               ↻
13 |               
14 |               
15 |        
16 | 
17 |        
32 | 
33 | 
--------------------------------------------------------------------------------
/SuperKoalio/html/webapp/refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/SuperKoalio/html/webapp/refresh.png
--------------------------------------------------------------------------------
/SuperKoalio/html/webapp/soundmanager2-setup.js:
--------------------------------------------------------------------------------
1 | window.SM2_DEFER = true;
--------------------------------------------------------------------------------
/SuperKoalio/html/webapp/styles.css:
--------------------------------------------------------------------------------
 1 | canvas {
 2 |     cursor: default;
 3 |     outline: none;
 4 | }
 5 | 
 6 | body {
 7 |     background-color: #222222;
 8 | }
 9 | 
10 | .superdev {
11 |     color: rgb(37,37,37);
12 |     text-shadow: 0px 1px 1px rgba(250,250,250,0.1);
13 |     font-size: 50pt;
14 |     display: block;
15 |     position: relative;
16 |     text-decoration: none;
17 |     background-color: rgb(83,87,93);
18 |     box-shadow: 0px 3px 0px 0px rgb(34,34,34),
19 |                 0px 7px 10px 0px rgb(17,17,17),
20 |                 inset 0px 1px 1px 0px rgba(250, 250, 250, .2),
21 |                 inset 0px -12px 35px 0px rgba(0, 0, 0, .5);
22 |     width: 70px;
23 |     height: 70px;
24 |     border: 0;
25 |     border-radius: 35px;
26 |     text-align: center;
27 |     line-height: 68px;
28 | }
29 | 
30 | .superdev:active {
31 |     box-shadow: 0px 0px 0px 0px rgb(34,34,34),
32 |                 0px 3px 7px 0px rgb(17,17,17),
33 |                 inset 0px 1px 1px 0px rgba(250, 250, 250, .2),
34 |                 inset 0px -10px 35px 5px rgba(0, 0, 0, .5);
35 |     background-color: rgb(83,87,93);
36 |     top: 3px;
37 |     color: #fff;
38 |     text-shadow: 0px 0px 3px rgb(250,250,250);
39 | }
40 | 
41 | .superdev:hover {
42 |     background-color: rgb(100,100,100);
43 | }
44 | 
--------------------------------------------------------------------------------
/SuperKoalio/settings.gradle:
--------------------------------------------------------------------------------
1 | include 'desktop', 'html', 'core'
--------------------------------------------------------------------------------
/Tetris/.gitignore:
--------------------------------------------------------------------------------
 1 | ## Java
 2 | 
 3 | *.class
 4 | *.war
 5 | *.ear
 6 | hs_err_pid*
 7 | 
 8 | ## Robovm
 9 | robovm-build/
10 | 
11 | ## GWT
12 | war/
13 | html/war/gwt_bree/
14 | html/gwt-unitCache/
15 | .apt_generated/
16 | html/war/WEB-INF/deploy/
17 | html/war/WEB-INF/classes/
18 | .gwt/
19 | gwt-unitCache/
20 | www-test/
21 | .gwt-tmp/
22 | 
23 | ## Android Studio and Intellij and Android in general
24 | android/libs/armeabi/
25 | android/libs/armeabi-v7a/
26 | android/libs/arm64-v8a/
27 | android/libs/x86/
28 | android/libs/x86_64/
29 | android/gen/
30 | .idea/
31 | *.ipr
32 | *.iws
33 | *.iml
34 | out/
35 | com_crashlytics_export_strings.xml
36 | 
37 | ## Eclipse
38 | .classpath
39 | .project
40 | .metadata
41 | **/bin/
42 | tmp/
43 | *.tmp
44 | *.bak
45 | *.swp
46 | *~.nib
47 | local.properties
48 | .settings/
49 | .loadpath
50 | .externalToolBuilders/
51 | *.launch
52 | 
53 | ## NetBeans
54 | **/nbproject/private/
55 | build/
56 | nbbuild/
57 | dist/
58 | nbdist/
59 | nbactions.xml
60 | nb-configuration.xml
61 | 
62 | ## Gradle
63 | 
64 | .gradle
65 | gradle-app.setting
66 | build/
67 | 
68 | ## OS Specific
69 | .DS_Store
70 | Thumbs.db
71 | 
--------------------------------------------------------------------------------
/Tetris/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 |         classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
10 |     }
11 | }
12 | 
13 | allprojects {
14 |     apply plugin: "eclipse"
15 |     apply plugin: "idea"
16 | 
17 |     version = '1.1'
18 |     ext {
19 |         appName = "Tetris"
20 |         gdxVersion = '1.9.3'
21 |         roboVMVersion = '2.1.0'
22 |         box2DLightsVersion = '1.4'
23 |         ashleyVersion = '1.7.0'
24 |         aiVersion = '1.8.0'
25 |     }
26 | 
27 |     repositories {
28 |         mavenLocal()
29 |         mavenCentral()
30 |         maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
31 |         maven { url "https://oss.sonatype.org/content/repositories/releases/" }
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 |     }
44 | }
45 | 
46 | project(":html") {
47 |     apply plugin: "gwt"
48 |     apply plugin: "war"
49 | 
50 | 
51 |     dependencies {
52 |         compile project(":core")
53 |         compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
54 |         compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
55 |         compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
56 |     }
57 | }
58 | 
59 | project(":core") {
60 |     apply plugin: "java"
61 | 
62 | 
63 |     dependencies {
64 |         compile "com.badlogicgames.gdx:gdx:$gdxVersion"
65 |     }
66 | }
67 | 
68 | tasks.eclipse.doLast {
69 |     delete ".project"
70 | }
--------------------------------------------------------------------------------
/Tetris/core/assets/shapes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/Tetris/core/assets/shapes.png
--------------------------------------------------------------------------------
/Tetris/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 | 
--------------------------------------------------------------------------------
/Tetris/core/src/MyGdxGame.gwt.xml:
--------------------------------------------------------------------------------
1 | 
2 | 
3 | 
4 | 	
5 | 
--------------------------------------------------------------------------------
/Tetris/core/src/net/sekao/tetris/MainScreen.java:
--------------------------------------------------------------------------------
  1 | package net.sekao.tetris;
  2 | 
  3 | import com.badlogic.gdx.*;
  4 | import com.badlogic.gdx.graphics.*;
  5 | import com.badlogic.gdx.graphics.g2d.*;
  6 | import com.badlogic.gdx.Input.*;
  7 | import com.badlogic.gdx.scenes.scene2d.*;
  8 | import com.badlogic.gdx.scenes.scene2d.ui.*;
  9 | import com.badlogic.gdx.utils.*;
 10 | import java.nio.ByteBuffer;
 11 | import java.util.ArrayList;
 12 | import java.util.Random;
 13 | 
 14 | public class MainScreen implements Screen {
 15 |     TextureRegion[] shapes = null;
 16 |     Image activePiece = null;
 17 |     Stage stage = null;
 18 |     Timer timer = null;
 19 |     int viewWidth = 0;
 20 |     int viewHeight = 0;
 21 |     int scale = 0;
 22 | 
 23 |     public void show() {
 24 |         viewWidth = Gdx.graphics.getWidth();
 25 |         viewHeight = Gdx.graphics.getHeight();
 26 |         scale = viewWidth / 15;
 27 |         stage = new Stage();
 28 |         Gdx.input.setInputProcessor(stage);
 29 | 
 30 |         Texture sheet = new Texture("shapes.png");
 31 |         shapes = new TextureRegion[] {
 32 |                 new TextureRegion(sheet, 0, 0, 1, 4),
 33 |                 new TextureRegion(sheet, 1, 0, 2, 3),
 34 |                 new TextureRegion(sheet, 3, 0, 2, 3),
 35 |                 new TextureRegion(sheet, 5, 0, 2, 2),
 36 |                 new TextureRegion(sheet, 7, 0, 2, 3),
 37 |                 new TextureRegion(sheet, 9, 0, 3, 2),
 38 |                 new TextureRegion(sheet, 12, 0, 2, 3)
 39 |         };
 40 | 
 41 |         timer = new Timer();
 42 |         timer.scheduleTask(new Timer.Task() {
 43 |             public void run() {
 44 |                 if (activePiece == null || !movePiece(activePiece, 0, -scale)) {
 45 |                     checkForFullRows();
 46 |                     activePiece = createPiece(new Random().nextInt(shapes.length));
 47 |                 }
 48 |             }
 49 |         }, 0, 1);
 50 |         timer.start();
 51 | 
 52 |         stage.addListener(new InputListener() {
 53 |             public boolean keyDown(InputEvent event, int keycode) {
 54 |                 if (activePiece == null) {
 55 |                     return false;
 56 |                 }
 57 | 
 58 |                 if (keycode == Keys.DPAD_DOWN) {
 59 |                     movePiece(activePiece, 0, -scale);
 60 |                 } else if (keycode == Keys.DPAD_LEFT) {
 61 |                     movePiece(activePiece, -scale, 0);
 62 |                 } else if (keycode == Keys.DPAD_RIGHT) {
 63 |                     movePiece(activePiece, scale, 0);
 64 |                 } else if (keycode == Keys.SPACE) {
 65 |                     rotatePiece(activePiece);
 66 |                 }
 67 | 
 68 |                 return true;
 69 |             }
 70 |         });
 71 |     }
 72 | 
 73 |     public void render(float delta) {
 74 |         Gdx.gl.glClearColor(0, 0, 0, 0);
 75 |         Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
 76 |         stage.act(delta);
 77 |         stage.draw();
 78 |     }
 79 | 
 80 |     public void dispose() {
 81 |     }
 82 | 
 83 |     public void hide() {
 84 |     }
 85 | 
 86 |     public void pause() {
 87 |     }
 88 | 
 89 |     public void resize(int width, int height) {
 90 |     }
 91 | 
 92 |     public void resume() {
 93 |     }
 94 | 
 95 |     Image createPiece(int index) {
 96 |         Image piece = new Image(shapes[index]);
 97 |         piece.setScale(scale);
 98 |         piece.setPosition(0, viewHeight - (4 * scale));
 99 |         stage.addActor(piece);
100 |         return piece;
101 |     }
102 | 
103 |     boolean movePiece(Image piece, float xChange, float yChange) {
104 |         int pixelCount = countPixels(0, 0, viewWidth, viewHeight);
105 |         piece.setPosition(piece.getX() + xChange, piece.getY() + yChange);
106 |         if (pixelCount != countPixels(0, 0, viewWidth, viewHeight)) {
107 |             piece.setPosition(piece.getX() - xChange, piece.getY() - yChange);
108 |             return false;
109 |         }
110 |         return true;
111 |     }
112 | 
113 |     boolean rotatePiece(Image piece) {
114 |         int pixelCount = countPixels(0, 0, viewWidth, viewHeight);
115 |         piece.rotateBy(90);
116 |         if (pixelCount != countPixels(0, 0, viewWidth, viewHeight)) {
117 |             piece.rotateBy(-90);
118 |             return false;
119 |         }
120 |         return true;
121 |     }
122 | 
123 |     int countPixels(int x, int y, int w, int h) {
124 |         render(0);
125 |         byte[] bytes = ScreenUtils.getFrameBufferPixels(x, y, w, h, false);
126 |         ByteBuffer pixels = ByteBuffer.wrap(bytes);
127 |         int count = 0;
128 |         while (pixels.hasRemaining()) {
129 |             if (new Color(pixels.getInt()).a != 0) {
130 |                 count++;
131 |             }
132 |         }
133 |         return count;
134 |     }
135 | 
136 |     void checkForFullRows() {
137 |         int y = viewHeight - scale;
138 |         while (y >= 0) {
139 |             if (countPixels(0, y, viewWidth, 1) == viewWidth) {
140 |                 moveColumnsDown(y + scale);
141 |             }
142 |             y = y - scale;
143 |         }
144 |     }
145 | 
146 |     void moveColumnsDown(int y) {
147 |         ArrayList bottomColumns = new ArrayList();
148 |         ArrayList topColumns = new ArrayList();
149 | 
150 |         int x = 0;
151 |         while (x < viewWidth) {
152 |             Image columnBottom = new Image(ScreenUtils.getFrameBufferTexture(x, 0, scale, y - scale));
153 |             columnBottom.setPosition(x, 0);
154 |             bottomColumns.add(columnBottom);
155 | 
156 |             if (countPixels(x, y, scale, viewHeight - y) > 0) {
157 |                 Image columnTop = new Image(ScreenUtils.getFrameBufferTexture(x, y, scale, viewHeight - y));
158 |                 columnTop.setPosition(x, y);
159 |                 topColumns.add(columnTop);
160 |             }
161 | 
162 |             x = x + scale;
163 |         }
164 | 
165 |         stage.getRoot().clearChildren();
166 | 
167 |         for (Image column : bottomColumns) {
168 |             stage.addActor(column);
169 |         }
170 |         for (Image column : topColumns) {
171 |             stage.addActor(column);
172 |             while (movePiece(column, 0, -scale)) {}
173 |         }
174 |     }
175 | }
176 | 
--------------------------------------------------------------------------------
/Tetris/core/src/net/sekao/tetris/MyGdxGame.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.tetris;
 2 | 
 3 | import com.badlogic.gdx.Game;
 4 | 
 5 | public class MyGdxGame extends Game {
 6 | 	@Override
 7 | 	public void create () {
 8 |         this.setScreen(new MainScreen());
 9 | 	}
10 | }
11 | 
--------------------------------------------------------------------------------
/Tetris/desktop/build.gradle:
--------------------------------------------------------------------------------
 1 | apply plugin: "java"
 2 | 
 3 | sourceCompatibility = 1.6
 4 | sourceSets.main.java.srcDirs = [ "src/" ]
 5 | 
 6 | project.ext.mainClassName = "net.sekao.tetris.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 dist(type: Jar) {
18 |     from files(sourceSets.main.output.classesDir)
19 |     from files(sourceSets.main.output.resourcesDir)
20 |     from {configurations.compile.collect {zipTree(it)}}
21 |     from files(project.assetsDir);
22 |  
23 |     manifest {
24 |         attributes 'Main-Class': project.mainClassName
25 |     }
26 | }
27 | 
28 | dist.dependsOn classes
29 | 
30 | eclipse {
31 |     project {
32 |         name = appName + "-desktop"
33 |         linkedResource name: 'assets', type: '2', location: 'PARENT-1-PROJECT_LOC/core/assets'
34 |     }
35 | }
36 | 
37 | task afterEclipseImport(description: "Post processing after project generation", group: "IDE") {
38 |   doLast {
39 |     def classpath = new XmlParser().parse(file(".classpath"))
40 |     new Node(classpath, "classpathentry", [ kind: 'src', path: 'assets' ]);
41 |     def writer = new FileWriter(file(".classpath"))
42 |     def printer = new XmlNodePrinter(new PrintWriter(writer))
43 |     printer.setPreserveWhitespace(true)
44 |     printer.print(classpath)
45 |   }
46 | }
--------------------------------------------------------------------------------
/Tetris/desktop/src/net/sekao/tetris/desktop/DesktopLauncher.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.tetris.desktop;
 2 | 
 3 | import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
 4 | import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
 5 | import net.sekao.tetris.MyGdxGame;
 6 | 
 7 | public class DesktopLauncher {
 8 | 	public static void main (String[] arg) {
 9 | 		LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
10 | 		new LwjglApplication(new MyGdxGame(), config);
11 | 	}
12 | }
13 | 
--------------------------------------------------------------------------------
/Tetris/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.daemon=true
2 | org.gradle.jvmargs=-Xms128m -Xmx1500m
3 | org.gradle.configureondemand=true
4 | 
--------------------------------------------------------------------------------
/Tetris/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/Tetris/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Tetris/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=http\://services.gradle.org/distributions/gradle-2.10-all.zip
7 | 
--------------------------------------------------------------------------------
/Tetris/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 | 
--------------------------------------------------------------------------------
/Tetris/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 | 
--------------------------------------------------------------------------------
/Tetris/html/build.gradle:
--------------------------------------------------------------------------------
 1 | apply plugin: "java"
 2 | apply plugin: "jetty"
 3 | 
 4 | gwt {
 5 |     gwtVersion='2.6.0' // Should match the gwt version used for building the gwt backend
 6 |     maxHeapSize="1G" // Default 256m is not enough for gwt compiler. GWT is HUNGRY
 7 |     minHeapSize="1G"
 8 | 
 9 |     src = files(file("src/")) // Needs to be in front of "modules" below.
10 |     modules 'net.sekao.tetris.GdxDefinition'
11 |     devModules 'net.sekao.tetris.GdxDefinitionSuperdev'
12 |     project.webAppDirName = 'webapp'
13 | 
14 |     compiler {
15 |         strict = true;
16 |         enableClosureCompiler = true;
17 |         disableCastChecking = true;
18 |     }
19 | }
20 | 
21 | task draftRun(type: JettyRunWar) {
22 |     dependsOn draftWar
23 |     dependsOn.remove('war')
24 |     webApp=draftWar.archivePath
25 |     daemon=true
26 | }
27 | 
28 | task superDev(type: de.richsource.gradle.plugins.gwt.GwtSuperDev) {
29 |     dependsOn draftRun
30 |     doFirst {
31 |     	gwt.modules = gwt.devModules
32 |     }
33 | }
34 | 
35 | task dist(dependsOn: [clean, compileGwt]) {
36 |     doLast {
37 |         file("build/dist").mkdirs()
38 |         copy {
39 |             from "build/gwt/out"
40 |             into "build/dist"
41 |         }
42 |         copy {
43 |             from "webapp"
44 |             into "build/dist"
45 |             }
46 |         copy {
47 |             from "war"
48 |             into "build/dist"
49 |         }
50 |     }
51 | }
52 | 
53 | draftWar {
54 |    from "war"
55 | }
56 | 
57 | task addSource << {
58 | 	sourceSets.main.compileClasspath += files(project(':core').sourceSets.main.allJava.srcDirs)
59 | }
60 | 
61 | tasks.compileGwt.dependsOn(addSource)
62 | tasks.draftCompileGwt.dependsOn(addSource)
63 | 
64 | sourceCompatibility = 1.6
65 | sourceSets.main.java.srcDirs = [ "src/" ]
66 | 
67 | 
68 | eclipse.project {
69 |     name = appName + "-html"
70 | }
71 | 
--------------------------------------------------------------------------------
/Tetris/html/src/net/sekao/tetris/GdxDefinition.gwt.xml:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 | 
 4 | 	
 5 | 
 6 | 	
 7 | 	
 8 | 	
 9 | 	
10 | 
11 | 
--------------------------------------------------------------------------------
/Tetris/html/src/net/sekao/tetris/GdxDefinitionSuperdev.gwt.xml:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 | 
 4 | 	
 5 | 
 6 |     
 7 |     
 8 |     
 9 |     
10 | 		
11 | 	
12 | 		
13 | 
14 | 
--------------------------------------------------------------------------------
/Tetris/html/src/net/sekao/tetris/client/HtmlLauncher.java:
--------------------------------------------------------------------------------
 1 | package net.sekao.tetris.client;
 2 | 
 3 | import com.badlogic.gdx.ApplicationListener;
 4 | import com.badlogic.gdx.backends.gwt.GwtApplication;
 5 | import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
 6 | import net.sekao.tetris.MyGdxGame;
 7 | 
 8 | public class HtmlLauncher extends GwtApplication {
 9 | 
10 |         @Override
11 |         public GwtApplicationConfiguration getConfig () {
12 |                 return new GwtApplicationConfiguration(800, 600);
13 |         }
14 | 
15 |         @Override
16 |         public ApplicationListener createApplicationListener () {
17 |                 return new MyGdxGame();
18 |         }
19 | }
20 | 
--------------------------------------------------------------------------------
/Tetris/html/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 | 
2 | 
3 | 
--------------------------------------------------------------------------------
/Tetris/html/webapp/index.html:
--------------------------------------------------------------------------------
 1 | 
 2 | 
 3 |        
 4 |               Tetris
 5 |               
 6 |               
 7 |               
 8 |   			  
 9 |        
10 | 
11 |        
12 |               ↻
13 |               
14 |               
15 |        
16 | 
17 |        
32 | 
33 | 
--------------------------------------------------------------------------------
/Tetris/html/webapp/refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/oakes/libgdx-examples/ebd16f7f64532f2fd8a22fecc940fc60e5a61f0f/Tetris/html/webapp/refresh.png
--------------------------------------------------------------------------------
/Tetris/html/webapp/soundmanager2-setup.js:
--------------------------------------------------------------------------------
1 | window.SM2_DEFER = true;
--------------------------------------------------------------------------------
/Tetris/html/webapp/styles.css:
--------------------------------------------------------------------------------
 1 | canvas {
 2 |     cursor: default;
 3 |     outline: none;
 4 | }
 5 | 
 6 | body {
 7 |     background-color: #222222;
 8 | }
 9 | 
10 | .superdev {
11 |     color: rgb(37,37,37);
12 |     text-shadow: 0px 1px 1px rgba(250,250,250,0.1);
13 |     font-size: 50pt;
14 |     display: block;
15 |     position: relative;
16 |     text-decoration: none;
17 |     background-color: rgb(83,87,93);
18 |     box-shadow: 0px 3px 0px 0px rgb(34,34,34),
19 |                 0px 7px 10px 0px rgb(17,17,17),
20 |                 inset 0px 1px 1px 0px rgba(250, 250, 250, .2),
21 |                 inset 0px -12px 35px 0px rgba(0, 0, 0, .5);
22 |     width: 70px;
23 |     height: 70px;
24 |     border: 0;
25 |     border-radius: 35px;
26 |     text-align: center;
27 |     line-height: 68px;
28 | }
29 | 
30 | .superdev:active {
31 |     box-shadow: 0px 0px 0px 0px rgb(34,34,34),
32 |                 0px 3px 7px 0px rgb(17,17,17),
33 |                 inset 0px 1px 1px 0px rgba(250, 250, 250, .2),
34 |                 inset 0px -10px 35px 5px rgba(0, 0, 0, .5);
35 |     background-color: rgb(83,87,93);
36 |     top: 3px;
37 |     color: #fff;
38 |     text-shadow: 0px 0px 3px rgb(250,250,250);
39 | }
40 | 
41 | .superdev:hover {
42 |     background-color: rgb(100,100,100);
43 | }
44 | 
--------------------------------------------------------------------------------
/Tetris/settings.gradle:
--------------------------------------------------------------------------------
1 | include 'desktop', 'html', 'core'
--------------------------------------------------------------------------------
/UNLICENSE:
--------------------------------------------------------------------------------
 1 | This is free and unencumbered software released into the public domain.
 2 | 
 3 | Anyone is free to copy, modify, publish, use, compile, sell, or
 4 | distribute this software, either in source code form or as a compiled
 5 | binary, for any purpose, commercial or non-commercial, and by any
 6 | means.
 7 | 
 8 | In jurisdictions that recognize copyright laws, the author or authors
 9 | of this software dedicate any and all copyright interest in the
10 | software to the public domain. We make this dedication for the benefit
11 | of the public at large and to the detriment of our heirs and
12 | successors. We intend this dedication to be an overt act of
13 | relinquishment in perpetuity of all present and future rights to this
14 | software under copyright law.
15 | 
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | OTHER DEALINGS IN THE SOFTWARE.
23 | 
24 | For more information, please refer to 
25 | 
--------------------------------------------------------------------------------