diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bf0e6d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,66 @@ +## Java + +*.class +*.war +*.ear +hs_err_pid* + +## GWT +war/ +html/war/gwt_bree/ +html/gwt-unitCache/ +.apt_generated/ +html/war/WEB-INF/deploy/ +html/war/WEB-INF/classes/ +.gwt/ +gwt-unitCache/ +www-test/ +.gwt-tmp/ + +## Android Studio and Intellij and Android in general +android/libs/armeabi/ +android/libs/armeabi-v7a/ +android/libs/x86/ +android/gen/ +.idea/ +*.ipr +*.iws +*.iml +out/ +com_crashlytics_export_strings.xml + +## Eclipse +.classpath +.project +.metadata +**/bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +.settings/ +.loadpath +.externalToolBuilders/ +*.launch + +## NetBeans +**/nbproject/private/ +build/ +nbbuild/ +dist/ +nbdist/ +nbactions.xml +nb-configuration.xml + +## Gradle + +.gradle +gradle-app.setting +build/ + +## OS Specific +.DS_Store +/android-sdk/ +/html/ +/keystore/ diff --git a/Graphisme/logo.png b/Graphisme/logo.png new file mode 100644 index 0000000..496d379 Binary files /dev/null and b/Graphisme/logo.png differ diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..7e5358d --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,167 @@ +## GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + +![logo](https://www.gnu.org/graphics/lgplv3-with-text-154x68.png) + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/README.md b/README.md new file mode 100644 index 0000000..362640d --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +---------------------------------------------------------------- +## WireChem + +![The new chemistry game](https://github.com/dahut87/WireChem/raw/develop/Graphisme/logo.png) + +http://wirechem.palon.fr + +*(C) Copyright 2013-2014 Nicolas Hordé + Licence GPL V3.0* + +---------------------------------------------------------------- +### A lire absolument + +#### QU'EST CE QUE WIRECHEM ? + + WireChem est un jeu de type puzzle basé sur les automates cellulaires + et sur la chimie. + +#### PUIS-JE COPIER LE JEU ? + + Le jeu est soumis à la licence LGPL V3.0 jointe au programme, vous + pouvez copier et modifier librement ce programme à des fins non- + commerciales. A vous de lire la suite... + +#### DOIS-JE PAYER SI JE JOUE ? + + Vous pouvez faire des dons pour encourager le développement du jeu + mais aucun droit n'est n'est du lors de l'usage du jeu. + + + + \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle new file mode 100644 index 0000000..078d64c --- /dev/null +++ b/android/build.gradle @@ -0,0 +1,121 @@ +android { + buildToolsVersion "21.1.2" + compileSdkVersion 21 + sourceSets { + main { + manifest.srcFile 'AndroidManifest.xml' + java.srcDirs = ['src'] + aidl.srcDirs = ['src'] + renderscript.srcDirs = ['src'] + res.srcDirs = ['res'] + assets.srcDirs = ['assets'] + } + + instrumentTest.setRoot('tests') + } +} + +// 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() + 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() { + file("libs/armeabi/").mkdirs(); + file("libs/armeabi-v7a/").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) { + copy { + from zipTree(jar) + into outputDir + include "*.so" + } + } + } +} + +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', 'fr.evolving.game.android/fr.evolving.game.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 + // ignores any nodes added in classpath.file.withXml + sourceSets { + main { + java.srcDirs "src", 'gen' + } + } + + jdt { + sourceCompatibility = 1.6 + targetCompatibility = 1.6 + } + + classpath { + plusConfigurations += [ project.configurations.compile ] + containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES' + } + + project { + name = appName + "-android" + natures 'com.android.ide.eclipse.adt.AndroidNature' + buildCommands.clear(); + buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder" + buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder" + buildCommand "org.eclipse.jdt.core.javabuilder" + 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]]] + + iml { + withXml { + def node = it.asNode() + def builder = NodeBuilder.newInstance(); + builder.current = node; + builder.component(name: "FacetManager") { + facet(type: "android", name: "Android") { + configuration { + option(name: "UPDATE_PROPERTY_FILES", value:"true") + } + } + } + } + } + } +} diff --git a/android/src/fr/evolving/game/android/AndroidLauncher.java b/android/src/fr/evolving/game/android/AndroidLauncher.java new file mode 100644 index 0000000..1ccb405 --- /dev/null +++ b/android/src/fr/evolving/game/android/AndroidLauncher.java @@ -0,0 +1,16 @@ +package fr.evolving.game.android; + +import android.os.Bundle; + +import com.badlogic.gdx.backends.android.AndroidApplication; +import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; +import fr.evolving.game.main; + +public class AndroidLauncher extends AndroidApplication { + @Override + protected void onCreate (Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); + initialize(new main(), config); + } +} diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..f482f5d --- /dev/null +++ b/build.gradle @@ -0,0 +1,121 @@ +buildscript { + repositories { + mavenCentral() + jcenter() + } + dependencies { + classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6' + classpath 'com.android.tools.build:gradle:1.2.3' + classpath 'org.robovm:robovm-gradle-plugin:1.9.0' + } +} + +allprojects { + apply plugin: "eclipse" + apply plugin: "idea" + + version = '1.0' + ext { + appName = 'WireChem' + gdxVersion = '1.7.2' + roboVMVersion = '1.9.0' + box2DLightsVersion = '1.4' + ashleyVersion = '1.5.0' + aiVersion = '1.5.0' + } + + repositories { + mavenCentral() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + maven { url "https://oss.sonatype.org/content/repositories/releases/" } + } +} + +project(":desktop") { + apply plugin: "java" + + + dependencies { + compile project(":core") + 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-controllers-desktop:$gdxVersion" + compile "com.badlogicgames.gdx:gdx-controllers-platform:$gdxVersion:natives-desktop" + compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion" + compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop" + compile "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop" + compile fileTree(dir: 'libs', include: ['*.jar']) + } +} + +project(":android") { + apply plugin: "android" + + configurations { natives } + + dependencies { + compile project(":core") + 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-x86" + 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-x86" + compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion" + compile "com.badlogicgames.gdx:gdx-controllers-android:$gdxVersion" + compile "com.badlogicgames.gdx:gdx-ai:$aiVersion" + 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" + compile "com.badlogicgames.gdx:gdx-bullet:$gdxVersion" + natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi" + natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi-v7a" + natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86" + compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion" + compile "com.badlogicgames.gdx:gdx-ai:$aiVersion" + compile fileTree(dir: 'libs', include: ['*.jar']) + } +} + +project(":ios") { + apply plugin: "java" + apply plugin: "robovm" + + configurations { natives } + + dependencies { + compile project(":core") + compile "org.robovm:robovm-rt:$roboVMVersion" + compile "org.robovm:robovm-cocoatouch:$roboVMVersion" + compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion" + compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios" + compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios" + compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios" + compile "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-ios" + } +} + +project(":core") { + apply plugin: "java" + + + dependencies { + compile "com.badlogicgames.gdx:gdx:$gdxVersion" + compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion" + compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion" + compile "com.badlogicgames.ashley:ashley:$ashleyVersion" + compile "com.badlogicgames.gdx:gdx-ai:$aiVersion" + compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion" + compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion" + compile "com.badlogicgames.gdx:gdx-bullet:$gdxVersion" + compile fileTree(dir: 'libs', include: ['*.jar']) + } +} + +tasks.eclipse.doLast { + delete ".project" +} \ No newline at end of file diff --git a/core/build.gradle b/core/build.gradle new file mode 100644 index 0000000..03cd1be --- /dev/null +++ b/core/build.gradle @@ -0,0 +1,11 @@ +apply plugin: "java" + +sourceCompatibility = 1.6 +[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' + +sourceSets.main.java.srcDirs = [ "src/" ] + + +eclipse.project { + name = appName + "-core" +} diff --git a/core/src/fr/evolving/UI/ButtonLevel.java b/core/src/fr/evolving/UI/ButtonLevel.java new file mode 100644 index 0000000..940c44c --- /dev/null +++ b/core/src/fr/evolving/UI/ButtonLevel.java @@ -0,0 +1,70 @@ +package fr.evolving.UI; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.Batch; +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.Sprite; +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton; +import com.badlogic.gdx.scenes.scene2d.ui.Label; +import com.badlogic.gdx.scenes.scene2d.ui.Skin; +import com.badlogic.gdx.scenes.scene2d.utils.Align; + +import fr.evolving.assets.AssetLoader; + +public class ButtonLevel extends ImageTextButton { + public int level; + public int world; + public boolean Final; + public int[][] Link; + public boolean Activated; + TextureRegion Finalled,Locked; + public String id,shortid; + public int xx,yy; + private Color[] Levelcolors={AssetLoader.Skin_level.getColor("world1"),AssetLoader.Skin_level.getColor("world2"),AssetLoader.Skin_level.getColor("world3"),AssetLoader.Skin_level.getColor("world4"),AssetLoader.Skin_level.getColor("world5")}; + Label Thelabel; + + public ButtonLevel(String shortid,String id,int world, int level, boolean Final, int[][] Link, boolean Activated,int x, int y) { + super(id, AssetLoader.Skin_level, "world"+String.valueOf(world)); + this.xx=x; + this.yy=y; + this.id=id; + this.shortid=shortid; + this.level=level; + this.world=world; + this.Final=Final; + this.Link=Link; + this.Activated=Activated; + if (Final==true) { + Finalled=AssetLoader.Skin_level.getAtlas().findRegion("boss"); + } + if (Activated==false) { + this.setDisabled(true); + Locked=AssetLoader.Skin_level.getAtlas().findRegion("locked"); + } + this.setColor(1f, 0.47f+(float)x/Gdx.graphics.getWidth()*0.529f,0.607f+(float)x/Gdx.graphics.getWidth()*0.392f, 1f); + this.setBounds(x/1024.0f*Gdx.graphics.getWidth(), y/768.0f*Gdx.graphics.getHeight(), 111, 125); + Thelabel=new Label(this.shortid, AssetLoader.Skin_level,"Levelshort"); + Thelabel.setColor(xx/1024f,xx/1024f,xx/1024f,1f); + Thelabel.setPosition(xx/1024.0f*Gdx.graphics.getWidth()+54, yy/768.0f*Gdx.graphics.getHeight()+20, Align.bottom | Align.center); + } + + public Color getLevelcolor() { + return Levelcolors[world]; + } + + @Override + public void draw(Batch batch, float parentAlpha) { + super.draw(batch, parentAlpha); + if (Final) { + batch.draw(Finalled,xx/1024.0f*Gdx.graphics.getWidth(),yy/768.0f*Gdx.graphics.getHeight()); + } + if (!Activated) { + batch.draw(Locked,xx/1024.0f*Gdx.graphics.getWidth()+this.getWidth()-Locked.getRegionWidth(),yy/768.0f*Gdx.graphics.getHeight()+this.getHeight()-Locked.getRegionWidth()); + } + Thelabel.draw(batch, 1f); + } + +} diff --git a/core/src/fr/evolving/assets/AssetLoader.java b/core/src/fr/evolving/assets/AssetLoader.java new file mode 100644 index 0000000..f1811d3 --- /dev/null +++ b/core/src/fr/evolving/assets/AssetLoader.java @@ -0,0 +1,95 @@ +package fr.evolving.assets; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Preferences; +import com.badlogic.gdx.audio.Sound; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.Pixmap; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.Texture.TextureFilter; +import com.badlogic.gdx.graphics.TextureData; +import com.badlogic.gdx.graphics.g2d.Animation; +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion; +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.graphics.Texture.TextureWrap; +import com.badlogic.gdx.graphics.g2d.TextureAtlas; +import com.badlogic.gdx.scenes.scene2d.ui.Skin; + +public class AssetLoader { + public static Skin Skin_level; + public static TextureAtlas Atlas_level; + public static Texture Texture_fond; + public static Texture Texture_fond2; + public static Texture Texture_logo; + public static Sound intro; + private static Preferences prefs; + + public static void addstyle(TextureAtlas Atlas_level,String Name) { + AtlasRegion AnAtlasRegion = Atlas_level.findRegion(Name); + if (AnAtlasRegion==null) return; + TextureData ATextureData = AnAtlasRegion.getTexture().getTextureData(); + ATextureData.prepare(); + Pixmap Pixmap_Over=ATextureData.consumePixmap(); + Pixmap Pixmap_Disable=new Pixmap(Pixmap_Over.getWidth(), Pixmap_Over.getHeight(), Pixmap.Format.RGBA8888); + Pixmap Pixmap_Down=new Pixmap(Pixmap_Over.getWidth(), Pixmap_Over.getHeight(), Pixmap.Format.RGBA8888); + for(int x=0; x < Pixmap_Over.getWidth(); x++) + { + for(int y =0; y < Pixmap_Over.getHeight(); y++) + { + Color acolor= new Color(Pixmap_Over.getPixel(x, y)); + Pixmap_Down.drawPixel(x, y,Color.rgba8888(acolor.a,0f,0f,acolor.a)); + Pixmap_Disable.drawPixel(x, y, Color.rgba8888(acolor.r*0.352f,acolor.g*0.352f,acolor.b*0.352f,acolor.a)); + Pixmap_Over.drawPixel(x, y, Color.rgba8888(acolor.r,acolor.g*0.2f,acolor.b*0.2f,acolor.a)); + } + } + Atlas_level.addRegion(Name+"_disabled", new TextureRegion(new Texture(Pixmap_Disable),AnAtlasRegion.getRegionX(),AnAtlasRegion.getRegionY(),AnAtlasRegion.getRegionWidth(),AnAtlasRegion.getRegionHeight())); + Atlas_level.addRegion(Name+"_over", new TextureRegion(new Texture(Pixmap_Over),AnAtlasRegion.getRegionX(),AnAtlasRegion.getRegionY(),AnAtlasRegion.getRegionWidth(),AnAtlasRegion.getRegionHeight())); + Atlas_level.addRegion(Name+"_down", new TextureRegion(new Texture(Pixmap_Down),AnAtlasRegion.getRegionX(),AnAtlasRegion.getRegionY(),AnAtlasRegion.getRegionWidth(),AnAtlasRegion.getRegionHeight())); + } + + public static void loadall() { + Gdx.app.log("Chargements des éléments multimédia","ok"); + Texture_fond = new Texture(Gdx.files.internal("pictures/fond.png")); + Texture_fond.setWrap(TextureWrap.Repeat, TextureWrap.Repeat); + Texture_fond2 = new Texture(Gdx.files.internal("pictures/fond2.png")); + Texture_fond2.setWrap(TextureWrap.Repeat, TextureWrap.Repeat); + Atlas_level= new TextureAtlas(Gdx.files.internal("textures/level.pack")); + for(int i=0; i < 5; i++) + addstyle(Atlas_level,"leveler"+String.valueOf(i)); + addstyle(Atlas_level,"arrows"); + addstyle(Atlas_level,"arrows2"); + addstyle(Atlas_level,"exit2"); + Skin_level = new Skin(Gdx.files.internal("textures/level.json"),Atlas_level); + prefs = Gdx.app.getPreferences("WireWorld"); + + if (!prefs.contains("resolutionx")) { + prefs.putInteger("resolutionx", 0); + } + } + + public static void load() { + Gdx.app.log("Chargements des éléments minimalistes","ok"); + Texture_logo = new Texture(Gdx.files.internal("pictures/logo.png")); + Texture_logo.setFilter(TextureFilter.Linear,TextureFilter.Linear); + intro = Gdx.audio.newSound(Gdx.files.internal("musics/intro.mp3")); + } + + public static void setHighScore(int val) { + prefs.putInteger("highScore", val); + prefs.flush(); + } + + public static int getHighScore() { + return prefs.getInteger("highScore"); + } + + public static void dispose() { + Texture_logo.dispose(); + Texture_fond.dispose(); + Skin_level.dispose(); + Atlas_level.dispose(); + intro.dispose(); + } + +} \ No newline at end of file diff --git a/core/src/fr/evolving/assets/SaveObject.java b/core/src/fr/evolving/assets/SaveObject.java new file mode 100644 index 0000000..34e5ecb --- /dev/null +++ b/core/src/fr/evolving/assets/SaveObject.java @@ -0,0 +1,127 @@ +package fr.evolving.assets; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.DriverManager; +import java.sql.SQLException; + +import fr.evolving.automata.Cell; +import fr.evolving.automata.Grid; +import fr.evolving.automata.Level; + +public class SaveObject { + + private static String DB_DRIVER = ""; + private static String DB_CONNECTION = ""; + private static String DB_USER = ""; + private static String DB_PASSWORD = ""; + + public SaveObject(String DRIVER, String CONNECTION, String USER, String PASSWORD) { + DB_DRIVER=DRIVER; + DB_CONNECTION=CONNECTION; + DB_USER=USER; + DB_PASSWORD=PASSWORD; + } + + public void saveObject(Object javaObject) throws Exception + { + try{ + Connection conn = getDBConnection(); + PreparedStatement ps=null; + String sql=null; + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(bos); + oos.writeObject(javaObject); + oos.flush(); + oos.close(); + bos.close(); + byte[] data = bos.toByteArray(); + sql="insert into worlds (javaObject) values(?)"; + ps=conn.prepareStatement(sql); + ps.setObject(1, data); + ps.executeUpdate(); + } + catch(Exception e) + { + e.printStackTrace(); + } + } + + public Object getObject(Object javaObject) throws Exception + { + Connection conn=getDBConnection(); + PreparedStatement ps=null; + ResultSet rs=null; + Object mc =null; + String sql="select * from worlds where id=1"; + ps=conn.prepareStatement(sql); + rs=ps.executeQuery(); + if(rs.next()) + { + ByteArrayInputStream bais; + ObjectInputStream ins; + try { + bais = new ByteArrayInputStream(rs.getBytes("javaObject")); + ins = new ObjectInputStream(bais); + mc = ins.readObject(); + ins.close(); + } + catch (Exception e) { + e.printStackTrace(); + } + } + return mc; + } + + private static Connection getDBConnection() { + Connection dbConnection = null; + try { + Class.forName(DB_DRIVER); + } + catch (ClassNotFoundException e) { + System.out.println(e.getMessage()); + } + try { + dbConnection = DriverManager.getConnection(DB_CONNECTION,DB_USER,DB_PASSWORD); + return dbConnection; + } + catch (SQLException e) { + System.out.println(e.getMessage()); + } + return dbConnection; + } + + public Level[] initObject() + { + Level[] thelevels=new Level[9]; + + thelevels[0]=new Level("Introduction", + "Prise en main de l'interface de WireChem{#169} et amener l'électron neutre sur le senseur.", + "e0", + new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + 38f, + 450f, + -1, + 0, + new Grid(20,20), + 0, + 0, + 0, + 0, + 99999, + 99999, + 99999, + 99999, + "", + false, + new int[][]{{0, 1}, {0, 8}}); + return thelevels; + } + +} diff --git a/core/src/fr/evolving/automata/Automata.java b/core/src/fr/evolving/automata/Automata.java new file mode 100644 index 0000000..010d076 --- /dev/null +++ b/core/src/fr/evolving/automata/Automata.java @@ -0,0 +1,28 @@ +package fr.evolving.automata; + +import java.io.Serializable; + +public class Automata implements Serializable{ + private int X; + private int Y; + private Grid MyGrid; + private Cell Current; + private transient Cell Old; + + public Automata(int X,int Y,Grid MyGrid) { + this.X=X; + this.Y=Y; + this.MyGrid=MyGrid; + this.Current=new Cell(); + this.Old=new Cell(); + } + + public Automata GetRelative(int X,int Y) { + int goX=this.X+X; + int goY=this.Y+Y; + if (goX<0 || goY<0 || goX>=this.MyGrid.automatas.length || goY>=this.MyGrid.automatas[0].length) { + return null; + } + return this.MyGrid.automatas[goX][goY]; + } +} diff --git a/core/src/fr/evolving/automata/Cell.java b/core/src/fr/evolving/automata/Cell.java new file mode 100644 index 0000000..ab1a31b --- /dev/null +++ b/core/src/fr/evolving/automata/Cell.java @@ -0,0 +1,21 @@ +package fr.evolving.automata; + +import java.io.Serializable; +import com.badlogic.gdx.graphics.g2d.Sprite; + +public class Cell implements Serializable{ + public int Fiber; + public boolean Copper; + public transient int Fiber_old; + public transient Sprite Sprite ; + public Transmuter Transmuter; + + public Cell() { + this.Fiber=0; + this.Copper=false; + this.Fiber_old=0; + this.Sprite=null; + this.Transmuter=null; + } + +} diff --git a/core/src/fr/evolving/automata/Grid.java b/core/src/fr/evolving/automata/Grid.java new file mode 100644 index 0000000..142a569 --- /dev/null +++ b/core/src/fr/evolving/automata/Grid.java @@ -0,0 +1,30 @@ +package fr.evolving.automata; + +import java.io.Serializable; +import com.badlogic.gdx.Gdx; + +public class Grid implements Serializable{ + public Cell[][] Cells; + private Integer sizeX,sizeY; + + public Grid(Integer X,Integer Y) { + this.sizeX=X; + this.sizeY=Y; + this.Cells = new Cell[this.sizeX][this.sizeY]; + for (int x=0;x=this.sizeX || Y>=this.sizeY) { + return null; + } + return this.Cells[X][Y]; + } + + +} diff --git a/core/src/fr/evolving/automata/Level.java b/core/src/fr/evolving/automata/Level.java new file mode 100644 index 0000000..3b75e94 --- /dev/null +++ b/core/src/fr/evolving/automata/Level.java @@ -0,0 +1,51 @@ +package fr.evolving.automata; + +import java.io.Serializable; + +public class Level implements Serializable{ + String Name; + String Description; + String Element; + int[] Current; + int[] Victory; + float X; + float Y; + int Tech; + int Cout; + Grid Grid; + int Cycle; + int Temp; + int Rayon; + int Nrj; + int Maxcycle; + int Maxtemp; + int Maxrayon; + int Maxnrj; + boolean Special; + String Tuto; + int[][] Link; + +public Level(String Name,String Description,String Element,int[] Current,int[] Victory,float X,float Y,int Tech,int Cout,Grid World,int Cycle,int Temp,int Rayon,int Nrj,int Maxcycle,int Maxtemp,int Maxrayon,int Maxnrj,String Tuto,boolean Special, int[][] Link){ + this.Name=Name; + this.Description=Description; + this.Element=Element; + this.Current=Current; + this.Victory=Victory; + this.X=X; + this.Y=Y; + this.Tech=Tech; + this.Cout=Cout; + this.Grid=World; + this.Cycle=Cycle; + this.Temp=Temp; + this.Rayon=Rayon; + this.Nrj=Nrj; + this.Maxcycle=Maxcycle; + this.Maxtemp=Maxtemp; + this.Maxrayon=Maxrayon; + this.Maxnrj=Maxnrj; + this.Special=Special; + this.Tuto=Tuto; + this.Link=Link; +} +} diff --git a/core/src/fr/evolving/automata/Transmuter.java b/core/src/fr/evolving/automata/Transmuter.java new file mode 100644 index 0000000..e17df72 --- /dev/null +++ b/core/src/fr/evolving/automata/Transmuter.java @@ -0,0 +1,5 @@ +package fr.evolving.automata; + +abstract public class Transmuter { + +} diff --git a/core/src/fr/evolving/automata/World.java b/core/src/fr/evolving/automata/World.java new file mode 100644 index 0000000..ffd4cc4 --- /dev/null +++ b/core/src/fr/evolving/automata/World.java @@ -0,0 +1,49 @@ +package fr.evolving.automata; + +import java.io.Serializable; + +public class World implements Serializable{ + String Name; + String Description; + String Element; + Integer[] Current; + Integer[] Victory; + Integer X; + Integer Y; + Integer Tech; + Integer Cout; + Grid World; + Integer Cycle; + Integer Temp; + Integer Rayon; + Integer Nrj; + Integer Maxcycle; + Integer Maxtemp; + Integer Maxrayon; + Integer Maxnrj; + String Tuto; + Integer[][] Link; + +public void World(String Name,String Description,String Element,Integer[] Current,Integer[] Victory,Integer X,Integer Y,Integer Tech,Integer Cout,Grid World,Integer Cycle,Integer Temp,Integer Rayon,Integer Nrj,Integer Maxcycle,Integer Maxtemp,Integer Maxrayon,Integer Maxnrj,String Tuto,Integer[][] Link){ + this.Name=Name; + this.Description=Description; + this.Element=Element; + this.Current=Current; + this.Victory=Victory; + this.X=X; + this.Y=Y; + this.Tech=Tech; + this.Cout=Cout; + this.World=World; + this.Cycle=Cycle; + this.Temp=Temp; + this.Rayon=Rayon; + this.Nrj=Nrj; + this.Maxcycle=Maxcycle; + this.Maxtemp=Maxtemp; + this.Maxrayon=Maxrayon; + this.Maxnrj=Maxnrj; + this.Tuto=Tuto; + this.Link=Link; +} +} diff --git a/core/src/fr/evolving/effects/Laser.java b/core/src/fr/evolving/effects/Laser.java new file mode 100644 index 0000000..e403789 --- /dev/null +++ b/core/src/fr/evolving/effects/Laser.java @@ -0,0 +1,131 @@ +package fr.evolving.effects; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.Texture.TextureFilter; +import com.badlogic.gdx.graphics.Texture.TextureWrap; +import com.badlogic.gdx.graphics.g2d.Sprite; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; +import com.badlogic.gdx.math.MathUtils; +import com.badlogic.gdx.math.Vector2; + +import fr.evolving.assets.AssetLoader; +import fr.evolving.math.Calcul; + +public class Laser { + + public float i=0; + TextureRegion overlaymiddle,middle,overlay; + + public Laser() { + i=0; + overlaymiddle=AssetLoader.Skin_level.getAtlas().findRegion("overlay-middle"); + middle=AssetLoader.Skin_level.getAtlas().findRegion("middle"); + overlay=AssetLoader.Skin_level.getAtlas().findRegion("overlay"); + } + + public void draw(float xx1,float yy1,float xx2,float yy2,float maxwidth,float power,boolean active,Color colorsrc,Color colordst) { + float x1=xx1/1024.0f*Gdx.graphics.getWidth(); + float x2=xx2/1024.0f*Gdx.graphics.getWidth(); + float y1=yy1/768.0f*Gdx.graphics.getHeight(); + float y2=yy2/768.0f*Gdx.graphics.getHeight(); + Vector2 vectorall = new Vector2(x2, y2).sub(new Vector2(x1, y1)); + float length = vectorall.len(); + Vector2 vectoradd = vectorall.scl(10/length); + SpriteBatch Laser=new SpriteBatch(); + Laser.begin(); + Laser.setColor(colorsrc); + Laser.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE); + Laser.draw(overlaymiddle,x1,y1,32,0,64,length,1f,1f,(float)Math.toDegrees(Calcul.getAngle(x1,y1,x2,y2))); + Laser.draw(middle,x1,y1,32,0,64,length,1f,1f,(float)Math.toDegrees(Calcul.getAngle(x1,y1,x2,y2))); + Laser.setColor(new Color(1f,1f,1f,1f)); + Laser.draw(overlay,x1+i*vectoradd.x,y1+i*vectoradd.y,32,0,64,Calcul.getLen(x1+i*vectoradd.x,y1+i*vectoradd.y,x2,y2),1f,1f,(float)Math.toDegrees(Calcul.getAngle(x1,y1,x2,y2))); + Laser.draw(overlay,x1,y1,32,0,64,Calcul.getLen(x1+i*vectoradd.x,y1+i*vectoradd.y,x2,y2),1f,1f,(float)Math.toDegrees(Calcul.getAngle(x1,y1,x2,y2))); + Laser.end(); + Laser.dispose(); + } + + public void drawnotsoold(float xx1,float yy1,float xx2,float yy2,float maxwidth,float power,boolean active,Color colorsrc,Color colordst) { + float x1=xx1/1024.0f*Gdx.graphics.getWidth(); + float x2=xx2/1024.0f*Gdx.graphics.getWidth(); + float y1=yy1/768.0f*Gdx.graphics.getHeight(); + float y2=yy2/768.0f*Gdx.graphics.getHeight(); + ShapeRenderer Laser=new ShapeRenderer(); + //Laser.begin(ShapeType.Line); + Laser.begin(ShapeType.Filled); + //Gdx.gl.glEnable(GL20.GL_BLEND); + Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); + if (active) { + Vector2 vectorall = new Vector2(x2, y2).sub(new Vector2(x1, y1)); + float length = vectorall.len(); + float size=20; + Vector2 vectoradd = vectorall.scl(size/length); + float adding=0; + for(float i = 2; i+2 < length/size; i += 1) + { + float width=(float)(maxwidth-Math.random()*2); + while(width >= 0) + { + adding=(width*power/maxwidth); + Color Acolor=colorsrc.cpy().lerp(colordst.cpy(), (i/(length/size))); + Laser.setColor(Acolor.add(adding,adding,adding,0.5f)); + if (Math.random()>0.4) Laser.rectLine(x1 + i*vectoradd.x, y1 + i*vectoradd.y, x1+ (i+1)*vectoradd.x, y1+(i+1)* vectoradd.y, width); + width=width-1; + } + } + } + else + { + Color Acolor=new Color(0.5f,0.5f,0.5f,1f); + Laser.setColor(Acolor); + Laser.rectLine(x1, y1 , x2, y2, 2); + } + Laser.end(); + Laser.dispose(); + Gdx.gl.glDisable(GL20.GL_BLEND); + } + + + public static void drawold(float xx1,float yy1,float xx2,float yy2,float maxwidth,float power,boolean active,Color colorsrc,Color colordst) { + float x1=xx1/1024.0f*Gdx.graphics.getWidth(); + float x2=xx2/1024.0f*Gdx.graphics.getWidth(); + float y1=yy1/768.0f*Gdx.graphics.getHeight(); + float y2=yy2/768.0f*Gdx.graphics.getHeight(); + ShapeRenderer Laser=new ShapeRenderer(); + //Laser.begin(ShapeType.Line); + float adding=0; + Laser.begin(ShapeType.Point); + Vector2 vec2 = new Vector2(x2, y2).sub(new Vector2(x1, y1)); + float length = vec2.len(); + float awidth=0,width = 0; + float size = 0; + for(int i = 0; i < length; i += 1) { + if ((i % 5)==0) + awidth=(float)(Math.random()*maxwidth/2); + width=awidth; + if (i % ((int)width*20+1)==0) + size=(float)(Math.random()); + vec2.clamp(length - i, length - i); + while(width >= 0) { + adding=(width*power/maxwidth); + Color Acolor=colordst.cpy().lerp(colorsrc.cpy(), (i/length)); + Laser.setColor(Acolor.add(adding,adding,adding,1f)); + if (size>0.4f) { + Laser.point(x1 + vec2.x-width/2, y1 + vec2.y+width/2, 0); + Laser.point(x1 + vec2.x+width/2, y1 + vec2.y-width/2, 0); + } + width=width-1; + } + } + Laser.end(); + Laser.dispose(); + + } +} + + diff --git a/core/src/fr/evolving/game/main.java b/core/src/fr/evolving/game/main.java new file mode 100644 index 0000000..57f258d --- /dev/null +++ b/core/src/fr/evolving/game/main.java @@ -0,0 +1,23 @@ +package fr.evolving.game; + +import com.badlogic.gdx.Game; +import com.badlogic.gdx.Gdx; + +import fr.evolving.screens.GameScreen; +import fr.evolving.screens.SplashScreen; +import fr.evolving.assets.AssetLoader; + +public class main extends Game { + + @Override + public void create() { + setScreen(new SplashScreen(this)); + } + + @Override + public void dispose() { + super.dispose(); + AssetLoader.dispose(); + } + +} \ No newline at end of file diff --git a/core/src/fr/evolving/inputs/InputHandler.java b/core/src/fr/evolving/inputs/InputHandler.java new file mode 100644 index 0000000..2b608b9 --- /dev/null +++ b/core/src/fr/evolving/inputs/InputHandler.java @@ -0,0 +1,74 @@ +package fr.evolving.inputs; + +import java.util.ArrayList; +import java.util.List; + +import com.badlogic.gdx.Input.Keys; +import com.badlogic.gdx.InputProcessor; + +import fr.evolving.worlds.GameWorld; + +public class InputHandler implements InputProcessor { + private GameWorld myWorld; + + private float scaleFactorX; + private float scaleFactorY; + + public InputHandler(float scaleFactorX, float scaleFactorY) { + this.scaleFactorX = scaleFactorX; + this.scaleFactorY = scaleFactorY; + } + + @Override + public boolean touchDown(int screenX, int screenY, int pointer, int button) { + screenX = scaleX(screenX); + screenY = scaleY(screenY); + return true; + } + + @Override + public boolean touchUp(int screenX, int screenY, int pointer, int button) { + screenX = scaleX(screenX); + screenY = scaleY(screenY); + return false; + } + + @Override + public boolean keyDown(int keycode) { + return false; + } + + @Override + public boolean keyUp(int keycode) { + return false; + } + + @Override + public boolean keyTyped(char character) { + return false; + } + + @Override + public boolean touchDragged(int screenX, int screenY, int pointer) { + return false; + } + + @Override + public boolean mouseMoved(int screenX, int screenY) { + return false; + } + + @Override + public boolean scrolled(int amount) { + return false; + } + + private int scaleX(int screenX) { + return (int) (screenX / scaleFactorX); + } + + private int scaleY(int screenY) { + return (int) (screenY / scaleFactorY); + } + +} diff --git a/core/src/fr/evolving/math/Calcul.java b/core/src/fr/evolving/math/Calcul.java new file mode 100644 index 0000000..ede6351 --- /dev/null +++ b/core/src/fr/evolving/math/Calcul.java @@ -0,0 +1,23 @@ +package fr.evolving.math; + +import com.badlogic.gdx.math.Vector2; + +public class Calcul { + + public static double getAngle(float x1,float y1,float x2,float y2) { + double theta = Math.atan2(y2 - y1, x2 - x1); + theta -= Math.PI/2.0f; + if (theta < 0) { + theta += 2.0f*Math.PI; + } + return theta; + } + + + public static float getLen(float x1,float y1,float x2,float y2) { + Vector2 src=new Vector2(x1,y1); + Vector2 dst=new Vector2(x2,y2); + return dst.sub(src).len(); + } + +} \ No newline at end of file diff --git a/core/src/fr/evolving/screens/GameScreen.java b/core/src/fr/evolving/screens/GameScreen.java new file mode 100644 index 0000000..0448150 --- /dev/null +++ b/core/src/fr/evolving/screens/GameScreen.java @@ -0,0 +1,63 @@ +package fr.evolving.screens; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Screen; +import fr.evolving.worlds.GameRenderer; +import fr.evolving.worlds.GameWorld; +import fr.evolving.inputs.InputHandler; + +public class GameScreen implements Screen { + + private GameWorld world; + private GameRenderer renderer; + private float runTime; + + // This is the constructor, not the class declaration + public GameScreen() { + + float screenWidth = Gdx.graphics.getWidth(); + float screenHeight = Gdx.graphics.getHeight(); + float gameWidth = 136; + float gameHeight = screenHeight / (screenWidth / gameWidth); + int midPointY = (int) (gameHeight / 2); + + world = new GameWorld(midPointY); + Gdx.input.setInputProcessor(new InputHandler(screenWidth / gameWidth, screenHeight / gameHeight)); + renderer = new GameRenderer(world, (int) gameHeight, midPointY); + world.setRenderer(renderer); + } + + @Override + public void render(float delta) { + runTime += delta; + world.update(delta); + renderer.render(delta, runTime); + } + + @Override + public void resize(int width, int height) { + } + + @Override + public void show() { + Gdx.app.log("Affichage du GameScreen","ok"); + + } + + @Override + public void hide() { + } + + @Override + public void pause() { + } + + @Override + public void resume() { + } + + @Override + public void dispose() { + } + +} diff --git a/core/src/fr/evolving/screens/LevelScreen.java b/core/src/fr/evolving/screens/LevelScreen.java new file mode 100644 index 0000000..47431b4 --- /dev/null +++ b/core/src/fr/evolving/screens/LevelScreen.java @@ -0,0 +1,123 @@ +package fr.evolving.screens; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Screen; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.g2d.TextureAtlas; +import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; +import com.badlogic.gdx.scenes.scene2d.ui.Skin; +import com.badlogic.gdx.scenes.scene2d.ui.Table; +import com.badlogic.gdx.scenes.scene2d.ui.TextButton; +import com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton; +import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; + +import fr.evolving.worlds.LevelRenderer; +import fr.evolving.UI.ButtonLevel; +import fr.evolving.inputs.InputHandler; +import java.util.Timer; +import java.util.TimerTask; +import fr.evolving.assets.AssetLoader; +import fr.evolving.effects.Laser; + + +public class LevelScreen implements Screen { + public ButtonLevel[] buttonLevels; + private LevelRenderer Renderer; + private float runTime; + private Timer ScrollTimer; + private TimerTask ScrollTask; + private Stage stage = new Stage(); + private Table table = new Table(); + private ImageButton Previous,Next,Exit; + private TextButton buttonPlay,buttonExit; + + // This is the constructor, not the class declaration + public LevelScreen() { + float screenWidth = Gdx.graphics.getWidth(); + float screenHeight = Gdx.graphics.getHeight(); + Renderer=new LevelRenderer((int)screenWidth,(int)screenHeight,this); + buttonLevels = new ButtonLevel[10]; + int[][] integer=new int[][] {{0,2},{0,3},{0,1}}; + buttonLevels[0]= new ButtonLevel("H","Hydrogene en test",0,0,true, integer, true,120,120); + buttonLevels[1]= new ButtonLevel("Li","Lithium a voir",0,1,false, new int[0][0], false,820,520); + buttonLevels[2]= new ButtonLevel("Ne","Neon",0,2,true, new int[0][0], true,420,420); + buttonLevels[3]= new ButtonLevel("Mg","Magnesium 23",0,3,false, new int[0][0], false,420,220); + buttonLevels[4]= new ButtonLevel("Pr","prout 21",1,3,true, integer, true,520,520); + int[][] integer2=new int[][] {{0,1},{1,3},{0,2}}; + buttonLevels[5]= new ButtonLevel("Pr","prout",4,5,true, integer2, true,900,40); + ScrollTimer=new Timer(); + ScrollTask = new TimerTask() + { + @Override + public void run() + { + Renderer.evolve(); + } + }; + ScrollTimer.scheduleAtFixedRate(ScrollTask, 0, 30); + buttonPlay = new TextButton("Play", AssetLoader.Skin_level); + buttonExit = new TextButton("Exit", AssetLoader.Skin_level); + Exit=new ImageButton(AssetLoader.Skin_level,"Exit"); + Exit.setPosition(900, Gdx.graphics.getHeight()-Exit.getHeight()); + Exit.addListener(new ClickListener(){ + @Override + public void clicked(InputEvent event, float x, float y) { + Gdx.app.exit(); + } + }); + Next=new ImageButton(AssetLoader.Skin_level,"Next"); + Next.setPosition(800, 100); + Previous=new ImageButton(AssetLoader.Skin_level,"Previous"); + Previous.setPosition(900, 100); + } + + @Override + public void render(float delta) { + runTime += delta; + Renderer.render(delta, runTime); + stage.act(); + stage.draw(); + } + + @Override + public void resize(int width, int height) { + } + + @Override + public void show() { + Gdx.app.log("Affichage du LevelScreen","ok"); + table.add(buttonPlay).size(150,60).padBottom(20).row(); + table.add(buttonExit).size(150,60).padBottom(20).row(); + for (int i=0;i<10;i++) { + if (buttonLevels[i]!=null) { + stage.addActor(buttonLevels[i]); + } + } + table.setFillParent(true); + stage.addActor(table); + stage.addActor(Exit); + stage.addActor(Next); + stage.addActor(Previous); + Gdx.input.setInputProcessor(stage); + } + + @Override + public void hide() { + } + + @Override + public void pause() { + } + + @Override + public void resume() { + } + + @Override + public void dispose() { + stage.dispose(); + } + +} diff --git a/core/src/fr/evolving/screens/SplashScreen.java b/core/src/fr/evolving/screens/SplashScreen.java new file mode 100644 index 0000000..6eae2df --- /dev/null +++ b/core/src/fr/evolving/screens/SplashScreen.java @@ -0,0 +1,85 @@ +package fr.evolving.screens; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Screen; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.g2d.Sprite; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.Game; + +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.actions.Actions; +import com.badlogic.gdx.scenes.scene2d.ui.Image; + +import fr.evolving.assets.AssetLoader; +import fr.evolving.game.main; + +public class SplashScreen implements Screen { + + private main game; + private Stage stage = new Stage(); + private Image splashImage; + + public SplashScreen(main game) { + this.game = game; + AssetLoader.load(); + splashImage = new Image(AssetLoader.Texture_logo); + } + + @Override + public void show() { + float width = Gdx.graphics.getWidth(); + float height = Gdx.graphics.getHeight(); + float desiredWidth = width * .7f; + float scale = desiredWidth / splashImage.getWidth(); + splashImage.setSize(splashImage.getWidth() * scale, splashImage.getHeight() * scale); + splashImage.setPosition((width / 2) - (splashImage.getWidth() / 2), (height / 2) - (splashImage.getHeight() / 2)); + stage.addActor(splashImage); + splashImage.addAction(Actions.sequence(Actions.alpha(0),Actions.fadeIn(0.5f),Actions.run(new Runnable() { + //splashImage.addAction(Actions.sequence(Actions.alpha(0),Actions.run(new Runnable() { + @Override + public void run() { + AssetLoader.loadall(); + } + }),Actions.run(new Runnable() { + //splashImage.addAction(Actions.sequence(Actions.alpha(0),Actions.run(new Runnable() { + @Override + public void run() { + ((Game)Gdx.app.getApplicationListener()).setScreen(new LevelScreen()); + } + }))); + + AssetLoader.intro.setLooping(0, true); + AssetLoader.intro.play(); + Gdx.app.log("Affichage du SplashScreen","ok"); + } + + @Override + public void render(float delta) { + Gdx.gl.glClearColor(0, 0, 0, 1); + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + stage.act(); + stage.draw(); + } + + @Override + public void resize(int width, int height) { + } + + @Override + public void hide() { + } + + @Override + public void pause() { + } + + @Override + public void resume() { + } + + @Override + public void dispose() { + stage.dispose(); + } +} diff --git a/core/src/fr/evolving/worlds/GameRenderer.java b/core/src/fr/evolving/worlds/GameRenderer.java new file mode 100644 index 0000000..fd053b5 --- /dev/null +++ b/core/src/fr/evolving/worlds/GameRenderer.java @@ -0,0 +1,71 @@ +package fr.evolving.worlds; + +import java.util.List; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.OrthographicCamera; +import com.badlogic.gdx.graphics.g2d.Animation; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; + +import fr.evolving.assets.AssetLoader; +import fr.evolving.inputs.InputHandler; + +public class GameRenderer { + + private GameWorld myWorld; + private OrthographicCamera cam; + private ShapeRenderer shapeRenderer; + private SpriteBatch batcher; + + private int midPointY; + + public GameRenderer(GameWorld world, int gameHeight, int midPointY) { + myWorld = world; + + this.midPointY = midPointY; + + cam = new OrthographicCamera(); + cam.setToOrtho(true, 136, gameHeight); + + batcher = new SpriteBatch(); + batcher.setProjectionMatrix(cam.combined); + shapeRenderer = new ShapeRenderer(); + shapeRenderer.setProjectionMatrix(cam.combined); + } + + + public void render(float delta, float runTime) { + + Gdx.gl.glClearColor(0, 0, 0, 1); + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + + shapeRenderer.begin(ShapeType.Filled); + + // Draw Background color + shapeRenderer.setColor(55 / 255.0f, 80 / 255.0f, 100 / 255.0f, 1); + shapeRenderer.rect(0, 0, 136, midPointY + 66); + + // Draw Grass + shapeRenderer.setColor(111 / 255.0f, 186 / 255.0f, 45 / 255.0f, 1); + shapeRenderer.rect(0, midPointY + 66, 136, 11); + + // Draw Dirt + shapeRenderer.setColor(147 / 255.0f, 80 / 255.0f, 27 / 255.0f, 1); + shapeRenderer.rect(0, midPointY + 77, 136, 52); + + shapeRenderer.end(); + + batcher.begin(); + batcher.disableBlending(); + + //batcher.draw(bg, 0, midPointY + 23, 136, 43); + + batcher.end(); + } + +} diff --git a/core/src/fr/evolving/worlds/GameWorld.java b/core/src/fr/evolving/worlds/GameWorld.java new file mode 100644 index 0000000..72c8d7e --- /dev/null +++ b/core/src/fr/evolving/worlds/GameWorld.java @@ -0,0 +1,44 @@ +package fr.evolving.worlds; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.math.Intersector; +import com.badlogic.gdx.math.Rectangle; + +import fr.evolving.assets.SaveObject; +import fr.evolving.assets.AssetLoader; +import fr.evolving.automata.Grid; + +public class GameWorld { + private float runTime = 0; + private int midPointY; + private GameRenderer renderer; + private GameState currentState; + private Grid myGrid; + private SaveObject MySaveObject; + + public enum GameState { + MENU, READY, RUNNING, GAMEOVER, OPTION + } + + public GameWorld(int midPointY) { + Gdx.app.log("Creation du plateau de jeu","ok"); + currentState = GameState.MENU; + myGrid= new Grid(20,20); + //MySaveObject= new SaveObject("com.mysql.jdbc.Driver","jdbc:mysql://dahut.fr:3306/popfr_games","popfr_games","ef^J,khGMIL~"); + MySaveObject= new SaveObject("com.mysql.jdbc.Driver","jdbc:mysql://192.168.1.252:3306/games","games","WoawGames!!87"); + try { + MySaveObject.saveObject(myGrid); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void update(float delta) { + runTime += delta; + } + + public void setRenderer(GameRenderer renderer) { + this.renderer = renderer; + } + +} diff --git a/core/src/fr/evolving/worlds/LevelRenderer.java b/core/src/fr/evolving/worlds/LevelRenderer.java new file mode 100644 index 0000000..b41bb28 --- /dev/null +++ b/core/src/fr/evolving/worlds/LevelRenderer.java @@ -0,0 +1,104 @@ +package fr.evolving.worlds; + +import java.util.List; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.OrthographicCamera; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.Animation; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer; +import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; + +import fr.evolving.assets.AssetLoader; +import fr.evolving.effects.Laser; +import fr.evolving.inputs.InputHandler; +import fr.evolving.screens.LevelScreen; + +public class LevelRenderer { + private ShapeRenderer shapeRenderer; + private SpriteBatch batcher; + int gameWidth; + int gameHeight; + int scrollx; + int scrolly; + int dirx; + int diry; + LevelScreen LevelScreen; + Laser Laser; + TextureRegion Texture_logobig; + TextureRegion Texture_logosmall; + + public LevelRenderer(int gameWidth, int gameHeight,LevelScreen LevelScreen) { + this.LevelScreen=LevelScreen; + this.scrollx=0; + this.scrolly=0; + this.dirx=1; + this.diry=1; + this.gameHeight=gameHeight; + this.gameWidth=gameWidth; + batcher = new SpriteBatch(); + shapeRenderer = new ShapeRenderer(); + Laser=new Laser(); + } + + public void evolve() { + this.scrollx+=dirx; + this.scrolly+=diry; + if (this.scrollx>1500) + this.scrolly+=diry; + if (this.scrollx > 1024) + this.dirx = -1; + if (this.scrolly > 768) + this.diry = -1; + if (this.scrollx < 0) + this.dirx = 1; + if (this.scrolly < 0) + this.diry = 1; + Laser.i+=1f; + if (Laser.i>10.0f) { + Laser.i=0; + } + } + + public void render(float delta, float runTime) { + Gdx.gl.glClearColor(0, 0, 0, 1); + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); + batcher.begin(); + batcher.setColor(0.25f,0.25f,0.25f,1); + batcher.draw(AssetLoader.Texture_fond2, 0, 0, this.scrollx/2, this.scrolly/2, this.gameWidth, this.gameHeight); + batcher.setColor(0.7f,0.7f,0.7f,1); + batcher.draw(AssetLoader.Texture_fond, 0, 0, this.scrollx, this.scrolly, this.gameWidth, this.gameHeight); + + batcher.setColor(1,1,1,1); + Texture_logobig=AssetLoader.Skin_level.getRegion("logo3"); + Texture_logosmall=AssetLoader.Skin_level.getRegion("logo2"); + batcher.draw(Texture_logosmall,20, this.gameHeight-Texture_logobig.getRegionHeight()+Texture_logosmall.getRegionHeight()/2); + batcher.draw(Texture_logobig,120, this.gameHeight-Texture_logobig.getRegionHeight()); + + batcher.end(); + for (int i=0;i + + + + \ No newline at end of file diff --git a/desktop/build.gradle b/desktop/build.gradle new file mode 100644 index 0000000..ed12df0 --- /dev/null +++ b/desktop/build.gradle @@ -0,0 +1,46 @@ +apply plugin: "java" + +sourceCompatibility = 1.6 +sourceSets.main.java.srcDirs = [ "src/" ] + +project.ext.mainClassName = "fr.evolving.game.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 dist(type: Jar) { + from files(sourceSets.main.output.classesDir) + from files(sourceSets.main.output.resourcesDir) + from {configurations.compile.collect {zipTree(it)}} + from files(project.assetsDir); + + manifest { + attributes 'Main-Class': project.mainClassName + } +} + +dist.dependsOn classes + +eclipse { + project { + name = appName + "-desktop" + linkedResource name: 'assets', type: '2', location: 'PARENT-1-PROJECT_LOC/android/assets' + } +} + +task afterEclipseImport(description: "Post processing after project generation", group: "IDE") { + doLast { + def classpath = new XmlParser().parse(file(".classpath")) + new Node(classpath, "classpathentry", [ kind: 'src', path: 'assets' ]); + def writer = new FileWriter(file(".classpath")) + def printer = new XmlNodePrinter(new PrintWriter(writer)) + printer.setPreserveWhitespace(true) + printer.print(classpath) + } +} \ No newline at end of file diff --git a/desktop/src/fr/evolving/game/desktop/DesktopLauncher.java b/desktop/src/fr/evolving/game/desktop/DesktopLauncher.java new file mode 100644 index 0000000..a2e647b --- /dev/null +++ b/desktop/src/fr/evolving/game/desktop/DesktopLauncher.java @@ -0,0 +1,18 @@ +package fr.evolving.game.desktop; + +import com.badlogic.gdx.backends.lwjgl.LwjglApplication; +import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; +import fr.evolving.game.main; + +public class DesktopLauncher { + public static void main (String[] arg) { + LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); + //config.fullscreen = true; + //config.width = 1920; + //config.height = 1080; + config.fullscreen = false; + config.width = 1280; + config.height = 1024; + new LwjglApplication(new main(), config); + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..fa55fd1 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.daemon=true +org.gradle.jvmargs=-Xms128m -Xmx512m +org.gradle.configureondemand=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..b979729 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..8e600c9 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sat Sep 21 13:08:26 CEST 2013 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=http\://services.gradle.org/distributions/gradle-2.2-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..91a7e26 --- /dev/null +++ b/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# 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 +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# 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\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +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" ] ; 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, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # 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=$((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 + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..aec9973 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,90 @@ +@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 + +@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= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@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 init + +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 init + +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 + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +: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 %CMD_LINE_ARGS% + +: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/ios/Info.plist.xml b/ios/Info.plist.xml new file mode 100644 index 0000000..407bec7 --- /dev/null +++ b/ios/Info.plist.xml @@ -0,0 +1,59 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ${app.name} + CFBundleExecutable + ${app.executable} + CFBundleIdentifier + ${app.id} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${app.name} + CFBundlePackageType + APPL + CFBundleShortVersionString + ${app.version} + CFBundleSignature + ???? + CFBundleVersion + ${app.build} + LSRequiresIPhoneOS + + UIViewControllerBasedStatusBarAppearance + + UIStatusBarHidden + + UIDeviceFamily + + 1 + 2 + + UIRequiredDeviceCapabilities + + armv7 + opengles-2 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + CFBundleIcons + + CFBundlePrimaryIcon + + CFBundleIconFiles + + Icon + Icon-72 + + + + + diff --git a/ios/build.gradle b/ios/build.gradle new file mode 100644 index 0000000..5ff1469 --- /dev/null +++ b/ios/build.gradle @@ -0,0 +1,7 @@ +apply plugin: 'java' +sourceSets { + main.java.srcDirs = ['src'] + main.resources.srcDirs = ['src'] + test.java.srcDirs = ['tests/java'] + test.resources.srcDirs = ['tests/resources'] +} diff --git a/ios/data/Default-375w-667h@2x.png b/ios/data/Default-375w-667h@2x.png new file mode 100644 index 0000000..f213ce6 Binary files /dev/null and b/ios/data/Default-375w-667h@2x.png differ diff --git a/ios/data/Default-414w-736h@3x.png b/ios/data/Default-414w-736h@3x.png new file mode 100644 index 0000000..685ba51 Binary files /dev/null and b/ios/data/Default-414w-736h@3x.png differ diff --git a/ios/data/Default-568h@2x.png b/ios/data/Default-568h@2x.png new file mode 100644 index 0000000..101752f Binary files /dev/null and b/ios/data/Default-568h@2x.png differ diff --git a/ios/data/Default.png b/ios/data/Default.png new file mode 100644 index 0000000..f1a5582 Binary files /dev/null and b/ios/data/Default.png differ diff --git a/ios/data/Default@2x.png b/ios/data/Default@2x.png new file mode 100644 index 0000000..ca32f62 Binary files /dev/null and b/ios/data/Default@2x.png differ diff --git a/ios/data/Default@2x~ipad.png b/ios/data/Default@2x~ipad.png new file mode 100644 index 0000000..bb77ef0 Binary files /dev/null and b/ios/data/Default@2x~ipad.png differ diff --git a/ios/data/Default~ipad.png b/ios/data/Default~ipad.png new file mode 100644 index 0000000..855e4f2 Binary files /dev/null and b/ios/data/Default~ipad.png differ diff --git a/ios/data/Icon-72.png b/ios/data/Icon-72.png new file mode 100644 index 0000000..8cc5759 Binary files /dev/null and b/ios/data/Icon-72.png differ diff --git a/ios/data/Icon-72@2x.png b/ios/data/Icon-72@2x.png new file mode 100644 index 0000000..ec5e380 Binary files /dev/null and b/ios/data/Icon-72@2x.png differ diff --git a/ios/data/Icon.png b/ios/data/Icon.png new file mode 100644 index 0000000..7f4bf36 Binary files /dev/null and b/ios/data/Icon.png differ diff --git a/ios/data/Icon@2x.png b/ios/data/Icon@2x.png new file mode 100644 index 0000000..eddc17c Binary files /dev/null and b/ios/data/Icon@2x.png differ diff --git a/ios/robovm.properties b/ios/robovm.properties new file mode 100644 index 0000000..129f3e1 --- /dev/null +++ b/ios/robovm.properties @@ -0,0 +1,6 @@ +app.version=1.0 +app.id=fr.evolving.game.IOSLauncher +app.mainclass=fr.evolving.game.IOSLauncher +app.executable=IOSLauncher +app.build=1 +app.name=Wireworld diff --git a/ios/robovm.xml b/ios/robovm.xml new file mode 100644 index 0000000..92b1c2f --- /dev/null +++ b/ios/robovm.xml @@ -0,0 +1,50 @@ + + ${app.executable} + ${app.mainclass} + ios + thumbv7 + ios + Info.plist.xml + + + ../android/assets + + ** + + true + + + data + + + + com.badlogic.gdx.scenes.scene2d.ui.* + com.badlogic.gdx.physics.bullet.** + com.badlogic.gdx.graphics.g3d.particles.** + com.android.okhttp.HttpHandler + com.android.okhttp.HttpsHandler + com.android.org.conscrypt.** + com.android.org.bouncycastle.jce.provider.BouncyCastleProvider + com.android.org.bouncycastle.jcajce.provider.keystore.BC$Mappings + com.android.org.bouncycastle.jcajce.provider.keystore.bc.BcKeyStoreSpi + com.android.org.bouncycastle.jcajce.provider.keystore.bc.BcKeyStoreSpi$Std + com.android.org.bouncycastle.jce.provider.PKIXCertPathValidatorSpi + com.android.org.bouncycastle.crypto.digests.AndroidDigestFactoryOpenSSL + org.apache.harmony.security.provider.cert.DRLCertFactory + org.apache.harmony.security.provider.crypto.CryptoProvider + + + build/libs/ios/libObjectAL.a + build/libs/ios/libgdx.a + build/libs/ios/libgdx-box2d.a + + + UIKit + OpenGLES + QuartzCore + CoreGraphics + OpenAL + AudioToolbox + AVFoundation + + diff --git a/ios/src/fr/evolving/game/IOSLauncher.java b/ios/src/fr/evolving/game/IOSLauncher.java new file mode 100644 index 0000000..b97530d --- /dev/null +++ b/ios/src/fr/evolving/game/IOSLauncher.java @@ -0,0 +1,22 @@ +package fr.evolving.game; + +import org.robovm.apple.foundation.NSAutoreleasePool; +import org.robovm.apple.uikit.UIApplication; + +import com.badlogic.gdx.backends.iosrobovm.IOSApplication; +import com.badlogic.gdx.backends.iosrobovm.IOSApplicationConfiguration; +import fr.evolving.game.main; + +public class IOSLauncher extends IOSApplication.Delegate { + @Override + protected IOSApplication createApplication() { + IOSApplicationConfiguration config = new IOSApplicationConfiguration(); + return new IOSApplication(new main(), config); + } + + public static void main(String[] argv) { + NSAutoreleasePool pool = new NSAutoreleasePool(); + UIApplication.main(argv, null, IOSLauncher.class); + pool.close(); + } +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..61be2f7 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include 'desktop', 'android', 'ios', 'core' \ No newline at end of file