forked from NathanFAIN/EpiCiv_2018
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
614 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module external.linked.project.id="Main_Epiciv" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4"> | ||
<component name="FacetManager"> | ||
<facet type="java-gradle" name="Java-Gradle"> | ||
<configuration> | ||
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" /> | ||
<option name="BUILDABLE" value="false" /> | ||
</configuration> | ||
</facet> | ||
</component> | ||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<excludeFolder url="file://$MODULE_DIR$/.gradle" /> | ||
<excludeFolder url="file://$MODULE_DIR$/build" /> | ||
</content> | ||
<orderEntry type="jdk" jdkName="JDK" jdkType="JavaSDK" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
buildscript { | ||
|
||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
maven { url "https://plugins.gradle.org/m2/" } | ||
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } | ||
jcenter() | ||
google() | ||
} | ||
dependencies { | ||
classpath 'com.android.tools.build:gradle:3.2.0' | ||
|
||
|
||
} | ||
} | ||
|
||
allprojects { | ||
apply plugin: "eclipse" | ||
apply plugin: "idea" | ||
|
||
version = '1.0' | ||
ext { | ||
appName = "EpiCiv" | ||
gdxVersion = '1.9.9' | ||
roboVMVersion = '2.3.5' | ||
box2DLightsVersion = '1.4' | ||
ashleyVersion = '1.7.0' | ||
aiVersion = '1.8.0' | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
google() | ||
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } | ||
maven { url "https://oss.sonatype.org/content/repositories/releases/" } | ||
} | ||
} | ||
|
||
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-arm64-v8a" | ||
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86" | ||
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64" | ||
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion" | ||
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi" | ||
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a" | ||
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a" | ||
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86" | ||
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64" | ||
compile "com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion" | ||
compile "com.badlogicgames.gdx:gdx-ai:$aiVersion" | ||
|
||
} | ||
} | ||
|
||
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.gdx:gdx-ai:$aiVersion" | ||
|
||
} | ||
} | ||
|
||
tasks.eclipse.doLast { | ||
delete ".project" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
Binary file not shown.
Binary file added
BIN
+5.62 KB
core/build/classes/java/main/eu/epiciv/scrollmanager/ScrollManager.class
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Manifest-Version: 1.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module external.linked.project.id=":core" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4"> | ||
<component name="FacetManager"> | ||
<facet type="android-gradle" name="Android-Gradle"> | ||
<configuration> | ||
<option name="GRADLE_PROJECT_PATH" value=":core" /> | ||
</configuration> | ||
</facet> | ||
<facet type="java-gradle" name="Java-Gradle"> | ||
<configuration> | ||
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" /> | ||
<option name="BUILDABLE" value="true" /> | ||
</configuration> | ||
</facet> | ||
</component> | ||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6"> | ||
<output url="file://$MODULE_DIR$/build/classes/java/main" /> | ||
<output-test url="file://$MODULE_DIR$/build/classes/java/test" /> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> | ||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" /> | ||
<excludeFolder url="file://$MODULE_DIR$/.gradle" /> | ||
</content> | ||
<orderEntry type="jdk" jdkName="JDK" jdkType="JavaSDK" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" exported="" name="Gradle: gdx-ai-1.8.0" level="project" /> | ||
<orderEntry type="library" exported="" name="Gradle: box2dlights-1.4" level="project" /> | ||
<orderEntry type="library" exported="" name="Gradle: gdx-box2d-1.9.9" level="project" /> | ||
<orderEntry type="library" exported="" name="Gradle: gdx-1.9.9" level="project" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package eu.epiciv.main; | ||
|
||
import com.badlogic.gdx.ApplicationAdapter; | ||
import com.badlogic.gdx.Gdx; | ||
import com.badlogic.gdx.graphics.GL20; | ||
import com.badlogic.gdx.graphics.Texture; | ||
import com.badlogic.gdx.graphics.g2d.SpriteBatch; | ||
import eu.epiciv.scrollmanager.ScrollManager; | ||
|
||
public class Main extends ApplicationAdapter { | ||
ScrollManager scroll; | ||
float delta; | ||
|
||
@Override | ||
public void create () { | ||
scroll = new ScrollManager(); | ||
} | ||
|
||
@Override | ||
public void render () { | ||
scroll.render(delta); | ||
} | ||
|
||
@Override | ||
public void dispose () { | ||
scroll.dispose(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
package eu.epiciv.scrollmanager; | ||
|
||
import com.badlogic.gdx.Gdx; | ||
import com.badlogic.gdx.Screen; | ||
import com.badlogic.gdx.graphics.GL20; | ||
import com.badlogic.gdx.graphics.OrthographicCamera; | ||
import com.badlogic.gdx.graphics.Texture; | ||
import com.badlogic.gdx.graphics.g2d.Sprite; | ||
import com.badlogic.gdx.graphics.g2d.SpriteBatch; | ||
import com.badlogic.gdx.input.GestureDetector; | ||
import com.badlogic.gdx.math.MathUtils; | ||
import com.badlogic.gdx.math.Vector2; | ||
import com.badlogic.gdx.math.Vector3; | ||
|
||
public class ScrollManager implements Screen, GestureDetector.GestureListener { | ||
|
||
private SpriteBatch batch; | ||
private Sprite sprite; | ||
OrthographicCamera camera; | ||
boolean test = false; | ||
Vector3 touchPosition; | ||
private float pos_cam_X = 0; | ||
private float pos_cam_Y = 0; | ||
private float temp_X = 0; | ||
private float temp_Y = 0; | ||
float GAME_WORLD_WIDTH = 1656; | ||
float GAME_WORLD_HEIGHT = 1248; | ||
float aspectRatio; | ||
|
||
public ScrollManager() { | ||
batch = new SpriteBatch(); | ||
sprite = new Sprite(new Texture(Gdx.files.internal("map.png"))); | ||
aspectRatio = (float)Gdx.graphics.getHeight() / (float)Gdx.graphics.getWidth(); | ||
camera = new OrthographicCamera(GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT); | ||
camera.position.set(GAME_WORLD_WIDTH / 2, GAME_WORLD_HEIGHT / 2, 0); | ||
camera.viewportWidth = GAME_WORLD_WIDTH / 2; | ||
camera.viewportHeight = GAME_WORLD_HEIGHT / 2; | ||
camera.update(); | ||
} | ||
|
||
@Override | ||
public void show() { | ||
camera.zoom = 5; | ||
touchPosition = new Vector3(); | ||
Gdx.input.setInputProcessor(new GestureDetector(this)); | ||
} | ||
|
||
public void render() | ||
{ | ||
handleInput(); | ||
camera.update(); | ||
Gdx.gl.glClearColor(1, 0, 0, 1); | ||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); | ||
batch.setProjectionMatrix(camera.combined); | ||
batch.begin(); | ||
sprite.draw(batch); | ||
batch.end(); | ||
} | ||
|
||
@Override | ||
public void render(float delta) { | ||
handleInput(); | ||
camera.update(); | ||
Gdx.gl.glClearColor(1, 0, 0, 1); | ||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); | ||
batch.setProjectionMatrix(camera.combined); | ||
batch.begin(); | ||
sprite.draw(batch); | ||
batch.end(); | ||
} | ||
|
||
@Override | ||
public void resize(int width, int height) { | ||
|
||
} | ||
|
||
@Override | ||
public void pause() { | ||
|
||
} | ||
|
||
@Override | ||
public void resume() { | ||
|
||
} | ||
|
||
@Override | ||
public void dispose() { | ||
sprite.getTexture().dispose(); | ||
} | ||
|
||
@Override | ||
public boolean touchDown(float x, float y, int pointer, int button) { | ||
touchPosition.set(x, y, 0); | ||
camera.unproject(touchPosition); | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean tap(float x, float y, int count, int button) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean longPress(float x, float y) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean fling(float velocityX, float velocityY, int button) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean pan(float x, float y, float deltaX, float deltaY) { | ||
camera.translate(-deltaX, deltaY); | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean panStop(float x, float y, int pointer, int button) { | ||
return false; | ||
} | ||
|
||
private void handleInput() { | ||
|
||
if (Gdx.input.isTouched()) { | ||
temp_X = Gdx.input.getX(); | ||
temp_Y = Gdx.input.getY(); | ||
if (test) { | ||
temp_X = pos_cam_X; | ||
temp_Y = pos_cam_Y; | ||
} | ||
pos_cam_X = Gdx.input.getX(); | ||
pos_cam_Y = Gdx.input.getY(); | ||
camera.translate(temp_X - pos_cam_X, pos_cam_Y - temp_Y, 0 ); | ||
} | ||
test = Gdx.input.isTouched(); | ||
camera.zoom = MathUtils.clamp(camera.zoom, 0.2f, 0.5f); | ||
float effectiveViewportWidth = camera.viewportWidth * camera.zoom; | ||
float effectiveViewportHeight = camera.viewportHeight * camera.zoom; | ||
camera.position.x = MathUtils.clamp(camera.position.x, effectiveViewportWidth / 2f, GAME_WORLD_WIDTH - effectiveViewportWidth / 2f); | ||
camera.position.y = MathUtils.clamp(camera.position.y, effectiveViewportHeight / 2f, GAME_WORLD_HEIGHT - effectiveViewportHeight / 2f); | ||
} | ||
|
||
@Override | ||
public boolean zoom(float initialDistance, float distance) { | ||
if (initialDistance >= distance) { | ||
camera.zoom += 0.02; | ||
} else { | ||
camera.zoom -= 0.02; | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean pinch(Vector2 initialPointer1, Vector2 initialPointer2, Vector2 pointer1, Vector2 pointer2) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void pinchStop() { | ||
} | ||
|
||
@Override | ||
public void hide() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
org.gradle.daemon=true | ||
org.gradle.jvmargs=-Xms128m -Xmx1500m | ||
org.gradle.configureondemand=false |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#Fri Jun 09 23:06:52 EDT 2017 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip |
Oops, something went wrong.