Skip to content

Commit

Permalink
First pass at updating to latest libgdx
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan committed Jan 16, 2017
1 parent 8ed3d20 commit c45355a
Show file tree
Hide file tree
Showing 44 changed files with 525 additions and 385 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Expand Up @@ -5,6 +5,9 @@
*.ear
hs_err_pid*

## Robovm
robovm-build/

## GWT
war/
html/war/gwt_bree/
Expand All @@ -20,7 +23,9 @@ www-test/
## Android Studio and Intellij and Android in general
android/libs/armeabi/
android/libs/armeabi-v7a/
android/libs/arm64-v8a/
android/libs/x86/
android/libs/x86_64/
android/gen/
.idea/
*.ipr
Expand Down Expand Up @@ -57,7 +62,9 @@ nb-configuration.xml
## Gradle

.gradle
gradle-app.setting
build/

## OS Specific
.DS_Store
Thumbs.db
47 changes: 28 additions & 19 deletions android/build.gradle
@@ -1,6 +1,6 @@
android {
buildToolsVersion '21.1.1'
compileSdkVersion 21
buildToolsVersion "23.0.1"
compileSdkVersion 20
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
Expand All @@ -9,32 +9,40 @@ android {
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}

instrumentTest.setRoot('tests')
}
packagingOptions {
exclude 'META-INF/robovm/ios/robovm.xml'
}
defaultConfig {
applicationId "com.scrappile.sushiloco.android"
minSdkVersion 8
targetSdkVersion 20
}
}

// needed to add JNI shared libraries to APK when compiling on CLI
tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
pkgTask.jniFolders = new HashSet<File>()
pkgTask.jniFolders.add(new File(projectDir, 'libs'))
}

// called every time gradle gets executed, takes the native dependencies of
// the natives configuration, and extracts them to the proper libs/ folders
// so they get packed with the APK.
task copyAndroidNatives() {
task copyAndroidNatives() {
file("libs/armeabi/").mkdirs();
file("libs/armeabi-v7a/").mkdirs();
file("libs/arm64-v8a/").mkdirs();
file("libs/x86_64/").mkdirs();
file("libs/x86/").mkdirs();

configurations.natives.files.each { jar ->
def outputDir = null
if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
if (jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
if (outputDir != null) {
if(jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
if(jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
if(outputDir != null) {
copy {
from zipTree(jar)
into outputDir
Expand All @@ -43,6 +51,7 @@ task copyAndroidNatives() {
}
}
}

task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
Expand All @@ -64,9 +73,10 @@ task run(type: Exec) {
def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.scrappile.sushiloco.android/com.scrappile.sushiloco.android.AndroidLauncher'
}

// sets up the Android Eclipse project, using the old Ant based build.
eclipse {
// need to specify Java source sets explicitely, SpringSource Gradle Eclipse plugin
// need to specify Java source sets explicitly, SpringSource Gradle Eclipse plugin
// ignores any nodes added in classpath.file.withXml
sourceSets {
main {
Expand All @@ -80,8 +90,8 @@ eclipse {
}

classpath {
plusConfigurations += [project.configurations.compile]
containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES'
plusConfigurations += [ project.configurations.compile ]
containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES'
}

project {
Expand All @@ -94,11 +104,12 @@ eclipse {
buildCommand "com.android.ide.eclipse.adt.ApkBuilder"
}
}

// sets up the Android Idea project, using the old Ant based build.
idea {
module {
sourceDirs += file("src");
scopes = [COMPILE: [plus: [project.configurations.compile]]]
scopes = [ COMPILE: [plus:[project.configurations.compile]]]

iml {
withXml {
Expand All @@ -108,13 +119,11 @@ idea {
builder.component(name: "FacetManager") {
facet(type: "android", name: "Android") {
configuration {
option(name: "UPDATE_PROPERTY_FILES", value: "true")
option(name: "UPDATE_PROPERTY_FILES", value:"true")
}
}
}
}
}
}
}
dependencies {
}
3 changes: 3 additions & 0 deletions android/proguard-project.txt
Expand Up @@ -26,6 +26,9 @@
-dontwarn com.badlogic.gdx.utils.GdxBuild
-dontwarn com.badlogic.gdx.physics.box2d.utils.Box2DBuild
-dontwarn com.badlogic.gdx.jnigen.BuildTarget*
-dontwarn com.badlogic.gdx.graphics.g2d.freetype.FreetypeBuild

-keep class com.badlogic.gdx.controllers.android.AndroidControllers

-keepclassmembers class com.badlogic.gdx.backends.android.AndroidInput* {
<init>(com.badlogic.gdx.Application, android.content.Context, java.lang.Object, com.badlogic.gdx.backends.android.AndroidApplicationConfiguration);
Expand Down
16 changes: 16 additions & 0 deletions android/src/com/scrappile/sushiloco/AndroidLauncher.java
@@ -0,0 +1,16 @@
package com.scrappile.sushiloco;

import android.os.Bundle;

import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;

public class AndroidLauncher extends AndroidApplication {
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
initialize(new SushiLoco(), config);
}
}
27 changes: 15 additions & 12 deletions build.gradle
@@ -1,9 +1,12 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.13+'
classpath 'com.android.tools.build:gradle:1.5.0'
}
}

Expand All @@ -13,12 +16,16 @@ allprojects {

version = '1.0'
ext {
appName = 'SushiLoco'
gdxVersion = '1.4.1'
roboVMVersion = '1.0.0-alpha-04'
appName = "SushiLoco"
gdxVersion = '1.9.5'
roboVMVersion = '2.3.0'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
}

repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
Expand All @@ -34,7 +41,6 @@ project(":desktop") {
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
}
}
Expand All @@ -49,16 +55,15 @@ project(":android") {
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
compile "com.badlogicgames.ashley:ashley:1.1.0"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
}
}

Expand All @@ -69,8 +74,6 @@ project(":core") {
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
compile "com.badlogicgames.ashley:ashley:1.1.0"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
}
}

Expand Down
4 changes: 1 addition & 3 deletions core/src/com/scrappile/sushiloco/Assets.java
Expand Up @@ -15,6 +15,7 @@

public class Assets implements Disposable, AssetErrorListener {
private static final String LOG = Assets.class.getSimpleName();

public static AssetManager manager;
public static TextureAtlas atlas;
public static SpriteBatch batch;
Expand Down Expand Up @@ -87,9 +88,6 @@ public static void playSound(Sound sound) {
sound.play(1);
}

/**
* Releases all resources of this object.
*/
@Override
public void dispose() {
manager.dispose();
Expand Down
2 changes: 1 addition & 1 deletion core/src/com/scrappile/sushiloco/Controller.java
Expand Up @@ -2,5 +2,5 @@


public interface Controller {
public void jump(GameObject object, float velocity);
void jump(GameObject object, float velocity);
}
38 changes: 19 additions & 19 deletions core/src/com/scrappile/sushiloco/ExperienceChain.java
Expand Up @@ -4,24 +4,26 @@
import com.badlogic.gdx.utils.Array;

public class ExperienceChain {
public class Level {

public final static class Level {

private final int maxScore;
private int tag;

public Level(int tag, int maxScore) {
this.tag = tag;
this.maxScore = maxScore;
}

int tag;
int maxScore;
}

public static Level MAX_LEVEL;

int totalScore;
int currentScore;
Level currentLevel;
Array<Level> levelChain = new Array<Level>();
private int totalScore;
private int currentScore;
private Level currentLevel;
private Array<Level> levelChain = new Array<Level>();

/** Assumes levels are in ascending order. (1..3) */
/** Levels are in ascending order. (1..3) */
public void populate(Level...levels) {
for (int i = 0; i < levels.length; i++) {
this.levelChain.add(levels[i]);
Expand All @@ -36,7 +38,6 @@ public void populate(Level...levels) {

public void levelUp() {
int remainder = currentScore - currentLevel.maxScore;

currentLevel = getNextLevel();
currentScore = remainder;
}
Expand All @@ -50,32 +51,31 @@ public int getTotalScore() {
}

public Level getNextLevel() {
if ((currentLevel.tag + 1) <= MAX_LEVEL.tag)
if ((currentLevel.tag + 1) <= MAX_LEVEL.tag) {
return levelChain.get(currentLevel.tag++);
else
} else {
return currentLevel;
}
}

public Level getPreviousLevel() {
if ((currentLevel.tag - 1) >= 0)
if ((currentLevel.tag - 1) >= 0) {
return levelChain.get(currentLevel.tag--);
else
} else {
return currentLevel;
}
}

public void addPoints(int points) {
currentScore += points;
totalScore += points;
}

public void setLevel(int level) {

}

public boolean justLeveledUp() {
if (currentScore >= currentLevel.maxScore) {
if (currentLevel.tag < MAX_LEVEL.tag)
if (currentLevel.tag < MAX_LEVEL.tag) {
return true;
}
}

return false;
Expand Down
12 changes: 5 additions & 7 deletions core/src/com/scrappile/sushiloco/GameObject.java
Expand Up @@ -6,9 +6,9 @@
import com.scrappile.sushiloco.box2d.PhysicsObject;

public class GameObject extends PhysicsObject {

public int points;
public int level;

public float rot;
public Vector2 pos = new Vector2();
public Vector2 rolledPos = new Vector2();
Expand All @@ -27,13 +27,11 @@ public void update() {
if (!isDead && body.isActive()) {
pos = body.getPosition();
rot = body.getAngle() * MathUtils.radiansToDegrees;
for (int i = 0; i < children.size; i++) {
children.get(i).pos = children.get(i).body.getPosition();
children.get(i).rot = children.get(i).body.getAngle() * MathUtils.radiansToDegrees;

for (GameObject child : children) {
child.pos = child.body.getPosition();
child.rot = child.body.getAngle() * MathUtils.radiansToDegrees;
}
}

}

}
@@ -1,6 +1,7 @@
package com.scrappile.sushiloco;

public class GameObjectRepresentation extends SingleTexture {

public GameObject gameObj;

public GameObjectRepresentation(GameObject gameObj) {
Expand Down

0 comments on commit c45355a

Please sign in to comment.