diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a4b5d51 --- /dev/null +++ b/.gitignore @@ -0,0 +1,115 @@ +## Java + +*.class +*.war +*.ear +hs_err_pid* + +## Robovm +/ios/robovm-build/ + +## GWT +/html/war/ +/html/gwt-unitCache/ +.apt_generated/ +.gwt/ +gwt-unitCache/ +www-test/ +.gwt-tmp/ + +## 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 +*.iws +*.iml +/android/out/ +com_crashlytics_export_strings.xml + +## Eclipse + +.classpath +.project +.metadata/ +/android/bin/ +/core/bin/ +/desktop/bin/ +/html/bin/ +/ios/bin/ +*.tmp +*.bak +*.swp +*~.nib +.settings/ +.loadpath +.externalToolBuilders/ +*.launch + +## NetBeans + +/nbproject/private/ +/android/nbproject/private/ +/core/nbproject/private/ +/desktop/nbproject/private/ +/html/nbproject/private/ +/ios/nbproject/private/ + +/build/ +/android/build/ +/core/build/ +/desktop/build/ +/html/build/ +/ios/build/ + +/nbbuild/ +/android/nbbuild/ +/core/nbbuild/ +/desktop/nbbuild/ +/html/nbbuild/ +/ios/nbbuild/ + +/dist/ +/android/dist/ +/core/dist/ +/desktop/dist/ +/html/dist/ +/ios/dist/ + +/nbdist/ +/android/nbdist/ +/core/nbdist/ +/desktop/nbdist/ +/html/nbdist/ +/ios/nbdist/ + +nbactions.xml +nb-configuration.xml + +## Gradle + +/local.properties +.gradle/ +gradle-app.setting +/build/ +/android/build/ +/core/build/ +/desktop/build/ +/html/build/ +/ios/build/ + +## OS Specific +.DS_Store +Thumbs.db + +## iOS +/ios/xcode/*.xcodeproj/* +!/ios/xcode/*.xcodeproj/xcshareddata +!/ios/xcode/*.xcodeproj/project.pbxproj +/ios/xcode/native/ +/ios/IOSLauncher.app +/ios/IOSLauncher.app.dSYM diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml new file mode 100644 index 0000000..a70f2f3 --- /dev/null +++ b/android/AndroidManifest.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + diff --git a/android/assets/badlogic.jpg b/android/assets/badlogic.jpg new file mode 100644 index 0000000..4390da6 Binary files /dev/null and b/android/assets/badlogic.jpg differ diff --git a/android/assets/bucket.png b/android/assets/bucket.png new file mode 100644 index 0000000..0538dc3 Binary files /dev/null and b/android/assets/bucket.png differ diff --git a/android/assets/drop.wav b/android/assets/drop.wav new file mode 100644 index 0000000..f63f553 Binary files /dev/null and b/android/assets/drop.wav differ diff --git a/android/assets/droplet.png b/android/assets/droplet.png new file mode 100644 index 0000000..8ce41f4 Binary files /dev/null and b/android/assets/droplet.png differ diff --git a/android/assets/rain.mp3 b/android/assets/rain.mp3 new file mode 100644 index 0000000..74624d1 Binary files /dev/null and b/android/assets/rain.mp3 differ diff --git a/android/build.gradle b/android/build.gradle new file mode 100644 index 0000000..dd5736d --- /dev/null +++ b/android/build.gradle @@ -0,0 +1,92 @@ +android { + buildToolsVersion "30.0.3" + compileSdkVersion 30 + sourceSets { + main { + manifest.srcFile 'AndroidManifest.xml' + java.srcDirs = ['src'] + aidl.srcDirs = ['src'] + renderscript.srcDirs = ['src'] + res.srcDirs = ['res'] + assets.srcDirs = ['assets'] + jniLibs.srcDirs = ['libs'] + } + + } + packagingOptions { + exclude 'META-INF/robovm/ios/robovm.xml' + } + defaultConfig { + applicationId "com.badlogic.drop" + minSdkVersion 14 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled true + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + + +// 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 { + doFirst { + 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.copy().files.each { jar -> + def 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 + include "*.so" + } + } + } + } +} + +tasks.whenTaskAdded { packageTask -> + if (packageTask.name.contains("package")) { + packageTask.dependsOn 'copyAndroidNatives' + } +} + +task run(type: Exec) { + def path + def localProperties = project.file("../local.properties") + if (localProperties.exists()) { + Properties properties = new Properties() + localProperties.withInputStream { instr -> + properties.load(instr) + } + def sdkDir = properties.getProperty('sdk.dir') + if (sdkDir) { + path = sdkDir + } else { + path = "$System.env.ANDROID_HOME" + } + } else { + path = "$System.env.ANDROID_HOME" + } + + def adb = path + "/platform-tools/adb" + commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.badlogic.drop/com.badlogic.drop.AndroidLauncher' +} + +eclipse.project.name = appName + "-android" diff --git a/android/ic_launcher-web.png b/android/ic_launcher-web.png new file mode 100644 index 0000000..8f0110d Binary files /dev/null and b/android/ic_launcher-web.png differ diff --git a/android/proguard-rules.pro b/android/proguard-rules.pro new file mode 100644 index 0000000..6e0b079 --- /dev/null +++ b/android/proguard-rules.pro @@ -0,0 +1,42 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +-verbose + +-dontwarn com.badlogic.gdx.backends.android.AndroidFragmentApplication +-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 + +# Required if using Gdx-Controllers extension +-keep class com.badlogic.gdx.controllers.android.AndroidControllers + +# Required if using Box2D extension +-keepclassmembers class com.badlogic.gdx.physics.box2d.World { + boolean contactFilter(long, long); + void beginContact(long); + void endContact(long); + void preSolve(long, long); + void postSolve(long, long); + boolean reportFixture(long); + float reportRayFixture(long, float, float, float, float, float); +} diff --git a/android/project.properties b/android/project.properties new file mode 100644 index 0000000..ff37982 --- /dev/null +++ b/android/project.properties @@ -0,0 +1,7 @@ +# This file is used by the Eclipse ADT plugin. It is unnecessary for IDEA and Android Studio projects, which +# configure Proguard and the Android target via the build.gradle file. +# To enable ProGuard to work with Eclipse ADT, uncomment this (available properties: sdk.dir, user.home) +# and ensure proguard.jar in the Android SDK is up to date (or alternately reduce the android target to 23 or lower): +# proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-rules.pro +# Project target. +target=android-19 diff --git a/android/res/drawable-anydpi-v26/ic_launcher.xml b/android/res/drawable-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..0898188 --- /dev/null +++ b/android/res/drawable-anydpi-v26/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/android/res/drawable-anydpi-v26/ic_launcher_foreground.xml b/android/res/drawable-anydpi-v26/ic_launcher_foreground.xml new file mode 100644 index 0000000..f46bbfd --- /dev/null +++ b/android/res/drawable-anydpi-v26/ic_launcher_foreground.xml @@ -0,0 +1,40 @@ + + + + + + + + + diff --git a/android/res/drawable-hdpi/ic_launcher.png b/android/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 0000000..91f696b Binary files /dev/null and b/android/res/drawable-hdpi/ic_launcher.png differ diff --git a/android/res/drawable-mdpi/ic_launcher.png b/android/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 0000000..c1ab239 Binary files /dev/null and b/android/res/drawable-mdpi/ic_launcher.png differ diff --git a/android/res/drawable-xhdpi/ic_launcher.png b/android/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 0000000..2011cc0 Binary files /dev/null and b/android/res/drawable-xhdpi/ic_launcher.png differ diff --git a/android/res/drawable-xxhdpi/ic_launcher.png b/android/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..25fcef0 Binary files /dev/null and b/android/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/android/res/drawable-xxxhdpi/ic_launcher.png b/android/res/drawable-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..d109946 Binary files /dev/null and b/android/res/drawable-xxxhdpi/ic_launcher.png differ diff --git a/android/res/values/color.xml b/android/res/values/color.xml new file mode 100644 index 0000000..91381a9 --- /dev/null +++ b/android/res/values/color.xml @@ -0,0 +1,4 @@ + + + #FFFFFFFF + diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml new file mode 100644 index 0000000..94c397d --- /dev/null +++ b/android/res/values/strings.xml @@ -0,0 +1,6 @@ + + + + drop + + diff --git a/android/res/values/styles.xml b/android/res/values/styles.xml new file mode 100644 index 0000000..e25e2c8 --- /dev/null +++ b/android/res/values/styles.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/android/src/com/badlogic/drop/AndroidLauncher.java b/android/src/com/badlogic/drop/AndroidLauncher.java new file mode 100644 index 0000000..c49ba32 --- /dev/null +++ b/android/src/com/badlogic/drop/AndroidLauncher.java @@ -0,0 +1,16 @@ +package com.badlogic.drop; + +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(); + config.useAccelerometer = false; + config.useCompass = false; + initialize(new Drop(), config); + } +} diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..8314119 --- /dev/null +++ b/build.gradle @@ -0,0 +1,105 @@ +buildscript { + + + repositories { + mavenLocal() + mavenCentral() + gradlePluginPortal() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + google() + } + dependencies { + classpath 'org.wisepersist:gwt-gradle-plugin:1.0.13' + classpath 'org.gretty:gretty:3.0.2' + classpath 'com.android.tools.build:gradle:4.2.0' + + + } +} + +allprojects { + apply plugin: "eclipse" + + version = '1.0' + ext { + appName = "drop" + gdxVersion = '1.10.0' + roboVMVersion = '2.3.12' + box2DLightsVersion = '1.5' + ashleyVersion = '1.7.3' + aiVersion = '1.8.2' + gdxControllersVersion = '2.1.0' + } + + repositories { + mavenLocal() + mavenCentral() + google() + gradlePluginPortal() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { url "https://oss.sonatype.org/content/repositories/releases/" } + } +} + +project(":desktop") { + apply plugin: "java-library" + + + dependencies { + implementation project(":core") + api "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion" + api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" + api "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop" + + } +} + +project(":core") { + apply plugin: "java-library" + + + dependencies { + api "com.badlogicgames.gdx:gdx:$gdxVersion" + api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion" + + } +} + +project(":html") { + apply plugin: "java-library" + apply plugin: "gwt" + apply plugin: "war" + apply plugin: "org.gretty" + + + dependencies { + implementation project(":core") + api "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion" + api "com.badlogicgames.gdx:gdx:$gdxVersion:sources" + api "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources" + api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion:sources" + api "com.badlogicgames.gdx:gdx-box2d-gwt:$gdxVersion:sources" + + } +} + +project(":android") { + apply plugin: "com.android.application" + + configurations { natives } + + dependencies { + implementation project(":core") + api "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion" + 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" + api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion" + 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" + natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64" + + } +} diff --git a/core/assets/badlogic.jpg b/core/assets/badlogic.jpg new file mode 100644 index 0000000..4390da6 Binary files /dev/null and b/core/assets/badlogic.jpg differ diff --git a/core/build.gradle b/core/build.gradle new file mode 100644 index 0000000..06c0764 --- /dev/null +++ b/core/build.gradle @@ -0,0 +1,6 @@ +sourceCompatibility = 1.7 +[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' + +sourceSets.main.java.srcDirs = ["src/"] + +eclipse.project.name = appName + "-core" diff --git a/core/src/Drop.gwt.xml b/core/src/Drop.gwt.xml new file mode 100644 index 0000000..8b992ca --- /dev/null +++ b/core/src/Drop.gwt.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/core/src/com/badlogic/drop/Drop.java b/core/src/com/badlogic/drop/Drop.java new file mode 100644 index 0000000..c177b5d --- /dev/null +++ b/core/src/com/badlogic/drop/Drop.java @@ -0,0 +1,118 @@ +package com.badlogic.drop; + +import com.badlogic.gdx.ApplicationAdapter; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input.Keys; +import com.badlogic.gdx.audio.Music; +import com.badlogic.gdx.audio.Sound; +import com.badlogic.gdx.graphics.OrthographicCamera; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.math.MathUtils; +import com.badlogic.gdx.math.Rectangle; +import com.badlogic.gdx.math.Vector3; +import com.badlogic.gdx.utils.Array; +import com.badlogic.gdx.utils.ScreenUtils; +import com.badlogic.gdx.utils.TimeUtils; +import java.util.Iterator; + +public class Drop extends ApplicationAdapter { + private Texture dropImage; + private Texture bucketImage; + private Sound dropSound; + private Music rainMusic; + + private OrthographicCamera camera; + private SpriteBatch batch; + + private Rectangle bucket; + + private Array raindrops; + + private long lastDropTime; + + @Override + public void create() { + dropImage = new Texture(Gdx.files.internal("droplet.png")); + bucketImage = new Texture(Gdx.files.internal("bucket.png")); + + dropSound = Gdx.audio.newSound(Gdx.files.internal("drop.wav")); + rainMusic = Gdx.audio.newMusic(Gdx.files.internal("rain.mp3")); + + rainMusic.setLooping(true); + rainMusic.play(); + + camera = new OrthographicCamera(); + camera.setToOrtho(false, 800, 480); + + batch = new SpriteBatch(); + + bucket = new Rectangle(); + bucket.x = 800 / 2 - 64 / 2; + bucket.y = 20; + bucket.width = 64; + bucket.height = 64; + + raindrops = new Array(); + spawnRainDrop(); + } + + @Override + public void render() { + ScreenUtils.clear(0, 0, 0.2f, 1); + + camera.update(); + + batch.setProjectionMatrix(camera.combined); + batch.begin(); + batch.draw(bucketImage, bucket.x, bucket.y); + for (Rectangle raindrop:raindrops) { + batch.draw(dropImage, raindrop.x, raindrop.y); + } + batch.end(); + + if (Gdx.input.isTouched()) { + Vector3 touchPos = new Vector3(); + touchPos.set(Gdx.input.getX(), Gdx.input.getY(), 0); + camera.unproject(touchPos); + bucket.x = touchPos.x - 64 / 2; + } + + if (Gdx.input.isKeyPressed(Keys.LEFT)) bucket.x -= 200 * Gdx.graphics.getDeltaTime(); + if (Gdx.input.isKeyPressed(Keys.RIGHT)) bucket.x += 200 * Gdx.graphics.getDeltaTime(); + + if (bucket.x < 0) bucket.x = 0; + if (bucket.x > 800 - 64) bucket.x = 800 - 64; + + if (TimeUtils.nanoTime() - lastDropTime > 1000000000) spawnRainDrop(); + + for (Iterator iter = raindrops.iterator(); iter.hasNext(); ) { + Rectangle raindrop = iter.next(); + raindrop.y -= 200 * Gdx.graphics.getDeltaTime(); + if (raindrop.y + 64 < 0) iter.remove(); + if (raindrop.overlaps(bucket)) { + dropSound.play(); + iter.remove(); + } + } + } + + private void spawnRainDrop() { + Rectangle raindrop = new Rectangle(); + raindrop.x = MathUtils.random(0, 800 - 64); + raindrop.y = 480; + raindrop.width = 64; + raindrop.height = 64; + raindrops.add(raindrop); + lastDropTime = TimeUtils.nanoTime(); + } + + @Override + public void dispose() { + dropImage.dispose(); + bucketImage.dispose(); + dropSound.dispose(); + rainMusic.dispose(); + batch.dispose(); + } +} diff --git a/desktop/build.gradle b/desktop/build.gradle new file mode 100644 index 0000000..6c12a0b --- /dev/null +++ b/desktop/build.gradle @@ -0,0 +1,39 @@ +sourceCompatibility = 1.7 +sourceSets.main.java.srcDirs = ["src/"] +sourceSets.main.resources.srcDirs = ["../android/assets"] + +project.ext.mainClassName = "com.badlogic.drop.desktop.DesktopLauncher" +project.ext.assetsDir = new File("../android/assets") + +task run(dependsOn: classes, type: JavaExec) { + main = project.mainClassName + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = project.assetsDir + ignoreExitValue = true +} + +task debug(dependsOn: classes, type: JavaExec) { + main = project.mainClassName + classpath = sourceSets.main.runtimeClasspath + standardInput = System.in + workingDir = project.assetsDir + ignoreExitValue = true + debug = true +} + +task dist(type: Jar) { + manifest { + attributes 'Main-Class': project.mainClassName + } + dependsOn configurations.runtimeClasspath + from { + configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } + } + with jar +} + + +dist.dependsOn classes + +eclipse.project.name = appName + "-desktop" diff --git a/desktop/src/com/badlogic/drop/desktop/DesktopLauncher.java b/desktop/src/com/badlogic/drop/desktop/DesktopLauncher.java new file mode 100644 index 0000000..624ea55 --- /dev/null +++ b/desktop/src/com/badlogic/drop/desktop/DesktopLauncher.java @@ -0,0 +1,15 @@ +package com.badlogic.drop.desktop; + +import com.badlogic.drop.Drop; +import com.badlogic.gdx.backends.lwjgl.LwjglApplication; +import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; + +public class DesktopLauncher { + public static void main(String[] arg) { + LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); + config.title = "Drop"; + config.width = 800; + config.height = 480; + new LwjglApplication(new Drop(), config); + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..ff329ac --- /dev/null +++ b/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.daemon=true +org.gradle.jvmargs=-Xms128m -Xmx1500m +org.gradle.configureondemand=false diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e708b1c Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..4d9ca16 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..4f906e0 --- /dev/null +++ b/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..107acd3 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/html/build.gradle b/html/build.gradle new file mode 100644 index 0000000..a4f9ae6 --- /dev/null +++ b/html/build.gradle @@ -0,0 +1,91 @@ +gwt { + gwtVersion = '2.8.2' // Should match the gwt version used for building the gwt backend + maxHeapSize = "1G" // Default 256m is not enough for gwt compiler. GWT is HUNGRY + minHeapSize = "1G" + + src = files(file("src/")) // Needs to be in front of "modules" below. + modules 'com.badlogic.drop.GdxDefinition' + devModules 'com.badlogic.drop.GdxDefinitionSuperdev' + project.webAppDirName = 'webapp' + + compiler { + strict = true; + disableCastChecking = true; + } +} + + +import org.akhikhl.gretty.AppBeforeIntegrationTestTask +import org.wisepersist.gradle.plugins.gwt.GwtSuperDev + +gretty.httpPort = 8080 +gretty.resourceBase = project.buildDir.path + "/gwt/draftOut" +gretty.contextPath = "/" +gretty.portPropertiesFileName = "TEMP_PORTS.properties" + +task startHttpServer() { + dependsOn draftCompileGwt + + doFirst { + copy { + from "webapp" + into gretty.resourceBase + } + + copy { + from "war" + into gretty.resourceBase + } + } +} + +task beforeRun(type: AppBeforeIntegrationTestTask, dependsOn: startHttpServer) { + // The next line allows ports to be reused instead of + // needing a process to be manually terminated. + file("build/TEMP_PORTS.properties").delete() + // Somewhat of a hack; uses Gretty's support for wrapping a task in + // a start and then stop of a Jetty server that serves files while + // also running the SuperDev code server. + integrationTestTask 'superDev' + + interactive false +} + +task superDev(type: GwtSuperDev) { + dependsOn startHttpServer + doFirst { + gwt.modules = gwt.devModules + } +} + +task dist(dependsOn: [clean, compileGwt]) { + doLast { + file("build/dist").mkdirs() + copy { + from "build/gwt/out" + into "build/dist" + } + copy { + from "webapp" + into "build/dist" + } + copy { + from "war" + into "build/dist" + } + } +} + +task addSource { + doLast { + sourceSets.main.compileClasspath += files(project(':core').sourceSets.main.allJava.srcDirs) + } +} + +tasks.compileGwt.dependsOn(addSource) +tasks.draftCompileGwt.dependsOn(addSource) + +sourceCompatibility = 1.7 +sourceSets.main.java.srcDirs = ["src/"] + +eclipse.project.name = appName + "-html" diff --git a/html/src/com/badlogic/drop/GdxDefinition.gwt.xml b/html/src/com/badlogic/drop/GdxDefinition.gwt.xml new file mode 100644 index 0000000..5c18a05 --- /dev/null +++ b/html/src/com/badlogic/drop/GdxDefinition.gwt.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/html/src/com/badlogic/drop/GdxDefinitionSuperdev.gwt.xml b/html/src/com/badlogic/drop/GdxDefinitionSuperdev.gwt.xml new file mode 100644 index 0000000..171b860 --- /dev/null +++ b/html/src/com/badlogic/drop/GdxDefinitionSuperdev.gwt.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/html/src/com/badlogic/drop/client/HtmlLauncher.java b/html/src/com/badlogic/drop/client/HtmlLauncher.java new file mode 100644 index 0000000..23f763f --- /dev/null +++ b/html/src/com/badlogic/drop/client/HtmlLauncher.java @@ -0,0 +1,22 @@ +package com.badlogic.drop.client; + +import com.badlogic.drop.Drop; +import com.badlogic.gdx.ApplicationListener; +import com.badlogic.gdx.backends.gwt.GwtApplication; +import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration; + +public class HtmlLauncher extends GwtApplication { + + @Override + public GwtApplicationConfiguration getConfig() { + // Resizable application, uses available space in browser +// return new GwtApplicationConfiguration(true); + // Fixed size application: + return new GwtApplicationConfiguration(800, 480); + } + + @Override + public ApplicationListener createApplicationListener() { + return new Drop(); + } +} diff --git a/html/webapp/WEB-INF/web.xml b/html/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..4301df2 --- /dev/null +++ b/html/webapp/WEB-INF/web.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/html/webapp/index.html b/html/webapp/index.html new file mode 100644 index 0000000..8c2547b --- /dev/null +++ b/html/webapp/index.html @@ -0,0 +1,32 @@ + + + + drop + + + + + + + +
+ + + + + diff --git a/html/webapp/refresh.png b/html/webapp/refresh.png new file mode 100644 index 0000000..24a48f1 Binary files /dev/null and b/html/webapp/refresh.png differ diff --git a/html/webapp/styles.css b/html/webapp/styles.css new file mode 100644 index 0000000..32ca343 --- /dev/null +++ b/html/webapp/styles.css @@ -0,0 +1,43 @@ +canvas { + cursor: default; + outline: none; +} + +body { + background-color: #222222; +} + +.superdev { + color: rgb(37, 37, 37); + text-shadow: 0px 1px 1px rgba(250, 250, 250, 0.1); + font-size: 50pt; + display: block; + position: relative; + text-decoration: none; + background-color: rgb(83, 87, 93); + box-shadow: 0px 3px 0px 0px rgb(34, 34, 34), + 0px 7px 10px 0px rgb(17, 17, 17), + inset 0px 1px 1px 0px rgba(250, 250, 250, .2), + inset 0px -12px 35px 0px rgba(0, 0, 0, .5); + width: 70px; + height: 70px; + border: 0; + border-radius: 35px; + text-align: center; + line-height: 68px; +} + +.superdev:active { + box-shadow: 0px 0px 0px 0px rgb(34, 34, 34), + 0px 3px 7px 0px rgb(17, 17, 17), + inset 0px 1px 1px 0px rgba(250, 250, 250, .2), + inset 0px -10px 35px 5px rgba(0, 0, 0, .5); + background-color: rgb(83, 87, 93); + top: 3px; + color: #fff; + text-shadow: 0px 0px 3px rgb(250, 250, 250); +} + +.superdev:hover { + background-color: rgb(100, 100, 100); +} diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..af06a80 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include 'desktop', 'core', 'html', 'android' \ No newline at end of file