Changes since migrating to GitTea.
This commit is contained in:
parent
a327ea6b82
commit
6516a139cf
24
.gitignore
vendored
24
.gitignore
vendored
@ -1,12 +1,12 @@
|
|||||||
.gradle
|
.gradle
|
||||||
*.apk
|
*.apk
|
||||||
output.json
|
output.json
|
||||||
/local.properties
|
/local.properties
|
||||||
/.idea/workspace.xml
|
/.idea/workspace.xml
|
||||||
/.idea/libraries
|
/.idea/libraries
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/build
|
/build
|
||||||
/captures
|
/captures
|
||||||
/app/build
|
/app/build
|
||||||
/app/release
|
/app/release
|
||||||
*.iml
|
*.iml
|
||||||
|
@ -1,44 +1,44 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:55 PM
|
* Last modified 7/10/18 3:55 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
}
|
}
|
||||||
compileSdkVersion 26
|
compileSdkVersion 26
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId 'de.frajul.endlessroll'
|
applicationId 'de.frajul.endlessroll'
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 26
|
targetSdkVersion 26
|
||||||
versionCode 9
|
versionCode 9
|
||||||
versionName '1.0'
|
versionName '1.0'
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
flavorDimensions 'releaseTargetGroup'
|
flavorDimensions 'releaseTargetGroup'
|
||||||
productFlavors {
|
productFlavors {
|
||||||
flavorStoreRelease {
|
flavorStoreRelease {
|
||||||
dimension 'releaseTargetGroup'
|
dimension 'releaseTargetGroup'
|
||||||
}
|
}
|
||||||
flavorTest {
|
flavorTest {
|
||||||
dimension 'releaseTargetGroup'
|
dimension 'releaseTargetGroup'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
compile 'com.android.support:appcompat-v7:26.1.0'
|
compile 'com.android.support:appcompat-v7:26.1.0'
|
||||||
compile 'com.google.android.gms:play-services-ads:15.0.1'
|
compile 'com.google.android.gms:play-services-ads:15.0.1'
|
||||||
compile files('libs/simple-xml-2.7.1.jar')
|
compile files('libs/simple-xml-2.7.1.jar')
|
||||||
}
|
}
|
||||||
|
@ -1,36 +1,36 @@
|
|||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
uniform sampler2D texture;
|
uniform sampler2D texture;
|
||||||
uniform float alpha;
|
uniform float alpha;
|
||||||
uniform vec2 texAtlasSize;
|
uniform vec2 texAtlasSize;
|
||||||
uniform float texAtlasIndex;
|
uniform float texAtlasIndex;
|
||||||
|
|
||||||
const float clampBorder = 0.005;
|
const float clampBorder = 0.005;
|
||||||
|
|
||||||
varying vec2 pass_TexCoords;
|
varying vec2 pass_TexCoords;
|
||||||
|
|
||||||
vec2 getTexCoordsInAtlas(in vec2 clampedTexCoords, in float atlasIndex);
|
vec2 getTexCoordsInAtlas(in vec2 clampedTexCoords, in float atlasIndex);
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
vec2 clampedTexCoords = pass_TexCoords;
|
vec2 clampedTexCoords = pass_TexCoords;
|
||||||
if(texAtlasSize.x > 1.0 || texAtlasSize.y > 1.0)
|
if(texAtlasSize.x > 1.0 || texAtlasSize.y > 1.0)
|
||||||
clampedTexCoords = clamp(pass_TexCoords, clampBorder, 1.0 - clampBorder);
|
clampedTexCoords = clamp(pass_TexCoords, clampBorder, 1.0 - clampBorder);
|
||||||
|
|
||||||
vec2 texAtlasCoords = getTexCoordsInAtlas(clampedTexCoords, texAtlasIndex);
|
vec2 texAtlasCoords = getTexCoordsInAtlas(clampedTexCoords, texAtlasIndex);
|
||||||
gl_FragColor = texture2D(texture, texAtlasCoords);
|
gl_FragColor = texture2D(texture, texAtlasCoords);
|
||||||
gl_FragColor.a = min(gl_FragColor.a, alpha);
|
gl_FragColor.a = min(gl_FragColor.a, alpha);
|
||||||
gl_FragColor.rgb = gl_FragColor.rgb / gl_FragColor.a;
|
gl_FragColor.rgb = gl_FragColor.rgb / gl_FragColor.a;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vec2 getTexCoordsInAtlas(in vec2 clampedTexCoords, in float atlasIndex){
|
vec2 getTexCoordsInAtlas(in vec2 clampedTexCoords, in float atlasIndex){
|
||||||
|
|
||||||
vec2 texAtlasCoords = vec2(0.0, 0.0);
|
vec2 texAtlasCoords = vec2(0.0, 0.0);
|
||||||
texAtlasCoords.x = mod(clampedTexCoords.x, 1.0) / texAtlasSize.x;
|
texAtlasCoords.x = mod(clampedTexCoords.x, 1.0) / texAtlasSize.x;
|
||||||
texAtlasCoords.x += mod(atlasIndex, texAtlasSize.x) / texAtlasSize.x;
|
texAtlasCoords.x += mod(atlasIndex, texAtlasSize.x) / texAtlasSize.x;
|
||||||
texAtlasCoords.y = mod(clampedTexCoords.y, 1.0) / texAtlasSize.y;
|
texAtlasCoords.y = mod(clampedTexCoords.y, 1.0) / texAtlasSize.y;
|
||||||
texAtlasCoords.y += floor(atlasIndex / texAtlasSize.y) / texAtlasSize.y;
|
texAtlasCoords.y += floor(atlasIndex / texAtlasSize.y) / texAtlasSize.y;
|
||||||
return texAtlasCoords;
|
return texAtlasCoords;
|
||||||
|
|
||||||
}
|
}
|
@ -1,23 +1,23 @@
|
|||||||
uniform mat4 mvpMatrix;
|
uniform mat4 mvpMatrix;
|
||||||
uniform mat4 transformationMatrix;
|
uniform mat4 transformationMatrix;
|
||||||
uniform vec2 texCoordScaling;
|
uniform vec2 texCoordScaling;
|
||||||
|
|
||||||
attribute vec4 position;
|
attribute vec4 position;
|
||||||
attribute vec2 texCoords;
|
attribute vec2 texCoords;
|
||||||
|
|
||||||
varying vec2 pass_TexCoords;
|
varying vec2 pass_TexCoords;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
|
|
||||||
vec2 scale = vec2(1.0, 1.0);
|
vec2 scale = vec2(1.0, 1.0);
|
||||||
if(texCoordScaling.x != 0.0)
|
if(texCoordScaling.x != 0.0)
|
||||||
scale.x = texCoordScaling.x;
|
scale.x = texCoordScaling.x;
|
||||||
if(texCoordScaling.y != 0.0)
|
if(texCoordScaling.y != 0.0)
|
||||||
scale.y *= texCoordScaling.y;
|
scale.y *= texCoordScaling.y;
|
||||||
|
|
||||||
vec4 transformatedPosition = transformationMatrix * position;
|
vec4 transformatedPosition = transformationMatrix * position;
|
||||||
gl_Position = mvpMatrix * transformatedPosition;
|
gl_Position = mvpMatrix * transformatedPosition;
|
||||||
pass_TexCoords = scale * texCoords;
|
pass_TexCoords = scale * texCoords;
|
||||||
|
|
||||||
}
|
}
|
@ -1,27 +1,27 @@
|
|||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
uniform sampler2D texture;
|
uniform sampler2D texture;
|
||||||
uniform vec3 color;
|
uniform vec3 color;
|
||||||
uniform float alpha;
|
uniform float alpha;
|
||||||
|
|
||||||
varying vec2 pass_TexCoords;
|
varying vec2 pass_TexCoords;
|
||||||
|
|
||||||
vec3 saturateColor(in vec3 color, in float a);
|
vec3 saturateColor(in vec3 color, in float a);
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
float a = texture2D(texture, pass_TexCoords).a * alpha;
|
float a = texture2D(texture, pass_TexCoords).a * alpha;
|
||||||
vec3 black = vec3(0.0, 0.0, 0.0);
|
vec3 black = vec3(0.0, 0.0, 0.0);
|
||||||
gl_FragColor.rgb = mix(color, black, 1.0 - a);
|
gl_FragColor.rgb = mix(color, black, 1.0 - a);
|
||||||
gl_FragColor.a = a;
|
gl_FragColor.a = a;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 saturateColor(in vec3 color, in float a){
|
vec3 saturateColor(in vec3 color, in float a){
|
||||||
|
|
||||||
float grayscale = (color.r * 0.299 + color.g * 0.587 + color. b * 0.114);
|
float grayscale = (color.r * 0.299 + color.g * 0.587 + color. b * 0.114);
|
||||||
float alpha = ((1.1 - a) * 0.5) * 40.0;
|
float alpha = ((1.1 - a) * 0.5) * 40.0;
|
||||||
|
|
||||||
return alpha * color + (1.0 - alpha) * vec3(grayscale, grayscale, grayscale);
|
return alpha * color + (1.0 - alpha) * vec3(grayscale, grayscale, grayscale);
|
||||||
|
|
||||||
}
|
}
|
@ -1,12 +1,12 @@
|
|||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
uniform sampler2D texture;
|
uniform sampler2D texture;
|
||||||
|
|
||||||
varying vec2 pass_TexCoords;
|
varying vec2 pass_TexCoords;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
gl_FragColor = texture2D(texture, pass_TexCoords);
|
gl_FragColor = texture2D(texture, pass_TexCoords);
|
||||||
gl_FragColor.rgb = gl_FragColor.rgb / gl_FragColor.a;
|
gl_FragColor.rgb = gl_FragColor.rgb / gl_FragColor.a;
|
||||||
|
|
||||||
}
|
}
|
@ -1,12 +1,12 @@
|
|||||||
attribute vec4 position;
|
attribute vec4 position;
|
||||||
attribute vec2 texCoords;
|
attribute vec2 texCoords;
|
||||||
|
|
||||||
varying vec2 pass_TexCoords;
|
varying vec2 pass_TexCoords;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
gl_Position = position;
|
gl_Position = position;
|
||||||
pass_TexCoords.x = texCoords.x;
|
pass_TexCoords.x = texCoords.x;
|
||||||
pass_TexCoords.y = -texCoords.y;
|
pass_TexCoords.y = -texCoords.y;
|
||||||
|
|
||||||
}
|
}
|
34
app/proguard-rules.pro
vendored
34
app/proguard-rules.pro
vendored
@ -1,17 +1,17 @@
|
|||||||
# Add project specific ProGuard rules here.
|
# Add project specific ProGuard rules here.
|
||||||
# By default, the flags in this file are appended to flags specified
|
# By default, the flags in this file are appended to flags specified
|
||||||
# in C:\Users\Julian\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt
|
# in C:\Users\Julian\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt
|
||||||
# You can edit the include path and order by changing the proguardFiles
|
# You can edit the include path and order by changing the proguardFiles
|
||||||
# directive in build.gradle.
|
# directive in build.gradle.
|
||||||
#
|
#
|
||||||
# For more details, see
|
# For more details, see
|
||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
# Add any project specific keep options here:
|
# Add any project specific keep options here:
|
||||||
|
|
||||||
# If your project uses WebView with JS, uncomment the following
|
# If your project uses WebView with JS, uncomment the following
|
||||||
# and specify the fully qualified class name to the JavaScript interface
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
# class:
|
# class:
|
||||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
# public *;
|
# public *;
|
||||||
#}
|
#}
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll;
|
package de.frajul.endlessroll;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.test.ApplicationTestCase;
|
import android.test.ApplicationTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
||||||
*/
|
*/
|
||||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||||
public ApplicationTest() {
|
public ApplicationTest() {
|
||||||
super(Application.class);
|
super(Application.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,36 +1,36 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
<!--
|
||||||
~ Created by Julian Mutter on 7/10/18 3:58 PM
|
~ Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
~ Copyright (c) 2018. All rights reserved.
|
~ Copyright (c) 2018. All rights reserved.
|
||||||
~ Last modified 7/10/18 3:54 PM
|
~ Last modified 7/10/18 3:54 PM
|
||||||
~
|
~
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="de.frajul.endlessroll">
|
package="de.frajul.endlessroll">
|
||||||
|
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:glEsVersion="0x00020000"
|
android:glEsVersion="0x00020000"
|
||||||
android:required="true" />
|
android:required="true" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
<activity
|
<activity
|
||||||
android:name=".main.GameActivity"
|
android:name=".main.GameActivity"
|
||||||
android:configChanges="orientation|screenSize|keyboardHidden"
|
android:configChanges="orientation|screenSize|keyboardHidden"
|
||||||
android:screenOrientation="sensorLandscape">
|
android:screenOrientation="sensorLandscape">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@ -1,42 +1,42 @@
|
|||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
uniform sampler2D texture;
|
uniform sampler2D texture;
|
||||||
uniform float alpha;
|
uniform float alpha;
|
||||||
uniform vec2 texAtlasSize;
|
uniform vec2 texAtlasSize;
|
||||||
uniform float texAtlasIndex;
|
uniform float texAtlasIndex;
|
||||||
uniform float hasColor;
|
uniform float hasColor;
|
||||||
uniform vec3 color;
|
uniform vec3 color;
|
||||||
|
|
||||||
const float clampBorder = 0.005;
|
const float clampBorder = 0.005;
|
||||||
|
|
||||||
varying vec2 pass_TexCoords;
|
varying vec2 pass_TexCoords;
|
||||||
|
|
||||||
vec2 getTexCoordsInAtlas(in vec2 clampedTexCoords, in float atlasIndex);
|
vec2 getTexCoordsInAtlas(in vec2 clampedTexCoords, in float atlasIndex);
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
vec2 clampedTexCoords = pass_TexCoords;
|
vec2 clampedTexCoords = pass_TexCoords;
|
||||||
if(texAtlasSize.x > 1.0 || texAtlasSize.y > 1.0)
|
if(texAtlasSize.x > 1.0 || texAtlasSize.y > 1.0)
|
||||||
clampedTexCoords = clamp(pass_TexCoords, clampBorder, 1.0 - clampBorder);
|
clampedTexCoords = clamp(pass_TexCoords, clampBorder, 1.0 - clampBorder);
|
||||||
|
|
||||||
vec2 texAtlasCoords = getTexCoordsInAtlas(clampedTexCoords, texAtlasIndex);
|
vec2 texAtlasCoords = getTexCoordsInAtlas(clampedTexCoords, texAtlasIndex);
|
||||||
gl_FragColor = texture2D(texture, texAtlasCoords);
|
gl_FragColor = texture2D(texture, texAtlasCoords);
|
||||||
gl_FragColor.a = min(gl_FragColor.a, alpha);
|
gl_FragColor.a = min(gl_FragColor.a, alpha);
|
||||||
if(hasColor == 1.0){
|
if(hasColor == 1.0){
|
||||||
gl_FragColor.rgb = color;
|
gl_FragColor.rgb = color;
|
||||||
} else {
|
} else {
|
||||||
gl_FragColor.rgb = gl_FragColor.rgb / gl_FragColor.a;
|
gl_FragColor.rgb = gl_FragColor.rgb / gl_FragColor.a;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vec2 getTexCoordsInAtlas(in vec2 clampedTexCoords, in float atlasIndex){
|
vec2 getTexCoordsInAtlas(in vec2 clampedTexCoords, in float atlasIndex){
|
||||||
|
|
||||||
vec2 texAtlasCoords = vec2(0.0, 0.0);
|
vec2 texAtlasCoords = vec2(0.0, 0.0);
|
||||||
texAtlasCoords.x = mod(clampedTexCoords.x, 1.0) / texAtlasSize.x;
|
texAtlasCoords.x = mod(clampedTexCoords.x, 1.0) / texAtlasSize.x;
|
||||||
texAtlasCoords.x += mod(atlasIndex, texAtlasSize.x) / texAtlasSize.x;
|
texAtlasCoords.x += mod(atlasIndex, texAtlasSize.x) / texAtlasSize.x;
|
||||||
texAtlasCoords.y = mod(clampedTexCoords.y, 1.0) / texAtlasSize.y;
|
texAtlasCoords.y = mod(clampedTexCoords.y, 1.0) / texAtlasSize.y;
|
||||||
texAtlasCoords.y += floor(atlasIndex / texAtlasSize.y) / texAtlasSize.y;
|
texAtlasCoords.y += floor(atlasIndex / texAtlasSize.y) / texAtlasSize.y;
|
||||||
return texAtlasCoords;
|
return texAtlasCoords;
|
||||||
|
|
||||||
}
|
}
|
@ -1,23 +1,23 @@
|
|||||||
uniform mat4 mvpMatrix;
|
uniform mat4 mvpMatrix;
|
||||||
uniform mat4 transformationMatrix;
|
uniform mat4 transformationMatrix;
|
||||||
uniform vec2 texCoordScaling;
|
uniform vec2 texCoordScaling;
|
||||||
|
|
||||||
attribute vec4 position;
|
attribute vec4 position;
|
||||||
attribute vec2 texCoords;
|
attribute vec2 texCoords;
|
||||||
|
|
||||||
varying vec2 pass_TexCoords;
|
varying vec2 pass_TexCoords;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
|
|
||||||
vec2 scale = vec2(1.0, 1.0);
|
vec2 scale = vec2(1.0, 1.0);
|
||||||
if(texCoordScaling.x != 0.0)
|
if(texCoordScaling.x != 0.0)
|
||||||
scale.x = texCoordScaling.x;
|
scale.x = texCoordScaling.x;
|
||||||
if(texCoordScaling.y != 0.0)
|
if(texCoordScaling.y != 0.0)
|
||||||
scale.y *= texCoordScaling.y;
|
scale.y *= texCoordScaling.y;
|
||||||
|
|
||||||
vec4 transformatedPosition = transformationMatrix * position;
|
vec4 transformatedPosition = transformationMatrix * position;
|
||||||
gl_Position = mvpMatrix * transformatedPosition;
|
gl_Position = mvpMatrix * transformatedPosition;
|
||||||
pass_TexCoords = scale * texCoords;
|
pass_TexCoords = scale * texCoords;
|
||||||
|
|
||||||
}
|
}
|
@ -1,53 +1,53 @@
|
|||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
uniform sampler2D texture;
|
uniform sampler2D texture;
|
||||||
uniform float useCustomColor;
|
uniform float useCustomColor;
|
||||||
uniform vec3 color;
|
uniform vec3 color;
|
||||||
uniform float alpha;
|
uniform float alpha;
|
||||||
uniform float roundValue;
|
uniform float roundValue;
|
||||||
uniform float visibleAmount;
|
uniform float visibleAmount;
|
||||||
|
|
||||||
varying vec2 pass_TexCoords;
|
varying vec2 pass_TexCoords;
|
||||||
|
|
||||||
float isInRoundedRange();
|
float isInRoundedRange();
|
||||||
float isInVisiblePart();
|
float isInVisiblePart();
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
if(isInRoundedRange() == 1.0 && isInVisiblePart() == 1.0){
|
if(isInRoundedRange() == 1.0 && isInVisiblePart() == 1.0){
|
||||||
if(useCustomColor == 1.0){
|
if(useCustomColor == 1.0){
|
||||||
gl_FragColor.rgb = color;
|
gl_FragColor.rgb = color;
|
||||||
gl_FragColor.a = alpha;
|
gl_FragColor.a = alpha;
|
||||||
} else {
|
} else {
|
||||||
gl_FragColor = texture2D(texture, pass_TexCoords);
|
gl_FragColor = texture2D(texture, pass_TexCoords);
|
||||||
gl_FragColor.a = min(gl_FragColor.a, alpha);
|
gl_FragColor.a = min(gl_FragColor.a, alpha);
|
||||||
}
|
}
|
||||||
gl_FragColor.rgb = gl_FragColor.rgb / gl_FragColor.a;
|
gl_FragColor.rgb = gl_FragColor.rgb / gl_FragColor.a;
|
||||||
} else {
|
} else {
|
||||||
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
|
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float isInRoundedRange(){
|
float isInRoundedRange(){
|
||||||
if(roundValue == 0.0)
|
if(roundValue == 0.0)
|
||||||
return 1.0;
|
return 1.0;
|
||||||
float relativeX = abs((pass_TexCoords.x- 0.5));
|
float relativeX = abs((pass_TexCoords.x- 0.5));
|
||||||
float relativeY = abs(pass_TexCoords.y - 0.5);
|
float relativeY = abs(pass_TexCoords.y - 0.5);
|
||||||
float circleX = abs(roundValue * 0.5 - 0.5);
|
float circleX = abs(roundValue * 0.5 - 0.5);
|
||||||
float circleY = abs(roundValue * 0.5 - 0.5);
|
float circleY = abs(roundValue * 0.5 - 0.5);
|
||||||
if(relativeX < circleX || relativeY < circleY)
|
if(relativeX < circleX || relativeY < circleY)
|
||||||
return 1.0;
|
return 1.0;
|
||||||
float radius = roundValue * 0.5;
|
float radius = roundValue * 0.5;
|
||||||
float distX = relativeX - circleX;
|
float distX = relativeX - circleX;
|
||||||
float distY = relativeY - circleY;
|
float distY = relativeY - circleY;
|
||||||
if(distX * distX + distY * distY > radius * radius)
|
if(distX * distX + distY * distY > radius * radius)
|
||||||
return 0.0;
|
return 0.0;
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float isInVisiblePart(){
|
float isInVisiblePart(){
|
||||||
if(pass_TexCoords.x >= visibleAmount)
|
if(pass_TexCoords.x >= visibleAmount)
|
||||||
return 1.0;
|
return 1.0;
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
@ -1,15 +1,15 @@
|
|||||||
uniform mat4 mvpMatrix;
|
uniform mat4 mvpMatrix;
|
||||||
uniform mat4 transformationMatrix;
|
uniform mat4 transformationMatrix;
|
||||||
|
|
||||||
attribute vec4 position;
|
attribute vec4 position;
|
||||||
attribute vec2 texCoords;
|
attribute vec2 texCoords;
|
||||||
|
|
||||||
varying vec2 pass_TexCoords;
|
varying vec2 pass_TexCoords;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
vec4 transformatedPosition = transformationMatrix * position;
|
vec4 transformatedPosition = transformationMatrix * position;
|
||||||
gl_Position = mvpMatrix * transformatedPosition;
|
gl_Position = mvpMatrix * transformatedPosition;
|
||||||
pass_TexCoords = texCoords;
|
pass_TexCoords = texCoords;
|
||||||
|
|
||||||
}
|
}
|
@ -1,115 +1,115 @@
|
|||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
uniform sampler2D texture;
|
uniform sampler2D texture;
|
||||||
uniform float alpha;
|
uniform float alpha;
|
||||||
uniform vec2 texAtlasSize;
|
uniform vec2 texAtlasSize;
|
||||||
uniform vec2 gridSize;
|
uniform vec2 gridSize;
|
||||||
uniform float deadly;
|
uniform float deadly;
|
||||||
uniform float floating;
|
uniform float floating;
|
||||||
uniform float bombSelected;
|
uniform float bombSelected;
|
||||||
uniform float bombExplosionState;
|
uniform float bombExplosionState;
|
||||||
|
|
||||||
varying vec2 pass_TexCoords;
|
varying vec2 pass_TexCoords;
|
||||||
|
|
||||||
const float clampBorder = 0.05;
|
const float clampBorder = 0.05;
|
||||||
|
|
||||||
float itermod(in float x, in float y);
|
float itermod(in float x, in float y);
|
||||||
vec2 getInGridPos();
|
vec2 getInGridPos();
|
||||||
vec2 getTexCoordsInGridSquare();
|
vec2 getTexCoordsInGridSquare();
|
||||||
vec2 getTexCoordsInAtlas(in vec2 texCoords, in float atlasIndex);
|
vec2 getTexCoordsInAtlas(in vec2 texCoords, in float atlasIndex);
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
vec2 gridPos = getInGridPos();
|
vec2 gridPos = getInGridPos();
|
||||||
float index = 0.0;
|
float index = 0.0;
|
||||||
|
|
||||||
bool top = gridPos.y == 0.0;
|
bool top = gridPos.y == 0.0;
|
||||||
bool bottom = gridPos.y == gridSize.y - 1.0;
|
bool bottom = gridPos.y == gridSize.y - 1.0;
|
||||||
bool left = gridPos.x == 0.0;
|
bool left = gridPos.x == 0.0;
|
||||||
bool right = gridPos.x == gridSize.x - 1.0;
|
bool right = gridPos.x == gridSize.x - 1.0;
|
||||||
|
|
||||||
if(top){
|
if(top){
|
||||||
if(left)
|
if(left)
|
||||||
index = 5.0 + itermod(gridSize.x, 2.0) + itermod(gridSize.y, 2.0);
|
index = 5.0 + itermod(gridSize.x, 2.0) + itermod(gridSize.y, 2.0);
|
||||||
else if(right)
|
else if(right)
|
||||||
index = 21.0 + itermod(gridSize.x, 2.0) + itermod(gridSize.y, 2.0);
|
index = 21.0 + itermod(gridSize.x, 2.0) + itermod(gridSize.y, 2.0);
|
||||||
else
|
else
|
||||||
index = itermod(gridPos.x, 3.0);
|
index = itermod(gridPos.x, 3.0);
|
||||||
if(deadly == 1.0)
|
if(deadly == 1.0)
|
||||||
index += 8.0;
|
index += 8.0;
|
||||||
} else if(bottom){
|
} else if(bottom){
|
||||||
if(left)
|
if(left)
|
||||||
index = 37.0 + itermod(gridSize.x, 2.0) + itermod(gridSize.y, 2.0);
|
index = 37.0 + itermod(gridSize.x, 2.0) + itermod(gridSize.y, 2.0);
|
||||||
else if(right)
|
else if(right)
|
||||||
index = 53.0 + itermod(gridSize.x, 2.0) + itermod(gridSize.y, 2.0);
|
index = 53.0 + itermod(gridSize.x, 2.0) + itermod(gridSize.y, 2.0);
|
||||||
else
|
else
|
||||||
index = 16.0 + itermod(gridPos.x, 3.0);
|
index = 16.0 + itermod(gridPos.x, 3.0);
|
||||||
if(floating == 1.0)
|
if(floating == 1.0)
|
||||||
index += 8.0;
|
index += 8.0;
|
||||||
} else if(left){
|
} else if(left){
|
||||||
index = 32.0 + itermod(gridPos.y, 3.0);
|
index = 32.0 + itermod(gridPos.y, 3.0);
|
||||||
} else if(gridPos.x == gridSize.x - 1.0){
|
} else if(gridPos.x == gridSize.x - 1.0){
|
||||||
index = 40.0 + itermod(gridPos.y, 3.0);
|
index = 40.0 + itermod(gridPos.y, 3.0);
|
||||||
} else{
|
} else{
|
||||||
index = 48.0 + itermod(gridPos.x, 2.0) + itermod(gridPos.y, 2.0);
|
index = 48.0 + itermod(gridPos.x, 2.0) + itermod(gridPos.y, 2.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
vec2 texCoordsInGridSquare = getTexCoordsInGridSquare();
|
vec2 texCoordsInGridSquare = getTexCoordsInGridSquare();
|
||||||
texCoordsInGridSquare = clamp(texCoordsInGridSquare, clampBorder, 1.0 - clampBorder);
|
texCoordsInGridSquare = clamp(texCoordsInGridSquare, clampBorder, 1.0 - clampBorder);
|
||||||
vec2 texCoordsInAtlas = getTexCoordsInAtlas(texCoordsInGridSquare, index);
|
vec2 texCoordsInAtlas = getTexCoordsInAtlas(texCoordsInGridSquare, index);
|
||||||
gl_FragColor = texture2D(texture, texCoordsInAtlas);
|
gl_FragColor = texture2D(texture, texCoordsInAtlas);
|
||||||
gl_FragColor.a = min(gl_FragColor.a, alpha);
|
gl_FragColor.a = min(gl_FragColor.a, alpha);
|
||||||
gl_FragColor.rgb = gl_FragColor.rgb / gl_FragColor.a;
|
gl_FragColor.rgb = gl_FragColor.rgb / gl_FragColor.a;
|
||||||
|
|
||||||
if(bombSelected == 1.0 || bombExplosionState >= 0.0){
|
if(bombSelected == 1.0 || bombExplosionState >= 0.0){
|
||||||
vec3 red = vec3(1.0, 0.0, 0.0);
|
vec3 red = vec3(1.0, 0.0, 0.0);
|
||||||
float mixValue = 0.4;
|
float mixValue = 0.4;
|
||||||
gl_FragColor.r += 0.2 * bombExplosionState;
|
gl_FragColor.r += 0.2 * bombExplosionState;
|
||||||
gl_FragColor.rgb = mix(gl_FragColor.rgb, red, mixValue);
|
gl_FragColor.rgb = mix(gl_FragColor.rgb, red, mixValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float itermod(in float x, in float y){
|
float itermod(in float x, in float y){
|
||||||
|
|
||||||
while(x - y >= 0.0){
|
while(x - y >= 0.0){
|
||||||
x -= y;
|
x -= y;
|
||||||
}
|
}
|
||||||
return x;
|
return x;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vec2 getInGridPos(){
|
vec2 getInGridPos(){
|
||||||
|
|
||||||
float gridX = floor(pass_TexCoords.x * gridSize.x);
|
float gridX = floor(pass_TexCoords.x * gridSize.x);
|
||||||
float gridY = floor(pass_TexCoords.y * gridSize.y);
|
float gridY = floor(pass_TexCoords.y * gridSize.y);
|
||||||
if(pass_TexCoords.y == 1.0)
|
if(pass_TexCoords.y == 1.0)
|
||||||
gridY -= 1.0;
|
gridY -= 1.0;
|
||||||
if(pass_TexCoords.x == 1.0)
|
if(pass_TexCoords.x == 1.0)
|
||||||
gridX -= 1.0;
|
gridX -= 1.0;
|
||||||
return vec2(gridX, gridY);
|
return vec2(gridX, gridY);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vec2 getTexCoordsInGridSquare(){
|
vec2 getTexCoordsInGridSquare(){
|
||||||
|
|
||||||
float x = mod(pass_TexCoords.x, 1.0 / gridSize.x) * gridSize.x;
|
float x = mod(pass_TexCoords.x, 1.0 / gridSize.x) * gridSize.x;
|
||||||
float y = mod(pass_TexCoords.y, 1.0 / gridSize.y) * gridSize.y;
|
float y = mod(pass_TexCoords.y, 1.0 / gridSize.y) * gridSize.y;
|
||||||
if(pass_TexCoords.x == 1.0)
|
if(pass_TexCoords.x == 1.0)
|
||||||
x = 1.0;
|
x = 1.0;
|
||||||
if(pass_TexCoords.y == 1.0)
|
if(pass_TexCoords.y == 1.0)
|
||||||
y = 1.0;
|
y = 1.0;
|
||||||
return vec2(x, y);
|
return vec2(x, y);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vec2 getTexCoordsInAtlas(in vec2 texCoords, in float atlasIndex){
|
vec2 getTexCoordsInAtlas(in vec2 texCoords, in float atlasIndex){
|
||||||
|
|
||||||
vec2 texAtlasCoords = vec2(0.0, 0.0);
|
vec2 texAtlasCoords = vec2(0.0, 0.0);
|
||||||
texAtlasCoords.x = mod(texCoords.x, 1.0) / texAtlasSize.x;
|
texAtlasCoords.x = mod(texCoords.x, 1.0) / texAtlasSize.x;
|
||||||
texAtlasCoords.x += mod(atlasIndex, texAtlasSize.x) / texAtlasSize.x;
|
texAtlasCoords.x += mod(atlasIndex, texAtlasSize.x) / texAtlasSize.x;
|
||||||
texAtlasCoords.y = mod(texCoords.y, 1.0) / texAtlasSize.y;
|
texAtlasCoords.y = mod(texCoords.y, 1.0) / texAtlasSize.y;
|
||||||
texAtlasCoords.y += floor(atlasIndex / texAtlasSize.y) / texAtlasSize.y;
|
texAtlasCoords.y += floor(atlasIndex / texAtlasSize.y) / texAtlasSize.y;
|
||||||
return texAtlasCoords;
|
return texAtlasCoords;
|
||||||
|
|
||||||
}
|
}
|
@ -1,27 +1,27 @@
|
|||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
uniform sampler2D texture;
|
uniform sampler2D texture;
|
||||||
uniform vec3 color;
|
uniform vec3 color;
|
||||||
uniform float alpha;
|
uniform float alpha;
|
||||||
|
|
||||||
varying vec2 pass_TexCoords;
|
varying vec2 pass_TexCoords;
|
||||||
|
|
||||||
vec3 saturateColor(in vec3 color, in float a);
|
vec3 saturateColor(in vec3 color, in float a);
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
float a = texture2D(texture, pass_TexCoords).a * alpha;
|
float a = texture2D(texture, pass_TexCoords).a * alpha;
|
||||||
vec3 black = vec3(0.0, 0.0, 0.0);
|
vec3 black = vec3(0.0, 0.0, 0.0);
|
||||||
gl_FragColor.rgb = mix(color, black, 1.0 - a);
|
gl_FragColor.rgb = mix(color, black, 1.0 - a);
|
||||||
gl_FragColor.a = a;
|
gl_FragColor.a = a;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 saturateColor(in vec3 color, in float a){
|
vec3 saturateColor(in vec3 color, in float a){
|
||||||
|
|
||||||
float grayscale = (color.r * 0.299 + color.g * 0.587 + color. b * 0.114);
|
float grayscale = (color.r * 0.299 + color.g * 0.587 + color. b * 0.114);
|
||||||
float alpha = ((1.1 - a) * 0.5) * 40.0;
|
float alpha = ((1.1 - a) * 0.5) * 40.0;
|
||||||
|
|
||||||
return alpha * color + (1.0 - alpha) * vec3(grayscale, grayscale, grayscale);
|
return alpha * color + (1.0 - alpha) * vec3(grayscale, grayscale, grayscale);
|
||||||
|
|
||||||
}
|
}
|
@ -1,12 +1,12 @@
|
|||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
uniform sampler2D texture;
|
uniform sampler2D texture;
|
||||||
|
|
||||||
varying vec2 pass_TexCoords;
|
varying vec2 pass_TexCoords;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
gl_FragColor = texture2D(texture, pass_TexCoords);
|
gl_FragColor = texture2D(texture, pass_TexCoords);
|
||||||
gl_FragColor.rgb = gl_FragColor.rgb / gl_FragColor.a;
|
gl_FragColor.rgb = gl_FragColor.rgb / gl_FragColor.a;
|
||||||
|
|
||||||
}
|
}
|
@ -1,12 +1,12 @@
|
|||||||
attribute vec4 position;
|
attribute vec4 position;
|
||||||
attribute vec2 texCoords;
|
attribute vec2 texCoords;
|
||||||
|
|
||||||
varying vec2 pass_TexCoords;
|
varying vec2 pass_TexCoords;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
gl_Position = position;
|
gl_Position = position;
|
||||||
pass_TexCoords.x = texCoords.x;
|
pass_TexCoords.x = texCoords.x;
|
||||||
pass_TexCoords.y = -texCoords.y;
|
pass_TexCoords.y = -texCoords.y;
|
||||||
|
|
||||||
}
|
}
|
@ -1,46 +1,46 @@
|
|||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
uniform sampler2D texture;
|
uniform sampler2D texture;
|
||||||
uniform float gridColumnCount;
|
uniform float gridColumnCount;
|
||||||
uniform float isEndlessTileList;
|
uniform float isEndlessTileList;
|
||||||
|
|
||||||
varying vec2 pass_TexCoords;
|
varying vec2 pass_TexCoords;
|
||||||
|
|
||||||
const float texAtlasWidth = 3.0;
|
const float texAtlasWidth = 3.0;
|
||||||
|
|
||||||
float getAtlasIndex();
|
float getAtlasIndex();
|
||||||
vec2 getTexCoordsInAtlas(in vec2 texCoordsInGrid, in float atlasIndex);
|
vec2 getTexCoordsInAtlas(in vec2 texCoordsInGrid, in float atlasIndex);
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
float atlasIndex = getAtlasIndex();
|
float atlasIndex = getAtlasIndex();
|
||||||
vec2 texCoordsInGrid = pass_TexCoords;
|
vec2 texCoordsInGrid = pass_TexCoords;
|
||||||
texCoordsInGrid.x *= gridColumnCount;
|
texCoordsInGrid.x *= gridColumnCount;
|
||||||
texCoordsInGrid.x = mod(texCoordsInGrid.x, 1.0);
|
texCoordsInGrid.x = mod(texCoordsInGrid.x, 1.0);
|
||||||
vec2 texCoordsInAtlas = getTexCoordsInAtlas(texCoordsInGrid, atlasIndex);
|
vec2 texCoordsInAtlas = getTexCoordsInAtlas(texCoordsInGrid, atlasIndex);
|
||||||
|
|
||||||
gl_FragColor = texture2D(texture, texCoordsInAtlas);
|
gl_FragColor = texture2D(texture, texCoordsInAtlas);
|
||||||
gl_FragColor.rgb = gl_FragColor.rgb / gl_FragColor.a;
|
gl_FragColor.rgb = gl_FragColor.rgb / gl_FragColor.a;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getAtlasIndex(){
|
float getAtlasIndex(){
|
||||||
|
|
||||||
if(isEndlessTileList == 1.0)
|
if(isEndlessTileList == 1.0)
|
||||||
return 1.0;
|
return 1.0;
|
||||||
|
|
||||||
if(pass_TexCoords.x < 1.0 / gridColumnCount)
|
if(pass_TexCoords.x < 1.0 / gridColumnCount)
|
||||||
return 0.0;
|
return 0.0;
|
||||||
if(pass_TexCoords.x > 1.0 - 1.0 / gridColumnCount)
|
if(pass_TexCoords.x > 1.0 - 1.0 / gridColumnCount)
|
||||||
return 2.0;
|
return 2.0;
|
||||||
return 1.0;
|
return 1.0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vec2 getTexCoordsInAtlas(in vec2 texCoordsInGrid, in float atlasIndex){
|
vec2 getTexCoordsInAtlas(in vec2 texCoordsInGrid, in float atlasIndex){
|
||||||
|
|
||||||
vec2 texAtlasCoords = vec2(0.0, texCoordsInGrid.y);
|
vec2 texAtlasCoords = vec2(0.0, texCoordsInGrid.y);
|
||||||
texAtlasCoords.x = texCoordsInGrid.x / texAtlasWidth;
|
texAtlasCoords.x = texCoordsInGrid.x / texAtlasWidth;
|
||||||
texAtlasCoords.x += mod(atlasIndex, texAtlasWidth) / texAtlasWidth;
|
texAtlasCoords.x += mod(atlasIndex, texAtlasWidth) / texAtlasWidth;
|
||||||
return texAtlasCoords;
|
return texAtlasCoords;
|
||||||
|
|
||||||
}
|
}
|
@ -1,74 +1,74 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.data;
|
package de.frajul.endlessroll.data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 02.08.2016.
|
* Created by Julian on 02.08.2016.
|
||||||
*/
|
*/
|
||||||
public class Color3f {
|
public class Color3f {
|
||||||
|
|
||||||
private float r, g, b;
|
private float r, g, b;
|
||||||
|
|
||||||
public Color3f() {
|
public Color3f() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color3f(float r, float g, float b) {
|
public Color3f(float r, float g, float b) {
|
||||||
this.r = r;
|
this.r = r;
|
||||||
this.g = g;
|
this.g = g;
|
||||||
this.b = b;
|
this.b = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color3f(Color3f other) {
|
public Color3f(Color3f other) {
|
||||||
this.r = other.getR();
|
this.r = other.getR();
|
||||||
this.g = other.getG();
|
this.g = other.getG();
|
||||||
this.b = other.getB();
|
this.b = other.getB();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color3f interpolate(float leftValue, float rightValue, Color3f color2) {
|
public Color3f interpolate(float leftValue, float rightValue, Color3f color2) {
|
||||||
float r = this.r + (color2.r - this.r) * leftValue;
|
float r = this.r + (color2.r - this.r) * leftValue;
|
||||||
float g = this.g + (color2.g - this.g) * leftValue;
|
float g = this.g + (color2.g - this.g) * leftValue;
|
||||||
float b = this.b + (color2.b - this.b) * leftValue;
|
float b = this.b + (color2.b - this.b) * leftValue;
|
||||||
return new Color3f(r, g, b);
|
return new Color3f(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mul(float a) {
|
private void mul(float a) {
|
||||||
r *= a;
|
r *= a;
|
||||||
g *= a;
|
g *= a;
|
||||||
b *= a;
|
b *= a;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void add(Color3f other) {
|
private void add(Color3f other) {
|
||||||
r += other.getR();
|
r += other.getR();
|
||||||
g += other.getG();
|
g += other.getG();
|
||||||
b += other.getB();
|
b += other.getB();
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getR() {
|
public float getR() {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setR(float r) {
|
public void setR(float r) {
|
||||||
this.r = r;
|
this.r = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getG() {
|
public float getG() {
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setG(float g) {
|
public void setG(float g) {
|
||||||
this.g = g;
|
this.g = g;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getB() {
|
public float getB() {
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setB(float b) {
|
public void setB(float b) {
|
||||||
this.b = b;
|
this.b = b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,65 +1,65 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.data;
|
package de.frajul.endlessroll.data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 02.08.2016.
|
* Created by Julian on 02.08.2016.
|
||||||
*/
|
*/
|
||||||
public class Color4f {
|
public class Color4f {
|
||||||
|
|
||||||
private float r, g, b, a;
|
private float r, g, b, a;
|
||||||
|
|
||||||
public Color4f() {
|
public Color4f() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color4f(float r, float g, float b, float a) {
|
public Color4f(float r, float g, float b, float a) {
|
||||||
this.r = r;
|
this.r = r;
|
||||||
this.g = g;
|
this.g = g;
|
||||||
this.b = b;
|
this.b = b;
|
||||||
this.a = a;
|
this.a = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color4f(Color4f other) {
|
public Color4f(Color4f other) {
|
||||||
this.r = other.getR();
|
this.r = other.getR();
|
||||||
this.g = other.getG();
|
this.g = other.getG();
|
||||||
this.b = other.getB();
|
this.b = other.getB();
|
||||||
this.a = other.getA();
|
this.a = other.getA();
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getR() {
|
public float getR() {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setR(float r) {
|
public void setR(float r) {
|
||||||
this.r = r;
|
this.r = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getG() {
|
public float getG() {
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setG(float g) {
|
public void setG(float g) {
|
||||||
this.g = g;
|
this.g = g;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getB() {
|
public float getB() {
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setB(float b) {
|
public void setB(float b) {
|
||||||
this.b = b;
|
this.b = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getA() {
|
public float getA() {
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setA(float a) {
|
public void setA(float a) {
|
||||||
this.a = a;
|
this.a = a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,154 +1,154 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.data;
|
package de.frajul.endlessroll.data;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 16.11.2016.
|
* Created by Julian on 16.11.2016.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class SynchronizedArrayList<E> extends ArrayList<E> {
|
public class SynchronizedArrayList<E> extends ArrayList<E> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized String toString() {
|
public synchronized String toString() {
|
||||||
return super.toString();
|
return super.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean add(E object) {
|
public synchronized boolean add(E object) {
|
||||||
return super.add(object);
|
return super.add(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void add(int index, E object) {
|
public synchronized void add(int index, E object) {
|
||||||
super.add(index, object);
|
super.add(index, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean addAll(Collection<? extends E> collection) {
|
public synchronized boolean addAll(Collection<? extends E> collection) {
|
||||||
return super.addAll(collection);
|
return super.addAll(collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean addAll(int index, Collection<? extends E> collection) {
|
public synchronized boolean addAll(int index, Collection<? extends E> collection) {
|
||||||
return super.addAll(index, collection);
|
return super.addAll(index, collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void clear() {
|
public synchronized void clear() {
|
||||||
super.clear();
|
super.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized Object clone() {
|
public synchronized Object clone() {
|
||||||
return super.clone();
|
return super.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void ensureCapacity(int minimumCapacity) {
|
public synchronized void ensureCapacity(int minimumCapacity) {
|
||||||
super.ensureCapacity(minimumCapacity);
|
super.ensureCapacity(minimumCapacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized E get(int index) {
|
public synchronized E get(int index) {
|
||||||
return super.get(index);
|
return super.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized int size() {
|
public synchronized int size() {
|
||||||
return super.size();
|
return super.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean isEmpty() {
|
public synchronized boolean isEmpty() {
|
||||||
return super.isEmpty();
|
return super.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean contains(Object object) {
|
public synchronized boolean contains(Object object) {
|
||||||
return super.contains(object);
|
return super.contains(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized int indexOf(Object object) {
|
public synchronized int indexOf(Object object) {
|
||||||
return super.indexOf(object);
|
return super.indexOf(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized int lastIndexOf(Object object) {
|
public synchronized int lastIndexOf(Object object) {
|
||||||
return super.lastIndexOf(object);
|
return super.lastIndexOf(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized E remove(int index) {
|
public synchronized E remove(int index) {
|
||||||
return super.remove(index);
|
return super.remove(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean remove(Object object) {
|
public synchronized boolean remove(Object object) {
|
||||||
return super.remove(object);
|
return super.remove(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected synchronized void removeRange(int fromIndex, int toIndex) {
|
protected synchronized void removeRange(int fromIndex, int toIndex) {
|
||||||
super.removeRange(fromIndex, toIndex);
|
super.removeRange(fromIndex, toIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized E set(int index, E object) {
|
public synchronized E set(int index, E object) {
|
||||||
return super.set(index, object);
|
return super.set(index, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized Object[] toArray() {
|
public synchronized Object[] toArray() {
|
||||||
return super.toArray();
|
return super.toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized <T> T[] toArray(T[] contents) {
|
public synchronized <T> T[] toArray(T[] contents) {
|
||||||
return super.toArray(contents);
|
return super.toArray(contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void trimToSize() {
|
public synchronized void trimToSize() {
|
||||||
super.trimToSize();
|
super.trimToSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized int hashCode() {
|
public synchronized int hashCode() {
|
||||||
return super.hashCode();
|
return super.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean equals(Object o) {
|
public synchronized boolean equals(Object o) {
|
||||||
return super.equals(o);
|
return super.equals(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized List<E> subList(int start, int end) {
|
public synchronized List<E> subList(int start, int end) {
|
||||||
return super.subList(start, end);
|
return super.subList(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean containsAll(Collection<?> collection) {
|
public synchronized boolean containsAll(Collection<?> collection) {
|
||||||
return super.containsAll(collection);
|
return super.containsAll(collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean removeAll(Collection<?> collection) {
|
public synchronized boolean removeAll(Collection<?> collection) {
|
||||||
return super.removeAll(collection);
|
return super.removeAll(collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean retainAll(Collection<?> collection) {
|
public synchronized boolean retainAll(Collection<?> collection) {
|
||||||
return super.retainAll(collection);
|
return super.retainAll(collection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,113 +1,113 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.data;
|
package de.frajul.endlessroll.data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 01.12.2015.
|
* Created by Julian on 01.12.2015.
|
||||||
*/
|
*/
|
||||||
public class Vector {
|
public class Vector {
|
||||||
|
|
||||||
public float x, y;
|
public float x, y;
|
||||||
|
|
||||||
public Vector() {
|
public Vector() {
|
||||||
this(0, 0);
|
this(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector(Vector other) {
|
public Vector(Vector other) {
|
||||||
this(other.x, other.y);
|
this(other.x, other.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector(float x, float y) {
|
public Vector(float x, float y) {
|
||||||
set(x, y);
|
set(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Vector(" + x + ", " + y + ")";
|
return "Vector(" + x + ", " + y + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set(float x, float y) {
|
public void set(float x, float y) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float length() {
|
public float length() {
|
||||||
return (float) Math.sqrt(x * x + y * y);
|
return (float) Math.sqrt(x * x + y * y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector normalize() {
|
public Vector normalize() {
|
||||||
float length = this.length();
|
float length = this.length();
|
||||||
x /= length;
|
x /= length;
|
||||||
y /= length;
|
y /= length;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector translate(Vector other) {
|
public Vector translate(Vector other) {
|
||||||
this.x += other.x;
|
this.x += other.x;
|
||||||
this.y += other.y;
|
this.y += other.y;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector translate(float x, float y) {
|
public Vector translate(float x, float y) {
|
||||||
this.x += x;
|
this.x += x;
|
||||||
this.y += y;
|
this.y += y;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector abs() {
|
public Vector abs() {
|
||||||
this.x = Math.abs(x);
|
this.x = Math.abs(x);
|
||||||
this.y = Math.abs(y);
|
this.y = Math.abs(y);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector mul(float z) {
|
public Vector mul(float z) {
|
||||||
x *= z;
|
x *= z;
|
||||||
y *= z;
|
y *= z;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector mul(Vector other) {
|
public Vector mul(Vector other) {
|
||||||
this.x *= other.x;
|
this.x *= other.x;
|
||||||
this.y *= other.y;
|
this.y *= other.y;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector mul(float x, float y) {
|
public Vector mul(float x, float y) {
|
||||||
this.x *= x;
|
this.x *= x;
|
||||||
this.y *= y;
|
this.y *= y;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector negate() {
|
public Vector negate() {
|
||||||
this.x *= -1;
|
this.x *= -1;
|
||||||
this.y *= -1;
|
this.y *= -1;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector vectorTo(Vector other) {
|
public Vector vectorTo(Vector other) {
|
||||||
float x = other.x - this.x;
|
float x = other.x - this.x;
|
||||||
float y = other.y - this.y;
|
float y = other.y - this.y;
|
||||||
return new Vector(x, y);
|
return new Vector(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setX(float x) {
|
public void setX(float x) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setY(float y) {
|
public void setY(float y) {
|
||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getX() {
|
public float getX() {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getY() {
|
public float getY() {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,32 +1,32 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities;
|
package de.frajul.endlessroll.entities;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.textures.Texture;
|
import de.frajul.endlessroll.entities.textures.Texture;
|
||||||
import de.frajul.endlessroll.main.game.Timer;
|
import de.frajul.endlessroll.main.game.Timer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 20.02.2017.
|
* Created by Julian on 20.02.2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class AnimatedEntity extends Entity {
|
public class AnimatedEntity extends Entity {
|
||||||
|
|
||||||
protected Animation animation;
|
protected Animation animation;
|
||||||
|
|
||||||
public AnimatedEntity(Texture texture, Vector position, float width, float height) {
|
public AnimatedEntity(Texture texture, Vector position, float width, float height) {
|
||||||
super(texture, position, width, height);
|
super(texture, position, width, height);
|
||||||
animation = new Animation();
|
animation = new Animation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(Timer timer) {
|
public void update(Timer timer) {
|
||||||
animation.update(timer);
|
animation.update(timer);
|
||||||
super.setTextureAtlasIndex(animation.getCurrentTexIndex());
|
super.setTextureAtlasIndex(animation.getCurrentTexIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,62 +1,62 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities;
|
package de.frajul.endlessroll.entities;
|
||||||
|
|
||||||
import de.frajul.endlessroll.main.game.Timer;
|
import de.frajul.endlessroll.main.game.Timer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 14.12.2015.
|
* Created by Julian on 14.12.2015.
|
||||||
*/
|
*/
|
||||||
public class Animation {
|
public class Animation {
|
||||||
|
|
||||||
private int[] indexSequence = {0, 1, 2, 3};
|
private int[] indexSequence = {0, 1, 2, 3};
|
||||||
private boolean looping = false;
|
private boolean looping = false;
|
||||||
private int requiredDelta = 110;
|
private int requiredDelta = 110;
|
||||||
|
|
||||||
private int indexPointer = 0;
|
private int indexPointer = 0;
|
||||||
private boolean stillRunning = true;
|
private boolean stillRunning = true;
|
||||||
private long lastSwitchTime = -1;
|
private long lastSwitchTime = -1;
|
||||||
|
|
||||||
public void disable() {
|
public void disable() {
|
||||||
stillRunning = false;
|
stillRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(Timer timer) {
|
public void update(Timer timer) {
|
||||||
if (lastSwitchTime == -1) {
|
if (lastSwitchTime == -1) {
|
||||||
lastSwitchTime = timer.getCurrentTime();
|
lastSwitchTime = timer.getCurrentTime();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (stillRunning) {
|
if (stillRunning) {
|
||||||
long delta = timer.getCurrentTime() - lastSwitchTime;
|
long delta = timer.getCurrentTime() - lastSwitchTime;
|
||||||
if (delta >= requiredDelta) {
|
if (delta >= requiredDelta) {
|
||||||
lastSwitchTime = timer.getCurrentTime();
|
lastSwitchTime = timer.getCurrentTime();
|
||||||
indexPointer++;
|
indexPointer++;
|
||||||
if (!looping && indexPointer == indexSequence.length - 1)
|
if (!looping && indexPointer == indexSequence.length - 1)
|
||||||
stillRunning = false;
|
stillRunning = false;
|
||||||
if (looping && indexPointer == indexSequence.length)
|
if (looping && indexPointer == indexSequence.length)
|
||||||
indexPointer = 0;
|
indexPointer = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCurrentTexIndex() {
|
public int getCurrentTexIndex() {
|
||||||
return indexSequence[indexPointer];
|
return indexSequence[indexPointer];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIndexSequence(int[] indexSequence) {
|
public void setIndexSequence(int[] indexSequence) {
|
||||||
this.indexSequence = indexSequence;
|
this.indexSequence = indexSequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRequiredDelta(int requiredDelta) {
|
public void setRequiredDelta(int requiredDelta) {
|
||||||
this.requiredDelta = requiredDelta;
|
this.requiredDelta = requiredDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLooping(boolean looping) {
|
public void setLooping(boolean looping) {
|
||||||
this.looping = looping;
|
this.looping = looping;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,55 +1,55 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities;
|
package de.frajul.endlessroll.entities;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.frajul.endlessroll.entities.textures.Texture;
|
import de.frajul.endlessroll.entities.textures.Texture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 20.07.2016.
|
* Created by Julian on 20.07.2016.
|
||||||
*/
|
*/
|
||||||
public class Background {
|
public class Background {
|
||||||
|
|
||||||
private List<BackgroundLayer> layers = Collections
|
private List<BackgroundLayer> layers = Collections
|
||||||
.synchronizedList(new ArrayList<BackgroundLayer>());
|
.synchronizedList(new ArrayList<BackgroundLayer>());
|
||||||
|
|
||||||
public Background(List<Texture> textures) {
|
public Background(List<Texture> textures) {
|
||||||
changeTextures(textures);
|
changeTextures(textures);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeTextures(List<Texture> textures) {
|
public void changeTextures(List<Texture> textures) {
|
||||||
layers.clear();
|
layers.clear();
|
||||||
for (int i = 0; i < textures.size(); i++) {
|
for (int i = 0; i < textures.size(); i++) {
|
||||||
Texture texture = textures.get(i);
|
Texture texture = textures.get(i);
|
||||||
float speed = (float) Math.pow(0.95f, Math.pow(i + 1, Math.sqrt(i + 1)));
|
float speed = (float) Math.pow(0.95f, Math.pow(i + 1, Math.sqrt(i + 1)));
|
||||||
layers.add(new BackgroundLayer(texture, speed));
|
layers.add(new BackgroundLayer(texture, speed));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void move(float playerMoveX, float cameraX) {
|
public void move(float playerMoveX, float cameraX) {
|
||||||
synchronized (layers) {
|
synchronized (layers) {
|
||||||
for (BackgroundLayer layer : layers) {
|
for (BackgroundLayer layer : layers) {
|
||||||
layer.move(playerMoveX, cameraX);
|
layer.move(playerMoveX, cameraX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetPosition() {
|
public void resetPosition() {
|
||||||
synchronized (layers) {
|
synchronized (layers) {
|
||||||
for (BackgroundLayer layer : layers)
|
for (BackgroundLayer layer : layers)
|
||||||
layer.resetPosition();
|
layer.resetPosition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BackgroundLayer> getLayers() {
|
public List<BackgroundLayer> getLayers() {
|
||||||
return layers;
|
return layers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,54 +1,54 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities;
|
package de.frajul.endlessroll.entities;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.SynchronizedArrayList;
|
import de.frajul.endlessroll.data.SynchronizedArrayList;
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.textures.Texture;
|
import de.frajul.endlessroll.entities.textures.Texture;
|
||||||
|
|
||||||
public class BackgroundLayer extends SynchronizedArrayList<Entity> {
|
public class BackgroundLayer extends SynchronizedArrayList<Entity> {
|
||||||
|
|
||||||
private final float PART_WIDTH = 5;
|
private final float PART_WIDTH = 5;
|
||||||
private final float HALF_PART_WIDTH = PART_WIDTH / 2f;
|
private final float HALF_PART_WIDTH = PART_WIDTH / 2f;
|
||||||
private final float HEIGHT = 2.5f;
|
private final float HEIGHT = 2.5f;
|
||||||
private Texture texture;
|
private Texture texture;
|
||||||
private float speed;
|
private float speed;
|
||||||
|
|
||||||
public BackgroundLayer(Texture texture, float speed) {
|
public BackgroundLayer(Texture texture, float speed) {
|
||||||
this.texture = texture;
|
this.texture = texture;
|
||||||
this.speed = speed;
|
this.speed = speed;
|
||||||
super.add(createPart(-HALF_PART_WIDTH));
|
super.add(createPart(-HALF_PART_WIDTH));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Entity createPart(float xLeftEdge) {
|
private Entity createPart(float xLeftEdge) {
|
||||||
return new Entity(texture, new Vector(xLeftEdge + HALF_PART_WIDTH, (HEIGHT - 2) / 2), PART_WIDTH, HEIGHT);
|
return new Entity(texture, new Vector(xLeftEdge + HALF_PART_WIDTH, (HEIGHT - 2) / 2), PART_WIDTH, HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void move(float playerMovX, float cameraX) {
|
public void move(float playerMovX, float cameraX) {
|
||||||
Vector movement = new Vector(playerMovX * speed, 0);
|
Vector movement = new Vector(playerMovX * speed, 0);
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
for (Entity part : this)
|
for (Entity part : this)
|
||||||
part.move(movement);
|
part.move(movement);
|
||||||
}
|
}
|
||||||
if (!super.isEmpty()) {
|
if (!super.isEmpty()) {
|
||||||
Entity last = super.get(super.size() - 1);
|
Entity last = super.get(super.size() - 1);
|
||||||
if (last.getRightEdge() - cameraX < 3) {
|
if (last.getRightEdge() - cameraX < 3) {
|
||||||
super.add(createPart(last.getRightEdge() - 0.001f));
|
super.add(createPart(last.getRightEdge() - 0.001f));
|
||||||
}
|
}
|
||||||
if (super.get(0).getRightEdge() - cameraX < -3) {
|
if (super.get(0).getRightEdge() - cameraX < -3) {
|
||||||
super.remove(0);
|
super.remove(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetPosition() {
|
public void resetPosition() {
|
||||||
super.clear();
|
super.clear();
|
||||||
super.add(createPart(-HALF_PART_WIDTH));
|
super.add(createPart(-HALF_PART_WIDTH));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,46 +1,46 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities;
|
package de.frajul.endlessroll.entities;
|
||||||
|
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.particles.ParticleEffect;
|
import de.frajul.endlessroll.entities.particles.ParticleEffect;
|
||||||
import de.frajul.endlessroll.entities.particles.ParticleSource;
|
import de.frajul.endlessroll.entities.particles.ParticleSource;
|
||||||
import de.frajul.endlessroll.entities.particles.ParticleSystem;
|
import de.frajul.endlessroll.entities.particles.ParticleSystem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 11.03.2016.
|
* Created by Julian on 11.03.2016.
|
||||||
*/
|
*/
|
||||||
public enum DestroyEffect {
|
public enum DestroyEffect {
|
||||||
|
|
||||||
EXPLOSION, STAR_EXPLOSION, ENERGY_COLLECT, NONE;
|
EXPLOSION, STAR_EXPLOSION, ENERGY_COLLECT, NONE;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public ParticleSource createEffect(ParticleSystem system, Vector position, Vector size) {
|
public ParticleSource createEffect(ParticleSystem system, Vector position, Vector size) {
|
||||||
if (this == NONE)
|
if (this == NONE)
|
||||||
return null;
|
return null;
|
||||||
ParticleSource source = new ParticleSource(position, getEffect(system));
|
ParticleSource source = new ParticleSource(position, getEffect(system));
|
||||||
source.setSpawnSize(size);
|
source.setSpawnSize(size);
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ParticleEffect getEffect(ParticleSystem system) {
|
private ParticleEffect getEffect(ParticleSystem system) {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case EXPLOSION:
|
case EXPLOSION:
|
||||||
return system.explosion;
|
return system.explosion;
|
||||||
case STAR_EXPLOSION:
|
case STAR_EXPLOSION:
|
||||||
return system.starCollect;
|
return system.starCollect;
|
||||||
case ENERGY_COLLECT:
|
case ENERGY_COLLECT:
|
||||||
return system.energyCollect;
|
return system.energyCollect;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,138 +1,138 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities;
|
package de.frajul.endlessroll.entities;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Color3f;
|
import de.frajul.endlessroll.data.Color3f;
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.collision.geometry.Quad;
|
import de.frajul.endlessroll.entities.collision.geometry.Quad;
|
||||||
import de.frajul.endlessroll.entities.textures.Texture;
|
import de.frajul.endlessroll.entities.textures.Texture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 20.11.2015.
|
* Created by Julian on 20.11.2015.
|
||||||
*/
|
*/
|
||||||
public class Entity extends Quad {
|
public class Entity extends Quad {
|
||||||
|
|
||||||
private int textureAtlasIndex;
|
private int textureAtlasIndex;
|
||||||
private Texture texture;
|
private Texture texture;
|
||||||
private Vector movement;
|
private Vector movement;
|
||||||
private float rotation;
|
private float rotation;
|
||||||
private float alpha = 1.0f;
|
private float alpha = 1.0f;
|
||||||
private boolean destroyed;
|
private boolean destroyed;
|
||||||
private DestroyEffect destroyEffect;
|
private DestroyEffect destroyEffect;
|
||||||
private Vector maxTexSize;
|
private Vector maxTexSize;
|
||||||
private boolean visible = true;
|
private boolean visible = true;
|
||||||
private Color3f color = null;
|
private Color3f color = null;
|
||||||
|
|
||||||
public Entity(Texture texture, Vector position, float width, float height) {
|
public Entity(Texture texture, Vector position, float width, float height) {
|
||||||
super(position, width, height);
|
super(position, width, height);
|
||||||
this.texture = texture;
|
this.texture = texture;
|
||||||
this.movement = new Vector();
|
this.movement = new Vector();
|
||||||
this.maxTexSize = new Vector();
|
this.maxTexSize = new Vector();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void move(Vector movement) {
|
public void move(Vector movement) {
|
||||||
position.translate(movement);
|
position.translate(movement);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rotate(float factor) {
|
public void rotate(float factor) {
|
||||||
rotation += factor;
|
rotation += factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setToTerrain(float terrainEdge) {
|
public void setToTerrain(float terrainEdge) {
|
||||||
position.y = terrainEdge + height / 2;
|
position.y = terrainEdge + height / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTopEdge(float y) {
|
public void setTopEdge(float y) {
|
||||||
position.y = y - height / 2;
|
position.y = y - height / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Texture getTexture() {
|
public Texture getTexture() {
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTexture(Texture texture) {
|
public void setTexture(Texture texture) {
|
||||||
this.texture = texture;
|
this.texture = texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector getMovement() {
|
public Vector getMovement() {
|
||||||
return movement;
|
return movement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMovement(Vector movement) {
|
public void setMovement(Vector movement) {
|
||||||
this.movement = movement;
|
this.movement = movement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getRotation() {
|
public float getRotation() {
|
||||||
return rotation;
|
return rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRotation(float rotation) {
|
public void setRotation(float rotation) {
|
||||||
this.rotation = rotation;
|
this.rotation = rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAlpha(float alpha) {
|
public void setAlpha(float alpha) {
|
||||||
this.alpha = alpha;
|
this.alpha = alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getAlpha() {
|
public float getAlpha() {
|
||||||
return alpha;
|
return alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void destroy(DestroyEffect destroyEffect) {
|
public void destroy(DestroyEffect destroyEffect) {
|
||||||
this.destroyed = true;
|
this.destroyed = true;
|
||||||
this.destroyEffect = destroyEffect;
|
this.destroyEffect = destroyEffect;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDestroyed() {
|
public boolean isDestroyed() {
|
||||||
return destroyed;
|
return destroyed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DestroyEffect getDestroyEffect() {
|
public DestroyEffect getDestroyEffect() {
|
||||||
return destroyEffect;
|
return destroyEffect;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTextureAtlasIndex(int textureAtlasIndex) {
|
public void setTextureAtlasIndex(int textureAtlasIndex) {
|
||||||
this.textureAtlasIndex = textureAtlasIndex;
|
this.textureAtlasIndex = textureAtlasIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTextureAtlasIndex() {
|
public int getTextureAtlasIndex() {
|
||||||
return textureAtlasIndex;
|
return textureAtlasIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxTexSize(Vector maxTexSize) {
|
public void setMaxTexSize(Vector maxTexSize) {
|
||||||
this.maxTexSize = maxTexSize;
|
this.maxTexSize = maxTexSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector getMaxTexSize() {
|
public Vector getMaxTexSize() {
|
||||||
return maxTexSize;
|
return maxTexSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float calcTexScaleX() {
|
public float calcTexScaleX() {
|
||||||
return getMaxTexSize().x == 0 ? 1 : getWidth() / getMaxTexSize().x;
|
return getMaxTexSize().x == 0 ? 1 : getWidth() / getMaxTexSize().x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float calcTexScaleY() {
|
public float calcTexScaleY() {
|
||||||
return getMaxTexSize().y == 0 ? 1 : getHeight() / getMaxTexSize().y;
|
return getMaxTexSize().y == 0 ? 1 : getHeight() / getMaxTexSize().y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVisible(boolean visible) {
|
public void setVisible(boolean visible) {
|
||||||
this.visible = visible;
|
this.visible = visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isVisible() {
|
public boolean isVisible() {
|
||||||
return visible;
|
return visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColor(Color3f color) {
|
public void setColor(Color3f color) {
|
||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color3f getColor() {
|
public Color3f getColor() {
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities;
|
package de.frajul.endlessroll.entities;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.textures.Texture;
|
import de.frajul.endlessroll.entities.textures.Texture;
|
||||||
|
|
||||||
public class Goal extends Entity {
|
public class Goal extends Entity {
|
||||||
|
|
||||||
public Goal(Texture texture) {
|
public Goal(Texture texture) {
|
||||||
super(texture, new Vector(), 0.1f, 3);
|
super(texture, new Vector(), 0.1f, 3);
|
||||||
super.getMaxTexSize().setY(0.2f);
|
super.getMaxTexSize().setY(0.2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGoalX(float goalX) {
|
public void setGoalX(float goalX) {
|
||||||
super.setPosition(new Vector(goalX - 0.05f, 0));
|
super.setPosition(new Vector(goalX - 0.05f, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,118 +1,118 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities;
|
package de.frajul.endlessroll.entities;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.levels.MoveComponent;
|
import de.frajul.endlessroll.levels.MoveComponent;
|
||||||
import de.frajul.endlessroll.levels.ObstacleData;
|
import de.frajul.endlessroll.levels.ObstacleData;
|
||||||
import de.frajul.endlessroll.levels.worlds.World;
|
import de.frajul.endlessroll.levels.worlds.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 20.11.2015.
|
* Created by Julian on 20.11.2015.
|
||||||
*/
|
*/
|
||||||
public class Obstacle extends Entity {
|
public class Obstacle extends Entity {
|
||||||
|
|
||||||
private boolean deadly;
|
private boolean deadly;
|
||||||
private boolean floating;
|
private boolean floating;
|
||||||
private boolean moving;
|
private boolean moving;
|
||||||
private final float GRID_SQUARE_SIZE = 0.1f;
|
private final float GRID_SQUARE_SIZE = 0.1f;
|
||||||
private Vector gridSize;
|
private Vector gridSize;
|
||||||
private MoveComponent moveComponent;
|
private MoveComponent moveComponent;
|
||||||
private float movementMultiplier = 1.0f;
|
private float movementMultiplier = 1.0f;
|
||||||
|
|
||||||
private float moveProgress;
|
private float moveProgress;
|
||||||
private float moveDirection;
|
private float moveDirection;
|
||||||
|
|
||||||
private int bombExplosionState = -1;
|
private int bombExplosionState = -1;
|
||||||
|
|
||||||
public Obstacle(World world, ObstacleData data, float terrainEdge, Player player) {
|
public Obstacle(World world, ObstacleData data, float terrainEdge, Player player) {
|
||||||
super(world.getObstacleTexture(), new Vector(data.getX(), data.getY()), data.getWidth(),
|
super(world.getObstacleTexture(), new Vector(data.getX(), data.getY()), data.getWidth(),
|
||||||
data.getHeight());
|
data.getHeight());
|
||||||
this.deadly = data.isDeadly();
|
this.deadly = data.isDeadly();
|
||||||
this.floating = data.isFloating();
|
this.floating = data.isFloating();
|
||||||
this.moving = data.isMoving();
|
this.moving = data.isMoving();
|
||||||
this.moveComponent = data.getMoveComponent();
|
this.moveComponent = data.getMoveComponent();
|
||||||
if (!floating)
|
if (!floating)
|
||||||
super.setToTerrain(terrainEdge);
|
super.setToTerrain(terrainEdge);
|
||||||
if (moveComponent != null && moving) {
|
if (moveComponent != null && moving) {
|
||||||
moveComponent.init(super.getPosition());
|
moveComponent.init(super.getPosition());
|
||||||
moveDirection = moveComponent.getDirection();
|
moveDirection = moveComponent.getDirection();
|
||||||
moveProgress = moveComponent.getStartOffset();
|
moveProgress = moveComponent.getStartOffset();
|
||||||
//Constant player speed assumed
|
//Constant player speed assumed
|
||||||
float triggerX = super.getPosition().getX() - super.getWidth() / 2 - moveComponent
|
float triggerX = super.getPosition().getX() - super.getWidth() / 2 - moveComponent
|
||||||
.getTriggerDistance();
|
.getTriggerDistance();
|
||||||
float timeTillPlayerReachesTrigger = player.getSpeed() * (triggerX - player
|
float timeTillPlayerReachesTrigger = player.getSpeed() * (triggerX - player
|
||||||
.getRightEdge());
|
.getRightEdge());
|
||||||
moveDirection *= -1;
|
moveDirection *= -1;
|
||||||
moveWithMoveComponent(timeTillPlayerReachesTrigger * 1000 * 1000, player.getSpeed());
|
moveWithMoveComponent(timeTillPlayerReachesTrigger * 1000 * 1000, player.getSpeed());
|
||||||
moveDirection *= -1;
|
moveDirection *= -1;
|
||||||
}
|
}
|
||||||
gridSize = calcGridSize();
|
gridSize = calcGridSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector calcGridSize() {
|
private Vector calcGridSize() {
|
||||||
int gridWidth = (int) (width / GRID_SQUARE_SIZE);
|
int gridWidth = (int) (width / GRID_SQUARE_SIZE);
|
||||||
int gridHeight = (int) (height / GRID_SQUARE_SIZE);
|
int gridHeight = (int) (height / GRID_SQUARE_SIZE);
|
||||||
gridWidth = Math.max(gridWidth, 2);
|
gridWidth = Math.max(gridWidth, 2);
|
||||||
gridHeight = Math.max(gridHeight, 2);
|
gridHeight = Math.max(gridHeight, 2);
|
||||||
return new Vector(gridWidth, gridHeight);
|
return new Vector(gridWidth, gridHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void slowMovementForOneFrame(float value) {
|
public void slowMovementForOneFrame(float value) {
|
||||||
movementMultiplier *= value;
|
movementMultiplier *= value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void moveWithMoveComponent(float frameTime, float playerSpeed) {
|
public void moveWithMoveComponent(float frameTime, float playerSpeed) {
|
||||||
if (moveComponent.isHasPlayerXSpeed()) {
|
if (moveComponent.isHasPlayerXSpeed()) {
|
||||||
moveComponent.calcSpeedForPlayerSpeed(playerSpeed);
|
moveComponent.calcSpeedForPlayerSpeed(playerSpeed);
|
||||||
}
|
}
|
||||||
float distance = frameTime * moveComponent
|
float distance = frameTime * moveComponent
|
||||||
.getSpeed() * moveComponent.TRANSITION_VALUE * movementMultiplier;
|
.getSpeed() * moveComponent.TRANSITION_VALUE * movementMultiplier;
|
||||||
float newProgress = moveDirection * distance / moveComponent.getLength();
|
float newProgress = moveDirection * distance / moveComponent.getLength();
|
||||||
moveProgress += newProgress;
|
moveProgress += newProgress;
|
||||||
if (moveProgress < 0) {
|
if (moveProgress < 0) {
|
||||||
moveProgress *= -1;
|
moveProgress *= -1;
|
||||||
moveDirection *= -1;
|
moveDirection *= -1;
|
||||||
}
|
}
|
||||||
while (moveProgress > 1) {
|
while (moveProgress > 1) {
|
||||||
moveProgress -= 2;
|
moveProgress -= 2;
|
||||||
if (moveProgress < 0) {
|
if (moveProgress < 0) {
|
||||||
moveProgress *= -1;
|
moveProgress *= -1;
|
||||||
moveDirection *= -1;
|
moveDirection *= -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.setPosition(moveComponent.getPositionForProgress(moveProgress));
|
super.setPosition(moveComponent.getPositionForProgress(moveProgress));
|
||||||
super.setMovement(moveComponent.getMovementVector(moveDirection));
|
super.setMovement(moveComponent.getMovementVector(moveDirection));
|
||||||
movementMultiplier = 1.0f;
|
movementMultiplier = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMoving() {
|
public boolean isMoving() {
|
||||||
return moving;
|
return moving;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDeadly() {
|
public boolean isDeadly() {
|
||||||
return deadly;
|
return deadly;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFloating() {
|
public boolean isFloating() {
|
||||||
return floating;
|
return floating;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector getGridSize() {
|
public Vector getGridSize() {
|
||||||
return gridSize;
|
return gridSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBombExplosionState() {
|
public int getBombExplosionState() {
|
||||||
return bombExplosionState;
|
return bombExplosionState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBombExplosionState(int bombExplosionState) {
|
public void setBombExplosionState(int bombExplosionState) {
|
||||||
this.bombExplosionState = bombExplosionState;
|
this.bombExplosionState = bombExplosionState;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,149 +1,149 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities;
|
package de.frajul.endlessroll.entities;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.particles.ParticleSource;
|
import de.frajul.endlessroll.entities.particles.ParticleSource;
|
||||||
import de.frajul.endlessroll.entities.particles.ParticleSystem;
|
import de.frajul.endlessroll.entities.particles.ParticleSystem;
|
||||||
import de.frajul.endlessroll.entities.shapes.PlayerShape;
|
import de.frajul.endlessroll.entities.shapes.PlayerShape;
|
||||||
import de.frajul.endlessroll.entities.tools.Stasis;
|
import de.frajul.endlessroll.entities.tools.Stasis;
|
||||||
import de.frajul.endlessroll.main.game.Timer;
|
import de.frajul.endlessroll.main.game.Timer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 20.11.2015.
|
* Created by Julian on 20.11.2015.
|
||||||
*/
|
*/
|
||||||
public class Player extends Entity {
|
public class Player extends Entity {
|
||||||
|
|
||||||
public final float RADIUS = 0.1f;
|
public final float RADIUS = 0.1f;
|
||||||
private final float START_X = -0.9f;
|
private final float START_X = -0.9f;
|
||||||
private final float SPEED = 0.002f;
|
private final float SPEED = 0.002f;
|
||||||
|
|
||||||
private float startSpeed, endSpeed;
|
private float startSpeed, endSpeed;
|
||||||
private float speed = SPEED;
|
private float speed = SPEED;
|
||||||
|
|
||||||
private long currentSuperPowerDuration;
|
private long currentSuperPowerDuration;
|
||||||
private boolean hasSuperPower;
|
private boolean hasSuperPower;
|
||||||
private long superPowerDuration;
|
private long superPowerDuration;
|
||||||
private ParticleSource superPowerParticles;
|
private ParticleSource superPowerParticles;
|
||||||
|
|
||||||
private ParticleSystem particleSystem;
|
private ParticleSystem particleSystem;
|
||||||
private List<Stasis> stases = new ArrayList<>();
|
private List<Stasis> stases = new ArrayList<>();
|
||||||
private List<Float> forces = new ArrayList<>();
|
private List<Float> forces = new ArrayList<>();
|
||||||
private float gravityForce;
|
private float gravityForce;
|
||||||
|
|
||||||
public Player() {
|
public Player() {
|
||||||
super(PlayerShape.BALL.getTexture(), new Vector(), 0, 0);
|
super(PlayerShape.BALL.getTexture(), new Vector(), 0, 0);
|
||||||
super.setWidth(RADIUS * 2);
|
super.setWidth(RADIUS * 2);
|
||||||
super.setHeight(RADIUS * 2);
|
super.setHeight(RADIUS * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startSuperPower(long duration) {
|
public void startSuperPower(long duration) {
|
||||||
this.superPowerDuration = duration;
|
this.superPowerDuration = duration;
|
||||||
currentSuperPowerDuration = 0;
|
currentSuperPowerDuration = 0;
|
||||||
hasSuperPower = true;
|
hasSuperPower = true;
|
||||||
superPowerParticles = new ParticleSource(
|
superPowerParticles = new ParticleSource(
|
||||||
new Vector(super.getPosition().x, super.getPosition().y), particleSystem.superPower);
|
new Vector(super.getPosition().x, super.getPosition().y), particleSystem.superPower);
|
||||||
superPowerParticles.start();
|
superPowerParticles.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(PlayerShape playerShape, float terrainEdge, float startSpeed, float endSpeed, ParticleSystem particleSystem) {
|
public void init(PlayerShape playerShape, float terrainEdge, float startSpeed, float endSpeed, ParticleSystem particleSystem) {
|
||||||
super.setTexture(playerShape.getTexture());
|
super.setTexture(playerShape.getTexture());
|
||||||
super.setToTerrain(terrainEdge);
|
super.setToTerrain(terrainEdge);
|
||||||
super.getPosition().x = START_X;
|
super.getPosition().x = START_X;
|
||||||
super.setMovement(new Vector(speed, 0));
|
super.setMovement(new Vector(speed, 0));
|
||||||
gravityForce = 0;
|
gravityForce = 0;
|
||||||
hasSuperPower = false;
|
hasSuperPower = false;
|
||||||
forces.clear();
|
forces.clear();
|
||||||
this.startSpeed = startSpeed;
|
this.startSpeed = startSpeed;
|
||||||
this.endSpeed = endSpeed;
|
this.endSpeed = endSpeed;
|
||||||
setSpeedByProgress(0);
|
setSpeedByProgress(0);
|
||||||
this.particleSystem = particleSystem;
|
this.particleSystem = particleSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSpeedByProgress(float progress) {
|
public void setSpeedByProgress(float progress) {
|
||||||
this.speed = ((endSpeed - startSpeed) * progress + startSpeed) * SPEED;
|
this.speed = ((endSpeed - startSpeed) * progress + startSpeed) * SPEED;
|
||||||
super.getMovement().x = speed;
|
super.getMovement().x = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void preMoveUpdate(Timer timer) {
|
public void preMoveUpdate(Timer timer) {
|
||||||
if (hasSuperPower && superPowerParticles != null) {
|
if (hasSuperPower && superPowerParticles != null) {
|
||||||
currentSuperPowerDuration += timer.getFrameTimeMilliseconds();
|
currentSuperPowerDuration += timer.getFrameTimeMilliseconds();
|
||||||
hasSuperPower = superPowerDuration >= currentSuperPowerDuration;
|
hasSuperPower = superPowerDuration >= currentSuperPowerDuration;
|
||||||
superPowerParticles.setPosition(new Vector(super.getPosition()));
|
superPowerParticles.setPosition(new Vector(super.getPosition()));
|
||||||
}
|
}
|
||||||
if (!hasSuperPower && superPowerParticles != null)
|
if (!hasSuperPower && superPowerParticles != null)
|
||||||
superPowerParticles.kill();
|
superPowerParticles.kill();
|
||||||
|
|
||||||
for (Stasis stasis : stases)
|
for (Stasis stasis : stases)
|
||||||
stasis.influencePlayerMovementValues(this);
|
stasis.influencePlayerMovementValues(this);
|
||||||
|
|
||||||
for (float force : forces)
|
for (float force : forces)
|
||||||
super.getMovement().y += force;
|
super.getMovement().y += force;
|
||||||
super.getMovement().y += gravityForce;
|
super.getMovement().y += gravityForce;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearAllForces() {
|
public void clearAllForces() {
|
||||||
forces.clear();
|
forces.clear();
|
||||||
gravityForce = 0;
|
gravityForce = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void manipulateAllForces(float factor) {
|
public void manipulateAllForces(float factor) {
|
||||||
for (int i = 0; i < forces.size(); i++)
|
for (int i = 0; i < forces.size(); i++)
|
||||||
forces.set(i, forces.get(i) * factor);
|
forces.set(i, forces.get(i) * factor);
|
||||||
gravityForce *= factor * factor;
|
gravityForce *= factor * factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postMoveUpdate() {
|
public void postMoveUpdate() {
|
||||||
stases.clear();
|
stases.clear();
|
||||||
forces.clear();
|
forces.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getProgress(float goalX) {
|
public float getProgress(float goalX) {
|
||||||
return (getPosition().x - START_X) / (goalX - START_X);
|
return (getPosition().x - START_X) / (goalX - START_X);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getXFromStart(){
|
public float getXFromStart(){
|
||||||
return getPosition().x - START_X;
|
return getPosition().x - START_X;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getSpeed() {
|
public float getSpeed() {
|
||||||
return speed;
|
return speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasSuperPower() {
|
public boolean hasSuperPower() {
|
||||||
return hasSuperPower;
|
return hasSuperPower;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addStasis(Stasis stasis) {
|
public void addStasis(Stasis stasis) {
|
||||||
stases.add(stasis);
|
stases.add(stasis);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Stasis> getStases() {
|
public List<Stasis> getStases() {
|
||||||
return stases;
|
return stases;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addForce(float force) {
|
public void addForce(float force) {
|
||||||
forces.add(force);
|
forces.add(force);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGravityForce(float gravityForce) {
|
public void setGravityForce(float gravityForce) {
|
||||||
this.gravityForce = gravityForce;
|
this.gravityForce = gravityForce;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void move(Vector movement) {
|
public void move(Vector movement) {
|
||||||
super.move(movement);
|
super.move(movement);
|
||||||
float circumference = 2 * 3.14f * RADIUS;
|
float circumference = 2 * 3.14f * RADIUS;
|
||||||
float rotation = -360 * (movement.x / circumference);
|
float rotation = -360 * (movement.x / circumference);
|
||||||
rotate(rotation);
|
rotate(rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,51 +1,51 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities;
|
package de.frajul.endlessroll.entities;
|
||||||
|
|
||||||
import de.frajul.endlessroll.main.GameLog;
|
import de.frajul.endlessroll.main.GameLog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 11.12.2016.
|
* Created by Julian on 11.12.2016.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public enum Vertex {
|
public enum Vertex {
|
||||||
|
|
||||||
UL(0, -1, 1), UR(1, 1, 1), BL(3, -1, -1), BR(2, 1, -1);
|
UL(0, -1, 1), UR(1, 1, 1), BL(3, -1, -1), BR(2, 1, -1);
|
||||||
|
|
||||||
private int index;
|
private int index;
|
||||||
private float x, y;
|
private float x, y;
|
||||||
|
|
||||||
Vertex(int index, float x, float y) {
|
Vertex(int index, float x, float y) {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vertex getNext(boolean clockwise) {
|
public Vertex getNext(boolean clockwise) {
|
||||||
int newIndex = index + 1;
|
int newIndex = index + 1;
|
||||||
if (!clockwise)
|
if (!clockwise)
|
||||||
newIndex = index - 1;
|
newIndex = index - 1;
|
||||||
if (newIndex > 3)
|
if (newIndex > 3)
|
||||||
newIndex = 0;
|
newIndex = 0;
|
||||||
if (newIndex < 0)
|
if (newIndex < 0)
|
||||||
newIndex = 3;
|
newIndex = 3;
|
||||||
for (Vertex vertex : values())
|
for (Vertex vertex : values())
|
||||||
if (vertex.index == newIndex)
|
if (vertex.index == newIndex)
|
||||||
return vertex;
|
return vertex;
|
||||||
GameLog.e("No vertex with index " + index + " found!!!");
|
GameLog.e("No vertex with index " + index + " found!!!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getX() {
|
public float getX() {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getY() {
|
public float getY() {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,74 +1,74 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.collectables;
|
package de.frajul.endlessroll.entities.collectables;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.SynchronizedArrayList;
|
import de.frajul.endlessroll.data.SynchronizedArrayList;
|
||||||
import de.frajul.endlessroll.entities.Entity;
|
import de.frajul.endlessroll.entities.Entity;
|
||||||
import de.frajul.endlessroll.entities.textures.TexturePack;
|
import de.frajul.endlessroll.entities.textures.TexturePack;
|
||||||
import de.frajul.endlessroll.levels.Level;
|
import de.frajul.endlessroll.levels.Level;
|
||||||
import de.frajul.endlessroll.levels.PositionData;
|
import de.frajul.endlessroll.levels.PositionData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 06.09.2017.
|
* Created by Julian on 06.09.2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Collectables extends SynchronizedArrayList<Entity> {
|
public class Collectables extends SynchronizedArrayList<Entity> {
|
||||||
|
|
||||||
private List<Star> stars = Collections.synchronizedList(new ArrayList<Star>());
|
private List<Star> stars = Collections.synchronizedList(new ArrayList<Star>());
|
||||||
private Energy energy;
|
private Energy energy;
|
||||||
|
|
||||||
public void init(Level level, TexturePack textures) {
|
public void init(Level level, TexturePack textures) {
|
||||||
for (int i = 0; i < level.getStars().size(); i++) {
|
for (int i = 0; i < level.getStars().size(); i++) {
|
||||||
if (level.isStarCollected(i))
|
if (level.isStarCollected(i))
|
||||||
continue;
|
continue;
|
||||||
addStar(new Star(i, textures.star, level.getStars().get(i)));
|
addStar(new Star(i, textures.star, level.getStars().get(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
PositionData energyData = level.getEnergyData();
|
PositionData energyData = level.getEnergyData();
|
||||||
if (energyData != null && !level.isEnergyCollected()) {
|
if (energyData != null && !level.isEnergyCollected()) {
|
||||||
setEnergy(new Energy(textures.energy, energyData));
|
setEnergy(new Energy(textures.energy, energyData));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean remove(Object object) {
|
public synchronized boolean remove(Object object) {
|
||||||
if (object instanceof Star)
|
if (object instanceof Star)
|
||||||
stars.remove(object);
|
stars.remove(object);
|
||||||
else
|
else
|
||||||
energy = null;
|
energy = null;
|
||||||
return super.remove(object);
|
return super.remove(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addStar(Star star) {
|
private void addStar(Star star) {
|
||||||
stars.add(star);
|
stars.add(star);
|
||||||
super.add(star);
|
super.add(star);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setEnergy(Energy energy) {
|
private void setEnergy(Energy energy) {
|
||||||
this.energy = energy;
|
this.energy = energy;
|
||||||
super.add(energy);
|
super.add(energy);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
stars.clear();
|
stars.clear();
|
||||||
energy = null;
|
energy = null;
|
||||||
super.clear();
|
super.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Star> getStars() {
|
public List<Star> getStars() {
|
||||||
return stars;
|
return stars;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Energy getEnergy() {
|
public Energy getEnergy() {
|
||||||
return energy;
|
return energy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.collectables;
|
package de.frajul.endlessroll.entities.collectables;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.AnimatedEntity;
|
import de.frajul.endlessroll.entities.AnimatedEntity;
|
||||||
import de.frajul.endlessroll.entities.textures.Texture;
|
import de.frajul.endlessroll.entities.textures.Texture;
|
||||||
import de.frajul.endlessroll.levels.PositionData;
|
import de.frajul.endlessroll.levels.PositionData;
|
||||||
|
|
||||||
public class Energy extends AnimatedEntity {
|
public class Energy extends AnimatedEntity {
|
||||||
|
|
||||||
private final static float SIZE = 0.3f;
|
private final static float SIZE = 0.3f;
|
||||||
|
|
||||||
public Energy(Texture texture, PositionData data) {
|
public Energy(Texture texture, PositionData data) {
|
||||||
super(texture, new Vector(data.getX(), data.getY()), SIZE, SIZE);
|
super(texture, new Vector(data.getX(), data.getY()), SIZE, SIZE);
|
||||||
animation.setLooping(true);
|
animation.setLooping(true);
|
||||||
animation.setRequiredDelta(130);
|
animation.setRequiredDelta(130);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.collectables;
|
package de.frajul.endlessroll.entities.collectables;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.Entity;
|
import de.frajul.endlessroll.entities.Entity;
|
||||||
import de.frajul.endlessroll.entities.textures.Texture;
|
import de.frajul.endlessroll.entities.textures.Texture;
|
||||||
import de.frajul.endlessroll.levels.PositionData;
|
import de.frajul.endlessroll.levels.PositionData;
|
||||||
|
|
||||||
public class Star extends Entity {
|
public class Star extends Entity {
|
||||||
|
|
||||||
private final static float SIZE = 0.25f;
|
private final static float SIZE = 0.25f;
|
||||||
private int index;
|
private int index;
|
||||||
|
|
||||||
public Star(int index, Texture texture, PositionData data) {
|
public Star(int index, Texture texture, PositionData data) {
|
||||||
super(texture, new Vector(data.getX(), data.getY()), SIZE, SIZE);
|
super(texture, new Vector(data.getX(), data.getY()), SIZE, SIZE);
|
||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getIndex() {
|
public int getIndex() {
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,82 +1,82 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.collision;
|
package de.frajul.endlessroll.entities.collision;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.collision.geometry.Circle;
|
import de.frajul.endlessroll.entities.collision.geometry.Circle;
|
||||||
import de.frajul.endlessroll.entities.collision.geometry.Triangle;
|
import de.frajul.endlessroll.entities.collision.geometry.Triangle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 28.02.2016.
|
* Created by Julian on 28.02.2016.
|
||||||
*/
|
*/
|
||||||
public class CircleTriangleCollisionDetector {
|
public class CircleTriangleCollisionDetector {
|
||||||
|
|
||||||
public boolean isCircleTriangleCollision(Circle circle, Triangle triangle) {
|
public boolean isCircleTriangleCollision(Circle circle, Triangle triangle) {
|
||||||
if (circleIntersectingWithTriangleVertices(circle, triangle))
|
if (circleIntersectingWithTriangleVertices(circle, triangle))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (circleCenterInsideTriangle(circle, triangle))
|
if (circleCenterInsideTriangle(circle, triangle))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return circleIntersectingWithTriangleEdges(circle, triangle);
|
return circleIntersectingWithTriangleEdges(circle, triangle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean circleIntersectingWithTriangleEdges(Circle circle, Triangle triangle) {
|
private boolean circleIntersectingWithTriangleEdges(Circle circle, Triangle triangle) {
|
||||||
Vector edge1 = triangle.getBottomRightVertex().vectorTo(triangle.getTopRightVertex());
|
Vector edge1 = triangle.getBottomRightVertex().vectorTo(triangle.getTopRightVertex());
|
||||||
Vector edge2 = triangle.getTopRightVertex().vectorTo(triangle.getBottomLeftVertex());
|
Vector edge2 = triangle.getTopRightVertex().vectorTo(triangle.getBottomLeftVertex());
|
||||||
Vector edge3 = triangle.getBottomLeftVertex().vectorTo(triangle.getBottomRightVertex());
|
Vector edge3 = triangle.getBottomLeftVertex().vectorTo(triangle.getBottomRightVertex());
|
||||||
|
|
||||||
boolean intersectingWithEdge1 = circleIntersectingWithTriangleEdge(circle, triangle.getBottomRightVertex(), edge1);
|
boolean intersectingWithEdge1 = circleIntersectingWithTriangleEdge(circle, triangle.getBottomRightVertex(), edge1);
|
||||||
boolean intersectingWithEdge2 = circleIntersectingWithTriangleEdge(circle, triangle.getTopRightVertex(), edge2);
|
boolean intersectingWithEdge2 = circleIntersectingWithTriangleEdge(circle, triangle.getTopRightVertex(), edge2);
|
||||||
boolean intersectingWithEdge3 = circleIntersectingWithTriangleEdge(circle, triangle.getBottomLeftVertex(), edge3);
|
boolean intersectingWithEdge3 = circleIntersectingWithTriangleEdge(circle, triangle.getBottomLeftVertex(), edge3);
|
||||||
return intersectingWithEdge1 || intersectingWithEdge2 || intersectingWithEdge3;
|
return intersectingWithEdge1 || intersectingWithEdge2 || intersectingWithEdge3;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean circleIntersectingWithTriangleEdge(Circle circle, Vector vertex, Vector edge) {
|
private boolean circleIntersectingWithTriangleEdge(Circle circle, Vector vertex, Vector edge) {
|
||||||
Vector vertexToCenter = vertex.vectorTo(circle.getPosition());
|
Vector vertexToCenter = vertex.vectorTo(circle.getPosition());
|
||||||
Vector kVector = new Vector(vertexToCenter).mul(edge);
|
Vector kVector = new Vector(vertexToCenter).mul(edge);
|
||||||
float k = kVector.x + kVector.y;
|
float k = kVector.x + kVector.y;
|
||||||
|
|
||||||
if (k > 0) {
|
if (k > 0) {
|
||||||
float length = edge.length();
|
float length = edge.length();
|
||||||
k = k / length;
|
k = k / length;
|
||||||
|
|
||||||
if (k < length)
|
if (k < length)
|
||||||
return Math.sqrt(vertexToCenter.x * vertexToCenter.x + vertexToCenter.y * vertexToCenter.y - k * k) <= circle.getRadius();
|
return Math.sqrt(vertexToCenter.x * vertexToCenter.x + vertexToCenter.y * vertexToCenter.y - k * k) <= circle.getRadius();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean circleCenterInsideTriangle(Circle circle, Triangle triangle) {
|
private boolean circleCenterInsideTriangle(Circle circle, Triangle triangle) {
|
||||||
Vector vertex1To2 = triangle.getBottomRightVertex().vectorTo(triangle.getTopRightVertex());
|
Vector vertex1To2 = triangle.getBottomRightVertex().vectorTo(triangle.getTopRightVertex());
|
||||||
Vector vertex2To3 = triangle.getTopRightVertex().vectorTo(triangle.getBottomLeftVertex());
|
Vector vertex2To3 = triangle.getTopRightVertex().vectorTo(triangle.getBottomLeftVertex());
|
||||||
Vector vertex3To1 = triangle.getBottomLeftVertex().vectorTo(triangle.getBottomRightVertex());
|
Vector vertex3To1 = triangle.getBottomLeftVertex().vectorTo(triangle.getBottomRightVertex());
|
||||||
Vector vertex1ToCenter = triangle.getBottomRightVertex().vectorTo(circle.getPosition());
|
Vector vertex1ToCenter = triangle.getBottomRightVertex().vectorTo(circle.getPosition());
|
||||||
Vector vertex2ToCenter = triangle.getTopRightVertex().vectorTo(circle.getPosition());
|
Vector vertex2ToCenter = triangle.getTopRightVertex().vectorTo(circle.getPosition());
|
||||||
Vector vertex3ToCenter = triangle.getBottomLeftVertex().vectorTo(circle.getPosition());
|
Vector vertex3ToCenter = triangle.getBottomLeftVertex().vectorTo(circle.getPosition());
|
||||||
|
|
||||||
boolean centerInsideV1V2 = vertex1To2.y * vertex1ToCenter.x - vertex1To2.x * vertex1ToCenter.y < 0;
|
boolean centerInsideV1V2 = vertex1To2.y * vertex1ToCenter.x - vertex1To2.x * vertex1ToCenter.y < 0;
|
||||||
boolean centerInsideV2V3 = vertex2To3.y * vertex2ToCenter.x - vertex2To3.x * vertex2ToCenter.y < 0;
|
boolean centerInsideV2V3 = vertex2To3.y * vertex2ToCenter.x - vertex2To3.x * vertex2ToCenter.y < 0;
|
||||||
boolean centerInsideV3V1 = vertex3To1.y * vertex3ToCenter.x - vertex3To1.x * vertex3ToCenter.y < 0;
|
boolean centerInsideV3V1 = vertex3To1.y * vertex3ToCenter.x - vertex3To1.x * vertex3ToCenter.y < 0;
|
||||||
|
|
||||||
return centerInsideV1V2 && centerInsideV2V3 && centerInsideV3V1;
|
return centerInsideV1V2 && centerInsideV2V3 && centerInsideV3V1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean circleIntersectingWithTriangleVertices(Circle circle, Triangle triangle) {
|
private boolean circleIntersectingWithTriangleVertices(Circle circle, Triangle triangle) {
|
||||||
boolean intersectingWithVertex1 = circleIntersectingWithTriangleVertex(circle, triangle.getBottomRightVertex());
|
boolean intersectingWithVertex1 = circleIntersectingWithTriangleVertex(circle, triangle.getBottomRightVertex());
|
||||||
boolean intersectingWithVertex2 = circleIntersectingWithTriangleVertex(circle, triangle.getTopRightVertex());
|
boolean intersectingWithVertex2 = circleIntersectingWithTriangleVertex(circle, triangle.getTopRightVertex());
|
||||||
boolean intersectingWithVertex3 = circleIntersectingWithTriangleVertex(circle, triangle.getBottomLeftVertex());
|
boolean intersectingWithVertex3 = circleIntersectingWithTriangleVertex(circle, triangle.getBottomLeftVertex());
|
||||||
return intersectingWithVertex1 || intersectingWithVertex2 || intersectingWithVertex3;
|
return intersectingWithVertex1 || intersectingWithVertex2 || intersectingWithVertex3;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean circleIntersectingWithTriangleVertex(Circle circle, Vector vertex) {
|
private boolean circleIntersectingWithTriangleVertex(Circle circle, Vector vertex) {
|
||||||
Vector centerToVertex = circle.getPosition().vectorTo(vertex);
|
Vector centerToVertex = circle.getPosition().vectorTo(vertex);
|
||||||
return centerToVertex.length() <= circle.getRadius();
|
return centerToVertex.length() <= circle.getRadius();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,356 +1,356 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.collision;
|
package de.frajul.endlessroll.entities.collision;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.Entity;
|
import de.frajul.endlessroll.entities.Entity;
|
||||||
import de.frajul.endlessroll.entities.Player;
|
import de.frajul.endlessroll.entities.Player;
|
||||||
import de.frajul.endlessroll.entities.collision.collisionData.EntityCollisionData;
|
import de.frajul.endlessroll.entities.collision.collisionData.EntityCollisionData;
|
||||||
import de.frajul.endlessroll.entities.collision.geometry.Circle;
|
import de.frajul.endlessroll.entities.collision.geometry.Circle;
|
||||||
import de.frajul.endlessroll.entities.collision.geometry.Geometry;
|
import de.frajul.endlessroll.entities.collision.geometry.Geometry;
|
||||||
import de.frajul.endlessroll.entities.collision.geometry.Quad;
|
import de.frajul.endlessroll.entities.collision.geometry.Quad;
|
||||||
import de.frajul.endlessroll.entities.collision.geometry.Triangle;
|
import de.frajul.endlessroll.entities.collision.geometry.Triangle;
|
||||||
import de.frajul.endlessroll.entities.tileLists.Tile;
|
import de.frajul.endlessroll.entities.tileLists.Tile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 01.12.2015.
|
* Created by Julian on 01.12.2015.
|
||||||
*/
|
*/
|
||||||
public class CollisionDetector {
|
public class CollisionDetector {
|
||||||
|
|
||||||
private CircleTriangleCollisionDetector triangleDetector;
|
private CircleTriangleCollisionDetector triangleDetector;
|
||||||
|
|
||||||
public CollisionDetector() {
|
public CollisionDetector() {
|
||||||
triangleDetector = new CircleTriangleCollisionDetector();
|
triangleDetector = new CircleTriangleCollisionDetector();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCollision(Geometry g1, Geometry g2) {
|
public boolean isCollision(Geometry g1, Geometry g2) {
|
||||||
if (g1 instanceof Triangle) {
|
if (g1 instanceof Triangle) {
|
||||||
if (g2 instanceof Triangle)
|
if (g2 instanceof Triangle)
|
||||||
return isTriangleTriangleCollision((Triangle) g1, (Triangle) g2);
|
return isTriangleTriangleCollision((Triangle) g1, (Triangle) g2);
|
||||||
if (g2 instanceof Quad)
|
if (g2 instanceof Quad)
|
||||||
return isQuadTriangleCollision((Quad) g2, (Triangle) g1);
|
return isQuadTriangleCollision((Quad) g2, (Triangle) g1);
|
||||||
if (g2 instanceof Circle)
|
if (g2 instanceof Circle)
|
||||||
return isCircleTriangleCollision((Circle) g2, (Triangle) g1);
|
return isCircleTriangleCollision((Circle) g2, (Triangle) g1);
|
||||||
}
|
}
|
||||||
if (g1 instanceof Quad) {
|
if (g1 instanceof Quad) {
|
||||||
if (g2 instanceof Triangle)
|
if (g2 instanceof Triangle)
|
||||||
return isQuadTriangleCollision((Quad) g1, (Triangle) g2);
|
return isQuadTriangleCollision((Quad) g1, (Triangle) g2);
|
||||||
if (g2 instanceof Quad)
|
if (g2 instanceof Quad)
|
||||||
return isQuadQuadCollision((Quad) g1, (Quad) g2);
|
return isQuadQuadCollision((Quad) g1, (Quad) g2);
|
||||||
if (g2 instanceof Circle)
|
if (g2 instanceof Circle)
|
||||||
return isCircleQuadCollision((Circle) g2, (Quad) g1);
|
return isCircleQuadCollision((Circle) g2, (Quad) g1);
|
||||||
}
|
}
|
||||||
if (g1 instanceof Circle) {
|
if (g1 instanceof Circle) {
|
||||||
if (g2 instanceof Triangle)
|
if (g2 instanceof Triangle)
|
||||||
return isCircleTriangleCollision((Circle) g1, (Triangle) g2);
|
return isCircleTriangleCollision((Circle) g1, (Triangle) g2);
|
||||||
if (g2 instanceof Quad)
|
if (g2 instanceof Quad)
|
||||||
return isCircleQuadCollision((Circle) g1, (Quad) g2);
|
return isCircleQuadCollision((Circle) g1, (Quad) g2);
|
||||||
if (g2 instanceof Circle)
|
if (g2 instanceof Circle)
|
||||||
return isCircleCircleCollision((Circle) g1, (Circle) g2);
|
return isCircleCircleCollision((Circle) g1, (Circle) g2);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPointInQuad(Vector point, Quad quad) {
|
public boolean isPointInQuad(Vector point, Quad quad) {
|
||||||
if (point.getX() >= quad.getLeftEdge() && point.getX() <= quad.getRightEdge()) {
|
if (point.getX() >= quad.getLeftEdge() && point.getX() <= quad.getRightEdge()) {
|
||||||
return point.getY() >= quad.getBottomEdge() && point.getY() <= quad.getTopEdge();
|
return point.getY() >= quad.getBottomEdge() && point.getY() <= quad.getTopEdge();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCircleCircleCollision(Circle c1, Circle c2) {
|
public boolean isCircleCircleCollision(Circle c1, Circle c2) {
|
||||||
float distance = Math.abs(c1.getPosition().vectorTo(c2.getPosition()).length());
|
float distance = Math.abs(c1.getPosition().vectorTo(c2.getPosition()).length());
|
||||||
float radiusSum = c1.getRadius() + c2.getRadius();
|
float radiusSum = c1.getRadius() + c2.getRadius();
|
||||||
return distance < radiusSum;
|
return distance < radiusSum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCircleQuadCollision(Circle circle, Quad quad) {
|
public boolean isCircleQuadCollision(Circle circle, Quad quad) {
|
||||||
Vector distance = circle.getPosition().vectorTo(quad.getPosition());
|
Vector distance = circle.getPosition().vectorTo(quad.getPosition());
|
||||||
distance.x = Math.abs(distance.x);
|
distance.x = Math.abs(distance.x);
|
||||||
distance.y = Math.abs(distance.y);
|
distance.y = Math.abs(distance.y);
|
||||||
|
|
||||||
if (distance.x > circle.getRadius() + quad.getWidth() / 2)
|
if (distance.x > circle.getRadius() + quad.getWidth() / 2)
|
||||||
return false;
|
return false;
|
||||||
if (distance.y > circle.getRadius() + quad.getHeight() / 2)
|
if (distance.y > circle.getRadius() + quad.getHeight() / 2)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (distance.x <= quad.getWidth() / 2)
|
if (distance.x <= quad.getWidth() / 2)
|
||||||
return true;
|
return true;
|
||||||
if (distance.y <= quad.getHeight() / 2)
|
if (distance.y <= quad.getHeight() / 2)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
float cornerDistance_sq = (distance.x - quad.getWidth() / 2) * (distance.x - quad
|
float cornerDistance_sq = (distance.x - quad.getWidth() / 2) * (distance.x - quad
|
||||||
.getWidth() / 2) + (distance.y - quad.getHeight() / 2) * (distance.y - quad
|
.getWidth() / 2) + (distance.y - quad.getHeight() / 2) * (distance.y - quad
|
||||||
.getHeight() / 2);
|
.getHeight() / 2);
|
||||||
return cornerDistance_sq <= circle.getRadius() * circle.getRadius();
|
return cornerDistance_sq <= circle.getRadius() * circle.getRadius();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCircleTriangleCollision(Circle circle, Triangle triangle) {
|
public boolean isCircleTriangleCollision(Circle circle, Triangle triangle) {
|
||||||
return triangleDetector.isCircleTriangleCollision(circle, triangle);
|
return triangleDetector.isCircleTriangleCollision(circle, triangle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isQuadQuadCollision(Quad q1, Quad q2) {
|
public boolean isQuadQuadCollision(Quad q1, Quad q2) {
|
||||||
float xDistance = Math.abs(q2.getPosition().x - q1.getPosition().x);
|
float xDistance = Math.abs(q2.getPosition().x - q1.getPosition().x);
|
||||||
float yDistance = Math.abs(q2.getPosition().y - q1.getPosition().y);
|
float yDistance = Math.abs(q2.getPosition().y - q1.getPosition().y);
|
||||||
if (xDistance >= q1.getWidth() / 2 + q2.getWidth() / 2)
|
if (xDistance >= q1.getWidth() / 2 + q2.getWidth() / 2)
|
||||||
return false;
|
return false;
|
||||||
return !(yDistance >= q1.getHeight() / 2 + q2.getHeight() / 2);
|
return !(yDistance >= q1.getHeight() / 2 + q2.getHeight() / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTriangleTriangleCollision(Triangle triangle1, Triangle triangle2) {
|
public boolean isTriangleTriangleCollision(Triangle triangle1, Triangle triangle2) {
|
||||||
boolean triangle1Vertex1InTriangle2 = isVertexInTriangle(triangle1.getBottomRightVertex(), triangle2);
|
boolean triangle1Vertex1InTriangle2 = isVertexInTriangle(triangle1.getBottomRightVertex(), triangle2);
|
||||||
if (triangle1Vertex1InTriangle2)
|
if (triangle1Vertex1InTriangle2)
|
||||||
return true;
|
return true;
|
||||||
boolean triangle1Vertex2InTriangle2 = isVertexInTriangle(triangle1.getTopRightVertex(), triangle2);
|
boolean triangle1Vertex2InTriangle2 = isVertexInTriangle(triangle1.getTopRightVertex(), triangle2);
|
||||||
if (triangle1Vertex2InTriangle2)
|
if (triangle1Vertex2InTriangle2)
|
||||||
return true;
|
return true;
|
||||||
boolean triangle1Vertex3InTriangle2 = isVertexInTriangle(triangle1.getBottomLeftVertex(), triangle2);
|
boolean triangle1Vertex3InTriangle2 = isVertexInTriangle(triangle1.getBottomLeftVertex(), triangle2);
|
||||||
if (triangle1Vertex3InTriangle2)
|
if (triangle1Vertex3InTriangle2)
|
||||||
return true;
|
return true;
|
||||||
boolean triangle2Vertex1InTriangle1 = isVertexInTriangle(triangle2.getBottomRightVertex(), triangle1);
|
boolean triangle2Vertex1InTriangle1 = isVertexInTriangle(triangle2.getBottomRightVertex(), triangle1);
|
||||||
if (triangle2Vertex1InTriangle1)
|
if (triangle2Vertex1InTriangle1)
|
||||||
return true;
|
return true;
|
||||||
boolean triangle2Vertex2InTriangle1 = isVertexInTriangle(triangle2.getTopRightVertex(), triangle1);
|
boolean triangle2Vertex2InTriangle1 = isVertexInTriangle(triangle2.getTopRightVertex(), triangle1);
|
||||||
if (triangle2Vertex2InTriangle1)
|
if (triangle2Vertex2InTriangle1)
|
||||||
return true;
|
return true;
|
||||||
boolean triangle2Vertex3InTriangle1 = isVertexInTriangle(triangle2.getBottomLeftVertex(), triangle1);
|
boolean triangle2Vertex3InTriangle1 = isVertexInTriangle(triangle2.getBottomLeftVertex(), triangle1);
|
||||||
return triangle2Vertex3InTriangle1;
|
return triangle2Vertex3InTriangle1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isQuadTriangleCollision(Quad quad, Triangle triangle) {
|
public boolean isQuadTriangleCollision(Quad quad, Triangle triangle) {
|
||||||
boolean quadVertex1InTriangle = isVertexInTriangle(
|
boolean quadVertex1InTriangle = isVertexInTriangle(
|
||||||
new Vector(quad.getLeftEdge(), quad.getTopEdge()), triangle);
|
new Vector(quad.getLeftEdge(), quad.getTopEdge()), triangle);
|
||||||
if (quadVertex1InTriangle)
|
if (quadVertex1InTriangle)
|
||||||
return true;
|
return true;
|
||||||
boolean quadVertex2InTriangle = isVertexInTriangle(
|
boolean quadVertex2InTriangle = isVertexInTriangle(
|
||||||
new Vector(quad.getRightEdge(), quad.getTopEdge()), triangle);
|
new Vector(quad.getRightEdge(), quad.getTopEdge()), triangle);
|
||||||
if (quadVertex2InTriangle)
|
if (quadVertex2InTriangle)
|
||||||
return true;
|
return true;
|
||||||
boolean quadVertex3InTriangle = isVertexInTriangle(
|
boolean quadVertex3InTriangle = isVertexInTriangle(
|
||||||
new Vector(quad.getRightEdge(), quad.getBottomEdge()), triangle);
|
new Vector(quad.getRightEdge(), quad.getBottomEdge()), triangle);
|
||||||
if (quadVertex3InTriangle)
|
if (quadVertex3InTriangle)
|
||||||
return true;
|
return true;
|
||||||
boolean quadVertex4InTriangle = isVertexInTriangle(
|
boolean quadVertex4InTriangle = isVertexInTriangle(
|
||||||
new Vector(quad.getLeftEdge(), quad.getBottomEdge()), triangle);
|
new Vector(quad.getLeftEdge(), quad.getBottomEdge()), triangle);
|
||||||
if (quadVertex4InTriangle)
|
if (quadVertex4InTriangle)
|
||||||
return true;
|
return true;
|
||||||
boolean triangleVertex1InQuad = isPointInQuad(triangle.getBottomRightVertex(), quad);
|
boolean triangleVertex1InQuad = isPointInQuad(triangle.getBottomRightVertex(), quad);
|
||||||
if (triangleVertex1InQuad)
|
if (triangleVertex1InQuad)
|
||||||
return true;
|
return true;
|
||||||
boolean triangleVertex2InQuad = isPointInQuad(triangle.getTopRightVertex(), quad);
|
boolean triangleVertex2InQuad = isPointInQuad(triangle.getTopRightVertex(), quad);
|
||||||
if (triangleVertex2InQuad)
|
if (triangleVertex2InQuad)
|
||||||
return true;
|
return true;
|
||||||
boolean triangleVertex3InQuad = isPointInQuad(triangle.getBottomLeftVertex(), quad);
|
boolean triangleVertex3InQuad = isPointInQuad(triangle.getBottomLeftVertex(), quad);
|
||||||
if (triangleVertex3InQuad)
|
if (triangleVertex3InQuad)
|
||||||
return true;
|
return true;
|
||||||
return triangle.getTopEdge() >= quad.getTopEdge() && triangle.getBottomEdge() <= quad.getBottomEdge() && ((triangle.getLeftEdge() <= quad.getRightEdge() && triangle.getLeftEdge() >= quad.getLeftEdge()) || (triangle.getRightEdge() <= quad.getRightEdge() && triangle.getRightEdge() >= quad.getLeftEdge()));
|
return triangle.getTopEdge() >= quad.getTopEdge() && triangle.getBottomEdge() <= quad.getBottomEdge() && ((triangle.getLeftEdge() <= quad.getRightEdge() && triangle.getLeftEdge() >= quad.getLeftEdge()) || (triangle.getRightEdge() <= quad.getRightEdge() && triangle.getRightEdge() >= quad.getLeftEdge()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isVertexInTriangle(Vector vertex, Triangle triangle) {
|
private boolean isVertexInTriangle(Vector vertex, Triangle triangle) {
|
||||||
if (!isPointInQuad(vertex, triangle))
|
if (!isPointInQuad(vertex, triangle))
|
||||||
return false;
|
return false;
|
||||||
float gradient = triangle.getGradient();
|
float gradient = triangle.getGradient();
|
||||||
float maxVertexY = vertex.getX() * gradient + triangle.getBottomEdge();
|
float maxVertexY = vertex.getX() * gradient + triangle.getBottomEdge();
|
||||||
return vertex.getY() <= maxVertexY;
|
return vertex.getY() <= maxVertexY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityCollisionData playerTerrainCollision(Player player, Tile terrainTile) {
|
public EntityCollisionData playerTerrainCollision(Player player, Tile terrainTile) {
|
||||||
Circle circle = new Circle(player);
|
Circle circle = new Circle(player);
|
||||||
if (circle.getTopEdge() < terrainTile.getTopEdge()) {
|
if (circle.getTopEdge() < terrainTile.getTopEdge()) {
|
||||||
float xDistance = Math.abs(circle.getPosition().x - terrainTile.getPosition().x);
|
float xDistance = Math.abs(circle.getPosition().x - terrainTile.getPosition().x);
|
||||||
if (xDistance < circle.getRadius() + terrainTile.getWidth() / 2)
|
if (xDistance < circle.getRadius() + terrainTile.getWidth() / 2)
|
||||||
return new EntityCollisionData(terrainTile, Edge.LEFT);
|
return new EntityCollisionData(terrainTile, Edge.LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCircleQuadCollision(circle, terrainTile)) {
|
if (isCircleQuadCollision(circle, terrainTile)) {
|
||||||
Edge edge = circleQuadCollisionEdge(circle, player.getMovement(), terrainTile,
|
Edge edge = circleQuadCollisionEdge(circle, player.getMovement(), terrainTile,
|
||||||
terrainTile.getMovement());
|
terrainTile.getMovement());
|
||||||
return new EntityCollisionData(terrainTile, edge);
|
return new EntityCollisionData(terrainTile, edge);
|
||||||
}
|
}
|
||||||
return new EntityCollisionData(null, null);
|
return new EntityCollisionData(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityCollisionData playerCeilingCollision(Player player, Tile ceilingTile) {
|
public EntityCollisionData playerCeilingCollision(Player player, Tile ceilingTile) {
|
||||||
Circle circle = new Circle(player);
|
Circle circle = new Circle(player);
|
||||||
if (circle.getBottomEdge() > ceilingTile.getBottomEdge()) {
|
if (circle.getBottomEdge() > ceilingTile.getBottomEdge()) {
|
||||||
float xDistance = Math.abs(circle.getPosition().x - ceilingTile.getPosition().x);
|
float xDistance = Math.abs(circle.getPosition().x - ceilingTile.getPosition().x);
|
||||||
if (xDistance < circle.getRadius() + ceilingTile.getWidth() / 2)
|
if (xDistance < circle.getRadius() + ceilingTile.getWidth() / 2)
|
||||||
return new EntityCollisionData(ceilingTile, Edge.LEFT);
|
return new EntityCollisionData(ceilingTile, Edge.LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCircleQuadCollision(circle, ceilingTile)) {
|
if (isCircleQuadCollision(circle, ceilingTile)) {
|
||||||
Edge edge = circleQuadCollisionEdge(circle, player.getMovement(), ceilingTile,
|
Edge edge = circleQuadCollisionEdge(circle, player.getMovement(), ceilingTile,
|
||||||
ceilingTile.getMovement());
|
ceilingTile.getMovement());
|
||||||
return new EntityCollisionData(ceilingTile, edge);
|
return new EntityCollisionData(ceilingTile, edge);
|
||||||
}
|
}
|
||||||
return new EntityCollisionData(null, null);
|
return new EntityCollisionData(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityCollisionData playerEntityCollision(Player player, Entity entity) {
|
public EntityCollisionData playerEntityCollision(Player player, Entity entity) {
|
||||||
Circle circle = new Circle(player);
|
Circle circle = new Circle(player);
|
||||||
Quad quad = entity;
|
Quad quad = entity;
|
||||||
if (isCircleQuadCollision(circle, quad)) {
|
if (isCircleQuadCollision(circle, quad)) {
|
||||||
Edge edge = circleQuadCollisionEdge(circle, player.getMovement(), quad,
|
Edge edge = circleQuadCollisionEdge(circle, player.getMovement(), quad,
|
||||||
entity.getMovement());
|
entity.getMovement());
|
||||||
return new EntityCollisionData(entity, edge);
|
return new EntityCollisionData(entity, edge);
|
||||||
}
|
}
|
||||||
return new EntityCollisionData(null, null);
|
return new EntityCollisionData(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Edge circleQuadCollisionEdge(Circle circle, Vector circleMovement, Quad quad, Vector quadMovement) {
|
private Edge circleQuadCollisionEdge(Circle circle, Vector circleMovement, Quad quad, Vector quadMovement) {
|
||||||
boolean circleFullyInsideQuad = false;
|
boolean circleFullyInsideQuad = false;
|
||||||
if (circle.getPosition().getX() + circle.getRadius() <= quad.getRightEdge() && circle
|
if (circle.getPosition().getX() + circle.getRadius() <= quad.getRightEdge() && circle
|
||||||
.getPosition().getX() - circle.getRadius() >= quad.getLeftEdge()) {
|
.getPosition().getX() - circle.getRadius() >= quad.getLeftEdge()) {
|
||||||
if (circle.getPosition().getY() + circle.getRadius() <= quad.getTopEdge() && circle
|
if (circle.getPosition().getY() + circle.getRadius() <= quad.getTopEdge() && circle
|
||||||
.getPosition().getY() - circle.getRadius() >= quad.getBottomEdge()) {
|
.getPosition().getY() - circle.getRadius() >= quad.getBottomEdge()) {
|
||||||
circleFullyInsideQuad = true;
|
circleFullyInsideQuad = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (circleFullyInsideQuad)
|
if (circleFullyInsideQuad)
|
||||||
return circleCenterInQuadCollisionEdge(circle, circleMovement, quad, quadMovement);
|
return circleCenterInQuadCollisionEdge(circle, circleMovement, quad, quadMovement);
|
||||||
return circlePartlyOutsideQuadCollisionEdge(circle, circleMovement, quad, quadMovement);
|
return circlePartlyOutsideQuadCollisionEdge(circle, circleMovement, quad, quadMovement);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Edge circlePartlyOutsideQuadCollisionEdge(Circle circle, Vector circleMovement, Quad quad, Vector quadMovement) {
|
private Edge circlePartlyOutsideQuadCollisionEdge(Circle circle, Vector circleMovement, Quad quad, Vector quadMovement) {
|
||||||
Vector relativeMovement = new Vector(circleMovement).translate(quadMovement.negate());
|
Vector relativeMovement = new Vector(circleMovement).translate(quadMovement.negate());
|
||||||
|
|
||||||
Edge edge = Edge.NONE;
|
Edge edge = Edge.NONE;
|
||||||
if (circle.getPosition().getY() + circle.getRadius() >= quad.getTopEdge())
|
if (circle.getPosition().getY() + circle.getRadius() >= quad.getTopEdge())
|
||||||
edge = Edge.TOP;
|
edge = Edge.TOP;
|
||||||
else if (circle.getPosition().getY() - circle.getRadius() <= quad.getBottomEdge())
|
else if (circle.getPosition().getY() - circle.getRadius() <= quad.getBottomEdge())
|
||||||
edge = Edge.BOTTOM;
|
edge = Edge.BOTTOM;
|
||||||
if (circle.getPosition().getX() - circle.getRadius() <= quad.getLeftEdge()) {
|
if (circle.getPosition().getX() - circle.getRadius() <= quad.getLeftEdge()) {
|
||||||
if (edge != Edge.NONE) {
|
if (edge != Edge.NONE) {
|
||||||
if (edge == Edge.TOP) {
|
if (edge == Edge.TOP) {
|
||||||
float m = -1;
|
float m = -1;
|
||||||
float t = quad.getTopEdge() - m * quad.getLeftEdge();
|
float t = quad.getTopEdge() - m * quad.getLeftEdge();
|
||||||
if (circle.getPosition().getY() >= m * circle.getPosition().getX() + t)
|
if (circle.getPosition().getY() >= m * circle.getPosition().getX() + t)
|
||||||
edge = Edge.TOP;
|
edge = Edge.TOP;
|
||||||
else
|
else
|
||||||
edge = Edge.LEFT;
|
edge = Edge.LEFT;
|
||||||
} else if (edge == Edge.BOTTOM) {
|
} else if (edge == Edge.BOTTOM) {
|
||||||
float m = 1;
|
float m = 1;
|
||||||
float t = quad.getBottomEdge() - m * quad.getLeftEdge();
|
float t = quad.getBottomEdge() - m * quad.getLeftEdge();
|
||||||
if (circle.getPosition().getY() <= m * circle.getPosition().getX() + t)
|
if (circle.getPosition().getY() <= m * circle.getPosition().getX() + t)
|
||||||
edge = Edge.BOTTOM;
|
edge = Edge.BOTTOM;
|
||||||
else
|
else
|
||||||
edge = Edge.LEFT;
|
edge = Edge.LEFT;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
edge = Edge.LEFT;
|
edge = Edge.LEFT;
|
||||||
} else if (circle.getPosition().getX() + circle.getRadius() >= quad.getRightEdge()) {
|
} else if (circle.getPosition().getX() + circle.getRadius() >= quad.getRightEdge()) {
|
||||||
if (edge != Edge.NONE) {
|
if (edge != Edge.NONE) {
|
||||||
if (edge == Edge.TOP) {
|
if (edge == Edge.TOP) {
|
||||||
//This movement check is because if player falls with too much speed on topLeft Vertex, sometimes RIGHT-Edge is returned
|
//This movement check is because if player falls with too much speed on topLeft Vertex, sometimes RIGHT-Edge is returned
|
||||||
if (relativeMovement.getY() < 0) {
|
if (relativeMovement.getY() < 0) {
|
||||||
return Edge.TOP;
|
return Edge.TOP;
|
||||||
} else {
|
} else {
|
||||||
float m = 1;
|
float m = 1;
|
||||||
float t = quad.getTopEdge() - m * quad.getRightEdge();
|
float t = quad.getTopEdge() - m * quad.getRightEdge();
|
||||||
if (circle.getPosition().getY() >= m * circle.getPosition().getX() + t)
|
if (circle.getPosition().getY() >= m * circle.getPosition().getX() + t)
|
||||||
edge = Edge.TOP;
|
edge = Edge.TOP;
|
||||||
else
|
else
|
||||||
edge = Edge.RIGHT;
|
edge = Edge.RIGHT;
|
||||||
}
|
}
|
||||||
} else if (edge == Edge.BOTTOM) {
|
} else if (edge == Edge.BOTTOM) {
|
||||||
float m = -1;
|
float m = -1;
|
||||||
float t = quad.getBottomEdge() - m * quad.getRightEdge();
|
float t = quad.getBottomEdge() - m * quad.getRightEdge();
|
||||||
if (circle.getPosition().getY() <= m * circle.getPosition().getX() + t)
|
if (circle.getPosition().getY() <= m * circle.getPosition().getX() + t)
|
||||||
edge = Edge.BOTTOM;
|
edge = Edge.BOTTOM;
|
||||||
else
|
else
|
||||||
edge = Edge.RIGHT;
|
edge = Edge.RIGHT;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
edge = Edge.RIGHT;
|
edge = Edge.RIGHT;
|
||||||
}
|
}
|
||||||
return edge;
|
return edge;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Edge circleCenterInQuadCollisionEdge(Circle circle, Vector circleMovement, Quad quad, Vector quadMovement) {
|
private Edge circleCenterInQuadCollisionEdge(Circle circle, Vector circleMovement, Quad quad, Vector quadMovement) {
|
||||||
Vector relativeMovement = new Vector(circleMovement).translate(quadMovement.negate());
|
Vector relativeMovement = new Vector(circleMovement).translate(quadMovement.negate());
|
||||||
|
|
||||||
float m = relativeMovement.getY() / relativeMovement.getX();
|
float m = relativeMovement.getY() / relativeMovement.getX();
|
||||||
float t = circle.getPosition().getY() - m * circle.getPosition().getX();
|
float t = circle.getPosition().getY() - m * circle.getPosition().getX();
|
||||||
|
|
||||||
float yAtLeftEdge = m * quad.getLeftEdge() + t;
|
float yAtLeftEdge = m * quad.getLeftEdge() + t;
|
||||||
boolean touchingLeftEdge = yAtLeftEdge < quad.getTopEdge() && yAtLeftEdge > quad
|
boolean touchingLeftEdge = yAtLeftEdge < quad.getTopEdge() && yAtLeftEdge > quad
|
||||||
.getBottomEdge();
|
.getBottomEdge();
|
||||||
float yAtRightEdge = m * quad.getRightEdge() + t;
|
float yAtRightEdge = m * quad.getRightEdge() + t;
|
||||||
boolean touchingRightEdge = yAtRightEdge < quad.getTopEdge() && yAtRightEdge > quad
|
boolean touchingRightEdge = yAtRightEdge < quad.getTopEdge() && yAtRightEdge > quad
|
||||||
.getBottomEdge();
|
.getBottomEdge();
|
||||||
|
|
||||||
float xAtTopEdge = (quad.getTopEdge() - t) / m;
|
float xAtTopEdge = (quad.getTopEdge() - t) / m;
|
||||||
boolean touchingTopEdge = xAtTopEdge >= quad.getLeftEdge() && xAtTopEdge <= quad
|
boolean touchingTopEdge = xAtTopEdge >= quad.getLeftEdge() && xAtTopEdge <= quad
|
||||||
.getRightEdge();
|
.getRightEdge();
|
||||||
float xAtBottomEdge = (quad.getBottomEdge() - t) / m;
|
float xAtBottomEdge = (quad.getBottomEdge() - t) / m;
|
||||||
boolean touchingBottomEdge = xAtBottomEdge >= quad.getLeftEdge() && xAtBottomEdge <= quad
|
boolean touchingBottomEdge = xAtBottomEdge >= quad.getLeftEdge() && xAtBottomEdge <= quad
|
||||||
.getRightEdge();
|
.getRightEdge();
|
||||||
|
|
||||||
if (relativeMovement.getX() == 0) {
|
if (relativeMovement.getX() == 0) {
|
||||||
if (circle.getPosition().getX() - circle.getRadius() <= quad.getRightEdge() && circle
|
if (circle.getPosition().getX() - circle.getRadius() <= quad.getRightEdge() && circle
|
||||||
.getPosition().getX() + circle.getRadius() >= quad.getLeftEdge()) {
|
.getPosition().getX() + circle.getRadius() >= quad.getLeftEdge()) {
|
||||||
touchingTopEdge = true;
|
touchingTopEdge = true;
|
||||||
touchingBottomEdge = true;
|
touchingBottomEdge = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CORNERS BELONGING TO TOP / BOTTOM EDGES
|
// CORNERS BELONGING TO TOP / BOTTOM EDGES
|
||||||
if (touchingLeftEdge) {
|
if (touchingLeftEdge) {
|
||||||
if (touchingRightEdge) {
|
if (touchingRightEdge) {
|
||||||
if (circle.getPosition().getX() <= quad.getPosition().getX())
|
if (circle.getPosition().getX() <= quad.getPosition().getX())
|
||||||
return Edge.LEFT;
|
return Edge.LEFT;
|
||||||
return Edge.RIGHT;
|
return Edge.RIGHT;
|
||||||
} else if (touchingTopEdge) {
|
} else if (touchingTopEdge) {
|
||||||
// Normale through vertex
|
// Normale through vertex
|
||||||
float mn = -1 / m;
|
float mn = -1 / m;
|
||||||
float tn = quad.getTopEdge() - mn * quad.getLeftEdge();
|
float tn = quad.getTopEdge() - mn * quad.getLeftEdge();
|
||||||
if (circle.getPosition().getY() < mn * circle.getPosition().getX() + tn)
|
if (circle.getPosition().getY() < mn * circle.getPosition().getX() + tn)
|
||||||
return Edge.LEFT;
|
return Edge.LEFT;
|
||||||
return Edge.TOP;
|
return Edge.TOP;
|
||||||
} else if (touchingBottomEdge) {
|
} else if (touchingBottomEdge) {
|
||||||
// Normale through vertex
|
// Normale through vertex
|
||||||
float mn = -1 / m;
|
float mn = -1 / m;
|
||||||
float tn = quad.getBottomEdge() - mn * quad.getLeftEdge();
|
float tn = quad.getBottomEdge() - mn * quad.getLeftEdge();
|
||||||
if (circle.getPosition().getY() > mn * circle.getPosition().getX() + tn)
|
if (circle.getPosition().getY() > mn * circle.getPosition().getX() + tn)
|
||||||
return Edge.LEFT;
|
return Edge.LEFT;
|
||||||
return Edge.BOTTOM;
|
return Edge.BOTTOM;
|
||||||
} else {
|
} else {
|
||||||
return Edge.LEFT;
|
return Edge.LEFT;
|
||||||
}
|
}
|
||||||
} else if (touchingRightEdge) {
|
} else if (touchingRightEdge) {
|
||||||
if (touchingTopEdge) {
|
if (touchingTopEdge) {
|
||||||
// Normale through vertex
|
// Normale through vertex
|
||||||
float mn = -1 / m;
|
float mn = -1 / m;
|
||||||
float tn = quad.getTopEdge() - mn * quad.getRightEdge();
|
float tn = quad.getTopEdge() - mn * quad.getRightEdge();
|
||||||
if (circle.getPosition().getY() < mn * circle.getPosition().getX() + tn)
|
if (circle.getPosition().getY() < mn * circle.getPosition().getX() + tn)
|
||||||
return Edge.RIGHT;
|
return Edge.RIGHT;
|
||||||
return Edge.TOP;
|
return Edge.TOP;
|
||||||
} else if (touchingBottomEdge) {
|
} else if (touchingBottomEdge) {
|
||||||
// Normale through vertex
|
// Normale through vertex
|
||||||
float mn = -1 / m;
|
float mn = -1 / m;
|
||||||
float tn = quad.getBottomEdge() - mn * quad.getRightEdge();
|
float tn = quad.getBottomEdge() - mn * quad.getRightEdge();
|
||||||
if (circle.getPosition().getY() > mn * circle.getPosition().getX() + tn)
|
if (circle.getPosition().getY() > mn * circle.getPosition().getX() + tn)
|
||||||
return Edge.RIGHT;
|
return Edge.RIGHT;
|
||||||
return Edge.BOTTOM;
|
return Edge.BOTTOM;
|
||||||
} else {
|
} else {
|
||||||
return Edge.RIGHT;
|
return Edge.RIGHT;
|
||||||
}
|
}
|
||||||
} else if (touchingTopEdge) {
|
} else if (touchingTopEdge) {
|
||||||
if (touchingBottomEdge) {
|
if (touchingBottomEdge) {
|
||||||
if (circle.getPosition().getY() >= quad.getPosition().getY())
|
if (circle.getPosition().getY() >= quad.getPosition().getY())
|
||||||
return Edge.TOP;
|
return Edge.TOP;
|
||||||
return Edge.BOTTOM;
|
return Edge.BOTTOM;
|
||||||
} else {
|
} else {
|
||||||
return Edge.TOP;
|
return Edge.TOP;
|
||||||
}
|
}
|
||||||
} else if (touchingBottomEdge) {
|
} else if (touchingBottomEdge) {
|
||||||
return Edge.BOTTOM;
|
return Edge.BOTTOM;
|
||||||
}
|
}
|
||||||
return Edge.NONE;
|
return Edge.NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,109 +1,109 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.collision;
|
package de.frajul.endlessroll.entities.collision;
|
||||||
|
|
||||||
import de.frajul.endlessroll.entities.DestroyEffect;
|
import de.frajul.endlessroll.entities.DestroyEffect;
|
||||||
import de.frajul.endlessroll.entities.Obstacle;
|
import de.frajul.endlessroll.entities.Obstacle;
|
||||||
import de.frajul.endlessroll.entities.Player;
|
import de.frajul.endlessroll.entities.Player;
|
||||||
import de.frajul.endlessroll.entities.collectables.Energy;
|
import de.frajul.endlessroll.entities.collectables.Energy;
|
||||||
import de.frajul.endlessroll.entities.collectables.Star;
|
import de.frajul.endlessroll.entities.collectables.Star;
|
||||||
import de.frajul.endlessroll.entities.collision.collisionData.EntityCollisionData;
|
import de.frajul.endlessroll.entities.collision.collisionData.EntityCollisionData;
|
||||||
import de.frajul.endlessroll.entities.collision.collisionData.ObstacleCollisionData;
|
import de.frajul.endlessroll.entities.collision.collisionData.ObstacleCollisionData;
|
||||||
import de.frajul.endlessroll.entities.collision.collisionData.PlayerCollisionData;
|
import de.frajul.endlessroll.entities.collision.collisionData.PlayerCollisionData;
|
||||||
import de.frajul.endlessroll.entities.collision.collisionData.ToolCollisionData;
|
import de.frajul.endlessroll.entities.collision.collisionData.ToolCollisionData;
|
||||||
import de.frajul.endlessroll.entities.tools.Tool;
|
import de.frajul.endlessroll.entities.tools.Tool;
|
||||||
import de.frajul.endlessroll.main.game.Game;
|
import de.frajul.endlessroll.main.game.Game;
|
||||||
import de.frajul.endlessroll.main.game.GameScene;
|
import de.frajul.endlessroll.main.game.GameScene;
|
||||||
import de.frajul.endlessroll.main.game.Timer;
|
import de.frajul.endlessroll.main.game.Timer;
|
||||||
import de.frajul.endlessroll.main.physics.Physics;
|
import de.frajul.endlessroll.main.physics.Physics;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 02.01.2016.
|
* Created by Julian on 02.01.2016.
|
||||||
*/
|
*/
|
||||||
public class CollisionManager {
|
public class CollisionManager {
|
||||||
|
|
||||||
private Game game;
|
private Game game;
|
||||||
private Player player;
|
private Player player;
|
||||||
private Timer timer;
|
private Timer timer;
|
||||||
|
|
||||||
public CollisionManager(Game game) {
|
public CollisionManager(Game game) {
|
||||||
this.game = game;
|
this.game = game;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check Obstacle always before tool, because at tool, player could be moved etc.
|
//Check Obstacle always before tool, because at tool, player could be moved etc.
|
||||||
public void update(Physics physics, GameScene scene, Timer timer) {
|
public void update(Physics physics, GameScene scene, Timer timer) {
|
||||||
physics.checkToolCollision(scene);
|
physics.checkToolCollision(scene);
|
||||||
|
|
||||||
this.player = scene.getPlayer();
|
this.player = scene.getPlayer();
|
||||||
this.timer = timer;
|
this.timer = timer;
|
||||||
PlayerCollisionData data = physics.getPlayerCollisionData(scene);
|
PlayerCollisionData data = physics.getPlayerCollisionData(scene);
|
||||||
if (data.isTerrainCollision())
|
if (data.isTerrainCollision())
|
||||||
checkTerrainCollision(data.getTerrainCollisionData());
|
checkTerrainCollision(data.getTerrainCollisionData());
|
||||||
if (data.isCeilingCollision())
|
if (data.isCeilingCollision())
|
||||||
checkCeilingCollision(data.getCeilingCollisionData());
|
checkCeilingCollision(data.getCeilingCollisionData());
|
||||||
if (data.isObstacleCollision())
|
if (data.isObstacleCollision())
|
||||||
checkObstacleCollision(data.getObstacleCollisionData(), player.hasSuperPower());
|
checkObstacleCollision(data.getObstacleCollisionData(), player.hasSuperPower());
|
||||||
if (data.isToolCollision())
|
if (data.isToolCollision())
|
||||||
checkToolCollision(data.getToolCollisionData());
|
checkToolCollision(data.getToolCollisionData());
|
||||||
if (data.isStarCollision())
|
if (data.isStarCollision())
|
||||||
game.onStarCollision((Star) data.getStarCollisionData().getEntity());
|
game.onStarCollision((Star) data.getStarCollisionData().getEntity());
|
||||||
if (data.isEnergyCollision())
|
if (data.isEnergyCollision())
|
||||||
game.onEnergyCollision((Energy) data.getEnergyCollisionData().getEntity());
|
game.onEnergyCollision((Energy) data.getEnergyCollisionData().getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkTerrainCollision(EntityCollisionData data) {
|
private void checkTerrainCollision(EntityCollisionData data) {
|
||||||
checkEntityCollision(data);
|
checkEntityCollision(data);
|
||||||
if (data.getEdge() != Edge.TOP)
|
if (data.getEdge() != Edge.TOP)
|
||||||
game.onGameOver(true);
|
game.onGameOver(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkCeilingCollision(EntityCollisionData data) {
|
private void checkCeilingCollision(EntityCollisionData data) {
|
||||||
checkEntityCollision(data);
|
checkEntityCollision(data);
|
||||||
if (data.getEdge() != Edge.BOTTOM)
|
if (data.getEdge() != Edge.BOTTOM)
|
||||||
game.onGameOver(true);
|
game.onGameOver(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkToolCollision(ToolCollisionData data) {
|
private void checkToolCollision(ToolCollisionData data) {
|
||||||
for (Tool tool : data.getTools())
|
for (Tool tool : data.getTools())
|
||||||
tool.onPlayerCollision(player, timer);
|
tool.onPlayerCollision(player, timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkObstacleCollision(ObstacleCollisionData data, boolean playerHasSuperpower) {
|
private void checkObstacleCollision(ObstacleCollisionData data, boolean playerHasSuperpower) {
|
||||||
for (EntityCollisionData entityData : data.getCollisions()) {
|
for (EntityCollisionData entityData : data.getCollisions()) {
|
||||||
if (playerHasSuperpower) {
|
if (playerHasSuperpower) {
|
||||||
entityData.getEntity().destroy(DestroyEffect.EXPLOSION);
|
entityData.getEntity().destroy(DestroyEffect.EXPLOSION);
|
||||||
} else {
|
} else {
|
||||||
if (entityData.getEdge() != Edge.TOP || ((Obstacle) entityData.getEntity())
|
if (entityData.getEdge() != Edge.TOP || ((Obstacle) entityData.getEntity())
|
||||||
.isDeadly())
|
.isDeadly())
|
||||||
game.onGameOver(true);
|
game.onGameOver(true);
|
||||||
else
|
else
|
||||||
checkEntityCollision(entityData);
|
checkEntityCollision(entityData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkEntityCollision(EntityCollisionData data) {
|
private void checkEntityCollision(EntityCollisionData data) {
|
||||||
switch (data.getEdge()) {
|
switch (data.getEdge()) {
|
||||||
case TOP:
|
case TOP:
|
||||||
player.getMovement().y = 0;
|
player.getMovement().y = 0;
|
||||||
player.setToTerrain(data.getEntity().getTopEdge());
|
player.setToTerrain(data.getEntity().getTopEdge());
|
||||||
break;
|
break;
|
||||||
case BOTTOM:
|
case BOTTOM:
|
||||||
player.getMovement().y = 0;
|
player.getMovement().y = 0;
|
||||||
player.setTopEdge(data.getEntity().getBottomEdge());
|
player.setTopEdge(data.getEntity().getBottomEdge());
|
||||||
break;
|
break;
|
||||||
case LEFT:
|
case LEFT:
|
||||||
player.getPosition().x = data.getEntity().getLeftEdge() - player.RADIUS;
|
player.getPosition().x = data.getEntity().getLeftEdge() - player.RADIUS;
|
||||||
break;
|
break;
|
||||||
case RIGHT:
|
case RIGHT:
|
||||||
player.getPosition().x = data.getEntity().getRightEdge() + player.RADIUS;
|
player.getPosition().x = data.getEntity().getRightEdge() + player.RADIUS;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.collision;
|
package de.frajul.endlessroll.entities.collision;
|
||||||
|
|
||||||
public enum Edge {
|
public enum Edge {
|
||||||
LEFT, RIGHT, TOP, BOTTOM, NONE
|
LEFT, RIGHT, TOP, BOTTOM, NONE
|
||||||
}
|
}
|
@ -1,37 +1,37 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.collision.collisionData;
|
package de.frajul.endlessroll.entities.collision.collisionData;
|
||||||
|
|
||||||
import de.frajul.endlessroll.entities.Entity;
|
import de.frajul.endlessroll.entities.Entity;
|
||||||
import de.frajul.endlessroll.entities.collision.Edge;
|
import de.frajul.endlessroll.entities.collision.Edge;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 01.01.2016.
|
* Created by Julian on 01.01.2016.
|
||||||
*/
|
*/
|
||||||
public class EntityCollisionData {
|
public class EntityCollisionData {
|
||||||
|
|
||||||
private Entity entity;
|
private Entity entity;
|
||||||
private Edge edge;
|
private Edge edge;
|
||||||
|
|
||||||
public EntityCollisionData(Entity entity, Edge edge) {
|
public EntityCollisionData(Entity entity, Edge edge) {
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
this.edge = edge;
|
this.edge = edge;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCollision() {
|
public boolean isCollision() {
|
||||||
return entity != null && edge != null;
|
return entity != null && edge != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entity getEntity() {
|
public Entity getEntity() {
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Edge getEdge() {
|
public Edge getEdge() {
|
||||||
return edge;
|
return edge;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,30 +1,30 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.collision.collisionData;
|
package de.frajul.endlessroll.entities.collision.collisionData;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 04.01.2016.
|
* Created by Julian on 04.01.2016.
|
||||||
*/
|
*/
|
||||||
public class ObstacleCollisionData {
|
public class ObstacleCollisionData {
|
||||||
|
|
||||||
private List<EntityCollisionData> collisions;
|
private List<EntityCollisionData> collisions;
|
||||||
|
|
||||||
public ObstacleCollisionData(List<EntityCollisionData> collisions) {
|
public ObstacleCollisionData(List<EntityCollisionData> collisions) {
|
||||||
this.collisions = collisions;
|
this.collisions = collisions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCollision() {
|
public boolean isCollision() {
|
||||||
return collisions.size() > 0;
|
return collisions.size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<EntityCollisionData> getCollisions() {
|
public List<EntityCollisionData> getCollisions() {
|
||||||
return collisions;
|
return collisions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,78 +1,78 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.collision.collisionData;
|
package de.frajul.endlessroll.entities.collision.collisionData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 05.12.2015.
|
* Created by Julian on 05.12.2015.
|
||||||
*/
|
*/
|
||||||
public class PlayerCollisionData {
|
public class PlayerCollisionData {
|
||||||
|
|
||||||
private EntityCollisionData terrainCollision;
|
private EntityCollisionData terrainCollision;
|
||||||
private EntityCollisionData ceilingCollision;
|
private EntityCollisionData ceilingCollision;
|
||||||
private ObstacleCollisionData obstacleCollision;
|
private ObstacleCollisionData obstacleCollision;
|
||||||
private ToolCollisionData toolCollision;
|
private ToolCollisionData toolCollision;
|
||||||
private EntityCollisionData starCollision;
|
private EntityCollisionData starCollision;
|
||||||
private EntityCollisionData energyCollision;
|
private EntityCollisionData energyCollision;
|
||||||
|
|
||||||
public PlayerCollisionData(EntityCollisionData terrainCollision, EntityCollisionData ceilingCollision, ObstacleCollisionData obstacleCollision, ToolCollisionData toolCollision, EntityCollisionData starCollision, EntityCollisionData energyCollision) {
|
public PlayerCollisionData(EntityCollisionData terrainCollision, EntityCollisionData ceilingCollision, ObstacleCollisionData obstacleCollision, ToolCollisionData toolCollision, EntityCollisionData starCollision, EntityCollisionData energyCollision) {
|
||||||
this.terrainCollision = terrainCollision;
|
this.terrainCollision = terrainCollision;
|
||||||
this.ceilingCollision = ceilingCollision;
|
this.ceilingCollision = ceilingCollision;
|
||||||
this.obstacleCollision = obstacleCollision;
|
this.obstacleCollision = obstacleCollision;
|
||||||
this.toolCollision = toolCollision;
|
this.toolCollision = toolCollision;
|
||||||
this.starCollision = starCollision;
|
this.starCollision = starCollision;
|
||||||
this.energyCollision = energyCollision;
|
this.energyCollision = energyCollision;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTerrainCollision() {
|
public boolean isTerrainCollision() {
|
||||||
return terrainCollision.isCollision();
|
return terrainCollision.isCollision();
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityCollisionData getTerrainCollisionData() {
|
public EntityCollisionData getTerrainCollisionData() {
|
||||||
return terrainCollision;
|
return terrainCollision;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCeilingCollision() {
|
public boolean isCeilingCollision() {
|
||||||
return ceilingCollision.isCollision();
|
return ceilingCollision.isCollision();
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityCollisionData getCeilingCollisionData() {
|
public EntityCollisionData getCeilingCollisionData() {
|
||||||
return ceilingCollision;
|
return ceilingCollision;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isObstacleCollision() {
|
public boolean isObstacleCollision() {
|
||||||
return obstacleCollision.isCollision();
|
return obstacleCollision.isCollision();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObstacleCollisionData getObstacleCollisionData() {
|
public ObstacleCollisionData getObstacleCollisionData() {
|
||||||
return obstacleCollision;
|
return obstacleCollision;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isToolCollision() {
|
public boolean isToolCollision() {
|
||||||
return toolCollision.isCollision();
|
return toolCollision.isCollision();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ToolCollisionData getToolCollisionData() {
|
public ToolCollisionData getToolCollisionData() {
|
||||||
return toolCollision;
|
return toolCollision;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isStarCollision() {
|
public boolean isStarCollision() {
|
||||||
return starCollision.isCollision();
|
return starCollision.isCollision();
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityCollisionData getStarCollisionData() {
|
public EntityCollisionData getStarCollisionData() {
|
||||||
return starCollision;
|
return starCollision;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnergyCollision() {
|
public boolean isEnergyCollision() {
|
||||||
return energyCollision.isCollision();
|
return energyCollision.isCollision();
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityCollisionData getEnergyCollisionData() {
|
public EntityCollisionData getEnergyCollisionData() {
|
||||||
return energyCollision;
|
return energyCollision;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,32 +1,32 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.collision.collisionData;
|
package de.frajul.endlessroll.entities.collision.collisionData;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.frajul.endlessroll.entities.tools.Tool;
|
import de.frajul.endlessroll.entities.tools.Tool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 21.02.2016.
|
* Created by Julian on 21.02.2016.
|
||||||
*/
|
*/
|
||||||
public class ToolCollisionData {
|
public class ToolCollisionData {
|
||||||
|
|
||||||
private List<Tool> tools;
|
private List<Tool> tools;
|
||||||
|
|
||||||
public ToolCollisionData(List<Tool> tools) {
|
public ToolCollisionData(List<Tool> tools) {
|
||||||
this.tools = tools;
|
this.tools = tools;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCollision() {
|
public boolean isCollision() {
|
||||||
return tools.size() > 0;
|
return tools.size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Tool> getTools() {
|
public List<Tool> getTools() {
|
||||||
return tools;
|
return tools;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,62 +1,62 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.collision.geometry;
|
package de.frajul.endlessroll.entities.collision.geometry;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.Player;
|
import de.frajul.endlessroll.entities.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 01.12.2015.
|
* Created by Julian on 01.12.2015.
|
||||||
*/
|
*/
|
||||||
public class Circle extends Geometry {
|
public class Circle extends Geometry {
|
||||||
|
|
||||||
private Vector center;
|
private Vector center;
|
||||||
private float radius;
|
private float radius;
|
||||||
|
|
||||||
public Circle(Player ball) {
|
public Circle(Player ball) {
|
||||||
this(new Vector(ball.getPosition()), ball.getWidth() / 2);
|
this(new Vector(ball.getPosition()), ball.getWidth() / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Circle(Vector center, float radius) {
|
public Circle(Vector center, float radius) {
|
||||||
this.center = center;
|
this.center = center;
|
||||||
this.radius = radius;
|
this.radius = radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getRightEdge() {
|
public float getRightEdge() {
|
||||||
return center.x + radius;
|
return center.x + radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getLeftEdge() {
|
public float getLeftEdge() {
|
||||||
return center.x - radius;
|
return center.x - radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getTopEdge() {
|
public float getTopEdge() {
|
||||||
return center.y + radius;
|
return center.y + radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getBottomEdge() {
|
public float getBottomEdge() {
|
||||||
return center.y - radius;
|
return center.y - radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector getPosition() {
|
public Vector getPosition() {
|
||||||
return center;
|
return center;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getRadius() {
|
public float getRadius() {
|
||||||
return radius;
|
return radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRadius(float radius) {
|
public void setRadius(float radius) {
|
||||||
this.radius = radius;
|
this.radius = radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.collision.geometry;
|
package de.frajul.endlessroll.entities.collision.geometry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 28.02.2016.
|
* Created by Julian on 28.02.2016.
|
||||||
*/
|
*/
|
||||||
public abstract class Geometry {
|
public abstract class Geometry {
|
||||||
|
|
||||||
public abstract float getTopEdge();
|
public abstract float getTopEdge();
|
||||||
|
|
||||||
public abstract float getBottomEdge();
|
public abstract float getBottomEdge();
|
||||||
|
|
||||||
public abstract float getRightEdge();
|
public abstract float getRightEdge();
|
||||||
|
|
||||||
public abstract float getLeftEdge();
|
public abstract float getLeftEdge();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,70 +1,70 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.collision.geometry;
|
package de.frajul.endlessroll.entities.collision.geometry;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 01.12.2015.
|
* Created by Julian on 01.12.2015.
|
||||||
*/
|
*/
|
||||||
public class Quad extends Geometry {
|
public class Quad extends Geometry {
|
||||||
|
|
||||||
protected Vector position;
|
protected Vector position;
|
||||||
protected float width, height;
|
protected float width, height;
|
||||||
|
|
||||||
public Quad(Vector position, float width, float height) {
|
public Quad(Vector position, float width, float height) {
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getRightEdge() {
|
public float getRightEdge() {
|
||||||
return position.x + width / 2;
|
return position.x + width / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getLeftEdge() {
|
public float getLeftEdge() {
|
||||||
return position.x - width / 2;
|
return position.x - width / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getTopEdge() {
|
public float getTopEdge() {
|
||||||
return position.y + height / 2;
|
return position.y + height / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getBottomEdge() {
|
public float getBottomEdge() {
|
||||||
return position.y - height / 2;
|
return position.y - height / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector getPosition() {
|
public Vector getPosition() {
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPosition(Vector position) {
|
public void setPosition(Vector position) {
|
||||||
this.position = position;
|
this.position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getWidth() {
|
public float getWidth() {
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWidth(float width) {
|
public void setWidth(float width) {
|
||||||
this.width = width;
|
this.width = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getHeight() {
|
public float getHeight() {
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHeight(float height) {
|
public void setHeight(float height) {
|
||||||
this.height = height;
|
this.height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,38 +1,38 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.collision.geometry;
|
package de.frajul.endlessroll.entities.collision.geometry;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.tools.Ramp;
|
import de.frajul.endlessroll.entities.tools.Ramp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 01.12.2015.
|
* Created by Julian on 01.12.2015.
|
||||||
*/
|
*/
|
||||||
public class Triangle extends Quad {
|
public class Triangle extends Quad {
|
||||||
|
|
||||||
public Triangle(Ramp ramp) {
|
public Triangle(Ramp ramp) {
|
||||||
super(ramp.getPosition(), ramp.getWidth(), ramp.getHeight());
|
super(ramp.getPosition(), ramp.getWidth(), ramp.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getGradient() {
|
public float getGradient() {
|
||||||
return super.getHeight() / super.getWidth();
|
return super.getHeight() / super.getWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector getBottomRightVertex() {
|
public Vector getBottomRightVertex() {
|
||||||
return new Vector(getRightEdge(), getBottomEdge());
|
return new Vector(getRightEdge(), getBottomEdge());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector getBottomLeftVertex() {
|
public Vector getBottomLeftVertex() {
|
||||||
return new Vector(getLeftEdge(), getBottomEdge());
|
return new Vector(getLeftEdge(), getBottomEdge());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector getTopRightVertex() {
|
public Vector getTopRightVertex() {
|
||||||
return new Vector(getRightEdge(), getTopEdge());
|
return new Vector(getRightEdge(), getTopEdge());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,101 +1,101 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.guis;
|
package de.frajul.endlessroll.entities.guis;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.textures.Texture;
|
import de.frajul.endlessroll.entities.textures.Texture;
|
||||||
import de.frajul.endlessroll.entities.textures.TexturePack;
|
import de.frajul.endlessroll.entities.textures.TexturePack;
|
||||||
import de.frajul.endlessroll.main.game.Game;
|
import de.frajul.endlessroll.main.game.Game;
|
||||||
import de.frajul.endlessroll.sounds.SoundManager;
|
import de.frajul.endlessroll.sounds.SoundManager;
|
||||||
import de.frajul.endlessroll.sounds.SoundStream;
|
import de.frajul.endlessroll.sounds.SoundStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 31.07.2016.
|
* Created by Julian on 31.07.2016.
|
||||||
*/
|
*/
|
||||||
public class Countdown extends Gui {
|
public class Countdown extends Gui {
|
||||||
|
|
||||||
private Game game;
|
private Game game;
|
||||||
private SoundManager soundManager;
|
private SoundManager soundManager;
|
||||||
private SoundStream soundStream;
|
private SoundStream soundStream;
|
||||||
private Texture texture3;
|
private Texture texture3;
|
||||||
private Texture texture2;
|
private Texture texture2;
|
||||||
private Texture texture1;
|
private Texture texture1;
|
||||||
|
|
||||||
private AtomicBoolean running;
|
private AtomicBoolean running;
|
||||||
private int currentSeconds = 0;
|
private int currentSeconds = 0;
|
||||||
private float time = 0;
|
private float time = 0;
|
||||||
|
|
||||||
public Countdown(Game game, SoundManager soundManager, TexturePack texturePack) {
|
public Countdown(Game game, SoundManager soundManager, TexturePack texturePack) {
|
||||||
super(texturePack.countdown3, new Vector(), 0.8f, 0.8f);
|
super(texturePack.countdown3, new Vector(), 0.8f, 0.8f);
|
||||||
this.game = game;
|
this.game = game;
|
||||||
this.soundManager = soundManager;
|
this.soundManager = soundManager;
|
||||||
this.texture3 = texturePack.countdown1;
|
this.texture3 = texturePack.countdown1;
|
||||||
this.texture2 = texturePack.countdown2;
|
this.texture2 = texturePack.countdown2;
|
||||||
this.texture1 = texturePack.countdown3;
|
this.texture1 = texturePack.countdown3;
|
||||||
running = new AtomicBoolean(false);
|
running = new AtomicBoolean(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(float delta) {
|
public void update(float delta) {
|
||||||
if (running.get()) {
|
if (running.get()) {
|
||||||
time += delta;
|
time += delta;
|
||||||
if (time >= 1000 && currentSeconds == 0) {
|
if (time >= 1000 && currentSeconds == 0) {
|
||||||
currentSeconds = 1;
|
currentSeconds = 1;
|
||||||
onNextSecondThread(currentSeconds, true);
|
onNextSecondThread(currentSeconds, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (time >= 2000 && currentSeconds == 1) {
|
if (time >= 2000 && currentSeconds == 1) {
|
||||||
currentSeconds = 2;
|
currentSeconds = 2;
|
||||||
onNextSecondThread(currentSeconds, true);
|
onNextSecondThread(currentSeconds, true);
|
||||||
}
|
}
|
||||||
if (time >= 3000 && currentSeconds == 2) {
|
if (time >= 3000 && currentSeconds == 2) {
|
||||||
currentSeconds = 3;
|
currentSeconds = 3;
|
||||||
running.set(false);
|
running.set(false);
|
||||||
game.countdownFinished();
|
game.countdownFinished();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
reset();
|
reset();
|
||||||
running.set(true);
|
running.set(true);
|
||||||
soundStream = soundManager.playSound(soundManager.countdownSoundSingle);
|
soundStream = soundManager.playSound(soundManager.countdownSoundSingle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
running.set(false);
|
running.set(false);
|
||||||
if (soundStream != null)
|
if (soundStream != null)
|
||||||
soundManager.stopSound(soundStream);
|
soundManager.stopSound(soundStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reset() {
|
private void reset() {
|
||||||
time = 0;
|
time = 0;
|
||||||
currentSeconds = 0;
|
currentSeconds = 0;
|
||||||
onNextSecondThread(0, false);
|
onNextSecondThread(0, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onNextSecondThread(final int second, final boolean playSound) {
|
private void onNextSecondThread(final int second, final boolean playSound) {
|
||||||
if (playSound) {
|
if (playSound) {
|
||||||
if (second == 2)
|
if (second == 2)
|
||||||
soundStream = soundManager.playSound(soundManager.countdownSoundLast);
|
soundStream = soundManager.playSound(soundManager.countdownSoundLast);
|
||||||
else
|
else
|
||||||
soundStream = soundManager.playSound(soundManager.countdownSoundSingle);
|
soundStream = soundManager.playSound(soundManager.countdownSoundSingle);
|
||||||
}
|
}
|
||||||
super.setTexture(texture1);
|
super.setTexture(texture1);
|
||||||
if (second == 1)
|
if (second == 1)
|
||||||
super.setTexture(texture2);
|
super.setTexture(texture2);
|
||||||
else if (second == 2)
|
else if (second == 2)
|
||||||
super.setTexture(texture3);
|
super.setTexture(texture3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVisible() {
|
public boolean isVisible() {
|
||||||
return running.get();
|
return running.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,31 +1,31 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.guis;
|
package de.frajul.endlessroll.entities.guis;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Color4f;
|
import de.frajul.endlessroll.data.Color4f;
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.Entity;
|
import de.frajul.endlessroll.entities.Entity;
|
||||||
import de.frajul.endlessroll.entities.textures.Texture;
|
import de.frajul.endlessroll.entities.textures.Texture;
|
||||||
|
|
||||||
public class Gui extends Entity {
|
public class Gui extends Entity {
|
||||||
|
|
||||||
protected float roundValue = 0;
|
protected float roundValue = 0;
|
||||||
|
|
||||||
public Gui(Texture texture, Vector position, float width, float height) {
|
public Gui(Texture texture, Vector position, float width, float height) {
|
||||||
super(texture, position, width, height);
|
super(texture, position, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getRoundValue() {
|
public float getRoundValue() {
|
||||||
return roundValue;
|
return roundValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRoundValue(float roundValue) {
|
public void setRoundValue(float roundValue) {
|
||||||
this.roundValue = roundValue;
|
this.roundValue = roundValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,48 +1,48 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.guis;
|
package de.frajul.endlessroll.entities.guis;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.textures.Texture;
|
import de.frajul.endlessroll.entities.textures.Texture;
|
||||||
|
|
||||||
public class Progressbar extends Gui {
|
public class Progressbar extends Gui {
|
||||||
|
|
||||||
private float maxTime;
|
private float maxTime;
|
||||||
private float progress;
|
private float progress;
|
||||||
|
|
||||||
public Progressbar(Texture texture, Vector position, float width, float height, float maxTime) {
|
public Progressbar(Texture texture, Vector position, float width, float height, float maxTime) {
|
||||||
super(texture, position, width, height);
|
super(texture, position, width, height);
|
||||||
this.maxTime = maxTime;
|
this.maxTime = maxTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(float frameTime) {
|
public void update(float frameTime) {
|
||||||
progress += frameTime / maxTime;
|
progress += frameTime / maxTime;
|
||||||
if (progress >= 1f)
|
if (progress >= 1f)
|
||||||
progress = 1f;
|
progress = 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasFinished() {
|
public boolean hasFinished() {
|
||||||
return progress == 1;
|
return progress == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getProgress() {
|
public float getProgress() {
|
||||||
return progress;
|
return progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProgress(float progress) {
|
public void setProgress(float progress) {
|
||||||
this.progress = progress;
|
this.progress = progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getMaxTime() {
|
public float getMaxTime() {
|
||||||
return maxTime;
|
return maxTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxTime(float maxTime) {
|
public void setMaxTime(float maxTime) {
|
||||||
this.maxTime = maxTime;
|
this.maxTime = maxTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,157 +1,157 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.guis;
|
package de.frajul.endlessroll.entities.guis;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Color3f;
|
import de.frajul.endlessroll.data.Color3f;
|
||||||
import de.frajul.endlessroll.data.Color4f;
|
import de.frajul.endlessroll.data.Color4f;
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.textures.Texture;
|
import de.frajul.endlessroll.entities.textures.Texture;
|
||||||
import de.frajul.endlessroll.entities.textures.TexturePack;
|
import de.frajul.endlessroll.entities.textures.TexturePack;
|
||||||
import de.frajul.endlessroll.entities.tools.ToolSlot;
|
import de.frajul.endlessroll.entities.tools.ToolSlot;
|
||||||
import de.frajul.endlessroll.entities.tools.ToolType;
|
import de.frajul.endlessroll.entities.tools.ToolType;
|
||||||
import de.frajul.endlessroll.entities.tools.ToolUpgradeType;
|
import de.frajul.endlessroll.entities.tools.ToolUpgradeType;
|
||||||
import de.frajul.endlessroll.main.game.Game;
|
import de.frajul.endlessroll.main.game.Game;
|
||||||
|
|
||||||
public class ToolButton {
|
public class ToolButton {
|
||||||
|
|
||||||
private final Color3f LOCKED = new Color3f(0.29f, 0.29f, 0.29f);
|
private final Color3f LOCKED = new Color3f(0.29f, 0.29f, 0.29f);
|
||||||
private final Color3f ACTIVE_READY = new Color3f(0.25f, 0.89f, 0.17f);
|
private final Color3f ACTIVE_READY = new Color3f(0.25f, 0.89f, 0.17f);
|
||||||
private final Color3f ACTIVE_NOT_READY = new Color3f(0.86f, 0.08f, 0.13f);
|
private final Color3f ACTIVE_NOT_READY = new Color3f(0.86f, 0.08f, 0.13f);
|
||||||
private final Color3f INACTIVE_READY = new Color3f(1.0f, 0.95f, 0.0f);
|
private final Color3f INACTIVE_READY = new Color3f(1.0f, 0.95f, 0.0f);
|
||||||
private final Color3f INACTIVE_NOT_READY = new Color3f(0.57f, 0.11f, 0.06f);
|
private final Color3f INACTIVE_NOT_READY = new Color3f(0.57f, 0.11f, 0.06f);
|
||||||
|
|
||||||
private Gui border;
|
private Gui border;
|
||||||
private Gui background;
|
private Gui background;
|
||||||
private Progressbar progressbar;
|
private Progressbar progressbar;
|
||||||
private ToolButtonAnimationLayer animationLayer;
|
private ToolButtonAnimationLayer animationLayer;
|
||||||
|
|
||||||
private Game game;
|
private Game game;
|
||||||
private ToolType toolType;
|
private ToolType toolType;
|
||||||
private boolean locked;
|
private boolean locked;
|
||||||
private AtomicBoolean active;
|
private AtomicBoolean active;
|
||||||
private Texture toolButtonLockedTexture;
|
private Texture toolButtonLockedTexture;
|
||||||
private Texture toolButtonEmptyTexture;
|
private Texture toolButtonEmptyTexture;
|
||||||
|
|
||||||
public ToolButton(Vector position, float width, float height, TexturePack texturePack, Game game) {
|
public ToolButton(Vector position, float width, float height, TexturePack texturePack, Game game) {
|
||||||
this.game = game;
|
this.game = game;
|
||||||
active = new AtomicBoolean(false);
|
active = new AtomicBoolean(false);
|
||||||
toolButtonLockedTexture = texturePack.toolButtonLocked;
|
toolButtonLockedTexture = texturePack.toolButtonLocked;
|
||||||
toolButtonEmptyTexture = texturePack.toolButtonEmpty;
|
toolButtonEmptyTexture = texturePack.toolButtonEmpty;
|
||||||
|
|
||||||
border = new Gui(texturePack.white, position, width, height);
|
border = new Gui(texturePack.white, position, width, height);
|
||||||
border.setRoundValue(0.3f);
|
border.setRoundValue(0.3f);
|
||||||
border.setAlpha(0.9f);
|
border.setAlpha(0.9f);
|
||||||
background = new Gui(null, position, height, height);
|
background = new Gui(null, position, height, height);
|
||||||
progressbar = new Progressbar(texturePack.white, position, height, height, 0);
|
progressbar = new Progressbar(texturePack.white, position, height, height, 0);
|
||||||
progressbar.setColor(new Color3f(0.4f, 0.4f, 0.4f));
|
progressbar.setColor(new Color3f(0.4f, 0.4f, 0.4f));
|
||||||
progressbar.setAlpha(0.6f);
|
progressbar.setAlpha(0.6f);
|
||||||
progressbar.setRoundValue(1);
|
progressbar.setRoundValue(1);
|
||||||
progressbar.setProgress(0.6f);
|
progressbar.setProgress(0.6f);
|
||||||
animationLayer = new ToolButtonAnimationLayer(toolButtonLockedTexture, position, height,
|
animationLayer = new ToolButtonAnimationLayer(toolButtonLockedTexture, position, height,
|
||||||
height);
|
height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setToolSlot(ToolSlot toolSlot) {
|
public void setToolSlot(ToolSlot toolSlot) {
|
||||||
this.toolType = toolSlot.getToolType();
|
this.toolType = toolSlot.getToolType();
|
||||||
this.locked = toolSlot.isLocked();
|
this.locked = toolSlot.isLocked();
|
||||||
|
|
||||||
if (locked) {
|
if (locked) {
|
||||||
background.setTexture(toolButtonLockedTexture);
|
background.setTexture(toolButtonLockedTexture);
|
||||||
} else if (toolType == null) {
|
} else if (toolType == null) {
|
||||||
background.setTexture(toolButtonEmptyTexture);
|
background.setTexture(toolButtonEmptyTexture);
|
||||||
} else {
|
} else {
|
||||||
background.setTexture(toolType.getToolButtonTexture());
|
background.setTexture(toolType.getToolButtonTexture());
|
||||||
animationLayer.setTexture(toolType.getToolButtonTexture());
|
animationLayer.setTexture(toolType.getToolButtonTexture());
|
||||||
}
|
}
|
||||||
if (toolType != null)
|
if (toolType != null)
|
||||||
progressbar.setMaxTime(toolType.getCurrentUpgradeValue(ToolUpgradeType.COOLDOWN));
|
progressbar.setMaxTime(toolType.getCurrentUpgradeValue(ToolUpgradeType.COOLDOWN));
|
||||||
|
|
||||||
if (locked || toolType == null)
|
if (locked || toolType == null)
|
||||||
border.setColor(LOCKED);
|
border.setColor(LOCKED);
|
||||||
else
|
else
|
||||||
border.setColor(INACTIVE_NOT_READY);
|
border.setColor(INACTIVE_NOT_READY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProgress(float progress) {
|
public void setProgress(float progress) {
|
||||||
progressbar.setProgress(progress);
|
progressbar.setProgress(progress);
|
||||||
updateBorderColor();
|
updateBorderColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasFinishedLoading() {
|
public boolean hasFinishedLoading() {
|
||||||
return progressbar.hasFinished();
|
return progressbar.hasFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(float frameTime, boolean gameRunning) {
|
public void update(float frameTime, boolean gameRunning) {
|
||||||
if (gameRunning) {
|
if (gameRunning) {
|
||||||
if (!progressbar.hasFinished()) {
|
if (!progressbar.hasFinished()) {
|
||||||
progressbar.update(frameTime);
|
progressbar.update(frameTime);
|
||||||
if (progressbar.hasFinished()) {
|
if (progressbar.hasFinished()) {
|
||||||
animationLayer.startAnimation();
|
animationLayer.startAnimation();
|
||||||
if (active.get())
|
if (active.get())
|
||||||
game.onToolButtonFinishedLoading(toolType);
|
game.onToolButtonFinishedLoading(toolType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateBorderColor();
|
updateBorderColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
animationLayer.update(frameTime);
|
animationLayer.update(frameTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void updateBorderColor() {
|
public synchronized void updateBorderColor() {
|
||||||
if (!locked && toolType != null) {
|
if (!locked && toolType != null) {
|
||||||
if (active.get()) {
|
if (active.get()) {
|
||||||
if (progressbar.hasFinished())
|
if (progressbar.hasFinished())
|
||||||
border.setColor(ACTIVE_READY);
|
border.setColor(ACTIVE_READY);
|
||||||
else
|
else
|
||||||
border.setColor(ACTIVE_NOT_READY);
|
border.setColor(ACTIVE_NOT_READY);
|
||||||
} else {
|
} else {
|
||||||
if (progressbar.hasFinished())
|
if (progressbar.hasFinished())
|
||||||
border.setColor(INACTIVE_READY);
|
border.setColor(INACTIVE_READY);
|
||||||
else
|
else
|
||||||
border.setColor(INACTIVE_NOT_READY);
|
border.setColor(INACTIVE_NOT_READY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVisible(boolean visible){
|
public void setVisible(boolean visible){
|
||||||
border.setVisible(visible);
|
border.setVisible(visible);
|
||||||
background.setVisible(visible);
|
background.setVisible(visible);
|
||||||
progressbar.setVisible(visible);
|
progressbar.setVisible(visible);
|
||||||
animationLayer.setVisible(visible);
|
animationLayer.setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActive(boolean active) {
|
public void setActive(boolean active) {
|
||||||
this.active.set(active);
|
this.active.set(active);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AtomicBoolean getActive() {
|
public AtomicBoolean getActive() {
|
||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gui getBorder() {
|
public Gui getBorder() {
|
||||||
return border;
|
return border;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gui getBackground() {
|
public Gui getBackground() {
|
||||||
return background;
|
return background;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Progressbar getProgressbar() {
|
public Progressbar getProgressbar() {
|
||||||
return progressbar;
|
return progressbar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ToolButtonAnimationLayer getAnimationLayer() {
|
public ToolButtonAnimationLayer getAnimationLayer() {
|
||||||
return animationLayer;
|
return animationLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ToolType getToolType() {
|
public ToolType getToolType() {
|
||||||
return toolType;
|
return toolType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,58 +1,58 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.guis;
|
package de.frajul.endlessroll.entities.guis;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.textures.Texture;
|
import de.frajul.endlessroll.entities.textures.Texture;
|
||||||
|
|
||||||
public class ToolButtonAnimationLayer extends Gui {
|
public class ToolButtonAnimationLayer extends Gui {
|
||||||
|
|
||||||
private final float ANIMATION_TIME = 500;
|
private final float ANIMATION_TIME = 500;
|
||||||
|
|
||||||
private float startWidth;
|
private float startWidth;
|
||||||
private float startHeight;
|
private float startHeight;
|
||||||
private boolean animationRunning = false;
|
private boolean animationRunning = false;
|
||||||
private float elapsedTime = 0;
|
private float elapsedTime = 0;
|
||||||
|
|
||||||
public ToolButtonAnimationLayer(Texture texture, Vector position, float width, float height) {
|
public ToolButtonAnimationLayer(Texture texture, Vector position, float width, float height) {
|
||||||
super(texture, position, width, height);
|
super(texture, position, width, height);
|
||||||
super.setVisible(false);
|
super.setVisible(false);
|
||||||
this.startWidth = width;
|
this.startWidth = width;
|
||||||
this.startHeight = height;
|
this.startHeight = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startAnimation() {
|
public void startAnimation() {
|
||||||
reset();
|
reset();
|
||||||
super.setVisible(true);
|
super.setVisible(true);
|
||||||
animationRunning = true;
|
animationRunning = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(float frameTime) {
|
public void update(float frameTime) {
|
||||||
if (animationRunning) {
|
if (animationRunning) {
|
||||||
elapsedTime += frameTime;
|
elapsedTime += frameTime;
|
||||||
if (elapsedTime >= ANIMATION_TIME) {
|
if (elapsedTime >= ANIMATION_TIME) {
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
float progress = elapsedTime / ANIMATION_TIME;
|
float progress = elapsedTime / ANIMATION_TIME;
|
||||||
super.setAlpha(0.5f - 0.5f * progress);
|
super.setAlpha(0.5f - 0.5f * progress);
|
||||||
float scaleFactor = 1 + 2 * progress;
|
float scaleFactor = 1 + 2 * progress;
|
||||||
super.setWidth(scaleFactor * startWidth);
|
super.setWidth(scaleFactor * startWidth);
|
||||||
super.setHeight(scaleFactor * startHeight);
|
super.setHeight(scaleFactor * startHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
animationRunning = false;
|
animationRunning = false;
|
||||||
elapsedTime = 0;
|
elapsedTime = 0;
|
||||||
super.setVisible(false);
|
super.setVisible(false);
|
||||||
super.setAlpha(0.5f);
|
super.setAlpha(0.5f);
|
||||||
super.setWidth(startWidth);
|
super.setWidth(startWidth);
|
||||||
super.setHeight(startHeight);
|
super.setHeight(startHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,101 +1,101 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.guis;
|
package de.frajul.endlessroll.entities.guis;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.textures.TexturePack;
|
import de.frajul.endlessroll.entities.textures.TexturePack;
|
||||||
import de.frajul.endlessroll.entities.tools.ToolType;
|
import de.frajul.endlessroll.entities.tools.ToolType;
|
||||||
import de.frajul.endlessroll.main.game.Game;
|
import de.frajul.endlessroll.main.game.Game;
|
||||||
import de.frajul.endlessroll.user.ToolSlotSettings;
|
import de.frajul.endlessroll.user.ToolSlotSettings;
|
||||||
|
|
||||||
public class ToolButtonBar {
|
public class ToolButtonBar {
|
||||||
|
|
||||||
private final int BUTTON_COUNT = 4;
|
private final int BUTTON_COUNT = 4;
|
||||||
private final float BUTTON_HEIGHT = 0.34f;
|
private final float BUTTON_HEIGHT = 0.34f;
|
||||||
private final float BUTTON_WIDTH = BUTTON_HEIGHT * 1.17f;
|
private final float BUTTON_WIDTH = BUTTON_HEIGHT * 1.17f;
|
||||||
private final float BUTTON_MARGIN = 0.012f;
|
private final float BUTTON_MARGIN = 0.012f;
|
||||||
|
|
||||||
private List<ToolButton> toolButtons = new ArrayList<>();
|
private List<ToolButton> toolButtons = new ArrayList<>();
|
||||||
|
|
||||||
public ToolButtonBar(TexturePack texturePack, Game game, ToolSlotSettings toolSlotSettings) {
|
public ToolButtonBar(TexturePack texturePack, Game game, ToolSlotSettings toolSlotSettings) {
|
||||||
float buttonWidth = BUTTON_WIDTH + 2 * BUTTON_MARGIN;
|
float buttonWidth = BUTTON_WIDTH + 2 * BUTTON_MARGIN;
|
||||||
float totalWidth = BUTTON_COUNT * buttonWidth;
|
float totalWidth = BUTTON_COUNT * buttonWidth;
|
||||||
|
|
||||||
for (int i = 0; i < BUTTON_COUNT; i++) {
|
for (int i = 0; i < BUTTON_COUNT; i++) {
|
||||||
Vector position = new Vector(-totalWidth / 2 + (i + 0.5f) * buttonWidth,
|
Vector position = new Vector(-totalWidth / 2 + (i + 0.5f) * buttonWidth,
|
||||||
1 - (0.5f * BUTTON_HEIGHT + BUTTON_MARGIN * 2));
|
1 - (0.5f * BUTTON_HEIGHT + BUTTON_MARGIN * 2));
|
||||||
ToolButton toolButton = new ToolButton(position, BUTTON_WIDTH, BUTTON_HEIGHT,
|
ToolButton toolButton = new ToolButton(position, BUTTON_WIDTH, BUTTON_HEIGHT,
|
||||||
texturePack, game);
|
texturePack, game);
|
||||||
toolButton.setToolSlot(toolSlotSettings.get(i));
|
toolButton.setToolSlot(toolSlotSettings.get(i));
|
||||||
toolButtons.add(toolButton);
|
toolButtons.add(toolButton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(float frameTime, boolean gameRunning) {
|
public void update(float frameTime, boolean gameRunning) {
|
||||||
for (ToolButton button : toolButtons)
|
for (ToolButton button : toolButtons)
|
||||||
button.update(frameTime, gameRunning);
|
button.update(frameTime, gameRunning);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeToolButtonTypes(ToolSlotSettings toolSlotSettings) {
|
public void changeToolButtonTypes(ToolSlotSettings toolSlotSettings) {
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
toolButtons.get(i).setToolSlot(toolSlotSettings.get(i));
|
toolButtons.get(i).setToolSlot(toolSlotSettings.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset(ToolSlotSettings toolSlotSettings) {
|
public void reset(ToolSlotSettings toolSlotSettings) {
|
||||||
changeToolButtonTypes(toolSlotSettings);
|
changeToolButtonTypes(toolSlotSettings);
|
||||||
|
|
||||||
boolean activeButtonAlreadySet = false;
|
boolean activeButtonAlreadySet = false;
|
||||||
for (ToolButton toolButton : toolButtons) {
|
for (ToolButton toolButton : toolButtons) {
|
||||||
if (!activeButtonAlreadySet && toolButton.getToolType() != null) {
|
if (!activeButtonAlreadySet && toolButton.getToolType() != null) {
|
||||||
toolButton.setActive(true);
|
toolButton.setActive(true);
|
||||||
activeButtonAlreadySet = true;
|
activeButtonAlreadySet = true;
|
||||||
} else
|
} else
|
||||||
toolButton.setActive(false);
|
toolButton.setActive(false);
|
||||||
toolButton.updateBorderColor();
|
toolButton.updateBorderColor();
|
||||||
toolButton.setProgress(1);
|
toolButton.setProgress(1);
|
||||||
toolButton.getAnimationLayer().reset();
|
toolButton.getAnimationLayer().reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActive(ToolType activeType) {
|
public void setActive(ToolType activeType) {
|
||||||
for (ToolButton button : toolButtons)
|
for (ToolButton button : toolButtons)
|
||||||
button.setActive(button.getToolType() == activeType);
|
button.setActive(button.getToolType() == activeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ToolButton getActiveButton() {
|
public ToolButton getActiveButton() {
|
||||||
for (ToolButton button : toolButtons)
|
for (ToolButton button : toolButtons)
|
||||||
if (button.getActive().get())
|
if (button.getActive().get())
|
||||||
return button;
|
return button;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Gui> toGuiList() {
|
public List<Gui> toGuiList() {
|
||||||
List<Gui> list = new ArrayList<>();
|
List<Gui> list = new ArrayList<>();
|
||||||
for (ToolButton button : toolButtons) {
|
for (ToolButton button : toolButtons) {
|
||||||
list.add(button.getBorder());
|
list.add(button.getBorder());
|
||||||
list.add(button.getBackground());
|
list.add(button.getBackground());
|
||||||
list.add(button.getProgressbar());
|
list.add(button.getProgressbar());
|
||||||
list.add(button.getAnimationLayer());
|
list.add(button.getAnimationLayer());
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVisible(boolean visible) {
|
public void setVisible(boolean visible) {
|
||||||
for (ToolButton button : toolButtons) {
|
for (ToolButton button : toolButtons) {
|
||||||
button.setVisible(visible);
|
button.setVisible(visible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ToolButton> getToolButtons() {
|
public List<ToolButton> getToolButtons() {
|
||||||
return toolButtons;
|
return toolButtons;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,50 +1,50 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.particles;
|
package de.frajul.endlessroll.entities.particles;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.main.game.Camera;
|
import de.frajul.endlessroll.main.game.Camera;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 15.07.2017.
|
* Created by Julian on 15.07.2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Firework {
|
public class Firework {
|
||||||
|
|
||||||
private ParticleEffect effect;
|
private ParticleEffect effect;
|
||||||
private Camera camera;
|
private Camera camera;
|
||||||
private Random random;
|
private Random random;
|
||||||
|
|
||||||
public Firework(ParticleEffect effect, Camera camera) {
|
public Firework(ParticleEffect effect, Camera camera) {
|
||||||
this.effect = effect;
|
this.effect = effect;
|
||||||
this.camera = camera;
|
this.camera = camera;
|
||||||
this.random = new Random();
|
this.random = new Random();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
randomExplosion(0);
|
randomExplosion(0);
|
||||||
randomExplosion(100);
|
randomExplosion(100);
|
||||||
randomExplosion(300);
|
randomExplosion(300);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void randomExplosion(float delay) {
|
private void randomExplosion(float delay) {
|
||||||
ParticleSource explosion = new ParticleSource(randomPosition(), effect);
|
ParticleSource explosion = new ParticleSource(randomPosition(), effect);
|
||||||
explosion.setDelayMS(delay);
|
explosion.setDelayMS(delay);
|
||||||
explosion.start();
|
explosion.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector randomPosition() {
|
private Vector randomPosition() {
|
||||||
float x = camera.getX() + (random.nextFloat() - 0.5f) * 2.5f;
|
float x = camera.getX() + (random.nextFloat() - 0.5f) * 2.5f;
|
||||||
float y = camera.getY() + (random.nextFloat() * 0.5f) - 1f;
|
float y = camera.getY() + (random.nextFloat() * 0.5f) - 1f;
|
||||||
return new Vector(x, y);
|
return new Vector(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,118 +1,118 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.particles;
|
package de.frajul.endlessroll.entities.particles;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Color3f;
|
import de.frajul.endlessroll.data.Color3f;
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.Entity;
|
import de.frajul.endlessroll.entities.Entity;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Range;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Range;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Timeline;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Timeline;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.TintTimeline;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.TintTimeline;
|
||||||
import de.frajul.endlessroll.main.game.Timer;
|
import de.frajul.endlessroll.main.game.Timer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 02.08.2016.
|
* Created by Julian on 02.08.2016.
|
||||||
*/
|
*/
|
||||||
public class Particle extends Entity {
|
public class Particle extends Entity {
|
||||||
|
|
||||||
private Color3f color;
|
private Color3f color;
|
||||||
private Random random;
|
private Random random;
|
||||||
private boolean active;
|
private boolean active;
|
||||||
private float maxLife;
|
private float maxLife;
|
||||||
private float passedLifetime;
|
private float passedLifetime;
|
||||||
|
|
||||||
private Timeline scaleTimeline;
|
private Timeline scaleTimeline;
|
||||||
private Range scale;
|
private Range scale;
|
||||||
private Timeline velocityTimeline;
|
private Timeline velocityTimeline;
|
||||||
private Range velocity;
|
private Range velocity;
|
||||||
private Timeline angleTimeline;
|
private Timeline angleTimeline;
|
||||||
private Range angle;
|
private Range angle;
|
||||||
private Timeline rotationTimeline;
|
private Timeline rotationTimeline;
|
||||||
private Range rotation;
|
private Range rotation;
|
||||||
private Timeline transparencyTimeline;
|
private Timeline transparencyTimeline;
|
||||||
private TintTimeline tintTimeline;
|
private TintTimeline tintTimeline;
|
||||||
private Timeline windTimeline;
|
private Timeline windTimeline;
|
||||||
private Range wind;
|
private Range wind;
|
||||||
private Timeline gravityTimeline;
|
private Timeline gravityTimeline;
|
||||||
private Range gravity;
|
private Range gravity;
|
||||||
|
|
||||||
public Particle(Random random) {
|
public Particle(Random random) {
|
||||||
super(null, new Vector(), 1, 1);
|
super(null, new Vector(), 1, 1);
|
||||||
this.random = random;
|
this.random = random;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void activate(Vector position, float liveValue, ParticleData particleData) {
|
public void activate(Vector position, float liveValue, ParticleData particleData) {
|
||||||
active = true;
|
active = true;
|
||||||
passedLifetime = 0;
|
passedLifetime = 0;
|
||||||
super.setPosition(position);
|
super.setPosition(position);
|
||||||
maxLife = particleData.getLife().createValue(random, liveValue);
|
maxLife = particleData.getLife().createValue(random, liveValue);
|
||||||
scaleTimeline = particleData.getScaleTR().getTimeline();
|
scaleTimeline = particleData.getScaleTR().getTimeline();
|
||||||
scale = particleData.getScaleTR().getRange().createNormalizedInstance(random);
|
scale = particleData.getScaleTR().getRange().createNormalizedInstance(random);
|
||||||
velocityTimeline = particleData.getVelocityTR().getTimeline();
|
velocityTimeline = particleData.getVelocityTR().getTimeline();
|
||||||
velocity = particleData.getVelocityTR().getRange().createNormalizedInstance(random);
|
velocity = particleData.getVelocityTR().getRange().createNormalizedInstance(random);
|
||||||
angleTimeline = particleData.getAngleTR().getTimeline();
|
angleTimeline = particleData.getAngleTR().getTimeline();
|
||||||
angle = particleData.getAngleTR().getRange().createNormalizedInstance(random);
|
angle = particleData.getAngleTR().getRange().createNormalizedInstance(random);
|
||||||
rotationTimeline = particleData.getRotationTR().getTimeline();
|
rotationTimeline = particleData.getRotationTR().getTimeline();
|
||||||
rotation = particleData.getRotationTR().getRange().createNormalizedInstance(random);
|
rotation = particleData.getRotationTR().getRange().createNormalizedInstance(random);
|
||||||
transparencyTimeline = particleData.getTransparencyT();
|
transparencyTimeline = particleData.getTransparencyT();
|
||||||
tintTimeline = particleData.getTint();
|
tintTimeline = particleData.getTint();
|
||||||
windTimeline = particleData.getWindTR().getTimeline();
|
windTimeline = particleData.getWindTR().getTimeline();
|
||||||
wind = particleData.getWindTR().getRange().createNormalizedInstance(random);
|
wind = particleData.getWindTR().getRange().createNormalizedInstance(random);
|
||||||
gravityTimeline = particleData.getGravityTR().getTimeline();
|
gravityTimeline = particleData.getGravityTR().getTimeline();
|
||||||
gravity = particleData.getGravityTR().getRange().createNormalizedInstance(random);
|
gravity = particleData.getGravityTR().getRange().createNormalizedInstance(random);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(Timer timer) {
|
public void update(Timer timer) {
|
||||||
if (active) {
|
if (active) {
|
||||||
passedLifetime += timer.getFrameTimeMilliseconds();
|
passedLifetime += timer.getFrameTimeMilliseconds();
|
||||||
if (passedLifetime >= maxLife)
|
if (passedLifetime >= maxLife)
|
||||||
active = false;
|
active = false;
|
||||||
float lifetimePercent = passedLifetime / maxLife;
|
float lifetimePercent = passedLifetime / maxLife;
|
||||||
setScale(scale.createValue(random, scaleTimeline.getValueAtTime(lifetimePercent)));
|
setScale(scale.createValue(random, scaleTimeline.getValueAtTime(lifetimePercent)));
|
||||||
setMovement(
|
setMovement(
|
||||||
velocity.createValue(random, velocityTimeline.getValueAtTime(lifetimePercent)),
|
velocity.createValue(random, velocityTimeline.getValueAtTime(lifetimePercent)),
|
||||||
angle.createValue(random, angleTimeline.getValueAtTime(lifetimePercent)),
|
angle.createValue(random, angleTimeline.getValueAtTime(lifetimePercent)),
|
||||||
wind.createValue(random, windTimeline.getValueAtTime(lifetimePercent)),
|
wind.createValue(random, windTimeline.getValueAtTime(lifetimePercent)),
|
||||||
gravity.createValue(random, gravityTimeline.getValueAtTime(lifetimePercent)));
|
gravity.createValue(random, gravityTimeline.getValueAtTime(lifetimePercent)));
|
||||||
super.setRotation(-rotation
|
super.setRotation(-rotation
|
||||||
.createValue(random, rotationTimeline.getValueAtTime(lifetimePercent)));
|
.createValue(random, rotationTimeline.getValueAtTime(lifetimePercent)));
|
||||||
super.setAlpha(transparencyTimeline.getValueAtTime(lifetimePercent));
|
super.setAlpha(transparencyTimeline.getValueAtTime(lifetimePercent));
|
||||||
setColor(tintTimeline.getValueAtTime(lifetimePercent));
|
setColor(tintTimeline.getValueAtTime(lifetimePercent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setScale(float scale) {
|
private void setScale(float scale) {
|
||||||
super.setWidth(scale * ParticleSystem.TRANSFER_VALUE);
|
super.setWidth(scale * ParticleSystem.TRANSFER_VALUE);
|
||||||
super.setHeight(scale * ParticleSystem.TRANSFER_VALUE);
|
super.setHeight(scale * ParticleSystem.TRANSFER_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setMovement(float velocity, float angle, float windStrength, float gravityStrength) {
|
private void setMovement(float velocity, float angle, float windStrength, float gravityStrength) {
|
||||||
float radians = (float) Math.toRadians(angle);
|
float radians = (float) Math.toRadians(angle);
|
||||||
Vector normalMovement = new Vector();
|
Vector normalMovement = new Vector();
|
||||||
normalMovement.setX((float) Math.cos(radians));
|
normalMovement.setX((float) Math.cos(radians));
|
||||||
normalMovement.setY((float) Math.sin(radians));
|
normalMovement.setY((float) Math.sin(radians));
|
||||||
normalMovement.mul(velocity * ParticleSystem.TRANSFER_VALUE);
|
normalMovement.mul(velocity * ParticleSystem.TRANSFER_VALUE);
|
||||||
normalMovement.translate(windStrength * ParticleSystem.TRANSFER_VALUE,
|
normalMovement.translate(windStrength * ParticleSystem.TRANSFER_VALUE,
|
||||||
gravityStrength * ParticleSystem.TRANSFER_VALUE);
|
gravityStrength * ParticleSystem.TRANSFER_VALUE);
|
||||||
super.setMovement(normalMovement);
|
super.setMovement(normalMovement);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isActive() {
|
public boolean isActive() {
|
||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColor(Color3f color) {
|
public void setColor(Color3f color) {
|
||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color3f getColor() {
|
public Color3f getColor() {
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,77 +1,77 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.particles;
|
package de.frajul.endlessroll.entities.particles;
|
||||||
|
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Range;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Range;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Timeline;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Timeline;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.TimelineRange;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.TimelineRange;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.TintTimeline;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.TintTimeline;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 03.08.2016.
|
* Created by Julian on 03.08.2016.
|
||||||
*/
|
*/
|
||||||
public class ParticleData {
|
public class ParticleData {
|
||||||
|
|
||||||
private Range life;
|
private Range life;
|
||||||
private TimelineRange scaleTR;
|
private TimelineRange scaleTR;
|
||||||
private TimelineRange velocityTR;
|
private TimelineRange velocityTR;
|
||||||
private TimelineRange angleTR;
|
private TimelineRange angleTR;
|
||||||
private TimelineRange rotationTR;
|
private TimelineRange rotationTR;
|
||||||
private Timeline transparencyT;
|
private Timeline transparencyT;
|
||||||
private TintTimeline tint;
|
private TintTimeline tint;
|
||||||
private TimelineRange windTR;
|
private TimelineRange windTR;
|
||||||
private TimelineRange gravityTR;
|
private TimelineRange gravityTR;
|
||||||
|
|
||||||
public ParticleData(Range life, TimelineRange scaleTR, TimelineRange velocityTR, TimelineRange angleTR, TimelineRange rotationTR, Timeline transparencyT, TintTimeline tint, TimelineRange windTR, TimelineRange gravityTR) {
|
public ParticleData(Range life, TimelineRange scaleTR, TimelineRange velocityTR, TimelineRange angleTR, TimelineRange rotationTR, Timeline transparencyT, TintTimeline tint, TimelineRange windTR, TimelineRange gravityTR) {
|
||||||
this.life = life;
|
this.life = life;
|
||||||
this.scaleTR = scaleTR;
|
this.scaleTR = scaleTR;
|
||||||
this.velocityTR = velocityTR;
|
this.velocityTR = velocityTR;
|
||||||
this.angleTR = angleTR;
|
this.angleTR = angleTR;
|
||||||
this.rotationTR = rotationTR;
|
this.rotationTR = rotationTR;
|
||||||
this.transparencyT = transparencyT;
|
this.transparencyT = transparencyT;
|
||||||
this.tint = tint;
|
this.tint = tint;
|
||||||
this.windTR = windTR;
|
this.windTR = windTR;
|
||||||
this.gravityTR = gravityTR;
|
this.gravityTR = gravityTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Range getLife() {
|
public Range getLife() {
|
||||||
return life;
|
return life;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimelineRange getScaleTR() {
|
public TimelineRange getScaleTR() {
|
||||||
return scaleTR;
|
return scaleTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimelineRange getVelocityTR() {
|
public TimelineRange getVelocityTR() {
|
||||||
return velocityTR;
|
return velocityTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimelineRange getAngleTR() {
|
public TimelineRange getAngleTR() {
|
||||||
return angleTR;
|
return angleTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimelineRange getRotationTR() {
|
public TimelineRange getRotationTR() {
|
||||||
return rotationTR;
|
return rotationTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Timeline getTransparencyT() {
|
public Timeline getTransparencyT() {
|
||||||
return transparencyT;
|
return transparencyT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TintTimeline getTint() {
|
public TintTimeline getTint() {
|
||||||
return tint;
|
return tint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimelineRange getWindTR() {
|
public TimelineRange getWindTR() {
|
||||||
return windTR;
|
return windTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimelineRange getGravityTR() {
|
public TimelineRange getGravityTR() {
|
||||||
return gravityTR;
|
return gravityTR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,236 +1,236 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.particles;
|
package de.frajul.endlessroll.entities.particles;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Options;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Options;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Range;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Range;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.SpawnShape;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.SpawnShape;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Timeline;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Timeline;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.TimelineRange;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.TimelineRange;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.TintTimeline;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.TintTimeline;
|
||||||
import de.frajul.endlessroll.entities.textures.Texture;
|
import de.frajul.endlessroll.entities.textures.Texture;
|
||||||
import de.frajul.endlessroll.main.game.Timer;
|
import de.frajul.endlessroll.main.game.Timer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 05.08.2016.
|
* Created by Julian on 05.08.2016.
|
||||||
*/
|
*/
|
||||||
public class ParticleEffect {
|
public class ParticleEffect {
|
||||||
|
|
||||||
private TimelineRange life;
|
private TimelineRange life;
|
||||||
//Particle Timeline
|
//Particle Timeline
|
||||||
private TimelineRange scale;
|
private TimelineRange scale;
|
||||||
private TimelineRange velocity;
|
private TimelineRange velocity;
|
||||||
private TimelineRange angle;
|
private TimelineRange angle;
|
||||||
private TimelineRange rotation;
|
private TimelineRange rotation;
|
||||||
private Timeline transparency;
|
private Timeline transparency;
|
||||||
private TintTimeline tint;
|
private TintTimeline tint;
|
||||||
private TimelineRange wind;
|
private TimelineRange wind;
|
||||||
private TimelineRange gravity;
|
private TimelineRange gravity;
|
||||||
|
|
||||||
//Source Timeline
|
//Source Timeline
|
||||||
private Range delay;
|
private Range delay;
|
||||||
private Range duration;
|
private Range duration;
|
||||||
private TimelineRange emission;
|
private TimelineRange emission;
|
||||||
private Range xOffset;
|
private Range xOffset;
|
||||||
private Range yOffset;
|
private Range yOffset;
|
||||||
private SpawnShape.Shape spawnShape;
|
private SpawnShape.Shape spawnShape;
|
||||||
private TimelineRange spawnWidth;
|
private TimelineRange spawnWidth;
|
||||||
private TimelineRange spawnHeight;
|
private TimelineRange spawnHeight;
|
||||||
|
|
||||||
private Options options;
|
private Options options;
|
||||||
private Texture texture;
|
private Texture texture;
|
||||||
private String textureName;
|
private String textureName;
|
||||||
|
|
||||||
private Random random;
|
private Random random;
|
||||||
private List<ParticleSource> sources = Collections.synchronizedList(new ArrayList<ParticleSource>());
|
private List<ParticleSource> sources = Collections.synchronizedList(new ArrayList<ParticleSource>());
|
||||||
|
|
||||||
public ParticleEffect() {
|
public ParticleEffect() {
|
||||||
this.random = new Random();
|
this.random = new Random();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(Timer timer) {
|
public void update(Timer timer) {
|
||||||
synchronized (sources) {
|
synchronized (sources) {
|
||||||
for (ParticleSource source : sources)
|
for (ParticleSource source : sources)
|
||||||
source.update(timer);
|
source.update(timer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParticleData createParticleData() {
|
public ParticleData createParticleData() {
|
||||||
return new ParticleData(life.getRange(), scale, velocity, angle, rotation, transparency, tint, wind, gravity);
|
return new ParticleData(life.getRange(), scale, velocity, angle, rotation, transparency, tint, wind, gravity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Random getRandom() {
|
public Random getRandom() {
|
||||||
return random;
|
return random;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSource(ParticleSource source) {
|
public void addSource(ParticleSource source) {
|
||||||
sources.add(source);
|
sources.add(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDelay(Range delay) {
|
public void setDelay(Range delay) {
|
||||||
this.delay = delay;
|
this.delay = delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDuration(Range duration) {
|
public void setDuration(Range duration) {
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEmission(TimelineRange emission) {
|
public void setEmission(TimelineRange emission) {
|
||||||
this.emission = emission;
|
this.emission = emission;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLife(TimelineRange life) {
|
public void setLife(TimelineRange life) {
|
||||||
this.life = life;
|
this.life = life;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setxOffset(Range xOffset) {
|
public void setxOffset(Range xOffset) {
|
||||||
this.xOffset = xOffset;
|
this.xOffset = xOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setyOffset(Range yOffset) {
|
public void setyOffset(Range yOffset) {
|
||||||
this.yOffset = yOffset;
|
this.yOffset = yOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSpawnShape(SpawnShape.Shape spawnShape) {
|
public void setSpawnShape(SpawnShape.Shape spawnShape) {
|
||||||
this.spawnShape = spawnShape;
|
this.spawnShape = spawnShape;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSpawnWidth(TimelineRange spawnWidth) {
|
public void setSpawnWidth(TimelineRange spawnWidth) {
|
||||||
this.spawnWidth = spawnWidth;
|
this.spawnWidth = spawnWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSpawnHeight(TimelineRange spawnHeight) {
|
public void setSpawnHeight(TimelineRange spawnHeight) {
|
||||||
this.spawnHeight = spawnHeight;
|
this.spawnHeight = spawnHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScale(TimelineRange scale) {
|
public void setScale(TimelineRange scale) {
|
||||||
this.scale = scale;
|
this.scale = scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVelocity(TimelineRange velocity) {
|
public void setVelocity(TimelineRange velocity) {
|
||||||
this.velocity = velocity;
|
this.velocity = velocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAngle(TimelineRange angle) {
|
public void setAngle(TimelineRange angle) {
|
||||||
this.angle = angle;
|
this.angle = angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRotation(TimelineRange rotation) {
|
public void setRotation(TimelineRange rotation) {
|
||||||
this.rotation = rotation;
|
this.rotation = rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWind(TimelineRange wind) {
|
public void setWind(TimelineRange wind) {
|
||||||
this.wind = wind;
|
this.wind = wind;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGravity(TimelineRange gravity) {
|
public void setGravity(TimelineRange gravity) {
|
||||||
this.gravity = gravity;
|
this.gravity = gravity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTint(TintTimeline tint) {
|
public void setTint(TintTimeline tint) {
|
||||||
this.tint = tint;
|
this.tint = tint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTransparency(Timeline transparency) {
|
public void setTransparency(Timeline transparency) {
|
||||||
this.transparency = transparency;
|
this.transparency = transparency;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Timeline getTransparency() {
|
public Timeline getTransparency() {
|
||||||
return transparency;
|
return transparency;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TintTimeline getTint() {
|
public TintTimeline getTint() {
|
||||||
return tint;
|
return tint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOptions(Options options) {
|
public void setOptions(Options options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTexture(Texture texture) {
|
public void setTexture(Texture texture) {
|
||||||
this.texture = texture;
|
this.texture = texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTextureName(String textureName) {
|
public void setTextureName(String textureName) {
|
||||||
this.textureName = textureName;
|
this.textureName = textureName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTextureName() {
|
public String getTextureName() {
|
||||||
return textureName;
|
return textureName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Texture getTexture() {
|
public Texture getTexture() {
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Range getDelay() {
|
public Range getDelay() {
|
||||||
return delay;
|
return delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Range getDuration() {
|
public Range getDuration() {
|
||||||
return duration;
|
return duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimelineRange getEmission() {
|
public TimelineRange getEmission() {
|
||||||
return emission;
|
return emission;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Options getOptions() {
|
public Options getOptions() {
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimelineRange getWind() {
|
public TimelineRange getWind() {
|
||||||
return wind;
|
return wind;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimelineRange getGravity() {
|
public TimelineRange getGravity() {
|
||||||
return gravity;
|
return gravity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Range getxOffset() {
|
public Range getxOffset() {
|
||||||
return xOffset;
|
return xOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Range getyOffset() {
|
public Range getyOffset() {
|
||||||
return yOffset;
|
return yOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized List<ParticleSource> getSources() {
|
public synchronized List<ParticleSource> getSources() {
|
||||||
return sources;
|
return sources;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimelineRange getLife() {
|
public TimelineRange getLife() {
|
||||||
return life;
|
return life;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpawnShape.Shape getSpawnShape() {
|
public SpawnShape.Shape getSpawnShape() {
|
||||||
return spawnShape;
|
return spawnShape;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimelineRange getSpawnHeight() {
|
public TimelineRange getSpawnHeight() {
|
||||||
return spawnHeight;
|
return spawnHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteSources() {
|
public void deleteSources() {
|
||||||
synchronized (sources) {
|
synchronized (sources) {
|
||||||
for (ParticleSource source : sources)
|
for (ParticleSource source : sources)
|
||||||
source.kill();
|
source.kill();
|
||||||
sources.clear();
|
sources.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimelineRange getSpawnWidth() {
|
public TimelineRange getSpawnWidth() {
|
||||||
return spawnWidth;
|
return spawnWidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,170 +1,170 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.particles;
|
package de.frajul.endlessroll.entities.particles;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.Attribute;
|
import de.frajul.endlessroll.entities.particles.attributes.Attribute;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.AttributeValueReader;
|
import de.frajul.endlessroll.entities.particles.attributes.AttributeValueReader;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.ParticleAttributeType;
|
import de.frajul.endlessroll.entities.particles.attributes.ParticleAttributeType;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.ImagePath;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.ImagePath;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Options;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Options;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.ParticleAttributeValueType;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.ParticleAttributeValueType;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Range;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Range;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.SpawnShape;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.SpawnShape;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Timeline;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Timeline;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.TimelineRange;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.TimelineRange;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.TintTimeline;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.TintTimeline;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 02.08.2016.
|
* Created by Julian on 02.08.2016.
|
||||||
*/
|
*/
|
||||||
public class ParticleReader {
|
public class ParticleReader {
|
||||||
|
|
||||||
private Context context;
|
private Context context;
|
||||||
private AttributeValueReader attributeValueReader;
|
private AttributeValueReader attributeValueReader;
|
||||||
|
|
||||||
private List<Attribute> attributes;
|
private List<Attribute> attributes;
|
||||||
private Attribute currentAttribute;
|
private Attribute currentAttribute;
|
||||||
|
|
||||||
public ParticleReader(Context context) {
|
public ParticleReader(Context context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
attributeValueReader = new AttributeValueReader();
|
attributeValueReader = new AttributeValueReader();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* reads ParticleEffect from *.pe files
|
* reads ParticleEffect from *.pe files
|
||||||
* !Ignores COUNT, LIFE_OFFSET!
|
* !Ignores COUNT, LIFE_OFFSET!
|
||||||
*/
|
*/
|
||||||
public ParticleEffect read(String filename) throws Exception {
|
public ParticleEffect read(String filename) throws Exception {
|
||||||
try {
|
try {
|
||||||
attributes = new ArrayList<>();
|
attributes = new ArrayList<>();
|
||||||
currentAttribute = null;
|
currentAttribute = null;
|
||||||
InputStream is = context.getAssets().open(filename);
|
InputStream is = context.getAssets().open(filename);
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
line = line.trim();
|
line = line.trim();
|
||||||
handleLine(line);
|
handleLine(line);
|
||||||
}
|
}
|
||||||
reader.close();
|
reader.close();
|
||||||
return createParticleEffect();
|
return createParticleEffect();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new Exception("Could not read particleFile: ", e);
|
throw new Exception("Could not read particleFile: ", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleLine(String line) throws Exception {
|
private void handleLine(String line) throws Exception {
|
||||||
if (line.startsWith("- ")) {
|
if (line.startsWith("- ")) {
|
||||||
Attribute attrib = ParticleAttributeType.getByInFileTitle(line).createInstance();
|
Attribute attrib = ParticleAttributeType.getByInFileTitle(line).createInstance();
|
||||||
attributes.add(attrib);
|
attributes.add(attrib);
|
||||||
currentAttribute = attrib;
|
currentAttribute = attrib;
|
||||||
} else if (currentAttribute != null)
|
} else if (currentAttribute != null)
|
||||||
attributeValueReader.addValueForAttribute(currentAttribute, line);
|
attributeValueReader.addValueForAttribute(currentAttribute, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ParticleEffect createParticleEffect() throws Exception {
|
private ParticleEffect createParticleEffect() throws Exception {
|
||||||
ParticleEffect effect = new ParticleEffect();
|
ParticleEffect effect = new ParticleEffect();
|
||||||
Timeline timeline = null;
|
Timeline timeline = null;
|
||||||
Range range = null;
|
Range range = null;
|
||||||
for (Attribute attribute : attributes) {
|
for (Attribute attribute : attributes) {
|
||||||
switch (attribute.getType()) {
|
switch (attribute.getType()) {
|
||||||
case DELAY:
|
case DELAY:
|
||||||
effect.setDelay((Range) attribute.get(ParticleAttributeValueType.RANGE));
|
effect.setDelay((Range) attribute.get(ParticleAttributeValueType.RANGE));
|
||||||
break;
|
break;
|
||||||
case DURATION:
|
case DURATION:
|
||||||
effect.setDuration((Range) attribute.get(ParticleAttributeValueType.RANGE));
|
effect.setDuration((Range) attribute.get(ParticleAttributeValueType.RANGE));
|
||||||
break;
|
break;
|
||||||
case COUNT:
|
case COUNT:
|
||||||
break;
|
break;
|
||||||
case EMISSION:
|
case EMISSION:
|
||||||
timeline = (Timeline) attribute.get(ParticleAttributeValueType.TIMELINE);
|
timeline = (Timeline) attribute.get(ParticleAttributeValueType.TIMELINE);
|
||||||
range = (Range) attribute.get(ParticleAttributeValueType.RANGE);
|
range = (Range) attribute.get(ParticleAttributeValueType.RANGE);
|
||||||
effect.setEmission(new TimelineRange(timeline, range));
|
effect.setEmission(new TimelineRange(timeline, range));
|
||||||
break;
|
break;
|
||||||
case LIFE:
|
case LIFE:
|
||||||
timeline = (Timeline) attribute.get(ParticleAttributeValueType.TIMELINE);
|
timeline = (Timeline) attribute.get(ParticleAttributeValueType.TIMELINE);
|
||||||
range = (Range) attribute.get(ParticleAttributeValueType.RANGE);
|
range = (Range) attribute.get(ParticleAttributeValueType.RANGE);
|
||||||
effect.setLife(new TimelineRange(timeline, range));
|
effect.setLife(new TimelineRange(timeline, range));
|
||||||
break;
|
break;
|
||||||
case LIFE_OFFSET:
|
case LIFE_OFFSET:
|
||||||
break;
|
break;
|
||||||
case X_OFFSET:
|
case X_OFFSET:
|
||||||
effect.setxOffset((Range) attribute.get(ParticleAttributeValueType.RANGE));
|
effect.setxOffset((Range) attribute.get(ParticleAttributeValueType.RANGE));
|
||||||
break;
|
break;
|
||||||
case Y_OFFSET:
|
case Y_OFFSET:
|
||||||
effect.setyOffset((Range) attribute.get(ParticleAttributeValueType.RANGE));
|
effect.setyOffset((Range) attribute.get(ParticleAttributeValueType.RANGE));
|
||||||
break;
|
break;
|
||||||
case SPAWN_SHAPE:
|
case SPAWN_SHAPE:
|
||||||
effect.setSpawnShape(((SpawnShape) attribute.get(ParticleAttributeValueType.SPAWN_SHAPE)).getShape());
|
effect.setSpawnShape(((SpawnShape) attribute.get(ParticleAttributeValueType.SPAWN_SHAPE)).getShape());
|
||||||
break;
|
break;
|
||||||
case SPAWN_WIDTH:
|
case SPAWN_WIDTH:
|
||||||
timeline = (Timeline) attribute.get(ParticleAttributeValueType.TIMELINE);
|
timeline = (Timeline) attribute.get(ParticleAttributeValueType.TIMELINE);
|
||||||
range = (Range) attribute.get(ParticleAttributeValueType.RANGE);
|
range = (Range) attribute.get(ParticleAttributeValueType.RANGE);
|
||||||
effect.setSpawnWidth(new TimelineRange(timeline, range));
|
effect.setSpawnWidth(new TimelineRange(timeline, range));
|
||||||
break;
|
break;
|
||||||
case SPAWN_HEIGHT:
|
case SPAWN_HEIGHT:
|
||||||
timeline = (Timeline) attribute.get(ParticleAttributeValueType.TIMELINE);
|
timeline = (Timeline) attribute.get(ParticleAttributeValueType.TIMELINE);
|
||||||
range = (Range) attribute.get(ParticleAttributeValueType.RANGE);
|
range = (Range) attribute.get(ParticleAttributeValueType.RANGE);
|
||||||
effect.setSpawnHeight(new TimelineRange(timeline, range));
|
effect.setSpawnHeight(new TimelineRange(timeline, range));
|
||||||
break;
|
break;
|
||||||
case SCALE:
|
case SCALE:
|
||||||
timeline = (Timeline) attribute.get(ParticleAttributeValueType.TIMELINE);
|
timeline = (Timeline) attribute.get(ParticleAttributeValueType.TIMELINE);
|
||||||
range = (Range) attribute.get(ParticleAttributeValueType.RANGE);
|
range = (Range) attribute.get(ParticleAttributeValueType.RANGE);
|
||||||
effect.setScale(new TimelineRange(timeline, range));
|
effect.setScale(new TimelineRange(timeline, range));
|
||||||
break;
|
break;
|
||||||
case VELOCITY:
|
case VELOCITY:
|
||||||
timeline = (Timeline) attribute.get(ParticleAttributeValueType.TIMELINE);
|
timeline = (Timeline) attribute.get(ParticleAttributeValueType.TIMELINE);
|
||||||
range = (Range) attribute.get(ParticleAttributeValueType.RANGE);
|
range = (Range) attribute.get(ParticleAttributeValueType.RANGE);
|
||||||
effect.setVelocity(new TimelineRange(timeline, range));
|
effect.setVelocity(new TimelineRange(timeline, range));
|
||||||
break;
|
break;
|
||||||
case ANGLE:
|
case ANGLE:
|
||||||
timeline = (Timeline) attribute.get(ParticleAttributeValueType.TIMELINE);
|
timeline = (Timeline) attribute.get(ParticleAttributeValueType.TIMELINE);
|
||||||
range = (Range) attribute.get(ParticleAttributeValueType.RANGE);
|
range = (Range) attribute.get(ParticleAttributeValueType.RANGE);
|
||||||
effect.setAngle(new TimelineRange(timeline, range));
|
effect.setAngle(new TimelineRange(timeline, range));
|
||||||
break;
|
break;
|
||||||
case ROTATION:
|
case ROTATION:
|
||||||
timeline = (Timeline) attribute.get(ParticleAttributeValueType.TIMELINE);
|
timeline = (Timeline) attribute.get(ParticleAttributeValueType.TIMELINE);
|
||||||
range = (Range) attribute.get(ParticleAttributeValueType.RANGE);
|
range = (Range) attribute.get(ParticleAttributeValueType.RANGE);
|
||||||
effect.setRotation(new TimelineRange(timeline, range));
|
effect.setRotation(new TimelineRange(timeline, range));
|
||||||
break;
|
break;
|
||||||
case WIND:
|
case WIND:
|
||||||
timeline = (Timeline) attribute.get(ParticleAttributeValueType.TIMELINE);
|
timeline = (Timeline) attribute.get(ParticleAttributeValueType.TIMELINE);
|
||||||
range = (Range) attribute.get(ParticleAttributeValueType.RANGE);
|
range = (Range) attribute.get(ParticleAttributeValueType.RANGE);
|
||||||
effect.setWind(new TimelineRange(timeline, range));
|
effect.setWind(new TimelineRange(timeline, range));
|
||||||
break;
|
break;
|
||||||
case GRAVITY:
|
case GRAVITY:
|
||||||
timeline = (Timeline) attribute.get(ParticleAttributeValueType.TIMELINE);
|
timeline = (Timeline) attribute.get(ParticleAttributeValueType.TIMELINE);
|
||||||
range = (Range) attribute.get(ParticleAttributeValueType.RANGE);
|
range = (Range) attribute.get(ParticleAttributeValueType.RANGE);
|
||||||
effect.setGravity(new TimelineRange(timeline, range));
|
effect.setGravity(new TimelineRange(timeline, range));
|
||||||
break;
|
break;
|
||||||
case TINT:
|
case TINT:
|
||||||
effect.setTint((TintTimeline) attribute.get(ParticleAttributeValueType.TINT_TIMELINE));
|
effect.setTint((TintTimeline) attribute.get(ParticleAttributeValueType.TINT_TIMELINE));
|
||||||
break;
|
break;
|
||||||
case TRANSPARENCY:
|
case TRANSPARENCY:
|
||||||
timeline = (Timeline) attribute.get(ParticleAttributeValueType.TIMELINE);
|
timeline = (Timeline) attribute.get(ParticleAttributeValueType.TIMELINE);
|
||||||
effect.setTransparency(timeline);
|
effect.setTransparency(timeline);
|
||||||
break;
|
break;
|
||||||
case OPTIONS:
|
case OPTIONS:
|
||||||
effect.setOptions((Options) attribute.get(ParticleAttributeValueType.OPTIONS));
|
effect.setOptions((Options) attribute.get(ParticleAttributeValueType.OPTIONS));
|
||||||
break;
|
break;
|
||||||
case IMAGE_PATH:
|
case IMAGE_PATH:
|
||||||
String path = ((ImagePath) attribute.get(ParticleAttributeValueType.IMAGE_PATH)).getImagePath();
|
String path = ((ImagePath) attribute.get(ParticleAttributeValueType.IMAGE_PATH)).getImagePath();
|
||||||
effect.setTextureName(path);
|
effect.setTextureName(path);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return effect;
|
return effect;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,183 +1,183 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.particles;
|
package de.frajul.endlessroll.entities.particles;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.SpawnShape;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.SpawnShape;
|
||||||
import de.frajul.endlessroll.main.game.Timer;
|
import de.frajul.endlessroll.main.game.Timer;
|
||||||
import de.frajul.endlessroll.rendering.Lock;
|
import de.frajul.endlessroll.rendering.Lock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 02.08.2016.
|
* Created by Julian on 02.08.2016.
|
||||||
*/
|
*/
|
||||||
public class ParticleSource {
|
public class ParticleSource {
|
||||||
|
|
||||||
private Vector position;
|
private Vector position;
|
||||||
private ParticleEffect effect;
|
private ParticleEffect effect;
|
||||||
private Random random;
|
private Random random;
|
||||||
|
|
||||||
private boolean delayManuallySet = false;
|
private boolean delayManuallySet = false;
|
||||||
|
|
||||||
private boolean alife;
|
private boolean alife;
|
||||||
private float currentDelay;
|
private float currentDelay;
|
||||||
private float lifePercent;
|
private float lifePercent;
|
||||||
private float maxTime = -1;
|
private float maxTime = -1;
|
||||||
private float passedTime;
|
private float passedTime;
|
||||||
private float emittPause;
|
private float emittPause;
|
||||||
private float passedEmittPause;
|
private float passedEmittPause;
|
||||||
private float passedSecond;
|
private float passedSecond;
|
||||||
|
|
||||||
private Vector spawnSize = null;
|
private Vector spawnSize = null;
|
||||||
private ParticleData particleData;
|
private ParticleData particleData;
|
||||||
private List<Particle> activeParticles = new ArrayList<>();
|
private List<Particle> activeParticles = new ArrayList<>();
|
||||||
private List<Particle> inactiveParticles = new ArrayList<>();
|
private List<Particle> inactiveParticles = new ArrayList<>();
|
||||||
private Lock activeParticleLock = new Lock();
|
private Lock activeParticleLock = new Lock();
|
||||||
|
|
||||||
public ParticleSource(Vector position, ParticleEffect effect) {
|
public ParticleSource(Vector position, ParticleEffect effect) {
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.effect = effect;
|
this.effect = effect;
|
||||||
random = effect.getRandom();
|
random = effect.getRandom();
|
||||||
effect.addSource(this);
|
effect.addSource(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
alife = true;
|
alife = true;
|
||||||
if (!delayManuallySet)
|
if (!delayManuallySet)
|
||||||
currentDelay = effect.getDelay().createValue(random, 0);
|
currentDelay = effect.getDelay().createValue(random, 0);
|
||||||
maxTime = effect.getDuration().createValue(random, 0) + currentDelay;
|
maxTime = effect.getDuration().createValue(random, 0) + currentDelay;
|
||||||
passedTime = 0;
|
passedTime = 0;
|
||||||
emittPause = calcEmittPause();
|
emittPause = calcEmittPause();
|
||||||
passedEmittPause = 0;
|
passedEmittPause = 0;
|
||||||
passedSecond = 0;
|
passedSecond = 0;
|
||||||
lifePercent = 0;
|
lifePercent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(Timer timer) {
|
public void update(Timer timer) {
|
||||||
if (alife) {
|
if (alife) {
|
||||||
passedTime += timer.getFrameTimeMilliseconds();
|
passedTime += timer.getFrameTimeMilliseconds();
|
||||||
lifePercent = passedTime / maxTime;
|
lifePercent = passedTime / maxTime;
|
||||||
|
|
||||||
if (passedTime >= currentDelay) {
|
if (passedTime >= currentDelay) {
|
||||||
passedEmittPause += timer.getFrameTimeMilliseconds();
|
passedEmittPause += timer.getFrameTimeMilliseconds();
|
||||||
while (passedEmittPause >= emittPause) {
|
while (passedEmittPause >= emittPause) {
|
||||||
passedEmittPause -= emittPause;
|
passedEmittPause -= emittPause;
|
||||||
emitt();
|
emitt();
|
||||||
}
|
}
|
||||||
|
|
||||||
passedSecond += timer.getFrameTimeMilliseconds();
|
passedSecond += timer.getFrameTimeMilliseconds();
|
||||||
if (passedSecond >= 1000) {
|
if (passedSecond >= 1000) {
|
||||||
passedSecond -= 1000;
|
passedSecond -= 1000;
|
||||||
calcEmittPause();
|
calcEmittPause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (passedTime >= maxTime)
|
if (passedTime >= maxTime)
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
updateParticles(timer);
|
updateParticles(timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateParticles(Timer timer) {
|
private void updateParticles(Timer timer) {
|
||||||
activeParticleLock.lock();
|
activeParticleLock.lock();
|
||||||
Iterator<Particle> iter = activeParticles.iterator();
|
Iterator<Particle> iter = activeParticles.iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
Particle particle = iter.next();
|
Particle particle = iter.next();
|
||||||
particle.update(timer);
|
particle.update(timer);
|
||||||
if (!particle.isActive()) {
|
if (!particle.isActive()) {
|
||||||
inactiveParticles.add(particle);
|
inactiveParticles.add(particle);
|
||||||
iter.remove();
|
iter.remove();
|
||||||
} else {
|
} else {
|
||||||
particle.move(
|
particle.move(
|
||||||
new Vector(particle.getMovement()).mul(timer.getFrameTimeMilliseconds() / 1000));
|
new Vector(particle.getMovement()).mul(timer.getFrameTimeMilliseconds() / 1000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
activeParticleLock.unlock();
|
activeParticleLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void die() {
|
private void die() {
|
||||||
alife = false;
|
alife = false;
|
||||||
if (effect.getOptions().isContinuous())
|
if (effect.getOptions().isContinuous())
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void kill() {
|
public void kill() {
|
||||||
alife = false;
|
alife = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void emitt() {
|
public void emitt() {
|
||||||
if (particleData == null)
|
if (particleData == null)
|
||||||
particleData = effect.createParticleData();
|
particleData = effect.createParticleData();
|
||||||
float xOff = effect.getxOffset().createValue(random, 0) * ParticleSystem.TRANSFER_VALUE;
|
float xOff = effect.getxOffset().createValue(random, 0) * ParticleSystem.TRANSFER_VALUE;
|
||||||
float yOff = effect.getyOffset().createValue(random, 0) * ParticleSystem.TRANSFER_VALUE;
|
float yOff = effect.getyOffset().createValue(random, 0) * ParticleSystem.TRANSFER_VALUE;
|
||||||
if (effect.getSpawnShape() == SpawnShape.Shape.SQUARE || effect.getSpawnShape() == SpawnShape.Shape.LINE) {
|
if (effect.getSpawnShape() == SpawnShape.Shape.SQUARE || effect.getSpawnShape() == SpawnShape.Shape.LINE) {
|
||||||
float width, height;
|
float width, height;
|
||||||
if (spawnSize == null) {
|
if (spawnSize == null) {
|
||||||
width = effect.getSpawnWidth().getRange().createValue(random,
|
width = effect.getSpawnWidth().getRange().createValue(random,
|
||||||
effect.getSpawnWidth().getTimeline().getValueAtTime(lifePercent));
|
effect.getSpawnWidth().getTimeline().getValueAtTime(lifePercent));
|
||||||
height = effect.getSpawnHeight().getRange().createValue(random,
|
height = effect.getSpawnHeight().getRange().createValue(random,
|
||||||
effect.getSpawnHeight().getTimeline().getValueAtTime(lifePercent));
|
effect.getSpawnHeight().getTimeline().getValueAtTime(lifePercent));
|
||||||
} else {
|
} else {
|
||||||
width = spawnSize.getX() / ParticleSystem.TRANSFER_VALUE;
|
width = spawnSize.getX() / ParticleSystem.TRANSFER_VALUE;
|
||||||
height = spawnSize.getY() / ParticleSystem.TRANSFER_VALUE;
|
height = spawnSize.getY() / ParticleSystem.TRANSFER_VALUE;
|
||||||
}
|
}
|
||||||
xOff += (random.nextFloat() * width - width * 0.5f) * ParticleSystem.TRANSFER_VALUE;
|
xOff += (random.nextFloat() * width - width * 0.5f) * ParticleSystem.TRANSFER_VALUE;
|
||||||
yOff += (random.nextFloat() * height - height * 0.5f) * ParticleSystem.TRANSFER_VALUE;
|
yOff += (random.nextFloat() * height - height * 0.5f) * ParticleSystem.TRANSFER_VALUE;
|
||||||
}
|
}
|
||||||
setUpParticle(new Vector(position).translate(xOff, yOff));
|
setUpParticle(new Vector(position).translate(xOff, yOff));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpParticle(Vector position) {
|
private void setUpParticle(Vector position) {
|
||||||
Particle particle;
|
Particle particle;
|
||||||
if (inactiveParticles.size() > 0)
|
if (inactiveParticles.size() > 0)
|
||||||
particle = inactiveParticles.remove(0);
|
particle = inactiveParticles.remove(0);
|
||||||
else
|
else
|
||||||
particle = new Particle(random);
|
particle = new Particle(random);
|
||||||
|
|
||||||
particle.activate(position, effect.getLife().getTimeline().getValueAtTime(lifePercent),
|
particle.activate(position, effect.getLife().getTimeline().getValueAtTime(lifePercent),
|
||||||
particleData);
|
particleData);
|
||||||
activeParticleLock.lock();
|
activeParticleLock.lock();
|
||||||
activeParticles.add(particle);
|
activeParticles.add(particle);
|
||||||
activeParticleLock.unlock();
|
activeParticleLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
private float calcEmittPause() {
|
private float calcEmittPause() {
|
||||||
float emittedPerSecond = effect.getEmission().getRange().createValue(random,
|
float emittedPerSecond = effect.getEmission().getRange().createValue(random,
|
||||||
effect.getEmission().getTimeline().getValueAtTime(passedTime / maxTime));
|
effect.getEmission().getTimeline().getValueAtTime(passedTime / maxTime));
|
||||||
return 1000 / emittedPerSecond;
|
return 1000 / emittedPerSecond;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Lock getActiveParticleLock() {
|
public Lock getActiveParticleLock() {
|
||||||
return activeParticleLock;
|
return activeParticleLock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Particle> getActiveParticles() {
|
public List<Particle> getActiveParticles() {
|
||||||
return activeParticles;
|
return activeParticles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSpawnSize(Vector spawnSize) {
|
public void setSpawnSize(Vector spawnSize) {
|
||||||
this.spawnSize = spawnSize;
|
this.spawnSize = spawnSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPosition(Vector position) {
|
public void setPosition(Vector position) {
|
||||||
this.position = position;
|
this.position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector getPosition() {
|
public Vector getPosition() {
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDelayMS(float delay) {
|
public void setDelayMS(float delay) {
|
||||||
currentDelay = delay;
|
currentDelay = delay;
|
||||||
delayManuallySet = true;
|
delayManuallySet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,78 +1,78 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.particles;
|
package de.frajul.endlessroll.entities.particles;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import de.frajul.endlessroll.entities.textures.TextureLoader;
|
import de.frajul.endlessroll.entities.textures.TextureLoader;
|
||||||
import de.frajul.endlessroll.main.game.Timer;
|
import de.frajul.endlessroll.main.game.Timer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 02.08.2016.
|
* Created by Julian on 02.08.2016.
|
||||||
*/
|
*/
|
||||||
public class ParticleSystem {
|
public class ParticleSystem {
|
||||||
|
|
||||||
public static final float TRANSFER_VALUE = 0.002f;
|
public static final float TRANSFER_VALUE = 0.002f;
|
||||||
public final ParticleEffect stasis;
|
public final ParticleEffect stasis;
|
||||||
public final ParticleEffect testFire;
|
public final ParticleEffect testFire;
|
||||||
public final ParticleEffect colorChange;
|
public final ParticleEffect colorChange;
|
||||||
public final ParticleEffect explosion;
|
public final ParticleEffect explosion;
|
||||||
public final ParticleEffect magnet;
|
public final ParticleEffect magnet;
|
||||||
public final ParticleEffect starCollect;
|
public final ParticleEffect starCollect;
|
||||||
public final ParticleEffect energyCollect;
|
public final ParticleEffect energyCollect;
|
||||||
public final ParticleEffect firework;
|
public final ParticleEffect firework;
|
||||||
public final ParticleEffect superPower;
|
public final ParticleEffect superPower;
|
||||||
public final ParticleEffect snow;
|
public final ParticleEffect snow;
|
||||||
private ParticleEffect[] effects;
|
private ParticleEffect[] effects;
|
||||||
|
|
||||||
private TextureLoader textureLoader;
|
private TextureLoader textureLoader;
|
||||||
|
|
||||||
public ParticleSystem(Context context) throws Exception {
|
public ParticleSystem(Context context) throws Exception {
|
||||||
this.textureLoader = new TextureLoader(context);
|
this.textureLoader = new TextureLoader(context);
|
||||||
ParticleReader reader = new ParticleReader(context);
|
ParticleReader reader = new ParticleReader(context);
|
||||||
stasis = reader.read("particleEffects/stasis.pe");
|
stasis = reader.read("particleEffects/stasis.pe");
|
||||||
testFire = reader.read("particleEffects/test_fire.pe");
|
testFire = reader.read("particleEffects/test_fire.pe");
|
||||||
colorChange = reader.read("particleEffects/colorChange.pe");
|
colorChange = reader.read("particleEffects/colorChange.pe");
|
||||||
explosion = reader.read("particleEffects/explosion.pe");
|
explosion = reader.read("particleEffects/explosion.pe");
|
||||||
magnet = reader.read("particleEffects/magnet.pe");
|
magnet = reader.read("particleEffects/magnet.pe");
|
||||||
starCollect = reader.read("particleEffects/collectStar.pe");
|
starCollect = reader.read("particleEffects/collectStar.pe");
|
||||||
energyCollect = reader.read("particleEffects/collectEnergy.pe");
|
energyCollect = reader.read("particleEffects/collectEnergy.pe");
|
||||||
firework = reader.read("particleEffects/firework.pe");
|
firework = reader.read("particleEffects/firework.pe");
|
||||||
superPower = reader.read("particleEffects/superPower.pe");
|
superPower = reader.read("particleEffects/superPower.pe");
|
||||||
snow = reader.read("particleEffects/snow.pe");
|
snow = reader.read("particleEffects/snow.pe");
|
||||||
|
|
||||||
effects = new ParticleEffect[]{stasis, testFire, colorChange, explosion, magnet, starCollect, energyCollect, firework, superPower, snow};
|
effects = new ParticleEffect[]{stasis, testFire, colorChange, explosion, magnet, starCollect, energyCollect, firework, superPower, snow};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(Timer timer) {
|
public void update(Timer timer) {
|
||||||
synchronized (effects) {
|
synchronized (effects) {
|
||||||
for (ParticleEffect effect : effects)
|
for (ParticleEffect effect : effects)
|
||||||
effect.update(timer);
|
effect.update(timer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadTextures() throws Exception {
|
public void loadTextures() throws Exception {
|
||||||
synchronized (effects) {
|
synchronized (effects) {
|
||||||
for (ParticleEffect effect : effects)
|
for (ParticleEffect effect : effects)
|
||||||
effect.setTexture(
|
effect.setTexture(
|
||||||
textureLoader.loadTexture("particleEffects/" + effect.getTextureName()));
|
textureLoader.loadTexture("particleEffects/" + effect.getTextureName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteAllSources() {
|
public void deleteAllSources() {
|
||||||
synchronized (effects) {
|
synchronized (effects) {
|
||||||
for (ParticleEffect effect : effects) {
|
for (ParticleEffect effect : effects) {
|
||||||
effect.deleteSources();
|
effect.deleteSources();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized ParticleEffect[] getEffects() {
|
public synchronized ParticleEffect[] getEffects() {
|
||||||
return effects;
|
return effects;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,40 +1,40 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.particles.attributes;
|
package de.frajul.endlessroll.entities.particles.attributes;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.ParticleAttributeValue;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.ParticleAttributeValue;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.ParticleAttributeValueType;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.ParticleAttributeValueType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 02.08.2016.
|
* Created by Julian on 02.08.2016.
|
||||||
*/
|
*/
|
||||||
public class Attribute {
|
public class Attribute {
|
||||||
|
|
||||||
private ParticleAttributeType type;
|
private ParticleAttributeType type;
|
||||||
private List<ParticleAttributeValue> values = new ArrayList<>();
|
private List<ParticleAttributeValue> values = new ArrayList<>();
|
||||||
|
|
||||||
public Attribute(ParticleAttributeType type, ParticleAttributeValueType... valueTypes) {
|
public Attribute(ParticleAttributeType type, ParticleAttributeValueType... valueTypes) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
for (ParticleAttributeValueType valueType : valueTypes)
|
for (ParticleAttributeValueType valueType : valueTypes)
|
||||||
values.add(valueType.createInstance());
|
values.add(valueType.createInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParticleAttributeValue get(ParticleAttributeValueType valueType) throws Exception {
|
public ParticleAttributeValue get(ParticleAttributeValueType valueType) throws Exception {
|
||||||
for (ParticleAttributeValue v : values)
|
for (ParticleAttributeValue v : values)
|
||||||
if (v.getType() == valueType)
|
if (v.getType() == valueType)
|
||||||
return v;
|
return v;
|
||||||
throw new Exception("ParticleAttributeValue with type: " + valueType + " does not exist in Attribute " + type);
|
throw new Exception("ParticleAttributeValue with type: " + valueType + " does not exist in Attribute " + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParticleAttributeType getType() {
|
public ParticleAttributeType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,84 +1,84 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.particles.attributes;
|
package de.frajul.endlessroll.entities.particles.attributes;
|
||||||
|
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.ImagePath;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.ImagePath;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Options;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Options;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.ParticleAttributeValueType;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.ParticleAttributeValueType;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Range;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Range;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.SpawnShape;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.SpawnShape;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Timeline;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.Timeline;
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.TintTimeline;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.TintTimeline;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 02.08.2016.
|
* Created by Julian on 02.08.2016.
|
||||||
*/
|
*/
|
||||||
public class AttributeValueReader {
|
public class AttributeValueReader {
|
||||||
|
|
||||||
public void addValueForAttribute(Attribute attribute, String line) throws Exception {
|
public void addValueForAttribute(Attribute attribute, String line) throws Exception {
|
||||||
//RANGE
|
//RANGE
|
||||||
if (line.startsWith("lowMin:") || line.startsWith("min:"))
|
if (line.startsWith("lowMin:") || line.startsWith("min:"))
|
||||||
((Range) attribute.get(ParticleAttributeValueType.RANGE)).setLowMin(parseFloat(line));
|
((Range) attribute.get(ParticleAttributeValueType.RANGE)).setLowMin(parseFloat(line));
|
||||||
else if (line.startsWith("lowMax:") || line.startsWith("max:"))
|
else if (line.startsWith("lowMax:") || line.startsWith("max:"))
|
||||||
((Range) attribute.get(ParticleAttributeValueType.RANGE)).setLowMax(parseFloat(line));
|
((Range) attribute.get(ParticleAttributeValueType.RANGE)).setLowMax(parseFloat(line));
|
||||||
else if (line.startsWith("highMin:"))
|
else if (line.startsWith("highMin:"))
|
||||||
((Range) attribute.get(ParticleAttributeValueType.RANGE)).setHighMin(parseFloat(line));
|
((Range) attribute.get(ParticleAttributeValueType.RANGE)).setHighMin(parseFloat(line));
|
||||||
else if (line.startsWith("highMax:"))
|
else if (line.startsWith("highMax:"))
|
||||||
((Range) attribute.get(ParticleAttributeValueType.RANGE)).setHighMax(parseFloat(line));
|
((Range) attribute.get(ParticleAttributeValueType.RANGE)).setHighMax(parseFloat(line));
|
||||||
//TIMELINE
|
//TIMELINE
|
||||||
else if (!line.startsWith("scalingCount") && line.startsWith("scaling"))
|
else if (!line.startsWith("scalingCount") && line.startsWith("scaling"))
|
||||||
((Timeline) attribute.get(ParticleAttributeValueType.TIMELINE)).setValueOfPoint(parseTimeLineIndex("scaling", line), parseFloat(line));
|
((Timeline) attribute.get(ParticleAttributeValueType.TIMELINE)).setValueOfPoint(parseTimeLineIndex("scaling", line), parseFloat(line));
|
||||||
else if (!line.startsWith("timelineCount") && line.startsWith("timeline") && attribute.getType() != ParticleAttributeType.TINT)
|
else if (!line.startsWith("timelineCount") && line.startsWith("timeline") && attribute.getType() != ParticleAttributeType.TINT)
|
||||||
((Timeline) attribute.get(ParticleAttributeValueType.TIMELINE)).setTimeOfPoint(parseTimeLineIndex("timeline", line), parseFloat(line));
|
((Timeline) attribute.get(ParticleAttributeValueType.TIMELINE)).setTimeOfPoint(parseTimeLineIndex("timeline", line), parseFloat(line));
|
||||||
//TINT_TIMELINE
|
//TINT_TIMELINE
|
||||||
else if (!line.startsWith("colorsCount") && line.startsWith("colors")) {
|
else if (!line.startsWith("colorsCount") && line.startsWith("colors")) {
|
||||||
int index = parseTimeLineIndex("colors", line);
|
int index = parseTimeLineIndex("colors", line);
|
||||||
((TintTimeline) attribute.get(ParticleAttributeValueType.TINT_TIMELINE)).setValueOfPoint((int) (index / 3f), index % 3, parseFloat(line));
|
((TintTimeline) attribute.get(ParticleAttributeValueType.TINT_TIMELINE)).setValueOfPoint((int) (index / 3f), index % 3, parseFloat(line));
|
||||||
} else if (!line.startsWith("timelineCount") && line.startsWith("timeline") && attribute.getType() == ParticleAttributeType.TINT)
|
} else if (!line.startsWith("timelineCount") && line.startsWith("timeline") && attribute.getType() == ParticleAttributeType.TINT)
|
||||||
((TintTimeline) attribute.get(ParticleAttributeValueType.TINT_TIMELINE)).setTimeOfPoint(parseTimeLineIndex("timeline", line), parseFloat(line));
|
((TintTimeline) attribute.get(ParticleAttributeValueType.TINT_TIMELINE)).setTimeOfPoint(parseTimeLineIndex("timeline", line), parseFloat(line));
|
||||||
//SPAWN_SHAPE
|
//SPAWN_SHAPE
|
||||||
else if (line.startsWith("shape:"))
|
else if (line.startsWith("shape:"))
|
||||||
((SpawnShape) attribute.get(ParticleAttributeValueType.SPAWN_SHAPE)).setShape(SpawnShape.Shape.byName(parseString(line)));
|
((SpawnShape) attribute.get(ParticleAttributeValueType.SPAWN_SHAPE)).setShape(SpawnShape.Shape.byName(parseString(line)));
|
||||||
//OPTIONS
|
//OPTIONS
|
||||||
else if (line.startsWith("attached:"))
|
else if (line.startsWith("attached:"))
|
||||||
((Options) attribute.get(ParticleAttributeValueType.OPTIONS)).setAttached(parseBoolean(line));
|
((Options) attribute.get(ParticleAttributeValueType.OPTIONS)).setAttached(parseBoolean(line));
|
||||||
else if (line.startsWith("continuous:"))
|
else if (line.startsWith("continuous:"))
|
||||||
((Options) attribute.get(ParticleAttributeValueType.OPTIONS)).setContinuous(parseBoolean(line));
|
((Options) attribute.get(ParticleAttributeValueType.OPTIONS)).setContinuous(parseBoolean(line));
|
||||||
else if (line.startsWith("aligned:"))
|
else if (line.startsWith("aligned:"))
|
||||||
((Options) attribute.get(ParticleAttributeValueType.OPTIONS)).setAligned(parseBoolean(line));
|
((Options) attribute.get(ParticleAttributeValueType.OPTIONS)).setAligned(parseBoolean(line));
|
||||||
else if (line.startsWith("additive:"))
|
else if (line.startsWith("additive:"))
|
||||||
((Options) attribute.get(ParticleAttributeValueType.OPTIONS)).setAdditive(parseBoolean(line));
|
((Options) attribute.get(ParticleAttributeValueType.OPTIONS)).setAdditive(parseBoolean(line));
|
||||||
else if (line.startsWith("behind:"))
|
else if (line.startsWith("behind:"))
|
||||||
((Options) attribute.get(ParticleAttributeValueType.OPTIONS)).setBehind(parseBoolean(line));
|
((Options) attribute.get(ParticleAttributeValueType.OPTIONS)).setBehind(parseBoolean(line));
|
||||||
else if (line.startsWith("premultipliedAlpha:"))
|
else if (line.startsWith("premultipliedAlpha:"))
|
||||||
((Options) attribute.get(ParticleAttributeValueType.OPTIONS)).setPremultipliedAlpha(parseBoolean(line));
|
((Options) attribute.get(ParticleAttributeValueType.OPTIONS)).setPremultipliedAlpha(parseBoolean(line));
|
||||||
//IMAGE PATH
|
//IMAGE PATH
|
||||||
else if (attribute.getType() == ParticleAttributeType.IMAGE_PATH)
|
else if (attribute.getType() == ParticleAttributeType.IMAGE_PATH)
|
||||||
((ImagePath) attribute.get(ParticleAttributeValueType.IMAGE_PATH)).setImagePath(line);
|
((ImagePath) attribute.get(ParticleAttributeValueType.IMAGE_PATH)).setImagePath(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int parseTimeLineIndex(String start, String line) {
|
private int parseTimeLineIndex(String start, String line) {
|
||||||
String asString = line.split(start)[1].split(":")[0];
|
String asString = line.split(start)[1].split(":")[0];
|
||||||
return Integer.parseInt(asString);
|
return Integer.parseInt(asString);
|
||||||
}
|
}
|
||||||
|
|
||||||
private float parseFloat(String line) {
|
private float parseFloat(String line) {
|
||||||
String asString = line.split(" ")[1];
|
String asString = line.split(" ")[1];
|
||||||
return Float.parseFloat(asString);
|
return Float.parseFloat(asString);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String parseString(String line) {
|
private String parseString(String line) {
|
||||||
return line.split(" ")[1];
|
return line.split(" ")[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean parseBoolean(String line) {
|
private boolean parseBoolean(String line) {
|
||||||
String asString = line.split(" ")[1];
|
String asString = line.split(" ")[1];
|
||||||
return Boolean.parseBoolean(asString);
|
return Boolean.parseBoolean(asString);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,62 +1,62 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.particles.attributes;
|
package de.frajul.endlessroll.entities.particles.attributes;
|
||||||
|
|
||||||
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.ParticleAttributeValueType;
|
import de.frajul.endlessroll.entities.particles.attributes.attributeValues.ParticleAttributeValueType;
|
||||||
|
|
||||||
public enum ParticleAttributeType {
|
public enum ParticleAttributeType {
|
||||||
NONE(""),
|
NONE(""),
|
||||||
DELAY("Delay", ParticleAttributeValueType.RANGE),
|
DELAY("Delay", ParticleAttributeValueType.RANGE),
|
||||||
DURATION("Duration", ParticleAttributeValueType.RANGE),
|
DURATION("Duration", ParticleAttributeValueType.RANGE),
|
||||||
COUNT("Count", ParticleAttributeValueType.RANGE),
|
COUNT("Count", ParticleAttributeValueType.RANGE),
|
||||||
EMISSION("Emission", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
EMISSION("Emission", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
||||||
LIFE("Life", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
LIFE("Life", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
||||||
LIFE_OFFSET("Life Offset", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
LIFE_OFFSET("Life Offset", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
||||||
X_OFFSET("X Offset", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
X_OFFSET("X Offset", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
||||||
Y_OFFSET("Y Offset", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
Y_OFFSET("Y Offset", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
||||||
SPAWN_SHAPE("Spawn Shape", ParticleAttributeValueType.SPAWN_SHAPE),
|
SPAWN_SHAPE("Spawn Shape", ParticleAttributeValueType.SPAWN_SHAPE),
|
||||||
SPAWN_WIDTH("Spawn Width", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
SPAWN_WIDTH("Spawn Width", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
||||||
SPAWN_HEIGHT("Spawn Height", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
SPAWN_HEIGHT("Spawn Height", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
||||||
SCALE("Scale", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
SCALE("Scale", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
||||||
VELOCITY("Velocity", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
VELOCITY("Velocity", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
||||||
ANGLE("Angle", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
ANGLE("Angle", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
||||||
ROTATION("Rotation", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
ROTATION("Rotation", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
||||||
WIND("Wind", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
WIND("Wind", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
||||||
GRAVITY("Gravity", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
GRAVITY("Gravity", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
||||||
TINT("Tint", ParticleAttributeValueType.TINT_TIMELINE),
|
TINT("Tint", ParticleAttributeValueType.TINT_TIMELINE),
|
||||||
TRANSPARENCY("Transparency", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
TRANSPARENCY("Transparency", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
|
||||||
OPTIONS("Options", ParticleAttributeValueType.OPTIONS),
|
OPTIONS("Options", ParticleAttributeValueType.OPTIONS),
|
||||||
IMAGE_PATH("Image Path", ParticleAttributeValueType.IMAGE_PATH);
|
IMAGE_PATH("Image Path", ParticleAttributeValueType.IMAGE_PATH);
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private ParticleAttributeValueType[] valueTypes;
|
private ParticleAttributeValueType[] valueTypes;
|
||||||
|
|
||||||
ParticleAttributeType(String name, ParticleAttributeValueType... valueTypes) {
|
ParticleAttributeType(String name, ParticleAttributeValueType... valueTypes) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.valueTypes = valueTypes;
|
this.valueTypes = valueTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getInFileTitle() {
|
private String getInFileTitle() {
|
||||||
return "- " + name + " -";
|
return "- " + name + " -";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ParticleAttributeType getByInFileTitle(String title) throws Exception {
|
public static ParticleAttributeType getByInFileTitle(String title) throws Exception {
|
||||||
for (ParticleAttributeType setting : values()) {
|
for (ParticleAttributeType setting : values()) {
|
||||||
if (setting != NONE && setting.getInFileTitle().equals(title))
|
if (setting != NONE && setting.getInFileTitle().equals(title))
|
||||||
return setting;
|
return setting;
|
||||||
}
|
}
|
||||||
throw new Exception("Could not find ParticleAttributeType by title: " + title);
|
throw new Exception("Could not find ParticleAttributeType by title: " + title);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Attribute createInstance() throws Exception {
|
public Attribute createInstance() throws Exception {
|
||||||
if (this == NONE)
|
if (this == NONE)
|
||||||
throw new Exception("Cannot create Instance from Attribute NONE");
|
throw new Exception("Cannot create Instance from Attribute NONE");
|
||||||
return new Attribute(this, valueTypes);
|
return new Attribute(this, valueTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,28 +1,28 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.particles.attributes.attributeValues;
|
package de.frajul.endlessroll.entities.particles.attributes.attributeValues;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 02.08.2016.
|
* Created by Julian on 02.08.2016.
|
||||||
*/
|
*/
|
||||||
public class ImagePath extends ParticleAttributeValue {
|
public class ImagePath extends ParticleAttributeValue {
|
||||||
|
|
||||||
private String imagePath;
|
private String imagePath;
|
||||||
|
|
||||||
public ImagePath() {
|
public ImagePath() {
|
||||||
super(ParticleAttributeValueType.IMAGE_PATH);
|
super(ParticleAttributeValueType.IMAGE_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getImagePath() {
|
public String getImagePath() {
|
||||||
return imagePath;
|
return imagePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setImagePath(String imagePath) {
|
public void setImagePath(String imagePath) {
|
||||||
this.imagePath = imagePath;
|
this.imagePath = imagePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,73 +1,73 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.particles.attributes.attributeValues;
|
package de.frajul.endlessroll.entities.particles.attributes.attributeValues;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 02.08.2016.
|
* Created by Julian on 02.08.2016.
|
||||||
*/
|
*/
|
||||||
public class Options extends ParticleAttributeValue {
|
public class Options extends ParticleAttributeValue {
|
||||||
|
|
||||||
private boolean attached;
|
private boolean attached;
|
||||||
private boolean continuous;
|
private boolean continuous;
|
||||||
private boolean aligned;
|
private boolean aligned;
|
||||||
private boolean additive;
|
private boolean additive;
|
||||||
private boolean behind;
|
private boolean behind;
|
||||||
private boolean premultipliedAlpha;
|
private boolean premultipliedAlpha;
|
||||||
|
|
||||||
public Options() {
|
public Options() {
|
||||||
super(ParticleAttributeValueType.OPTIONS);
|
super(ParticleAttributeValueType.OPTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAttached() {
|
public boolean isAttached() {
|
||||||
return attached;
|
return attached;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAttached(boolean attached) {
|
public void setAttached(boolean attached) {
|
||||||
this.attached = attached;
|
this.attached = attached;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isContinuous() {
|
public boolean isContinuous() {
|
||||||
return continuous;
|
return continuous;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setContinuous(boolean continuous) {
|
public void setContinuous(boolean continuous) {
|
||||||
this.continuous = continuous;
|
this.continuous = continuous;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAligned() {
|
public boolean isAligned() {
|
||||||
return aligned;
|
return aligned;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAligned(boolean aligned) {
|
public void setAligned(boolean aligned) {
|
||||||
this.aligned = aligned;
|
this.aligned = aligned;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAdditive() {
|
public boolean isAdditive() {
|
||||||
return additive;
|
return additive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAdditive(boolean additive) {
|
public void setAdditive(boolean additive) {
|
||||||
this.additive = additive;
|
this.additive = additive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBehind() {
|
public boolean isBehind() {
|
||||||
return behind;
|
return behind;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBehind(boolean behind) {
|
public void setBehind(boolean behind) {
|
||||||
this.behind = behind;
|
this.behind = behind;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPremultipliedAlpha() {
|
public boolean isPremultipliedAlpha() {
|
||||||
return premultipliedAlpha;
|
return premultipliedAlpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPremultipliedAlpha(boolean premultipliedAlpha) {
|
public void setPremultipliedAlpha(boolean premultipliedAlpha) {
|
||||||
this.premultipliedAlpha = premultipliedAlpha;
|
this.premultipliedAlpha = premultipliedAlpha;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.particles.attributes.attributeValues;
|
package de.frajul.endlessroll.entities.particles.attributes.attributeValues;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 02.08.2016.
|
* Created by Julian on 02.08.2016.
|
||||||
*/
|
*/
|
||||||
public abstract class ParticleAttributeValue {
|
public abstract class ParticleAttributeValue {
|
||||||
|
|
||||||
private ParticleAttributeValueType type;
|
private ParticleAttributeValueType type;
|
||||||
|
|
||||||
public ParticleAttributeValue(ParticleAttributeValueType type) {
|
public ParticleAttributeValue(ParticleAttributeValueType type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParticleAttributeValueType getType() {
|
public ParticleAttributeValueType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,35 +1,35 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.particles.attributes.attributeValues;
|
package de.frajul.endlessroll.entities.particles.attributes.attributeValues;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 02.08.2016.
|
* Created by Julian on 02.08.2016.
|
||||||
*/
|
*/
|
||||||
public enum ParticleAttributeValueType {
|
public enum ParticleAttributeValueType {
|
||||||
|
|
||||||
RANGE, TIMELINE, TINT_TIMELINE, SPAWN_SHAPE, OPTIONS, IMAGE_PATH;
|
RANGE, TIMELINE, TINT_TIMELINE, SPAWN_SHAPE, OPTIONS, IMAGE_PATH;
|
||||||
|
|
||||||
public ParticleAttributeValue createInstance() {
|
public ParticleAttributeValue createInstance() {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case RANGE:
|
case RANGE:
|
||||||
return new Range();
|
return new Range();
|
||||||
case TIMELINE:
|
case TIMELINE:
|
||||||
return new Timeline();
|
return new Timeline();
|
||||||
case TINT_TIMELINE:
|
case TINT_TIMELINE:
|
||||||
return new TintTimeline();
|
return new TintTimeline();
|
||||||
case SPAWN_SHAPE:
|
case SPAWN_SHAPE:
|
||||||
return new SpawnShape();
|
return new SpawnShape();
|
||||||
case OPTIONS:
|
case OPTIONS:
|
||||||
return new Options();
|
return new Options();
|
||||||
case IMAGE_PATH:
|
case IMAGE_PATH:
|
||||||
return new ImagePath();
|
return new ImagePath();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,89 +1,89 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.particles.attributes.attributeValues;
|
package de.frajul.endlessroll.entities.particles.attributes.attributeValues;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 02.08.2016.
|
* Created by Julian on 02.08.2016.
|
||||||
*/
|
*/
|
||||||
public class Range extends ParticleAttributeValue {
|
public class Range extends ParticleAttributeValue {
|
||||||
|
|
||||||
private float lowMin;
|
private float lowMin;
|
||||||
private float lowMax;
|
private float lowMax;
|
||||||
private float highMin;
|
private float highMin;
|
||||||
private float highMax;
|
private float highMax;
|
||||||
|
|
||||||
public Range() {
|
public Range() {
|
||||||
super(ParticleAttributeValueType.RANGE);
|
super(ParticleAttributeValueType.RANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Range createNormalizedInstance(Random random) {
|
public Range createNormalizedInstance(Random random) {
|
||||||
Range range = new Range();
|
Range range = new Range();
|
||||||
float high = createHighValue(random);
|
float high = createHighValue(random);
|
||||||
range.setHighMax(high);
|
range.setHighMax(high);
|
||||||
range.setHighMin(high);
|
range.setHighMin(high);
|
||||||
float low = createLowValue(random);
|
float low = createLowValue(random);
|
||||||
range.setLowMax(low);
|
range.setLowMax(low);
|
||||||
range.setLowMin(low);
|
range.setLowMin(low);
|
||||||
return range;
|
return range;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float createValue(Random random, float mix) {
|
public float createValue(Random random, float mix) {
|
||||||
if (mix == 1)
|
if (mix == 1)
|
||||||
return createHighValue(random);
|
return createHighValue(random);
|
||||||
else if (mix == 0)
|
else if (mix == 0)
|
||||||
return createLowValue(random);
|
return createLowValue(random);
|
||||||
else {
|
else {
|
||||||
float highValue = createHighValue(random);
|
float highValue = createHighValue(random);
|
||||||
float lowValue = createLowValue(random);
|
float lowValue = createLowValue(random);
|
||||||
return mix * (highValue - lowValue) + lowValue;
|
return mix * (highValue - lowValue) + lowValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private float createHighValue(Random random) {
|
private float createHighValue(Random random) {
|
||||||
float min = highMin;
|
float min = highMin;
|
||||||
float max = highMax;
|
float max = highMax;
|
||||||
if (min == max)
|
if (min == max)
|
||||||
return min;
|
return min;
|
||||||
return random.nextFloat() * (max - min) + min;
|
return random.nextFloat() * (max - min) + min;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float createLowValue(Random random) {
|
private float createLowValue(Random random) {
|
||||||
float min = lowMin;
|
float min = lowMin;
|
||||||
float max = lowMax;
|
float max = lowMax;
|
||||||
if (min == max)
|
if (min == max)
|
||||||
return min;
|
return min;
|
||||||
return random.nextFloat() * (max - min) + min;
|
return random.nextFloat() * (max - min) + min;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLowMin(float lowMin) {
|
public void setLowMin(float lowMin) {
|
||||||
this.lowMin = lowMin;
|
this.lowMin = lowMin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLowMax(float lowMax) {
|
public void setLowMax(float lowMax) {
|
||||||
this.lowMax = lowMax;
|
this.lowMax = lowMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHighMin(float highMin) {
|
public void setHighMin(float highMin) {
|
||||||
this.highMin = highMin;
|
this.highMin = highMin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHighMax(float highMax) {
|
public void setHighMax(float highMax) {
|
||||||
this.highMax = highMax;
|
this.highMax = highMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isLowDifference() {
|
private boolean isLowDifference() {
|
||||||
return lowMin - lowMax != 0;
|
return lowMin - lowMax != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isHighDifference() {
|
private boolean isHighDifference() {
|
||||||
return highMin - highMax != 0;
|
return highMin - highMax != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,45 +1,45 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.particles.attributes.attributeValues;
|
package de.frajul.endlessroll.entities.particles.attributes.attributeValues;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 02.08.2016.
|
* Created by Julian on 02.08.2016.
|
||||||
*/
|
*/
|
||||||
public class SpawnShape extends ParticleAttributeValue {
|
public class SpawnShape extends ParticleAttributeValue {
|
||||||
|
|
||||||
public enum Shape {
|
public enum Shape {
|
||||||
POINT("point"), SQUARE("square"), LINE("line");
|
POINT("point"), SQUARE("square"), LINE("line");
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
Shape(String name) {
|
Shape(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Shape byName(String text) throws Exception {
|
public static Shape byName(String text) throws Exception {
|
||||||
for (Shape shape : values())
|
for (Shape shape : values())
|
||||||
if (shape.name.equals(text))
|
if (shape.name.equals(text))
|
||||||
return shape;
|
return shape;
|
||||||
throw new Exception("spawnShape with name \"" + text + "\" does not exist");
|
throw new Exception("spawnShape with name \"" + text + "\" does not exist");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Shape shape;
|
private Shape shape;
|
||||||
|
|
||||||
public SpawnShape() {
|
public SpawnShape() {
|
||||||
super(ParticleAttributeValueType.SPAWN_SHAPE);
|
super(ParticleAttributeValueType.SPAWN_SHAPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Shape getShape() {
|
public Shape getShape() {
|
||||||
return shape;
|
return shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShape(Shape shape) {
|
public void setShape(Shape shape) {
|
||||||
this.shape = shape;
|
this.shape = shape;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,61 +1,61 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.particles.attributes.attributeValues;
|
package de.frajul.endlessroll.entities.particles.attributes.attributeValues;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 02.08.2016.
|
* Created by Julian on 02.08.2016.
|
||||||
*/
|
*/
|
||||||
public class Timeline extends ParticleAttributeValue {
|
public class Timeline extends ParticleAttributeValue {
|
||||||
|
|
||||||
private List<TimelinePoint> points = new ArrayList<>();
|
private List<TimelinePoint> points = new ArrayList<>();
|
||||||
|
|
||||||
public Timeline() {
|
public Timeline() {
|
||||||
super(ParticleAttributeValueType.TIMELINE);
|
super(ParticleAttributeValueType.TIMELINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValueOfPoint(int index, float value) {
|
public void setValueOfPoint(int index, float value) {
|
||||||
if (points.size() <= index) {
|
if (points.size() <= index) {
|
||||||
points.add(new TimelinePoint());
|
points.add(new TimelinePoint());
|
||||||
}
|
}
|
||||||
points.get(index).setValue(value);
|
points.get(index).setValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTimeOfPoint(int index, float time) {
|
public void setTimeOfPoint(int index, float time) {
|
||||||
if (points.size() <= index) {
|
if (points.size() <= index) {
|
||||||
points.add(new TimelinePoint());
|
points.add(new TimelinePoint());
|
||||||
}
|
}
|
||||||
points.get(index).setTime(time);
|
points.get(index).setTime(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getValueAtTime(float time) {
|
public float getValueAtTime(float time) {
|
||||||
TimelinePoint left = null, right = null;
|
TimelinePoint left = null, right = null;
|
||||||
for (TimelinePoint point : points) {
|
for (TimelinePoint point : points) {
|
||||||
if (point.getTime() <= time) {
|
if (point.getTime() <= time) {
|
||||||
if (left == null || left.getTime() < point.getTime())
|
if (left == null || left.getTime() < point.getTime())
|
||||||
left = point;
|
left = point;
|
||||||
} else if (right == null || right.getTime() > point.getTime())
|
} else if (right == null || right.getTime() > point.getTime())
|
||||||
right = point;
|
right = point;
|
||||||
}
|
}
|
||||||
if (left != null) {
|
if (left != null) {
|
||||||
if (right != null) {
|
if (right != null) {
|
||||||
float leftDist = Math.abs(left.getTime() - time);
|
float leftDist = Math.abs(left.getTime() - time);
|
||||||
float rightDist = Math.abs(right.getTime() - time);
|
float rightDist = Math.abs(right.getTime() - time);
|
||||||
float totalDist = leftDist + rightDist;
|
float totalDist = leftDist + rightDist;
|
||||||
float leftMultiplier = 1 - (leftDist / totalDist);
|
float leftMultiplier = 1 - (leftDist / totalDist);
|
||||||
float rightMultiplier = 1 - (rightDist / totalDist);
|
float rightMultiplier = 1 - (rightDist / totalDist);
|
||||||
return left.getValue() * leftMultiplier + right.getValue() * rightMultiplier;
|
return left.getValue() * leftMultiplier + right.getValue() * rightMultiplier;
|
||||||
}
|
}
|
||||||
return left.getValue();
|
return left.getValue();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,30 +1,30 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.particles.attributes.attributeValues;
|
package de.frajul.endlessroll.entities.particles.attributes.attributeValues;
|
||||||
|
|
||||||
public class TimelinePoint {
|
public class TimelinePoint {
|
||||||
|
|
||||||
private float time, value;
|
private float time, value;
|
||||||
|
|
||||||
public float getTime() {
|
public float getTime() {
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTime(float time) {
|
public void setTime(float time) {
|
||||||
this.time = time;
|
this.time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getValue() {
|
public float getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValue(float value) {
|
public void setValue(float value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,38 +1,38 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.particles.attributes.attributeValues;
|
package de.frajul.endlessroll.entities.particles.attributes.attributeValues;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 02.08.2016.
|
* Created by Julian on 02.08.2016.
|
||||||
*/
|
*/
|
||||||
public class TimelineRange {
|
public class TimelineRange {
|
||||||
|
|
||||||
private Timeline timeline;
|
private Timeline timeline;
|
||||||
private Range range;
|
private Range range;
|
||||||
|
|
||||||
public TimelineRange(Timeline timeline, Range range) {
|
public TimelineRange(Timeline timeline, Range range) {
|
||||||
this.timeline = timeline;
|
this.timeline = timeline;
|
||||||
this.range = range;
|
this.range = range;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Timeline getTimeline() {
|
public Timeline getTimeline() {
|
||||||
return timeline;
|
return timeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTimeline(Timeline timeline) {
|
public void setTimeline(Timeline timeline) {
|
||||||
this.timeline = timeline;
|
this.timeline = timeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Range getRange() {
|
public Range getRange() {
|
||||||
return range;
|
return range;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRange(Range range) {
|
public void setRange(Range range) {
|
||||||
this.range = range;
|
this.range = range;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,64 +1,64 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.particles.attributes.attributeValues;
|
package de.frajul.endlessroll.entities.particles.attributes.attributeValues;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Color3f;
|
import de.frajul.endlessroll.data.Color3f;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 02.08.2016.
|
* Created by Julian on 02.08.2016.
|
||||||
*/
|
*/
|
||||||
public class TintTimeline extends ParticleAttributeValue {
|
public class TintTimeline extends ParticleAttributeValue {
|
||||||
|
|
||||||
private List<TintTimelinePoint> points = new ArrayList<>();
|
private List<TintTimelinePoint> points = new ArrayList<>();
|
||||||
|
|
||||||
public TintTimeline() {
|
public TintTimeline() {
|
||||||
super(ParticleAttributeValueType.TINT_TIMELINE);
|
super(ParticleAttributeValueType.TINT_TIMELINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValueOfPoint(int index, int colorIndex, float value) {
|
public void setValueOfPoint(int index, int colorIndex, float value) {
|
||||||
if (points.size() <= index) {
|
if (points.size() <= index) {
|
||||||
points.add(new TintTimelinePoint());
|
points.add(new TintTimelinePoint());
|
||||||
}
|
}
|
||||||
points.get(index).setValue(colorIndex, value);
|
points.get(index).setValue(colorIndex, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTimeOfPoint(int index, float time) {
|
public void setTimeOfPoint(int index, float time) {
|
||||||
if (points.size() <= index) {
|
if (points.size() <= index) {
|
||||||
points.add(new TintTimelinePoint());
|
points.add(new TintTimelinePoint());
|
||||||
}
|
}
|
||||||
points.get(index).setTime(time);
|
points.get(index).setTime(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color3f getValueAtTime(float time) {
|
public Color3f getValueAtTime(float time) {
|
||||||
TintTimelinePoint left = null, right = null;
|
TintTimelinePoint left = null, right = null;
|
||||||
for (TintTimelinePoint point : points) {
|
for (TintTimelinePoint point : points) {
|
||||||
if (point.getTime() <= time) {
|
if (point.getTime() <= time) {
|
||||||
if (left == null || left.getTime() < point.getTime())
|
if (left == null || left.getTime() < point.getTime())
|
||||||
left = point;
|
left = point;
|
||||||
} else if (right == null || right.getTime() > point.getTime())
|
} else if (right == null || right.getTime() > point.getTime())
|
||||||
right = point;
|
right = point;
|
||||||
}
|
}
|
||||||
if (left != null) {
|
if (left != null) {
|
||||||
if (right != null) {
|
if (right != null) {
|
||||||
float leftDist = Math.abs(left.getTime() - time);
|
float leftDist = Math.abs(left.getTime() - time);
|
||||||
float rightDist = Math.abs(right.getTime() - time);
|
float rightDist = Math.abs(right.getTime() - time);
|
||||||
float totalDist = leftDist + rightDist;
|
float totalDist = leftDist + rightDist;
|
||||||
float leftMultiplier = leftDist / totalDist;
|
float leftMultiplier = leftDist / totalDist;
|
||||||
float rightMultiplier = rightDist / totalDist;
|
float rightMultiplier = rightDist / totalDist;
|
||||||
|
|
||||||
return left.getColor().interpolate(leftMultiplier, rightMultiplier, right.getColor());
|
return left.getColor().interpolate(leftMultiplier, rightMultiplier, right.getColor());
|
||||||
}
|
}
|
||||||
return left.getColor();
|
return left.getColor();
|
||||||
}
|
}
|
||||||
return new Color3f();
|
return new Color3f();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,40 +1,40 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.particles.attributes.attributeValues;
|
package de.frajul.endlessroll.entities.particles.attributes.attributeValues;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Color3f;
|
import de.frajul.endlessroll.data.Color3f;
|
||||||
|
|
||||||
public class TintTimelinePoint {
|
public class TintTimelinePoint {
|
||||||
|
|
||||||
private float time;
|
private float time;
|
||||||
private Color3f color;
|
private Color3f color;
|
||||||
|
|
||||||
public float getTime() {
|
public float getTime() {
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTime(float time) {
|
public void setTime(float time) {
|
||||||
this.time = time;
|
this.time = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color3f getColor() {
|
public Color3f getColor() {
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValue(int colorIndex, float value) {
|
public void setValue(int colorIndex, float value) {
|
||||||
if (color == null)
|
if (color == null)
|
||||||
color = new Color3f();
|
color = new Color3f();
|
||||||
if (colorIndex == 0)
|
if (colorIndex == 0)
|
||||||
color.setR(value);
|
color.setR(value);
|
||||||
else if (colorIndex == 1)
|
else if (colorIndex == 1)
|
||||||
color.setG(value);
|
color.setG(value);
|
||||||
else if (colorIndex == 2)
|
else if (colorIndex == 2)
|
||||||
color.setB(value);
|
color.setB(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,38 +1,38 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.shapes;
|
package de.frajul.endlessroll.entities.shapes;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import de.frajul.endlessroll.R;
|
import de.frajul.endlessroll.R;
|
||||||
import de.frajul.endlessroll.levels.LevelManager;
|
import de.frajul.endlessroll.levels.LevelManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 30.10.2017.
|
* Created by Julian on 30.10.2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CollectEnergyTask extends Task {
|
public class CollectEnergyTask extends Task {
|
||||||
|
|
||||||
public CollectEnergyTask(int condition) {
|
public CollectEnergyTask(int condition) {
|
||||||
super(condition);
|
super(condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean checkConditionFulfilled(LevelManager levelManager) {
|
protected boolean checkConditionFulfilled(LevelManager levelManager) {
|
||||||
return levelManager.getTotalCollectedEnergyCount() >= condition;
|
return levelManager.getTotalCollectedEnergyCount() >= condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(Context context, LevelManager levelManager) {
|
public String toString(Context context, LevelManager levelManager) {
|
||||||
if (conditionFulfilled) {
|
if (conditionFulfilled) {
|
||||||
return context.getString(R.string.task_collect_energy_format_d, condition);
|
return context.getString(R.string.task_collect_energy_format_d, condition);
|
||||||
}
|
}
|
||||||
return context.getString(R.string.task_collect_energy_progress_format_ddd, condition,
|
return context.getString(R.string.task_collect_energy_progress_format_ddd, condition,
|
||||||
levelManager.getTotalCollectedEnergyCount(), condition);
|
levelManager.getTotalCollectedEnergyCount(), condition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,38 +1,38 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.shapes;
|
package de.frajul.endlessroll.entities.shapes;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import de.frajul.endlessroll.R;
|
import de.frajul.endlessroll.R;
|
||||||
import de.frajul.endlessroll.levels.LevelManager;
|
import de.frajul.endlessroll.levels.LevelManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 30.10.2017.
|
* Created by Julian on 30.10.2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CollectStarTask extends Task {
|
public class CollectStarTask extends Task {
|
||||||
|
|
||||||
public CollectStarTask(int condition) {
|
public CollectStarTask(int condition) {
|
||||||
super(condition);
|
super(condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean checkConditionFulfilled(LevelManager levelManager) {
|
protected boolean checkConditionFulfilled(LevelManager levelManager) {
|
||||||
return levelManager.getTotalCollectedStarCount() >= condition;
|
return levelManager.getTotalCollectedStarCount() >= condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(Context context, LevelManager levelManager) {
|
public String toString(Context context, LevelManager levelManager) {
|
||||||
if (conditionFulfilled) {
|
if (conditionFulfilled) {
|
||||||
return context.getString(R.string.task_collect_stars_format_d, condition);
|
return context.getString(R.string.task_collect_stars_format_d, condition);
|
||||||
}
|
}
|
||||||
return context.getString(R.string.task_collect_stars_progress_format_ddd, condition,
|
return context.getString(R.string.task_collect_stars_progress_format_ddd, condition,
|
||||||
levelManager.getTotalCollectedStarCount(), condition);
|
levelManager.getTotalCollectedStarCount(), condition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.shapes;
|
package de.frajul.endlessroll.entities.shapes;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import de.frajul.endlessroll.R;
|
import de.frajul.endlessroll.R;
|
||||||
import de.frajul.endlessroll.levels.LevelManager;
|
import de.frajul.endlessroll.levels.LevelManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 30.10.2017.
|
* Created by Julian on 30.10.2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class CompleteWorldTask extends Task {
|
public class CompleteWorldTask extends Task {
|
||||||
|
|
||||||
public CompleteWorldTask(int condition) {
|
public CompleteWorldTask(int condition) {
|
||||||
super(condition);
|
super(condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean checkConditionFulfilled(LevelManager levelManager) {
|
protected boolean checkConditionFulfilled(LevelManager levelManager) {
|
||||||
return levelManager.getPackWithId(condition).isAllLevelsFinished();
|
return levelManager.getPackWithId(condition).isAllLevelsFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(Context context, LevelManager levelManager) {
|
public String toString(Context context, LevelManager levelManager) {
|
||||||
return context.getString(R.string.task_complete_world_format_d, condition);
|
return context.getString(R.string.task_complete_world_format_d, condition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.shapes;
|
package de.frajul.endlessroll.entities.shapes;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import de.frajul.endlessroll.R;
|
import de.frajul.endlessroll.R;
|
||||||
import de.frajul.endlessroll.levels.LevelManager;
|
import de.frajul.endlessroll.levels.LevelManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 30.10.2017.
|
* Created by Julian on 30.10.2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class EmptyTask extends Task {
|
public class EmptyTask extends Task {
|
||||||
|
|
||||||
public EmptyTask() {
|
public EmptyTask() {
|
||||||
super(0);
|
super(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean checkConditionFulfilled(LevelManager levelManager) {
|
protected boolean checkConditionFulfilled(LevelManager levelManager) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(Context context, LevelManager levelManager) {
|
public String toString(Context context, LevelManager levelManager) {
|
||||||
return context.getString(R.string.task_empty);
|
return context.getString(R.string.task_empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,99 +1,99 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.shapes;
|
package de.frajul.endlessroll.entities.shapes;
|
||||||
|
|
||||||
import android.support.annotation.DrawableRes;
|
import android.support.annotation.DrawableRes;
|
||||||
import android.support.annotation.StringRes;
|
import android.support.annotation.StringRes;
|
||||||
|
|
||||||
import de.frajul.endlessroll.R;
|
import de.frajul.endlessroll.R;
|
||||||
import de.frajul.endlessroll.entities.textures.Texture;
|
import de.frajul.endlessroll.entities.textures.Texture;
|
||||||
import de.frajul.endlessroll.entities.textures.TexturePack;
|
import de.frajul.endlessroll.entities.textures.TexturePack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 22.10.2017.
|
* Created by Julian on 22.10.2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public enum PlayerShape {
|
public enum PlayerShape {
|
||||||
BALL(R.string.playershape_name_ball, R.string.playershape_description_ball,
|
BALL(R.string.playershape_name_ball, R.string.playershape_description_ball,
|
||||||
R.drawable.playershapes_ball, true, new EmptyTask()),
|
R.drawable.playershapes_ball, true, new EmptyTask()),
|
||||||
CLOCK(R.string.playershape_name_clock, R.string.playershape_description_clock,
|
CLOCK(R.string.playershape_name_clock, R.string.playershape_description_clock,
|
||||||
R.drawable.playershapes_clock, true, new CollectStarTask(15)),
|
R.drawable.playershapes_clock, true, new CollectStarTask(15)),
|
||||||
SMILEY(R.string.playershape_name_smiley, R.string.playershape_description_smiley,
|
SMILEY(R.string.playershape_name_smiley, R.string.playershape_description_smiley,
|
||||||
R.drawable.playershapes_smiley, true, new CollectStarTask(50)),
|
R.drawable.playershapes_smiley, true, new CollectStarTask(50)),
|
||||||
WHEEL(R.string.playershape_name_wheel, R.string.playershape_description_wheel,
|
WHEEL(R.string.playershape_name_wheel, R.string.playershape_description_wheel,
|
||||||
R.drawable.playershapes_wheel, true, new CollectStarTask(80)),
|
R.drawable.playershapes_wheel, true, new CollectStarTask(80)),
|
||||||
|
|
||||||
PACMAN(R.string.playershape_name_pacman, R.string.playershape_description_pacman,
|
PACMAN(R.string.playershape_name_pacman, R.string.playershape_description_pacman,
|
||||||
R.drawable.playershapes_pacman, false, new CompleteWorldTask(1)),
|
R.drawable.playershapes_pacman, false, new CompleteWorldTask(1)),
|
||||||
SOCCER(R.string.playershape_name_soccer, R.string.playershape_description_soccer, R.drawable.playershapes_soccer, false, new CompleteWorldTask(2)),
|
SOCCER(R.string.playershape_name_soccer, R.string.playershape_description_soccer, R.drawable.playershapes_soccer, false, new CompleteWorldTask(2)),
|
||||||
HYPNO_SPIRAL(R.string.playershape_name_hypno_spiral,
|
HYPNO_SPIRAL(R.string.playershape_name_hypno_spiral,
|
||||||
R.string.playershape_description_hypno_spiral, R.drawable.playershapes_hypno_spiral, false,
|
R.string.playershape_description_hypno_spiral, R.drawable.playershapes_hypno_spiral, false,
|
||||||
new CollectEnergyTask(5)),
|
new CollectEnergyTask(5)),
|
||||||
BLUE(R.string.playershape_name_blue, R.string.playershape_description_blue,
|
BLUE(R.string.playershape_name_blue, R.string.playershape_description_blue,
|
||||||
R.drawable.playershapes_blue, false, new CollectEnergyTask(20)),
|
R.drawable.playershapes_blue, false, new CollectEnergyTask(20)),
|
||||||
SUN(R.string.playershape_name_sun, R.string.playershape_description_sun,
|
SUN(R.string.playershape_name_sun, R.string.playershape_description_sun,
|
||||||
R.drawable.playershapes_sun, false, new CollectEnergyTask(30)),
|
R.drawable.playershapes_sun, false, new CollectEnergyTask(30)),
|
||||||
RAINBOW(R.string.playershape_name_rainbow, R.string.playershape_description_rainbow, R.drawable.playershapes_rainbow, true, new EmptyTask());
|
RAINBOW(R.string.playershape_name_rainbow, R.string.playershape_description_rainbow, R.drawable.playershapes_rainbow, true, new EmptyTask());
|
||||||
|
|
||||||
@StringRes
|
@StringRes
|
||||||
private int nameId;
|
private int nameId;
|
||||||
@StringRes
|
@StringRes
|
||||||
private int descriptionId;
|
private int descriptionId;
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
private int drawableId;
|
private int drawableId;
|
||||||
private boolean inTopRow;
|
private boolean inTopRow;
|
||||||
private Task unlockTask;
|
private Task unlockTask;
|
||||||
|
|
||||||
private Texture texture;
|
private Texture texture;
|
||||||
|
|
||||||
PlayerShape(@StringRes int nameId, @StringRes int descriptionId, @DrawableRes int drawableId, boolean inTopRow, Task unlockTask) {
|
PlayerShape(@StringRes int nameId, @StringRes int descriptionId, @DrawableRes int drawableId, boolean inTopRow, Task unlockTask) {
|
||||||
this.nameId = nameId;
|
this.nameId = nameId;
|
||||||
this.descriptionId = descriptionId;
|
this.descriptionId = descriptionId;
|
||||||
this.drawableId = drawableId;
|
this.drawableId = drawableId;
|
||||||
this.inTopRow = inTopRow;
|
this.inTopRow = inTopRow;
|
||||||
this.unlockTask = unlockTask;
|
this.unlockTask = unlockTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadAllTextures(TexturePack texturePack) {
|
public static void loadAllTextures(TexturePack texturePack) {
|
||||||
for (PlayerShape playerShape : values())
|
for (PlayerShape playerShape : values())
|
||||||
playerShape.loadTexture(texturePack);
|
playerShape.loadTexture(texturePack);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadTexture(TexturePack texturePack) {
|
private void loadTexture(TexturePack texturePack) {
|
||||||
if (drawableId == -1)
|
if (drawableId == -1)
|
||||||
return;
|
return;
|
||||||
texture = texturePack.loadTexture(drawableId);
|
texture = texturePack.loadTexture(drawableId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task getUnlockTask() {
|
public Task getUnlockTask() {
|
||||||
return unlockTask;
|
return unlockTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@StringRes
|
@StringRes
|
||||||
public int getNameId() {
|
public int getNameId() {
|
||||||
return nameId;
|
return nameId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@StringRes
|
@StringRes
|
||||||
public int getDescriptionId() {
|
public int getDescriptionId() {
|
||||||
return descriptionId;
|
return descriptionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
public int getDrawableId() {
|
public int getDrawableId() {
|
||||||
return drawableId;
|
return drawableId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Texture getTexture() {
|
public Texture getTexture() {
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInTopRow() {
|
public boolean isInTopRow() {
|
||||||
return inTopRow;
|
return inTopRow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.shapes;
|
package de.frajul.endlessroll.entities.shapes;
|
||||||
|
|
||||||
import de.frajul.endlessroll.views.PlayerShapeButton;
|
import de.frajul.endlessroll.views.PlayerShapeButton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 22.10.2017.
|
* Created by Julian on 22.10.2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public interface PlayerShapeButtonOnClickListener {
|
public interface PlayerShapeButtonOnClickListener {
|
||||||
|
|
||||||
void onClick(PlayerShapeButton button);
|
void onClick(PlayerShapeButton button);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,38 +1,38 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.shapes;
|
package de.frajul.endlessroll.entities.shapes;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import de.frajul.endlessroll.levels.LevelManager;
|
import de.frajul.endlessroll.levels.LevelManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 29.10.2017.
|
* Created by Julian on 29.10.2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract class Task {
|
public abstract class Task {
|
||||||
|
|
||||||
protected int condition;
|
protected int condition;
|
||||||
protected boolean conditionFulfilled;
|
protected boolean conditionFulfilled;
|
||||||
|
|
||||||
public Task(int condition) {
|
public Task(int condition) {
|
||||||
this.condition = condition;
|
this.condition = condition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(LevelManager levelManager) {
|
public void update(LevelManager levelManager) {
|
||||||
conditionFulfilled = checkConditionFulfilled(levelManager);
|
conditionFulfilled = checkConditionFulfilled(levelManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract boolean checkConditionFulfilled(LevelManager levelManager);
|
protected abstract boolean checkConditionFulfilled(LevelManager levelManager);
|
||||||
|
|
||||||
public abstract String toString(Context context, LevelManager levelManager);
|
public abstract String toString(Context context, LevelManager levelManager);
|
||||||
|
|
||||||
public boolean isConditionFulfilled() {
|
public boolean isConditionFulfilled() {
|
||||||
return conditionFulfilled;
|
return conditionFulfilled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,43 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.textures;
|
package de.frajul.endlessroll.entities.textures;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 11.12.2015.
|
* Created by Julian on 11.12.2015.
|
||||||
*/
|
*/
|
||||||
public class Texture {
|
public class Texture {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private int atlasWidth;
|
private int atlasWidth;
|
||||||
private int atlasHeight;
|
private int atlasHeight;
|
||||||
|
|
||||||
public Texture(int id, int atlasWidth, int atlasHeight) {
|
public Texture(int id, int atlasWidth, int atlasHeight) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.atlasWidth = atlasWidth;
|
this.atlasWidth = atlasWidth;
|
||||||
this.atlasHeight = atlasHeight;
|
this.atlasHeight = atlasHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Texture(Texture other) {
|
public Texture(Texture other) {
|
||||||
this.id = other.getId();
|
this.id = other.getId();
|
||||||
this.atlasWidth = other.getAtlasWidth();
|
this.atlasWidth = other.getAtlasWidth();
|
||||||
this.atlasHeight = other.getAtlasHeight();
|
this.atlasHeight = other.getAtlasHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAtlasWidth() {
|
public int getAtlasWidth() {
|
||||||
return atlasWidth;
|
return atlasWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAtlasHeight() {
|
public int getAtlasHeight() {
|
||||||
return atlasHeight;
|
return atlasHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,66 +1,66 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.textures;
|
package de.frajul.endlessroll.entities.textures;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.opengl.GLES20;
|
import android.opengl.GLES20;
|
||||||
import android.opengl.GLUtils;
|
import android.opengl.GLUtils;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import de.frajul.endlessroll.main.GameLog;
|
import de.frajul.endlessroll.main.GameLog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 26.11.2015.
|
* Created by Julian on 26.11.2015.
|
||||||
*/
|
*/
|
||||||
public class TextureLoader {
|
public class TextureLoader {
|
||||||
|
|
||||||
private Context context;
|
private Context context;
|
||||||
|
|
||||||
public TextureLoader(Context context) {
|
public TextureLoader(Context context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int loadTextureId(int texture, boolean isAtlas) {
|
public int loadTextureId(int texture, boolean isAtlas) {
|
||||||
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), texture);
|
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), texture);
|
||||||
return loadTextureId(bitmap, isAtlas);
|
return loadTextureId(bitmap, isAtlas);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Texture loadTexture(String inAssetsLocation) throws Exception {
|
public Texture loadTexture(String inAssetsLocation) throws Exception {
|
||||||
InputStream is = context.getAssets().open(inAssetsLocation);
|
InputStream is = context.getAssets().open(inAssetsLocation);
|
||||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||||
options.inScaled = false;
|
options.inScaled = false;
|
||||||
Bitmap bitmap = BitmapFactory.decodeStream(is, null, options);
|
Bitmap bitmap = BitmapFactory.decodeStream(is, null, options);
|
||||||
return new Texture(loadTextureId(bitmap, false), 1, 1);
|
return new Texture(loadTextureId(bitmap, false), 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int loadTextureId(Bitmap bitmap, boolean isAtlas) {
|
private int loadTextureId(Bitmap bitmap, boolean isAtlas) {
|
||||||
int id = genTexture();
|
int id = genTexture();
|
||||||
|
|
||||||
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, id);
|
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, id);
|
||||||
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER,
|
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER,
|
||||||
GLES20.GL_NEAREST);
|
GLES20.GL_NEAREST);
|
||||||
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER,
|
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER,
|
||||||
GLES20.GL_NEAREST);
|
GLES20.GL_NEAREST);
|
||||||
|
|
||||||
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
|
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
|
||||||
|
|
||||||
bitmap.recycle();
|
bitmap.recycle();
|
||||||
GameLog.d("Texture " + id + " successfully loaded");
|
GameLog.d("Texture " + id + " successfully loaded");
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int genTexture() {
|
private int genTexture() {
|
||||||
int[] idField = new int[1];
|
int[] idField = new int[1];
|
||||||
GLES20.glGenTextures(1, idField, 0);
|
GLES20.glGenTextures(1, idField, 0);
|
||||||
return idField[0];
|
return idField[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,63 +1,63 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.textures;
|
package de.frajul.endlessroll.entities.textures;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.annotation.DrawableRes;
|
import android.support.annotation.DrawableRes;
|
||||||
|
|
||||||
import de.frajul.endlessroll.R;
|
import de.frajul.endlessroll.R;
|
||||||
import de.frajul.endlessroll.entities.shapes.PlayerShape;
|
import de.frajul.endlessroll.entities.shapes.PlayerShape;
|
||||||
import de.frajul.endlessroll.entities.tools.ToolType;
|
import de.frajul.endlessroll.entities.tools.ToolType;
|
||||||
import de.frajul.endlessroll.levels.worlds.World;
|
import de.frajul.endlessroll.levels.worlds.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 05.12.2015.
|
* Created by Julian on 05.12.2015.
|
||||||
*/
|
*/
|
||||||
public class TexturePack {
|
public class TexturePack {
|
||||||
|
|
||||||
private TextureLoader loader;
|
private TextureLoader loader;
|
||||||
|
|
||||||
public final Texture white;
|
public final Texture white;
|
||||||
public final Texture goal;
|
public final Texture goal;
|
||||||
public final Texture playerArrow;
|
public final Texture playerArrow;
|
||||||
public final Texture star;
|
public final Texture star;
|
||||||
public final Texture energy;
|
public final Texture energy;
|
||||||
public final Texture countdown3, countdown2, countdown1;
|
public final Texture countdown3, countdown2, countdown1;
|
||||||
public final Texture toolButtonLocked;
|
public final Texture toolButtonLocked;
|
||||||
public final Texture toolButtonEmpty;
|
public final Texture toolButtonEmpty;
|
||||||
|
|
||||||
public TexturePack(Context context) {
|
public TexturePack(Context context) {
|
||||||
loader = new TextureLoader(context);
|
loader = new TextureLoader(context);
|
||||||
white = loadTexture(R.drawable.white);
|
white = loadTexture(R.drawable.white);
|
||||||
goal = loadTexture(R.drawable.guis_goal);
|
goal = loadTexture(R.drawable.guis_goal);
|
||||||
playerArrow = loadTexture(R.drawable.guis_playerarrow);
|
playerArrow = loadTexture(R.drawable.guis_playerarrow);
|
||||||
|
|
||||||
star = loadTexture(R.drawable.currency_star);
|
star = loadTexture(R.drawable.currency_star);
|
||||||
energy = loadAtlas(R.drawable.currency_energy_atlas, 2, 2);
|
energy = loadAtlas(R.drawable.currency_energy_atlas, 2, 2);
|
||||||
|
|
||||||
countdown3 = loadTexture(R.drawable.guis_countdown_3);
|
countdown3 = loadTexture(R.drawable.guis_countdown_3);
|
||||||
countdown2 = loadTexture(R.drawable.guis_countdown_2);
|
countdown2 = loadTexture(R.drawable.guis_countdown_2);
|
||||||
countdown1 = loadTexture(R.drawable.guis_countdown_1);
|
countdown1 = loadTexture(R.drawable.guis_countdown_1);
|
||||||
toolButtonLocked = loadTexture(R.drawable.tools_button_locked);
|
toolButtonLocked = loadTexture(R.drawable.tools_button_locked);
|
||||||
toolButtonEmpty = loadTexture(R.drawable.tools_button_empty);
|
toolButtonEmpty = loadTexture(R.drawable.tools_button_empty);
|
||||||
|
|
||||||
PlayerShape.loadAllTextures(this);
|
PlayerShape.loadAllTextures(this);
|
||||||
ToolType.loadAllToolTextures(this);
|
ToolType.loadAllToolTextures(this);
|
||||||
World.loadAllSpecificTextures(this);
|
World.loadAllSpecificTextures(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Texture loadTexture(@DrawableRes int id) {
|
public Texture loadTexture(@DrawableRes int id) {
|
||||||
int texId = loader.loadTextureId(id, false);
|
int texId = loader.loadTextureId(id, false);
|
||||||
return new Texture(texId, 1, 1);
|
return new Texture(texId, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Texture loadAtlas(@DrawableRes int id, int atlasWidth, int atlasHeight) {
|
public Texture loadAtlas(@DrawableRes int id, int atlasWidth, int atlasHeight) {
|
||||||
int texId = loader.loadTextureId(id, true);
|
int texId = loader.loadTextureId(id, true);
|
||||||
return new Texture(texId, atlasWidth, atlasHeight);
|
return new Texture(texId, atlasWidth, atlasHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.tileLists;
|
package de.frajul.endlessroll.entities.tileLists;
|
||||||
|
|
||||||
import de.frajul.endlessroll.entities.textures.Texture;
|
import de.frajul.endlessroll.entities.textures.Texture;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class Ceiling extends TileList {
|
public class Ceiling extends TileList {
|
||||||
|
|
||||||
public Ceiling(Texture texture) {
|
public Ceiling(Texture texture) {
|
||||||
super(Type.CEILING, texture);
|
super(Type.CEILING, texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.tileLists;
|
package de.frajul.endlessroll.entities.tileLists;
|
||||||
|
|
||||||
import de.frajul.endlessroll.entities.textures.Texture;
|
import de.frajul.endlessroll.entities.textures.Texture;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class Terrain extends TileList {
|
public class Terrain extends TileList {
|
||||||
|
|
||||||
public Terrain(Texture texture) {
|
public Terrain(Texture texture) {
|
||||||
super(TileList.Type.TERRAIN, texture);
|
super(TileList.Type.TERRAIN, texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,46 +1,46 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.tileLists;
|
package de.frajul.endlessroll.entities.tileLists;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.Entity;
|
import de.frajul.endlessroll.entities.Entity;
|
||||||
import de.frajul.endlessroll.entities.textures.Texture;
|
import de.frajul.endlessroll.entities.textures.Texture;
|
||||||
import de.frajul.endlessroll.levels.TileData;
|
import de.frajul.endlessroll.levels.TileData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 18.12.2015.
|
* Created by Julian on 18.12.2015.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Tile extends Entity {
|
public class Tile extends Entity {
|
||||||
|
|
||||||
private int gridColumnCount;
|
private int gridColumnCount;
|
||||||
|
|
||||||
public Tile(TileList.Type type, Texture texture, float edge, TileData data) {
|
public Tile(TileList.Type type, Texture texture, float edge, TileData data) {
|
||||||
this(type, texture, edge, data.getX(), data.getWidth());
|
this(type, texture, edge, data.getX(), data.getWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tile(TileList.Type type, Texture texture, float edge, float x, float width) {
|
public Tile(TileList.Type type, Texture texture, float edge, float x, float width) {
|
||||||
super(texture, new Vector(), width, 0);
|
super(texture, new Vector(), width, 0);
|
||||||
super.height = type.calculateTileHeightFromEdge(edge);
|
super.height = type.calculateTileHeightFromEdge(edge);
|
||||||
super.position.x = x;
|
super.position.x = x;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TERRAIN:
|
case TERRAIN:
|
||||||
super.position.y = edge - super.height / 2;
|
super.position.y = edge - super.height / 2;
|
||||||
break;
|
break;
|
||||||
case CEILING:
|
case CEILING:
|
||||||
super.position.y = edge + super.height / 2;
|
super.position.y = edge + super.height / 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
gridColumnCount = (int) (width / height);
|
gridColumnCount = (int) (width / height);
|
||||||
gridColumnCount = Math.max(gridColumnCount, 3);
|
gridColumnCount = Math.max(gridColumnCount, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getGridColumnCount() {
|
public int getGridColumnCount() {
|
||||||
return gridColumnCount;
|
return gridColumnCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,106 +1,106 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.tileLists;
|
package de.frajul.endlessroll.entities.tileLists;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.SynchronizedArrayList;
|
import de.frajul.endlessroll.data.SynchronizedArrayList;
|
||||||
import de.frajul.endlessroll.entities.textures.Texture;
|
import de.frajul.endlessroll.entities.textures.Texture;
|
||||||
import de.frajul.endlessroll.levels.TileData;
|
import de.frajul.endlessroll.levels.TileData;
|
||||||
import de.frajul.endlessroll.levels.worlds.World;
|
import de.frajul.endlessroll.levels.worlds.World;
|
||||||
import de.frajul.endlessroll.main.GameLog;
|
import de.frajul.endlessroll.main.GameLog;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class TileList extends SynchronizedArrayList<Tile> {
|
public class TileList extends SynchronizedArrayList<Tile> {
|
||||||
|
|
||||||
public enum Type {
|
public enum Type {
|
||||||
TERRAIN,
|
TERRAIN,
|
||||||
CEILING;
|
CEILING;
|
||||||
|
|
||||||
public float calculateTileHeightFromEdge(float edge) {
|
public float calculateTileHeightFromEdge(float edge) {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case TERRAIN:
|
case TERRAIN:
|
||||||
if (edge <= -0.6f)
|
if (edge <= -0.6f)
|
||||||
return 0.4f;
|
return 0.4f;
|
||||||
return 1 + edge;
|
return 1 + edge;
|
||||||
case CEILING:
|
case CEILING:
|
||||||
if (edge >= 0.6f)
|
if (edge >= 0.6f)
|
||||||
return 0.4f;
|
return 0.4f;
|
||||||
return 1 - edge;
|
return 1 - edge;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Type type;
|
private Type type;
|
||||||
private Texture texture;
|
private Texture texture;
|
||||||
private float edge;
|
private float edge;
|
||||||
private boolean endless;
|
private boolean endless;
|
||||||
|
|
||||||
public TileList(Type type, Texture texture) {
|
public TileList(Type type, Texture texture) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.texture = texture;
|
this.texture = texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadData(World world, float edge, List<TileData> tileData) {
|
public void loadData(World world, float edge, List<TileData> tileData) {
|
||||||
this.texture = world.getTerrainTexture();
|
this.texture = world.getTerrainTexture();
|
||||||
if (type == Type.CEILING)
|
if (type == Type.CEILING)
|
||||||
this.texture = world.getCeilingTexture();
|
this.texture = world.getCeilingTexture();
|
||||||
this.endless = false;
|
this.endless = false;
|
||||||
super.clear();
|
super.clear();
|
||||||
float lastRightEdge = -10;
|
float lastRightEdge = -10;
|
||||||
for (TileData data : tileData) {
|
for (TileData data : tileData) {
|
||||||
float leftEdge = data.getX() - data.getWidth() / 2;
|
float leftEdge = data.getX() - data.getWidth() / 2;
|
||||||
float rightEdge = data.getX() + data.getWidth() / 2;
|
float rightEdge = data.getX() + data.getWidth() / 2;
|
||||||
if (Math.abs(lastRightEdge - leftEdge) < 0.1f)
|
if (Math.abs(lastRightEdge - leftEdge) < 0.1f)
|
||||||
GameLog.i("!!! Too small gap found !!! " + toMeters(lastRightEdge) + "m; " + lastRightEdge + "-" + leftEdge + "; iRight=" + tileData.indexOf(data));
|
GameLog.i("!!! Too small gap found !!! " + toMeters(lastRightEdge) + "m; " + lastRightEdge + "-" + leftEdge + "; iRight=" + tileData.indexOf(data));
|
||||||
lastRightEdge = rightEdge;
|
lastRightEdge = rightEdge;
|
||||||
super.add(new Tile(type, texture, edge, data));
|
super.add(new Tile(type, texture, edge, data));
|
||||||
}
|
}
|
||||||
this.edge = edge;
|
this.edge = edge;
|
||||||
if (edge >= 1 || edge <= -1)
|
if (edge >= 1 || edge <= -1)
|
||||||
super.clear();
|
super.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private float toMeters(float value) {
|
private float toMeters(float value) {
|
||||||
return ((int) (value * 20)) / 10f;
|
return ((int) (value * 20)) / 10f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createEndless(World world, float edge) {
|
public void createEndless(World world, float edge) {
|
||||||
loadData(world, edge, new ArrayList<TileData>());
|
loadData(world, edge, new ArrayList<TileData>());
|
||||||
super.add(createEndlessTile(0));
|
super.add(createEndlessTile(0));
|
||||||
this.endless = true;
|
this.endless = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(float cameraX) {
|
public void update(float cameraX) {
|
||||||
if (!super.isEmpty()) {
|
if (!super.isEmpty()) {
|
||||||
if (endless) {
|
if (endless) {
|
||||||
Tile last = super.get(super.size() - 1);
|
Tile last = super.get(super.size() - 1);
|
||||||
if (last.getRightEdge() - cameraX < 3)
|
if (last.getRightEdge() - cameraX < 3)
|
||||||
super.add(createEndlessTile(last.getRightEdge() + 2.5f));
|
super.add(createEndlessTile(last.getRightEdge() + 2.5f));
|
||||||
}
|
}
|
||||||
if (super.get(0).getRightEdge() - cameraX < -3) {
|
if (super.get(0).getRightEdge() - cameraX < -3) {
|
||||||
super.remove(0);
|
super.remove(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Tile createEndlessTile(float x) {
|
private Tile createEndlessTile(float x) {
|
||||||
return new Tile(type, texture, edge, x, 5);
|
return new Tile(type, texture, edge, x, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getEdge() {
|
public float getEdge() {
|
||||||
return edge;
|
return edge;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEndless() {
|
public boolean isEndless() {
|
||||||
return endless;
|
return endless;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,80 +1,80 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.tools;
|
package de.frajul.endlessroll.entities.tools;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.DestroyEffect;
|
import de.frajul.endlessroll.entities.DestroyEffect;
|
||||||
import de.frajul.endlessroll.entities.Obstacle;
|
import de.frajul.endlessroll.entities.Obstacle;
|
||||||
import de.frajul.endlessroll.entities.Player;
|
import de.frajul.endlessroll.entities.Player;
|
||||||
import de.frajul.endlessroll.entities.collision.geometry.Geometry;
|
import de.frajul.endlessroll.entities.collision.geometry.Geometry;
|
||||||
import de.frajul.endlessroll.main.game.Timer;
|
import de.frajul.endlessroll.main.game.Timer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 20.02.2016.
|
* Created by Julian on 20.02.2016.
|
||||||
*/
|
*/
|
||||||
public class Bomb extends Tool {
|
public class Bomb extends Tool {
|
||||||
|
|
||||||
private float delta;
|
private float delta;
|
||||||
private boolean exploding = false;
|
private boolean exploding = false;
|
||||||
private Obstacle attachedObstacle;
|
private Obstacle attachedObstacle;
|
||||||
private Vector offsetToObstaclePosition = new Vector();
|
private Vector offsetToObstaclePosition = new Vector();
|
||||||
|
|
||||||
public Bomb(Vector position) {
|
public Bomb(Vector position) {
|
||||||
super(ToolType.BOMB, position, .25f, .25f, false, false);
|
super(ToolType.BOMB, position, .25f, .25f, false, false);
|
||||||
animation.setIndexSequence(new int[]{0, 1, 2});
|
animation.setIndexSequence(new int[]{0, 1, 2});
|
||||||
animation.setLooping(false);
|
animation.setLooping(false);
|
||||||
animation.setRequiredDelta(
|
animation.setRequiredDelta(
|
||||||
(int) (ToolType.BOMB.getCurrentUpgradeValue(ToolUpgradeType.DURATION) / 3f));
|
(int) (ToolType.BOMB.getCurrentUpgradeValue(ToolUpgradeType.DURATION) / 3f));
|
||||||
super.setFloating(true);
|
super.setFloating(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Timer timer) {
|
public void update(Timer timer) {
|
||||||
super.update(timer);
|
super.update(timer);
|
||||||
float explosionDuration = ToolType.BOMB.getCurrentUpgradeValue(ToolUpgradeType.DURATION);
|
float explosionDuration = ToolType.BOMB.getCurrentUpgradeValue(ToolUpgradeType.DURATION);
|
||||||
delta += timer.getFrameTimeMilliseconds();
|
delta += timer.getFrameTimeMilliseconds();
|
||||||
int currentExplosionState = Math.min((int) (delta / (explosionDuration / 3f)), 3);
|
int currentExplosionState = Math.min((int) (delta / (explosionDuration / 3f)), 3);
|
||||||
if (attachedObstacle != null) {
|
if (attachedObstacle != null) {
|
||||||
if (attachedObstacle.isMoving())
|
if (attachedObstacle.isMoving())
|
||||||
super.setPosition(new Vector(attachedObstacle.getPosition()).translate(offsetToObstaclePosition));
|
super.setPosition(new Vector(attachedObstacle.getPosition()).translate(offsetToObstaclePosition));
|
||||||
attachedObstacle.setBombExplosionState(currentExplosionState);
|
attachedObstacle.setBombExplosionState(currentExplosionState);
|
||||||
}
|
}
|
||||||
if (delta >= explosionDuration)
|
if (delta >= explosionDuration)
|
||||||
exploding = true;
|
exploding = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerCollision(Player player, Timer timer) {
|
public void onPlayerCollision(Player player, Timer timer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Geometry createWorldCollisionBounds() {
|
protected Geometry createWorldCollisionBounds() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Geometry createPlayerCollisionBounds() {
|
protected Geometry createPlayerCollisionBounds() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAttachedObstacle(Obstacle attachedObstacle) {
|
public void setAttachedObstacle(Obstacle attachedObstacle) {
|
||||||
this.attachedObstacle = attachedObstacle;
|
this.attachedObstacle = attachedObstacle;
|
||||||
offsetToObstaclePosition = attachedObstacle.getPosition().vectorTo(super.getPosition());
|
offsetToObstaclePosition = attachedObstacle.getPosition().vectorTo(super.getPosition());
|
||||||
attachedObstacle.setBombExplosionState(0);
|
attachedObstacle.setBombExplosionState(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isExploding() {
|
public boolean isExploding() {
|
||||||
return exploding;
|
return exploding;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void explode() {
|
public void explode() {
|
||||||
if (attachedObstacle != null)
|
if (attachedObstacle != null)
|
||||||
attachedObstacle.destroy(DestroyEffect.EXPLOSION);
|
attachedObstacle.destroy(DestroyEffect.EXPLOSION);
|
||||||
super.destroy(DestroyEffect.EXPLOSION);
|
super.destroy(DestroyEffect.EXPLOSION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,84 +1,84 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.tools;
|
package de.frajul.endlessroll.entities.tools;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.DestroyEffect;
|
import de.frajul.endlessroll.entities.DestroyEffect;
|
||||||
import de.frajul.endlessroll.entities.Player;
|
import de.frajul.endlessroll.entities.Player;
|
||||||
import de.frajul.endlessroll.entities.collision.geometry.Circle;
|
import de.frajul.endlessroll.entities.collision.geometry.Circle;
|
||||||
import de.frajul.endlessroll.entities.collision.geometry.Geometry;
|
import de.frajul.endlessroll.entities.collision.geometry.Geometry;
|
||||||
import de.frajul.endlessroll.entities.particles.ParticleSource;
|
import de.frajul.endlessroll.entities.particles.ParticleSource;
|
||||||
import de.frajul.endlessroll.entities.particles.ParticleSystem;
|
import de.frajul.endlessroll.entities.particles.ParticleSystem;
|
||||||
import de.frajul.endlessroll.main.game.Timer;
|
import de.frajul.endlessroll.main.game.Timer;
|
||||||
import de.frajul.endlessroll.sounds.SoundManager;
|
import de.frajul.endlessroll.sounds.SoundManager;
|
||||||
import de.frajul.endlessroll.sounds.SoundStream;
|
import de.frajul.endlessroll.sounds.SoundStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 11.02.2016.
|
* Created by Julian on 11.02.2016.
|
||||||
*/
|
*/
|
||||||
public class Magnet extends Tool {
|
public class Magnet extends Tool {
|
||||||
|
|
||||||
private SoundManager soundManager;
|
private SoundManager soundManager;
|
||||||
private ParticleSource particleSource;
|
private ParticleSource particleSource;
|
||||||
private SoundStream soundStream;
|
private SoundStream soundStream;
|
||||||
|
|
||||||
public Magnet(Vector position, ParticleSystem particleSystem, SoundManager soundManager) {
|
public Magnet(Vector position, ParticleSystem particleSystem, SoundManager soundManager) {
|
||||||
super(ToolType.MAGNET, position, .24f, .24f, false, false);
|
super(ToolType.MAGNET, position, .24f, .24f, false, false);
|
||||||
this.soundManager = soundManager;
|
this.soundManager = soundManager;
|
||||||
animation.setRequiredDelta(300);
|
animation.setRequiredDelta(300);
|
||||||
animation.setIndexSequence(new int[]{1, 1, 0});
|
animation.setIndexSequence(new int[]{1, 1, 0});
|
||||||
animation.setLooping(true);
|
animation.setLooping(true);
|
||||||
super.setFloating(true);
|
super.setFloating(true);
|
||||||
particleSource = new ParticleSource(new Vector(position), particleSystem.magnet);
|
particleSource = new ParticleSource(new Vector(position), particleSystem.magnet);
|
||||||
particleSource.start();
|
particleSource.start();
|
||||||
soundStream = soundManager.playSound(soundManager.magnetSound);
|
soundStream = soundManager.playSound(soundManager.magnetSound);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy(DestroyEffect destroyEffect) {
|
public void destroy(DestroyEffect destroyEffect) {
|
||||||
super.destroy(destroyEffect);
|
super.destroy(destroyEffect);
|
||||||
particleSource.kill();
|
particleSource.kill();
|
||||||
soundManager.stopSound(soundStream);
|
soundManager.stopSound(soundStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateSoundVolume(Player player) {
|
public void updateSoundVolume(Player player) {
|
||||||
float distanceToPlayer = super.getPosition().vectorTo(player.getPosition()).length();
|
float distanceToPlayer = super.getPosition().vectorTo(player.getPosition()).length();
|
||||||
float factor = 1.0f / distanceToPlayer;
|
float factor = 1.0f / distanceToPlayer;
|
||||||
if (distanceToPlayer > 3 && player.getPosition().getX() > super.getPosition().getX()) {
|
if (distanceToPlayer > 3 && player.getPosition().getX() > super.getPosition().getX()) {
|
||||||
soundManager.stopSound(soundStream);
|
soundManager.stopSound(soundStream);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
soundStream.setCurrentVolumeModifier(factor);
|
soundStream.setCurrentVolumeModifier(factor);
|
||||||
soundManager.onStreamVolumeChanged(soundStream);
|
soundManager.onStreamVolumeChanged(soundStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerCollision(Player player, Timer timer) {
|
public void onPlayerCollision(Player player, Timer timer) {
|
||||||
float fromPlayerDistance = player.getPosition().vectorTo(super.getPosition()).length();
|
float fromPlayerDistance = player.getPosition().vectorTo(super.getPosition()).length();
|
||||||
float fromPlayerDistanceGreaterFour = Math.max(fromPlayerDistance, 0.4f);
|
float fromPlayerDistanceGreaterFour = Math.max(fromPlayerDistance, 0.4f);
|
||||||
float fromPlayerYDistance = super.getPosition().y - player.getPosition().y;
|
float fromPlayerYDistance = super.getPosition().y - player.getPosition().y;
|
||||||
float force = 0.0000012f / (fromPlayerDistanceGreaterFour * fromPlayerDistanceGreaterFour);
|
float force = 0.0000012f / (fromPlayerDistanceGreaterFour * fromPlayerDistanceGreaterFour);
|
||||||
force *= ToolType.MAGNET.getCurrentUpgradeValue(ToolUpgradeType.FORCE) / 100;
|
force *= ToolType.MAGNET.getCurrentUpgradeValue(ToolUpgradeType.FORCE) / 100;
|
||||||
force *= timer.getFrameTimeMilliseconds();
|
force *= timer.getFrameTimeMilliseconds();
|
||||||
|
|
||||||
if (fromPlayerYDistance < 0) {
|
if (fromPlayerYDistance < 0) {
|
||||||
force = -force;
|
force = -force;
|
||||||
}
|
}
|
||||||
player.addForce(force);
|
player.addForce(force);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Geometry createWorldCollisionBounds() {
|
protected Geometry createWorldCollisionBounds() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Geometry createPlayerCollisionBounds() {
|
protected Geometry createPlayerCollisionBounds() {
|
||||||
return new Circle(super.getPosition(), 2);
|
return new Circle(super.getPosition(), 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,47 +1,47 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.tools;
|
package de.frajul.endlessroll.entities.tools;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.DestroyEffect;
|
import de.frajul.endlessroll.entities.DestroyEffect;
|
||||||
import de.frajul.endlessroll.entities.Player;
|
import de.frajul.endlessroll.entities.Player;
|
||||||
import de.frajul.endlessroll.entities.collision.geometry.Geometry;
|
import de.frajul.endlessroll.entities.collision.geometry.Geometry;
|
||||||
import de.frajul.endlessroll.main.game.Timer;
|
import de.frajul.endlessroll.main.game.Timer;
|
||||||
import de.frajul.endlessroll.sounds.SoundManager;
|
import de.frajul.endlessroll.sounds.SoundManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 02.10.2017.
|
* Created by Julian on 02.10.2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class PowerMushroom extends Tool {
|
public class PowerMushroom extends Tool {
|
||||||
|
|
||||||
private SoundManager soundManager;
|
private SoundManager soundManager;
|
||||||
|
|
||||||
public PowerMushroom(Vector position, SoundManager soundManager) {
|
public PowerMushroom(Vector position, SoundManager soundManager) {
|
||||||
super(ToolType.POWER_MUSHROOM, position, .35f, .3f, true, true);
|
super(ToolType.POWER_MUSHROOM, position, .35f, .3f, true, true);
|
||||||
animation.disable();
|
animation.disable();
|
||||||
this.soundManager = soundManager;
|
this.soundManager = soundManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerCollision(Player player, Timer timer) {
|
public void onPlayerCollision(Player player, Timer timer) {
|
||||||
player.startSuperPower((long) ToolType.POWER_MUSHROOM.getCurrentUpgradeValue(ToolUpgradeType.DURATION));
|
player.startSuperPower((long) ToolType.POWER_MUSHROOM.getCurrentUpgradeValue(ToolUpgradeType.DURATION));
|
||||||
soundManager.playSound(soundManager.mushroomSound);
|
soundManager.playSound(soundManager.mushroomSound);
|
||||||
super.destroy(DestroyEffect.ENERGY_COLLECT);
|
super.destroy(DestroyEffect.ENERGY_COLLECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Geometry createWorldCollisionBounds() {
|
protected Geometry createWorldCollisionBounds() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Geometry createPlayerCollisionBounds() {
|
protected Geometry createPlayerCollisionBounds() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,71 +1,71 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.tools;
|
package de.frajul.endlessroll.entities.tools;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.Player;
|
import de.frajul.endlessroll.entities.Player;
|
||||||
import de.frajul.endlessroll.entities.collision.geometry.Geometry;
|
import de.frajul.endlessroll.entities.collision.geometry.Geometry;
|
||||||
import de.frajul.endlessroll.entities.collision.geometry.Triangle;
|
import de.frajul.endlessroll.entities.collision.geometry.Triangle;
|
||||||
import de.frajul.endlessroll.main.game.Timer;
|
import de.frajul.endlessroll.main.game.Timer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 29.11.2015.
|
* Created by Julian on 29.11.2015.
|
||||||
*/
|
*/
|
||||||
public class Ramp extends Tool {
|
public class Ramp extends Tool {
|
||||||
|
|
||||||
public Ramp(Vector position) {
|
public Ramp(Vector position) {
|
||||||
super(ToolType.RAMP, position, .4f, .35f, true, true);
|
super(ToolType.RAMP, position, .4f, .35f, true, true);
|
||||||
animation.setLooping(true);
|
animation.setLooping(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getGradient() {
|
public float getGradient() {
|
||||||
return super.getHeight() / super.getWidth();
|
return super.getHeight() / super.getWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getHeightAt(float x, boolean clamp) {
|
public float getHeightAt(float x, boolean clamp) {
|
||||||
float ratio = (x - getLeftEdge()) / super.getWidth();
|
float ratio = (x - getLeftEdge()) / super.getWidth();
|
||||||
if (clamp) {
|
if (clamp) {
|
||||||
if (ratio < 0)
|
if (ratio < 0)
|
||||||
return getBottomEdge();
|
return getBottomEdge();
|
||||||
if (ratio > 1)
|
if (ratio > 1)
|
||||||
return getTopEdge();
|
return getTopEdge();
|
||||||
}
|
}
|
||||||
return getBottomEdge() + super.getHeight() * ratio;
|
return getBottomEdge() + super.getHeight() * ratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerCollision(Player player, Timer timer) {
|
public void onPlayerCollision(Player player, Timer timer) {
|
||||||
float necessaryY = calcNecessaryPlayerY(player);
|
float necessaryY = calcNecessaryPlayerY(player);
|
||||||
player.getPosition().y = necessaryY;
|
player.getPosition().y = necessaryY;
|
||||||
float acceleration = player.getMovement().x * getGradient();
|
float acceleration = player.getMovement().x * getGradient();
|
||||||
|
|
||||||
player.setGravityForce(0);
|
player.setGravityForce(0);
|
||||||
player.getMovement().setY(0);
|
player.getMovement().setY(0);
|
||||||
player.addForce(acceleration);
|
player.addForce(acceleration);
|
||||||
}
|
}
|
||||||
|
|
||||||
private float calcNecessaryPlayerY(Player player) {
|
private float calcNecessaryPlayerY(Player player) {
|
||||||
float normalM = -1 / getGradient();
|
float normalM = -1 / getGradient();
|
||||||
Vector normalToCircleCenter = new Vector(-1, -normalM).normalize();
|
Vector normalToCircleCenter = new Vector(-1, -normalM).normalize();
|
||||||
normalToCircleCenter.mul(player.RADIUS);
|
normalToCircleCenter.mul(player.RADIUS);
|
||||||
float normalX = player.getPosition().x - normalToCircleCenter.x;
|
float normalX = player.getPosition().x - normalToCircleCenter.x;
|
||||||
float normalY = getHeightAt(normalX, false);
|
float normalY = getHeightAt(normalX, false);
|
||||||
return normalY + normalToCircleCenter.y;
|
return normalY + normalToCircleCenter.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Geometry createWorldCollisionBounds() {
|
protected Geometry createWorldCollisionBounds() {
|
||||||
return new Triangle(this);
|
return new Triangle(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Geometry createPlayerCollisionBounds() {
|
protected Geometry createPlayerCollisionBounds() {
|
||||||
return new Triangle(this);
|
return new Triangle(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,59 +1,59 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.tools;
|
package de.frajul.endlessroll.entities.tools;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.Player;
|
import de.frajul.endlessroll.entities.Player;
|
||||||
import de.frajul.endlessroll.entities.collision.geometry.Geometry;
|
import de.frajul.endlessroll.entities.collision.geometry.Geometry;
|
||||||
import de.frajul.endlessroll.entities.collision.geometry.Quad;
|
import de.frajul.endlessroll.entities.collision.geometry.Quad;
|
||||||
import de.frajul.endlessroll.main.game.Timer;
|
import de.frajul.endlessroll.main.game.Timer;
|
||||||
import de.frajul.endlessroll.sounds.SoundManager;
|
import de.frajul.endlessroll.sounds.SoundManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 04.01.2016.
|
* Created by Julian on 04.01.2016.
|
||||||
*/
|
*/
|
||||||
public class Spring extends Tool {
|
public class Spring extends Tool {
|
||||||
|
|
||||||
private boolean hasYetCollided = false;
|
private boolean hasYetCollided = false;
|
||||||
private SoundManager soundManager;
|
private SoundManager soundManager;
|
||||||
|
|
||||||
public Spring(Vector position, SoundManager soundManager) {
|
public Spring(Vector position, SoundManager soundManager) {
|
||||||
super(ToolType.SPRING, position, .3f, .35f, true, true);
|
super(ToolType.SPRING, position, .3f, .35f, true, true);
|
||||||
animation.setIndexSequence(new int[]{1, 3, 3, 1});
|
animation.setIndexSequence(new int[]{1, 3, 3, 1});
|
||||||
animation.setRequiredDelta(80);
|
animation.setRequiredDelta(80);
|
||||||
this.soundManager = soundManager;
|
this.soundManager = soundManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Timer timer) {
|
public void update(Timer timer) {
|
||||||
if (hasYetCollided)
|
if (hasYetCollided)
|
||||||
super.update(timer);
|
super.update(timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerCollision(Player player, Timer timer) {
|
public void onPlayerCollision(Player player, Timer timer) {
|
||||||
if (!hasYetCollided) {
|
if (!hasYetCollided) {
|
||||||
hasYetCollided = true;
|
hasYetCollided = true;
|
||||||
soundManager.playSound(soundManager.springSound);
|
soundManager.playSound(soundManager.springSound);
|
||||||
|
|
||||||
player.clearAllForces();
|
player.clearAllForces();
|
||||||
player.getMovement().setY(0);
|
player.getMovement().setY(0);
|
||||||
player.addForce(.0022f);
|
player.addForce(.0022f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Geometry createWorldCollisionBounds() {
|
protected Geometry createWorldCollisionBounds() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Geometry createPlayerCollisionBounds() {
|
protected Geometry createPlayerCollisionBounds() {
|
||||||
return new Quad(super.getPosition(), .2f, .1f);
|
return new Quad(super.getPosition(), .2f, .1f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,103 +1,103 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.tools;
|
package de.frajul.endlessroll.entities.tools;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.DestroyEffect;
|
import de.frajul.endlessroll.entities.DestroyEffect;
|
||||||
import de.frajul.endlessroll.entities.Player;
|
import de.frajul.endlessroll.entities.Player;
|
||||||
import de.frajul.endlessroll.entities.collision.geometry.Geometry;
|
import de.frajul.endlessroll.entities.collision.geometry.Geometry;
|
||||||
import de.frajul.endlessroll.entities.particles.ParticleSource;
|
import de.frajul.endlessroll.entities.particles.ParticleSource;
|
||||||
import de.frajul.endlessroll.entities.particles.ParticleSystem;
|
import de.frajul.endlessroll.entities.particles.ParticleSystem;
|
||||||
import de.frajul.endlessroll.main.game.Timer;
|
import de.frajul.endlessroll.main.game.Timer;
|
||||||
import de.frajul.endlessroll.sounds.SoundManager;
|
import de.frajul.endlessroll.sounds.SoundManager;
|
||||||
import de.frajul.endlessroll.sounds.SoundStream;
|
import de.frajul.endlessroll.sounds.SoundStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 11.02.2016.
|
* Created by Julian on 11.02.2016.
|
||||||
*/
|
*/
|
||||||
public class Stasis extends Tool {
|
public class Stasis extends Tool {
|
||||||
|
|
||||||
private SoundManager soundManager;
|
private SoundManager soundManager;
|
||||||
private ParticleSource particleSource;
|
private ParticleSource particleSource;
|
||||||
private boolean firstCollision = true;
|
private boolean firstCollision = true;
|
||||||
private final static float Y_SLOW_FACTOR = .4f; //Final .2f
|
private final static float Y_SLOW_FACTOR = .4f; //Final .2f
|
||||||
private final static float X_SLOW_FACTOR = .9f; //Final .8f
|
private final static float X_SLOW_FACTOR = .9f; //Final .8f
|
||||||
private float forceValue;
|
private float forceValue;
|
||||||
|
|
||||||
private SoundStream soundStream;
|
private SoundStream soundStream;
|
||||||
|
|
||||||
public Stasis(Vector position, ParticleSystem particleSystem, SoundManager soundManager) {
|
public Stasis(Vector position, ParticleSystem particleSystem, SoundManager soundManager) {
|
||||||
super(ToolType.STASIS, position,
|
super(ToolType.STASIS, position,
|
||||||
.7f * ToolType.STASIS.getCurrentUpgradeValue(ToolUpgradeType.SIZE) / 100,
|
.7f * ToolType.STASIS.getCurrentUpgradeValue(ToolUpgradeType.SIZE) / 100,
|
||||||
.7f * ToolType.STASIS.getCurrentUpgradeValue(ToolUpgradeType.SIZE) / 100, false,
|
.7f * ToolType.STASIS.getCurrentUpgradeValue(ToolUpgradeType.SIZE) / 100, false,
|
||||||
false);
|
false);
|
||||||
this.soundManager = soundManager;
|
this.soundManager = soundManager;
|
||||||
animation.setLooping(true);
|
animation.setLooping(true);
|
||||||
animation.setRequiredDelta(300);
|
animation.setRequiredDelta(300);
|
||||||
animation.setIndexSequence(new int[]{1, 1, 2, 3, 2, 4, 4, 3, 2, 2, 3, 3});
|
animation.setIndexSequence(new int[]{1, 1, 2, 3, 2, 4, 4, 3, 2, 2, 3, 3});
|
||||||
super.setFloating(true);
|
super.setFloating(true);
|
||||||
particleSource = new ParticleSource(new Vector(position), particleSystem.stasis);
|
particleSource = new ParticleSource(new Vector(position), particleSystem.stasis);
|
||||||
particleSource.setSpawnSize(new Vector(super.width, super.height));
|
particleSource.setSpawnSize(new Vector(super.width, super.height));
|
||||||
particleSource.start();
|
particleSource.start();
|
||||||
forceValue = ToolType.STASIS.getCurrentUpgradeValue(ToolUpgradeType.FORCE);
|
forceValue = ToolType.STASIS.getCurrentUpgradeValue(ToolUpgradeType.FORCE);
|
||||||
soundStream = soundManager.playSound(soundManager.stasisSound);
|
soundStream = soundManager.playSound(soundManager.stasisSound);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateSoundVolume(Player player) {
|
public void updateSoundVolume(Player player) {
|
||||||
float distanceToPlayer = super.getPosition().getX() - player.getPosition().getX();
|
float distanceToPlayer = super.getPosition().getX() - player.getPosition().getX();
|
||||||
boolean playerInXRange = (player.getRightEdge() >= super.getLeftEdge() && player
|
boolean playerInXRange = (player.getRightEdge() >= super.getLeftEdge() && player
|
||||||
.getRightEdge() <= super.getRightEdge()) || (player.getLeftEdge() >= super
|
.getRightEdge() <= super.getRightEdge()) || (player.getLeftEdge() >= super
|
||||||
.getLeftEdge() && player.getLeftEdge() <= super.getRightEdge());
|
.getLeftEdge() && player.getLeftEdge() <= super.getRightEdge());
|
||||||
float factor = 1.0f;
|
float factor = 1.0f;
|
||||||
if (!playerInXRange) {
|
if (!playerInXRange) {
|
||||||
factor = 1.0f / (distanceToPlayer * distanceToPlayer);
|
factor = 1.0f / (distanceToPlayer * distanceToPlayer);
|
||||||
if (distanceToPlayer < -2) {
|
if (distanceToPlayer < -2) {
|
||||||
soundManager.stopSound(soundStream);
|
soundManager.stopSound(soundStream);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
soundStream.setCurrentVolumeModifier(factor);
|
soundStream.setCurrentVolumeModifier(factor);
|
||||||
soundManager.onStreamVolumeChanged(soundStream);
|
soundManager.onStreamVolumeChanged(soundStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy(DestroyEffect destroyEffect) {
|
public void destroy(DestroyEffect destroyEffect) {
|
||||||
super.destroy(destroyEffect);
|
super.destroy(destroyEffect);
|
||||||
particleSource.kill();
|
particleSource.kill();
|
||||||
soundManager.stopSound(soundStream);
|
soundManager.stopSound(soundStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerCollision(Player player, Timer timer) {
|
public void onPlayerCollision(Player player, Timer timer) {
|
||||||
player.addStasis(this);
|
player.addStasis(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Geometry createWorldCollisionBounds() {
|
protected Geometry createWorldCollisionBounds() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Geometry createPlayerCollisionBounds() {
|
protected Geometry createPlayerCollisionBounds() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void influencePlayerMovementValues(Player player) {
|
public void influencePlayerMovementValues(Player player) {
|
||||||
float finalXSlow = getCurrentXSlowFactor();
|
float finalXSlow = getCurrentXSlowFactor();
|
||||||
player.manipulateAllForces(Y_SLOW_FACTOR / forceValue);
|
player.manipulateAllForces(Y_SLOW_FACTOR / forceValue);
|
||||||
player.getMovement().setX(player.getMovement().getX() * finalXSlow);
|
player.getMovement().setX(player.getMovement().getX() * finalXSlow);
|
||||||
if (firstCollision) {
|
if (firstCollision) {
|
||||||
player.getMovement().y *= Y_SLOW_FACTOR / forceValue;
|
player.getMovement().y *= Y_SLOW_FACTOR / forceValue;
|
||||||
firstCollision = false;
|
firstCollision = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getCurrentXSlowFactor() {
|
public float getCurrentXSlowFactor() {
|
||||||
return X_SLOW_FACTOR - forceValue / 20f;
|
return X_SLOW_FACTOR - forceValue / 20f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,64 +1,64 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.tools;
|
package de.frajul.endlessroll.entities.tools;
|
||||||
|
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.AnimatedEntity;
|
import de.frajul.endlessroll.entities.AnimatedEntity;
|
||||||
import de.frajul.endlessroll.entities.Player;
|
import de.frajul.endlessroll.entities.Player;
|
||||||
import de.frajul.endlessroll.entities.collision.geometry.Geometry;
|
import de.frajul.endlessroll.entities.collision.geometry.Geometry;
|
||||||
import de.frajul.endlessroll.main.game.Timer;
|
import de.frajul.endlessroll.main.game.Timer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 04.01.2016.
|
* Created by Julian on 04.01.2016.
|
||||||
*/
|
*/
|
||||||
public abstract class Tool extends AnimatedEntity {
|
public abstract class Tool extends AnimatedEntity {
|
||||||
|
|
||||||
private boolean placedByRightEdge;
|
private boolean placedByRightEdge;
|
||||||
private boolean updateBounds;
|
private boolean updateBounds;
|
||||||
private Geometry worldCollisionBounds;
|
private Geometry worldCollisionBounds;
|
||||||
private Geometry playerCollisionBounds;
|
private Geometry playerCollisionBounds;
|
||||||
private boolean floating = false;
|
private boolean floating = false;
|
||||||
|
|
||||||
public Tool(ToolType type, Vector position, float width, float height, boolean updateBounds, boolean placedByRightEdge) {
|
public Tool(ToolType type, Vector position, float width, float height, boolean updateBounds, boolean placedByRightEdge) {
|
||||||
super(type.getToolTexture(), position, width, height);
|
super(type.getToolTexture(), position, width, height);
|
||||||
this.updateBounds = updateBounds;
|
this.updateBounds = updateBounds;
|
||||||
this.placedByRightEdge = placedByRightEdge;
|
this.placedByRightEdge = placedByRightEdge;
|
||||||
worldCollisionBounds = createWorldCollisionBounds();
|
worldCollisionBounds = createWorldCollisionBounds();
|
||||||
playerCollisionBounds = createPlayerCollisionBounds();
|
playerCollisionBounds = createPlayerCollisionBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void onPlayerCollision(Player player, Timer timer);
|
public abstract void onPlayerCollision(Player player, Timer timer);
|
||||||
|
|
||||||
protected abstract Geometry createWorldCollisionBounds();
|
protected abstract Geometry createWorldCollisionBounds();
|
||||||
|
|
||||||
protected abstract Geometry createPlayerCollisionBounds();
|
protected abstract Geometry createPlayerCollisionBounds();
|
||||||
|
|
||||||
public Geometry getWorldCollisionBounds() {
|
public Geometry getWorldCollisionBounds() {
|
||||||
if (updateBounds)
|
if (updateBounds)
|
||||||
return createWorldCollisionBounds();
|
return createWorldCollisionBounds();
|
||||||
return worldCollisionBounds;
|
return worldCollisionBounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Geometry getPlayerCollisionBounds() {
|
public Geometry getPlayerCollisionBounds() {
|
||||||
if (updateBounds)
|
if (updateBounds)
|
||||||
return createPlayerCollisionBounds();
|
return createPlayerCollisionBounds();
|
||||||
return playerCollisionBounds;
|
return playerCollisionBounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFloating(boolean floating) {
|
public void setFloating(boolean floating) {
|
||||||
this.floating = floating;
|
this.floating = floating;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFloating() {
|
public boolean isFloating() {
|
||||||
return floating;
|
return floating;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlacedByRightEdge() {
|
public boolean isPlacedByRightEdge() {
|
||||||
return placedByRightEdge;
|
return placedByRightEdge;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,49 +1,49 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.tools;
|
package de.frajul.endlessroll.entities.tools;
|
||||||
|
|
||||||
import de.frajul.endlessroll.R;
|
import de.frajul.endlessroll.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 16.07.2016.
|
* Created by Julian on 16.07.2016.
|
||||||
*/
|
*/
|
||||||
public class ToolSlot {
|
public class ToolSlot {
|
||||||
|
|
||||||
private ToolType toolType;
|
private ToolType toolType;
|
||||||
private boolean locked;
|
private boolean locked;
|
||||||
|
|
||||||
public ToolSlot(ToolType toolType, boolean locked) {
|
public ToolSlot(ToolType toolType, boolean locked) {
|
||||||
this.toolType = toolType;
|
this.toolType = toolType;
|
||||||
this.locked = locked;
|
this.locked = locked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ToolType getToolType() {
|
public ToolType getToolType() {
|
||||||
return toolType;
|
return toolType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDrawable() {
|
public int getDrawable() {
|
||||||
if (locked)
|
if (locked)
|
||||||
return R.drawable.tools_button_locked;
|
return R.drawable.tools_button_locked;
|
||||||
else if (toolType != null)
|
else if (toolType != null)
|
||||||
return toolType.getButtonDrawable();
|
return toolType.getButtonDrawable();
|
||||||
else
|
else
|
||||||
return R.drawable.tools_button_empty;
|
return R.drawable.tools_button_empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setToolType(ToolType toolType) {
|
public void setToolType(ToolType toolType) {
|
||||||
this.toolType = toolType;
|
this.toolType = toolType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLocked() {
|
public boolean isLocked() {
|
||||||
return locked;
|
return locked;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocked(boolean locked) {
|
public void setLocked(boolean locked) {
|
||||||
this.locked = locked;
|
this.locked = locked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,195 +1,195 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.tools;
|
package de.frajul.endlessroll.entities.tools;
|
||||||
|
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.annotation.StringRes;
|
import android.support.annotation.StringRes;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import de.frajul.endlessroll.R;
|
import de.frajul.endlessroll.R;
|
||||||
import de.frajul.endlessroll.data.Vector;
|
import de.frajul.endlessroll.data.Vector;
|
||||||
import de.frajul.endlessroll.entities.particles.ParticleSystem;
|
import de.frajul.endlessroll.entities.particles.ParticleSystem;
|
||||||
import de.frajul.endlessroll.entities.textures.Texture;
|
import de.frajul.endlessroll.entities.textures.Texture;
|
||||||
import de.frajul.endlessroll.entities.textures.TexturePack;
|
import de.frajul.endlessroll.entities.textures.TexturePack;
|
||||||
import de.frajul.endlessroll.sounds.SoundManager;
|
import de.frajul.endlessroll.sounds.SoundManager;
|
||||||
|
|
||||||
public enum ToolType {
|
public enum ToolType {
|
||||||
|
|
||||||
//Check newInstance when new Tool is added!
|
//Check newInstance when new Tool is added!
|
||||||
RAMP(R.string.tool_name_ramp, R.string.tool_description_ramp, R.drawable.tools_ramp,
|
RAMP(R.string.tool_name_ramp, R.string.tool_description_ramp, R.drawable.tools_ramp,
|
||||||
R.drawable.tools_ramp_button, 0, 1, 5,
|
R.drawable.tools_ramp_button, 0, 1, 5,
|
||||||
new ToolUpgrade(ToolUpgradeType.COOLDOWN, 3000, 1000)),
|
new ToolUpgrade(ToolUpgradeType.COOLDOWN, 3000, 1000)),
|
||||||
SPRING(R.string.tool_name_spring, R.string.tool_description_spring, R.drawable.tools_spring,
|
SPRING(R.string.tool_name_spring, R.string.tool_description_spring, R.drawable.tools_spring,
|
||||||
R.drawable.tools_spring_button, 5, 2, 5,
|
R.drawable.tools_spring_button, 5, 2, 5,
|
||||||
new ToolUpgrade(ToolUpgradeType.COOLDOWN, 4000, 2000)),
|
new ToolUpgrade(ToolUpgradeType.COOLDOWN, 4000, 2000)),
|
||||||
BOMB(R.string.tool_name_bomb, R.string.tool_description_bomb, R.drawable.tools_bomb,
|
BOMB(R.string.tool_name_bomb, R.string.tool_description_bomb, R.drawable.tools_bomb,
|
||||||
R.drawable.tools_bomb_button, 25, 4, 5,
|
R.drawable.tools_bomb_button, 25, 4, 5,
|
||||||
new ToolUpgrade(ToolUpgradeType.COOLDOWN, 5000, 2000),
|
new ToolUpgrade(ToolUpgradeType.COOLDOWN, 5000, 2000),
|
||||||
new ToolUpgrade(ToolUpgradeType.DURATION, 1200, 500)),
|
new ToolUpgrade(ToolUpgradeType.DURATION, 1200, 500)),
|
||||||
MAGNET(R.string.tool_name_magnet, R.string.tool_description_magnet, R.drawable.tools_magnet,
|
MAGNET(R.string.tool_name_magnet, R.string.tool_description_magnet, R.drawable.tools_magnet,
|
||||||
R.drawable.tools_magnet_button, 22, 2, 5,
|
R.drawable.tools_magnet_button, 22, 2, 5,
|
||||||
new ToolUpgrade(ToolUpgradeType.COOLDOWN, 5000, 3000),
|
new ToolUpgrade(ToolUpgradeType.COOLDOWN, 5000, 3000),
|
||||||
new ToolUpgrade(ToolUpgradeType.FORCE, 100, 500)),
|
new ToolUpgrade(ToolUpgradeType.FORCE, 100, 500)),
|
||||||
STASIS(R.string.tool_name_stasis, R.string.tool_description_stasis, R.drawable.tools_stasis,
|
STASIS(R.string.tool_name_stasis, R.string.tool_description_stasis, R.drawable.tools_stasis,
|
||||||
R.drawable.tools_stasis_button, 27, 4, 6,
|
R.drawable.tools_stasis_button, 27, 4, 6,
|
||||||
new ToolUpgrade(ToolUpgradeType.COOLDOWN, 6000, 4000),
|
new ToolUpgrade(ToolUpgradeType.COOLDOWN, 6000, 4000),
|
||||||
new ToolUpgrade(ToolUpgradeType.FORCE, 1, 2),
|
new ToolUpgrade(ToolUpgradeType.FORCE, 1, 2),
|
||||||
new ToolUpgrade(ToolUpgradeType.SIZE, 100, 200)),
|
new ToolUpgrade(ToolUpgradeType.SIZE, 100, 200)),
|
||||||
POWER_MUSHROOM(R.string.tool_name_power_mushroom, R.string.tool_description_power_mushroom,
|
POWER_MUSHROOM(R.string.tool_name_power_mushroom, R.string.tool_description_power_mushroom,
|
||||||
R.drawable.tools_power_mushroom, R.drawable.tools_power_mushroom_button, 50,
|
R.drawable.tools_power_mushroom, R.drawable.tools_power_mushroom_button, 50,
|
||||||
5, 7, new ToolUpgrade(ToolUpgradeType.COOLDOWN, 15000, 11000),
|
5, 7, new ToolUpgrade(ToolUpgradeType.COOLDOWN, 15000, 11000),
|
||||||
new ToolUpgrade(ToolUpgradeType.DURATION, 5000, 10000));
|
new ToolUpgrade(ToolUpgradeType.DURATION, 5000, 10000));
|
||||||
|
|
||||||
@StringRes
|
@StringRes
|
||||||
private final int name;
|
private final int name;
|
||||||
@StringRes
|
@StringRes
|
||||||
private final int description;
|
private final int description;
|
||||||
private final int toolTextureId;
|
private final int toolTextureId;
|
||||||
private final int buttonDrawable;
|
private final int buttonDrawable;
|
||||||
private final int buyPrice;
|
private final int buyPrice;
|
||||||
private final int upgradePrice;
|
private final int upgradePrice;
|
||||||
private final int maxUpgradeLevel;
|
private final int maxUpgradeLevel;
|
||||||
private final List<ToolUpgrade> upgrades;
|
private final List<ToolUpgrade> upgrades;
|
||||||
|
|
||||||
private Texture toolTexture = null;
|
private Texture toolTexture = null;
|
||||||
private Texture toolButtonTexture = null;
|
private Texture toolButtonTexture = null;
|
||||||
private boolean bought;
|
private boolean bought;
|
||||||
private int currentUpgradeLevel = 1;
|
private int currentUpgradeLevel = 1;
|
||||||
|
|
||||||
ToolType(@StringRes int name, @StringRes int description, int toolTextureId, int buttonDrawable, int buyPrice, int upgradePrice, int maxUpgradeLevel, ToolUpgrade... upgrades) {
|
ToolType(@StringRes int name, @StringRes int description, int toolTextureId, int buttonDrawable, int buyPrice, int upgradePrice, int maxUpgradeLevel, ToolUpgrade... upgrades) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.toolTextureId = toolTextureId;
|
this.toolTextureId = toolTextureId;
|
||||||
this.buttonDrawable = buttonDrawable;
|
this.buttonDrawable = buttonDrawable;
|
||||||
this.buyPrice = buyPrice;
|
this.buyPrice = buyPrice;
|
||||||
this.upgradePrice = upgradePrice;
|
this.upgradePrice = upgradePrice;
|
||||||
this.maxUpgradeLevel = maxUpgradeLevel;
|
this.maxUpgradeLevel = maxUpgradeLevel;
|
||||||
this.upgrades = Arrays.asList(upgrades);
|
this.upgrades = Arrays.asList(upgrades);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Tool newInstance(Vector position, ParticleSystem particleSystem, SoundManager soundManager) {
|
public Tool newInstance(Vector position, ParticleSystem particleSystem, SoundManager soundManager) {
|
||||||
Tool tool = null;
|
Tool tool = null;
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case RAMP:
|
case RAMP:
|
||||||
tool = new Ramp(position);
|
tool = new Ramp(position);
|
||||||
break;
|
break;
|
||||||
case SPRING:
|
case SPRING:
|
||||||
tool = new Spring(position, soundManager);
|
tool = new Spring(position, soundManager);
|
||||||
break;
|
break;
|
||||||
case MAGNET:
|
case MAGNET:
|
||||||
tool = new Magnet(position, particleSystem, soundManager);
|
tool = new Magnet(position, particleSystem, soundManager);
|
||||||
break;
|
break;
|
||||||
case BOMB:
|
case BOMB:
|
||||||
tool = new Bomb(position);
|
tool = new Bomb(position);
|
||||||
break;
|
break;
|
||||||
case POWER_MUSHROOM:
|
case POWER_MUSHROOM:
|
||||||
tool = new PowerMushroom(position, soundManager);
|
tool = new PowerMushroom(position, soundManager);
|
||||||
break;
|
break;
|
||||||
case STASIS:
|
case STASIS:
|
||||||
tool = new Stasis(position, particleSystem, soundManager);
|
tool = new Stasis(position, particleSystem, soundManager);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (tool != null && tool.isPlacedByRightEdge())
|
if (tool != null && tool.isPlacedByRightEdge())
|
||||||
tool.move(new Vector(-tool.getWidth() / 2, 0));
|
tool.move(new Vector(-tool.getWidth() / 2, 0));
|
||||||
return tool;
|
return tool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadAllToolTextures(TexturePack texturePack) {
|
public static void loadAllToolTextures(TexturePack texturePack) {
|
||||||
for (ToolType type : values()) {
|
for (ToolType type : values()) {
|
||||||
type.loadToolTexture(texturePack);
|
type.loadToolTexture(texturePack);
|
||||||
type.loadToolButtonTexture(texturePack);
|
type.loadToolButtonTexture(texturePack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadToolTexture(TexturePack texturePack) {
|
private void loadToolTexture(TexturePack texturePack) {
|
||||||
if (toolTextureId == -1)
|
if (toolTextureId == -1)
|
||||||
return;
|
return;
|
||||||
if (this != POWER_MUSHROOM)
|
if (this != POWER_MUSHROOM)
|
||||||
toolTexture = texturePack.loadAtlas(toolTextureId, 2, 2);
|
toolTexture = texturePack.loadAtlas(toolTextureId, 2, 2);
|
||||||
else
|
else
|
||||||
toolTexture = texturePack.loadTexture(toolTextureId);
|
toolTexture = texturePack.loadTexture(toolTextureId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadToolButtonTexture(TexturePack texturePack) {
|
private void loadToolButtonTexture(TexturePack texturePack) {
|
||||||
if (buttonDrawable == -1)
|
if (buttonDrawable == -1)
|
||||||
return;
|
return;
|
||||||
toolButtonTexture = texturePack.loadTexture(buttonDrawable);
|
toolButtonTexture = texturePack.loadTexture(buttonDrawable);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Texture getToolTexture() {
|
public Texture getToolTexture() {
|
||||||
return toolTexture;
|
return toolTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Texture getToolButtonTexture() {
|
public Texture getToolButtonTexture() {
|
||||||
return toolButtonTexture;
|
return toolButtonTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getButtonDrawable() {
|
public int getButtonDrawable() {
|
||||||
return buttonDrawable;
|
return buttonDrawable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@StringRes
|
@StringRes
|
||||||
public int getName() {
|
public int getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@StringRes
|
@StringRes
|
||||||
public int getDescription() {
|
public int getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBought(boolean bought) {
|
public void setBought(boolean bought) {
|
||||||
this.bought = bought;
|
this.bought = bought;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBought() {
|
public boolean isBought() {
|
||||||
if (this == RAMP)
|
if (this == RAMP)
|
||||||
bought = true;
|
bought = true;
|
||||||
return bought;
|
return bought;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void upgrade() {
|
public void upgrade() {
|
||||||
currentUpgradeLevel++;
|
currentUpgradeLevel++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
setBought(false);
|
setBought(false);
|
||||||
currentUpgradeLevel = 1;
|
currentUpgradeLevel = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBuyPrice() {
|
public int getBuyPrice() {
|
||||||
return buyPrice;
|
return buyPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getUpgradePrice() {
|
public int getUpgradePrice() {
|
||||||
return upgradePrice + currentUpgradeLevel - 1;
|
return upgradePrice + currentUpgradeLevel - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCurrentUpgradeLevel() {
|
public int getCurrentUpgradeLevel() {
|
||||||
return currentUpgradeLevel;
|
return currentUpgradeLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentUpgradeLevel(int currentUpgradeLevel) {
|
public void setCurrentUpgradeLevel(int currentUpgradeLevel) {
|
||||||
this.currentUpgradeLevel = currentUpgradeLevel;
|
this.currentUpgradeLevel = currentUpgradeLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getCurrentUpgradeValue(ToolUpgradeType type) {
|
public float getCurrentUpgradeValue(ToolUpgradeType type) {
|
||||||
for (ToolUpgrade upgrade : upgrades)
|
for (ToolUpgrade upgrade : upgrades)
|
||||||
if (upgrade.getType().equals(type))
|
if (upgrade.getType().equals(type))
|
||||||
return upgrade.getValueAtLevel(currentUpgradeLevel, maxUpgradeLevel);
|
return upgrade.getValueAtLevel(currentUpgradeLevel, maxUpgradeLevel);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAtMaxUpgradeLevel() {
|
public boolean isAtMaxUpgradeLevel() {
|
||||||
return currentUpgradeLevel == maxUpgradeLevel;
|
return currentUpgradeLevel == maxUpgradeLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,34 +1,34 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.tools;
|
package de.frajul.endlessroll.entities.tools;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 09.06.2017.
|
* Created by Julian on 09.06.2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ToolUpgrade {
|
public class ToolUpgrade {
|
||||||
|
|
||||||
private ToolUpgradeType type;
|
private ToolUpgradeType type;
|
||||||
private float first, last;
|
private float first, last;
|
||||||
|
|
||||||
public ToolUpgrade(ToolUpgradeType type, float first, float last) {
|
public ToolUpgrade(ToolUpgradeType type, float first, float last) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.first = first;
|
this.first = first;
|
||||||
this.last = last;
|
this.last = last;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ToolUpgradeType getType() {
|
public ToolUpgradeType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getValueAtLevel(int level, int maxLevel) {
|
public float getValueAtLevel(int level, int maxLevel) {
|
||||||
float step = (last - first) / ((float) maxLevel - 1);
|
float step = (last - first) / ((float) maxLevel - 1);
|
||||||
return first + (level - 1) * step;
|
return first + (level - 1) * step;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* Created by Julian Mutter on 7/10/18 3:58 PM
|
* Created by Julian Mutter on 7/10/18 3:58 PM
|
||||||
* Copyright (c) 2018. All rights reserved.
|
* Copyright (c) 2018. All rights reserved.
|
||||||
* Last modified 7/10/18 3:54 PM
|
* Last modified 7/10/18 3:54 PM
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.frajul.endlessroll.entities.tools;
|
package de.frajul.endlessroll.entities.tools;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Julian on 28.10.2017.
|
* Created by Julian on 28.10.2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public enum ToolUpgradeType {
|
public enum ToolUpgradeType {
|
||||||
|
|
||||||
COOLDOWN, DURATION, FORCE, SIZE
|
COOLDOWN, DURATION, FORCE, SIZE
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user