consolidate all repos to one for archive

This commit is contained in:
2025-01-28 13:46:42 +01:00
commit a6610fbc7a
5350 changed files with 2705721 additions and 0 deletions

View File

@@ -0,0 +1,109 @@
## Java
*.class
*.war
*.ear
hs_err_pid*
## Robovm
/ios/robovm-build/
## GWT
/html/war/
/html/gwt-unitCache/
.apt_generated/
.gwt/
gwt-unitCache/
www-test/
.gwt-tmp/
## Android Studio and Intellij and Android in general
/android/libs/armeabi-v7a/
/android/libs/arm64-v8a/
/android/libs/x86/
/android/libs/x86_64/
/android/gen/
.idea/
*.ipr
*.iws
*.iml
/android/out/
com_crashlytics_export_strings.xml
## Eclipse
.classpath
.project
.metadata/
/android/bin/
/core/bin/
/desktop/bin/
/html/bin/
/ios/bin/
*.tmp
*.bak
*.swp
*~.nib
.settings/
.loadpath
.externalToolBuilders/
*.launch
## NetBeans
/nbproject/private/
/android/nbproject/private/
/core/nbproject/private/
/desktop/nbproject/private/
/html/nbproject/private/
/ios/nbproject/private/
/build/
/android/build/
/core/build/
/desktop/build/
/html/build/
/ios/build/
/nbbuild/
/android/nbbuild/
/core/nbbuild/
/desktop/nbbuild/
/html/nbbuild/
/ios/nbbuild/
/dist/
/android/dist/
/core/dist/
/desktop/dist/
/html/dist/
/ios/dist/
/nbdist/
/android/nbdist/
/core/nbdist/
/desktop/nbdist/
/html/nbdist/
/ios/nbdist/
nbactions.xml
nb-configuration.xml
## Gradle
/local.properties
.gradle/
gradle-app.setting
## OS Specific
.DS_Store
Thumbs.db
## iOS
/ios/xcode/*.xcodeproj/*
!/ios/xcode/*.xcodeproj/xcshareddata
!/ios/xcode/*.xcodeproj/project.pbxproj
/ios/xcode/native/
/ios/IOSLauncher.app
/ios/IOSLauncher.app.dSYM

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:isGame="true"
android:appCategory="game"
android:label="@string/app_name"
android:theme="@style/AppTheme"
tools:ignore="UnusedAttribute">
<activity
android:name="com.mygdx.game.AndroidLauncher"
android:screenOrientation="landscape"
android:configChanges="keyboard|keyboardHidden|navigation|orientation|screenSize|screenLayout"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,95 @@
android {
namespace "com.mygdx.game"
buildToolsVersion "34.0.0"
compileSdkVersion 34
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['../assets']
jniLibs.srcDirs = ['libs']
}
}
packagingOptions {
resources {
excludes += ['META-INF/robovm/ios/robovm.xml']
}
}
defaultConfig {
applicationId "com.mygdx.game"
minSdkVersion 14
targetSdkVersion 34
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildFeatures {
renderScript true
aidl true
}
}
// called every time gradle gets executed, takes the native dependencies of
// the natives configuration, and extracts them to the proper libs/ folders
// so they get packed with the APK.
tasks.register('copyAndroidNatives') {
doFirst {
file("libs/armeabi-v7a/").mkdirs()
file("libs/arm64-v8a/").mkdirs()
file("libs/x86_64/").mkdirs()
file("libs/x86/").mkdirs()
configurations.natives.copy().files.each { jar ->
def outputDir = null
if (jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
if (jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
if (jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
if (jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
if (outputDir != null) {
copy {
from zipTree(jar)
into outputDir
include "*.so"
}
}
}
}
}
tasks.matching { it.name.contains("merge") && it.name.contains("JniLibFolders") }.configureEach { packageTask ->
packageTask.dependsOn 'copyAndroidNatives'
}
tasks.register('run', Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}
def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.mygdx.game/com.mygdx.game.AndroidLauncher'
}
eclipse.project.name = appName + "-android"

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -0,0 +1,38 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-verbose
-dontwarn com.badlogic.gdx.backends.android.AndroidFragmentApplication
# Required if using Gdx-Controllers extension
-keep class com.badlogic.gdx.controllers.android.AndroidControllers
# Required if using Box2D extension
-keepclassmembers class com.badlogic.gdx.physics.box2d.World {
boolean contactFilter(long, long);
void beginContact(long);
void endContact(long);
void preSolve(long, long);
void postSolve(long, long);
boolean reportFixture(long);
float reportRayFixture(long, float, float, float, float, float);
}

View File

@@ -0,0 +1,9 @@
# This file is used by the Eclipse ADT plugin. It is unnecessary for IDEA and Android Studio projects, which
# configure Proguard and the Android target via the build.gradle file.
# To enable ProGuard to work with Eclipse ADT, uncomment this (available properties: sdk.dir, user.home)
# and ensure proguard.jar in the Android SDK is up to date (or alternately reduce the android target to 23 or lower):
# proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-rules.pro
# Project target.
target=android-19

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon
xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_background_color"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>

View File

@@ -0,0 +1,40 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:pathData="M22,48.667l2.987,0l0,10.667l-2.987,0z"
android:fillColor="#000000"
android:strokeColor="#00000000"
android:fillAlpha="1"/>
<path
android:pathData="M26.907,52.72l2.987,0l0,6.613l-2.987,0z"
android:fillColor="#000000"
android:strokeColor="#00000000"
android:fillAlpha="1"/>
<path
android:pathData="M26.907,48.667l2.987,0l0,2.56l-2.987,0z"
android:fillColor="#000000"
android:strokeColor="#00000000"
android:fillAlpha="1"/>
<path
android:pathData="M31.813,48.667L31.813,52.72 31.813,55.067 31.813,56.767 31.813,59.333l2.992,0 2.117,0c1.654,0 2.998,-1.481 2.998,-3.307 0,-1.826 -1.344,-3.307 -2.998,-3.307l-2.117,0L34.805,48.667ZM34.805,55.067l1.269,0c0.469,0 0.848,0.384 0.848,0.853 0,0.469 -0.379,0.847 -0.848,0.847l-1.269,0z"
android:fillColor="#000000"
android:strokeColor="#00000000"
android:fillAlpha="1"/>
<path
android:pathData="m44.192,48.667c-1.65,0 -2.992,1.481 -2.992,3.307 0,0.023 -0,0.044 0,0.067 0,0.004 -0,0.009 0,0.013l0,3.893c-0.001,0.027 0,0.053 0,0.08 0,1.826 1.341,3.307 2.992,3.307l2.112,0 0.247,0 2.739,0 0.247,0 2.112,0c1.651,0 2.992,-1.481 2.992,-3.307 0,-1.826 -1.341,-3.307 -2.992,-3.307l-1.199,0 -0.48,0 -2.372,0l0,2.347l2.372,0 0.48,0 0.353,0c0.468,0 0.846,0.384 0.846,0.853 0,0.469 -0.378,0.847 -0.846,0.847l-0.833,0 -0.433,0 -0.247,0 -2.739,0 -0.247,0 -0.433,0 -0.833,0c-0.459,0 -0.832,-0.363 -0.846,-0.82l0,-3.893 0,-0.013c0.021,-0.45 0.391,-0.807 0.846,-0.807l0.833,0 0.433,0 1.293,0l0,0.007L54.207,51.24L54.207,48.667l-4.917,0 -1.692,0 -1.293,0 -2.112,0z"
android:fillColor="#e74a45"
android:strokeColor="#00000000"
android:fillAlpha="1"/>
<path
android:pathData="M56.133,48.667L56.133,51.238l5.406,0 1.859,0 1.105,0 0.43,0 0.827,0c0.452,0 0.82,0.356 0.84,0.806l0,0.013 0,3.891c-0.014,0.456 -0.384,0.819 -0.84,0.819l-0.827,0 -0.43,0 -1.899,0 -1.065,0 -2.442,0L59.098,52.724L56.133,52.724l0,4.044 0,1.752 0,0.813l5.406,0 1.065,0 1.899,0 2.098,0c1.639,0 2.971,-1.48 2.971,-3.305 0,-0.027 0.001,-0.053 0,-0.08L69.573,52.058c0,-0.004 -0,-0.009 0,-0.013 0,-0.022 0,-0.044 0,-0.067 0,-1.825 -1.332,-3.305 -2.971,-3.305l-2.098,0 -1.105,0l0,-0.007L56.133,48.667Z"
android:fillColor="#e74a45"
android:strokeColor="#00000000"
android:fillAlpha="1"/>
<path
android:pathData="M69.572,48.667L73.72,48.667L77.787,52.733 81.853,48.667l4.147,0l-5.333,5.333 5.333,5.333L81.853,59.333L77.787,55.267 73.72,59.333l-4.147,0l5.333,-5.333z"
android:fillColor="#e74a45"
android:strokeColor="#00000000"/>
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme.Material.Light.NoActionBar.Fullscreen">
<item name="android:colorBackground">@color/ic_background_color</item>
</style>
</resources>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_background_color">#FFFFFFFF</color>
</resources>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">My GDX Game</string>
</resources>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme.Holo.Light.NoActionBar.Fullscreen">
<item name="android:windowBackground">@color/ic_background_color</item>
</style>
</resources>

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Sample data extraction rules file; uncomment and customize as necessary.
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
for details.
-->
<data-extraction-rules>
<cloud-backup>
<!--
TODO: Use <include> and <exclude> to control what is backed up.
The domain can be file, database, sharedpref, external or root.
Examples:
<include domain="file" path="file_to_include"/>
<exclude domain="file" path="file_to_exclude"/>
<include domain="file" path="include_folder"/>
<exclude domain="file" path="include_folder/file_to_exclude"/>
<exclude domain="file" path="exclude_folder"/>
<include domain="file" path="exclude_folder/file_to_include"/>
<include domain="sharedpref" path="include_shared_pref1.xml"/>
<include domain="database" path="db_name/file_to_include"/>
<exclude domain="database" path="db_name/include_folder/file_to_exclude"/>
<include domain="external" path="file_to_include"/>
<exclude domain="external" path="file_to_exclude"/>
<include domain="root" path="file_to_include"/>
<exclude domain="root" path="file_to_exclude"/>
-->
</cloud-backup>
<!--
<device-transfer>
<include .../>
<exclude .../>
</device-transfer>
-->
</data-extraction-rules>

View File

@@ -0,0 +1,15 @@
package com.mygdx.game;
import android.os.Bundle;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
public class AndroidLauncher extends AndroidApplication {
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
initialize(new MyGame(), config);
}
}

View File

@@ -0,0 +1,90 @@
chess.png
size: 1024, 64
format: RGBA8888
filter: Nearest, Nearest
repeat: none
bishop_b
rotate: false
xy: 2, 2
size: 45, 45
orig: 45, 45
offset: 0, 0
index: -1
bishop_w
rotate: false
xy: 49, 2
size: 45, 45
orig: 45, 45
offset: 0, 0
index: -1
king_b
rotate: false
xy: 96, 2
size: 45, 45
orig: 45, 45
offset: 0, 0
index: -1
king_w
rotate: false
xy: 143, 2
size: 45, 45
orig: 45, 45
offset: 0, 0
index: -1
knight_b
rotate: false
xy: 190, 2
size: 45, 45
orig: 45, 45
offset: 0, 0
index: -1
knight_w
rotate: false
xy: 237, 2
size: 45, 45
orig: 45, 45
offset: 0, 0
index: -1
pawn_b
rotate: false
xy: 284, 2
size: 45, 45
orig: 45, 45
offset: 0, 0
index: -1
pawn_w
rotate: false
xy: 331, 2
size: 45, 45
orig: 45, 45
offset: 0, 0
index: -1
queen_b
rotate: false
xy: 378, 2
size: 45, 45
orig: 45, 45
offset: 0, 0
index: -1
queen_w
rotate: false
xy: 425, 2
size: 45, 45
orig: 45, 45
offset: 0, 0
index: -1
rook_b
rotate: false
xy: 472, 2
size: 45, 45
orig: 45, 45
offset: 0, 0
index: -1
rook_w
rotate: false
xy: 519, 2
size: 45, 45
orig: 45, 45
offset: 0, 0
index: -1

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 879 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 886 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -0,0 +1,101 @@
info face="Commodore 64 Pixelized" size=20 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=1,1,1,1 spacing=-2,-2
common lineHeight=20 base=18 scaleW=512 scaleH=64 pages=1 packed=0
page id=0 file="commodore-64.png"
chars count=96
char id=10 x=0 y=0 width=0 height=0 xoffset=0 yoffset=0 xadvance=0 page=0 chnl=0
char id=32 x=0 y=0 width=0 height=0 xoffset=-1 yoffset=17 xadvance=16 page=0 chnl=0
char id=33 x=502 y=0 width=6 height=16 xoffset=5 yoffset=3 xadvance=16 page=0 chnl=0
char id=34 x=188 y=34 width=14 height=6 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=35 x=248 y=18 width=18 height=16 xoffset=-1 yoffset=3 xadvance=16 page=0 chnl=0
char id=36 x=220 y=18 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=37 x=234 y=18 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=38 x=266 y=18 width=16 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=39 x=142 y=34 width=10 height=8 xoffset=5 yoffset=3 xadvance=16 page=0 chnl=0
char id=40 x=90 y=18 width=10 height=16 xoffset=3 yoffset=3 xadvance=16 page=0 chnl=0
char id=41 x=100 y=18 width=10 height=16 xoffset=3 yoffset=3 xadvance=16 page=0 chnl=0
char id=42 x=114 y=34 width=18 height=12 xoffset=-1 yoffset=5 xadvance=16 page=0 chnl=0
char id=43 x=100 y=34 width=14 height=12 xoffset=1 yoffset=5 xadvance=16 page=0 chnl=0
char id=44 x=152 y=34 width=8 height=8 xoffset=3 yoffset=13 xadvance=16 page=0 chnl=0
char id=45 x=208 y=34 width=14 height=4 xoffset=1 yoffset=9 xadvance=16 page=0 chnl=0
char id=46 x=202 y=34 width=6 height=6 xoffset=5 yoffset=13 xadvance=16 page=0 chnl=0
char id=47 x=392 y=18 width=16 height=14 xoffset=1 yoffset=5 xadvance=16 page=0 chnl=0
char id=48 x=56 y=18 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=49 x=430 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=50 x=444 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=51 x=458 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=52 x=472 y=0 width=16 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=53 x=488 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=54 x=0 y=18 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=55 x=14 y=18 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=56 x=28 y=18 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=57 x=42 y=18 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=58 x=84 y=18 width=6 height=16 xoffset=5 yoffset=3 xadvance=16 page=0 chnl=0
char id=59 x=0 y=0 width=8 height=18 xoffset=3 yoffset=3 xadvance=16 page=0 chnl=0
char id=60 x=158 y=18 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=61 x=160 y=34 width=14 height=8 xoffset=1 yoffset=7 xadvance=16 page=0 chnl=0
char id=62 x=172 y=18 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=63 x=70 y=18 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=64 x=192 y=18 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=65 x=8 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=66 x=22 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=67 x=36 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=68 x=50 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=69 x=64 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=15 page=0 chnl=0
char id=70 x=78 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=15 page=0 chnl=0
char id=71 x=92 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=72 x=106 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=73 x=120 y=0 width=10 height=16 xoffset=3 yoffset=3 xadvance=16 page=0 chnl=0
char id=74 x=130 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=75 x=144 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=76 x=158 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=15 page=0 chnl=0
char id=77 x=172 y=0 width=16 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=78 x=188 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=79 x=202 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=80 x=216 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=81 x=230 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=82 x=244 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=83 x=258 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=84 x=272 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=85 x=286 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=86 x=300 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=87 x=314 y=0 width=16 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=88 x=330 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=89 x=344 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=90 x=358 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=91 x=110 y=18 width=10 height=16 xoffset=3 yoffset=3 xadvance=16 page=0 chnl=0
char id=92 x=408 y=18 width=16 height=14 xoffset=1 yoffset=5 xadvance=16 page=0 chnl=0
char id=93 x=120 y=18 width=10 height=16 xoffset=3 yoffset=3 xadvance=16 page=0 chnl=0
char id=94 x=206 y=18 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=95 x=222 y=34 width=18 height=4 xoffset=-1 yoffset=15 xadvance=16 page=0 chnl=0
char id=96 x=132 y=34 width=10 height=8 xoffset=5 yoffset=3 xadvance=16 page=0 chnl=0
char id=97 x=424 y=18 width=14 height=12 xoffset=1 yoffset=7 xadvance=16 page=0 chnl=0
char id=98 x=282 y=18 width=14 height=14 xoffset=1 yoffset=5 xadvance=16 page=0 chnl=0
char id=99 x=438 y=18 width=12 height=12 xoffset=1 yoffset=7 xadvance=16 page=0 chnl=0
char id=100 x=296 y=18 width=14 height=14 xoffset=1 yoffset=5 xadvance=16 page=0 chnl=0
char id=101 x=450 y=18 width=14 height=12 xoffset=1 yoffset=7 xadvance=16 page=0 chnl=0
char id=102 x=310 y=18 width=12 height=14 xoffset=3 yoffset=5 xadvance=16 page=0 chnl=0
char id=103 x=322 y=18 width=14 height=14 xoffset=1 yoffset=7 xadvance=16 page=0 chnl=0
char id=104 x=372 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=105 x=386 y=0 width=10 height=16 xoffset=3 yoffset=3 xadvance=16 page=0 chnl=0
char id=106 x=396 y=0 width=10 height=16 xoffset=3 yoffset=5 xadvance=16 page=0 chnl=0
char id=107 x=406 y=0 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=108 x=420 y=0 width=10 height=16 xoffset=3 yoffset=3 xadvance=16 page=0 chnl=0
char id=109 x=464 y=18 width=16 height=12 xoffset=1 yoffset=7 xadvance=16 page=0 chnl=0
char id=110 x=480 y=18 width=14 height=12 xoffset=1 yoffset=7 xadvance=16 page=0 chnl=0
char id=111 x=494 y=18 width=14 height=12 xoffset=1 yoffset=7 xadvance=16 page=0 chnl=0
char id=112 x=336 y=18 width=14 height=14 xoffset=1 yoffset=7 xadvance=16 page=0 chnl=0
char id=113 x=350 y=18 width=14 height=14 xoffset=1 yoffset=7 xadvance=16 page=0 chnl=0
char id=114 x=0 y=34 width=14 height=12 xoffset=1 yoffset=7 xadvance=16 page=0 chnl=0
char id=115 x=14 y=34 width=14 height=12 xoffset=1 yoffset=7 xadvance=16 page=0 chnl=0
char id=116 x=364 y=18 width=14 height=14 xoffset=1 yoffset=5 xadvance=16 page=0 chnl=0
char id=117 x=28 y=34 width=14 height=12 xoffset=1 yoffset=7 xadvance=16 page=0 chnl=0
char id=118 x=42 y=34 width=14 height=12 xoffset=1 yoffset=7 xadvance=16 page=0 chnl=0
char id=119 x=56 y=34 width=16 height=12 xoffset=1 yoffset=7 xadvance=16 page=0 chnl=0
char id=120 x=72 y=34 width=14 height=12 xoffset=1 yoffset=7 xadvance=16 page=0 chnl=0
char id=121 x=378 y=18 width=14 height=14 xoffset=1 yoffset=7 xadvance=16 page=0 chnl=0
char id=122 x=86 y=34 width=14 height=12 xoffset=1 yoffset=7 xadvance=16 page=0 chnl=0
char id=123 x=130 y=18 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=124 x=186 y=18 width=6 height=16 xoffset=5 yoffset=3 xadvance=16 page=0 chnl=0
char id=125 x=144 y=18 width=14 height=16 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
char id=126 x=174 y=34 width=14 height=8 xoffset=1 yoffset=3 xadvance=16 page=0 chnl=0
kernings count=0

View File

@@ -0,0 +1,274 @@
uiskin.png
size: 860,229
format: RGBA8888
filter: Nearest,Nearest
repeat: none
blue
rotate: false
xy: 106, 137
size: 2, 2
orig: 2, 2
offset: 0, 0
index: -1
button
rotate: false
xy: 715, 139
size: 36, 24
split: 18, 17, 11, 12
pad: 14, 14, 4, 4
orig: 36, 24
offset: 0, 0
index: -1
button-down
rotate: false
xy: 106, 140
size: 36, 24
split: 18, 17, 12, 11
pad: 14, 14, 4, 4
orig: 36, 24
offset: 0, 0
index: -1
check-box
rotate: false
xy: 162, 152
size: 12, 12
orig: 12, 12
offset: 0, 0
index: -1
check-box-off
rotate: false
xy: 715, 109
size: 12, 12
orig: 12, 12
offset: 0, 0
index: -1
commodore-64
rotate: false
xy: 1, 165
size: 512, 64
orig: 512, 64
offset: 0, 0
index: -1
cursor
rotate: false
xy: 143, 148
size: 18, 16
split: 9, 8, 7, 8
pad: 2, 0, 0, 0
orig: 18, 16
offset: 0, 0
index: -1
cursor-black
rotate: false
xy: 1, 14
size: 18, 16
split: 9, 8, 7, 8
pad: 2, 0, 0, 0
orig: 18, 16
offset: 0, 0
index: -1
dialog
rotate: false
xy: 1, 31
size: 38, 38
split: 19, 18, 18, 19
pad: 13, 13, 24, 13
orig: 38, 38
offset: 0, 0
index: -1
grey
rotate: false
xy: 752, 161
size: 2, 2
orig: 2, 2
offset: 0, 0
index: -1
horizontal-split-pane
rotate: false
xy: 732, 128
size: 14, 10
split: 6, 6, 0, 0
pad: 0, 0, 0, 0
orig: 14, 10
offset: 0, 0
index: -1
light-blue
rotate: false
xy: 143, 145
size: 2, 2
orig: 2, 2
offset: 0, 0
index: -1
list
rotate: false
xy: 821, 215
size: 22, 14
split: 0, 21, 0, 13
pad: 0, 17, 0, 2
orig: 22, 14
offset: 0, 0
index: -1
minus
rotate: false
xy: 78, 117
size: 14, 14
orig: 14, 14
offset: 0, 0
index: -1
music
rotate: false
xy: 715, 164
size: 46, 32
orig: 46, 32
offset: 0, 0
index: -1
music-off
rotate: false
xy: 774, 197
size: 46, 32
orig: 46, 32
offset: 0, 0
index: -1
plus
rotate: false
xy: 821, 200
size: 14, 14
orig: 14, 14
offset: 0, 0
index: -1
progress-bar
rotate: false
xy: 777, 180
size: 16, 16
split: 7, 8, 7, 8
pad: 2, 2, 2, 2
orig: 16, 16
offset: 0, 0
index: -1
progress-bar-knob
rotate: false
xy: 715, 122
size: 16, 16
split: 4, 4, 4, 4
pad: 0, 0, 0, 0
orig: 16, 16
offset: 0, 0
index: -1
radio-button
rotate: false
xy: 844, 217
size: 16, 12
orig: 16, 12
offset: 0, 0
index: -1
radio-button
rotate: false
xy: 844, 217
size: 16, 12
split: 14, 0, 5, 5
pad: 13, 0, 0, 0
orig: 16, 12
offset: 0, 0
index: -1
radio-button-off
rotate: false
xy: 1, 1
size: 16, 12
orig: 16, 12
offset: 0, 0
index: -1
scroll-bar
rotate: false
xy: 20, 16
size: 14, 14
split: 6, 6, 6, 6
pad: 0, 0, 0, 0
orig: 14, 14
offset: 0, 0
index: -1
scroll-bar-horizontal-knob
rotate: false
xy: 47, 117
size: 30, 14
split: 15, 14, 7, 6
pad: 0, 0, 0, 0
orig: 30, 14
offset: 0, 0
index: -1
scroll-bar-vertical-knob
rotate: false
xy: 762, 166
size: 14, 30
split: 7, 6, 16, 13
pad: 0, 0, 0, 0
orig: 14, 30
offset: 0, 0
index: -1
slider
rotate: false
xy: 40, 65
size: 4, 4
orig: 4, 4
offset: 0, 0
index: -1
slider-knob
rotate: false
xy: 777, 167
size: 10, 12
orig: 10, 12
offset: 0, 0
index: -1
sound
rotate: false
xy: 715, 197
size: 58, 32
orig: 58, 32
offset: 0, 0
index: -1
sound-off
rotate: false
xy: 47, 132
size: 58, 32
orig: 58, 32
offset: 0, 0
index: -1
touchpad
rotate: false
xy: 514, 29
size: 200, 200
orig: 200, 200
offset: 0, 0
index: -1
touchpad-knob
rotate: false
xy: 1, 70
size: 44, 44
orig: 44, 44
offset: 0, 0
index: -1
vertical-split-pane
rotate: false
xy: 794, 182
size: 10, 14
split: 0, 0, 6, 6
pad: 0, 1, 0, 0
orig: 10, 14
offset: 0, 0
index: -1
white
rotate: false
xy: 93, 129
size: 2, 2
orig: 2, 2
offset: 0, 0
index: -1
window
rotate: false
xy: 1, 115
size: 45, 49
split: 20, 20, 22, 22
pad: 22, 22, 24, 24
orig: 45, 49
offset: 0, 0
index: -1

View File

@@ -0,0 +1,172 @@
{
"com.badlogic.gdx.graphics.Color": {
"green": { "g": 1, "a": 1 },
"light_grey": { "r": 0.8, "g": 0.8, "b": 0.8, "a": 1 },
"white": { "r": 1, "g": 1, "b": 1, "a": 1 },
"red": { "r": 1, "a": 1 },
"light_blue": { "r": 0.64705884, "g": 0.64705884, "b": 1, "a": 1 },
"grey": { "r": 0.7, "g": 0.7, "b": 0.7, "a": 1 },
"dark_grey": { "r": 0.4, "g": 0.4, "b": 0.4, "a": 1 },
"blue": { "r": 0.25882354, "g": 0.25882354, "b": 0.90588236, "a": 1 },
"black": { "a": 1 }
},
"com.badlogic.gdx.graphics.g2d.BitmapFont": {
"commodore-64": { "file": "commodore-64.fnt" }
},
"com.badlogic.gdx.scenes.scene2d.ui.Skin$TintedDrawable": {
"dialogDim": {
"name": "white",
"color": { "a": 1, "b": 0.2, "g": 0.2, "r": 0.2 }
}
},
"com.badlogic.gdx.scenes.scene2d.ui.ProgressBar$ProgressBarStyle": {
"default-horizontal": { "background": "progress-bar", "knobBefore": "progress-bar-knob" },
"default-vertical": { "background": "progress-bar", "knobBefore": "progress-bar-knob" }
},
"com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle": {
"default": {
"font": "commodore-64",
"fontColor": { "a": 1, "b": 1, "g": 0.64705884, "r": 0.64705884 },
"downFontColor": { "a": 1, "b": 0.90588236, "g": 0.25882354, "r": 0.25882354 },
"disabledFontColor": { "a": 1, "b": 0.8, "g": 0.8, "r": 0.8 },
"up": "button",
"down": "button-down"
},
"toggle": {
"font": "commodore-64",
"fontColor": { "a": 1, "b": 1, "g": 0.64705884, "r": 0.64705884 },
"downFontColor": { "a": 1, "b": 0.90588236, "g": 0.25882354, "r": 0.25882354 },
"checkedFontColor": { "a": 1, "b": 0.90588236, "g": 0.25882354, "r": 0.25882354 },
"up": "button",
"down": "button-down",
"checked": "button-down"
}
},
"com.badlogic.gdx.scenes.scene2d.ui.ImageButton$ImageButtonStyle": {
"default": { "up": "button", "down": "button-down" }
},
"com.badlogic.gdx.scenes.scene2d.ui.SplitPane$SplitPaneStyle": {
"default-vertical": { "handle": "vertical-split-pane" },
"default-horizontal": { "handle": "horizontal-split-pane" }
},
"com.badlogic.gdx.scenes.scene2d.ui.Touchpad$TouchpadStyle": {
"default": { "background": "touchpad", "knob": "touchpad-knob" }
},
"com.badlogic.gdx.scenes.scene2d.ui.Button$ButtonStyle": {
"default": { "up": "button", "down": "button-down" },
"music": { "up": "music-off", "down": "music", "checked": "music" },
"sound": { "up": "sound-off", "down": "sound", "checked": "sound" },
"toggle": { "up": "button", "down": "button-down", "checked": "button-down" }
},
"com.badlogic.gdx.scenes.scene2d.ui.Window$WindowStyle": {
"default": {
"background": "window",
"titleFont": "commodore-64",
"titleFontColor": { "a": 1, "b": 1, "g": 0.64705884, "r": 0.64705884 }
},
"dialog": {
"background": "dialog",
"titleFont": "commodore-64",
"titleFontColor": { "a": 1, "b": 1, "g": 0.64705884, "r": 0.64705884 }
},
"dialog-modal": {
"background": "dialog",
"titleFont": "commodore-64",
"titleFontColor": { "a": 1, "b": 1, "g": 1, "r": 1 },
"stageBackground": "blue"
}
},
"com.badlogic.gdx.scenes.scene2d.ui.TextField$TextFieldStyle": {
"default": {
"font": "commodore-64",
"fontColor": { "a": 1 },
"background": "white",
"cursor": "cursor-black",
"selection": "light-blue",
"messageFont": "commodore-64",
"messageFontColor": { "a": 1, "b": 0.8, "g": 0.8, "r": 0.8 }
},
"nobg": {
"font": "commodore-64",
"fontColor": { "a": 1, "b": 1, "g": 0.64705884, "r": 0.64705884 },
"cursor": "cursor",
"selection": "white",
"messageFont": "commodore-64",
"messageFontColor": { "a": 1, "b": 0.8, "g": 0.8, "r": 0.8 }
}
},
"com.badlogic.gdx.scenes.scene2d.ui.ScrollPane$ScrollPaneStyle": {
"default": {
"background": "blue",
"hScroll": "scroll-bar",
"hScrollKnob": "scroll-bar-horizontal-knob",
"vScroll": "scroll-bar",
"vScrollKnob": "scroll-bar-vertical-knob"
}
},
"com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle": {
"optional": {
"font": "commodore-64",
"fontColor": { "a": 1, "b": 1, "g": 1, "r": 1 }
},
"default": {
"font": "commodore-64",
"fontColor": { "a": 1, "b": 1, "g": 0.64705884, "r": 0.64705884 }
},
"error": {
"font": "commodore-64",
"fontColor": { "a": 1, "b": 0.4, "g": 0.4, "r": 0.4 }
},
"title": {
"font": "commodore-64",
"fontColor": { "a": 1, "b": 1, "g": 0.64705884, "r": 0.64705884 },
"background": "button"
}
},
"com.badlogic.gdx.scenes.scene2d.ui.List$ListStyle": {
"default": {
"font": "commodore-64",
"fontColorSelected": { "a": 1, "b": 0.90588236, "g": 0.25882354, "r": 0.25882354 },
"fontColorUnselected": { "a": 1, "b": 1, "g": 0.64705884, "r": 0.64705884 },
"selection": "white"
},
"dimmed": {
"font": "commodore-64",
"fontColorSelected": { "a": 1, "b": 0.90588236, "g": 0.25882354, "r": 0.25882354 },
"fontColorUnselected": { "a": 1, "b": 0.90588236, "g": 0.25882354, "r": 0.25882354 },
"selection": "light-blue",
"background": "white"
}
},
"com.badlogic.gdx.scenes.scene2d.ui.CheckBox$CheckBoxStyle": {
"default": {
"checkboxOn": "check-box",
"checkboxOff": "check-box-off",
"font": "commodore-64",
"fontColor": { "a": 1, "b": 1, "g": 0.64705884, "r": 0.64705884 }
},
"radio": {
"checkboxOn": "radio-button",
"checkboxOff": "radio-button-off",
"font": "commodore-64",
"fontColor": { "a": 1, "b": 1, "g": 0.64705884, "r": 0.64705884 },
"checkedFontColor": { "a": 1, "b": 1, "g": 1, "r": 1 }
}
},
"com.badlogic.gdx.scenes.scene2d.ui.Tree$TreeStyle": {
"default": { "plus": "plus", "minus": "minus", "selection": "progress-bar" }
},
"com.badlogic.gdx.scenes.scene2d.ui.Slider$SliderStyle": {
"default-vertical": { "background": "slider", "knob": "slider-knob" },
"default-horizontal": { "background": "slider", "knob": "slider-knob" }
},
"com.badlogic.gdx.scenes.scene2d.ui.SelectBox$SelectBoxStyle": {
"default": {
"font": "commodore-64",
"fontColor": { "a": 1, "b": 1, "g": 0.64705884, "r": 0.64705884 },
"background": "list",
"scrollStyle": "default",
"listStyle": "dimmed"
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@@ -0,0 +1,92 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
gradlePluginPortal()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.4'
}
}
allprojects {
apply plugin: "eclipse"
version = '1.0'
ext {
appName = "My GDX Game"
gdxVersion = '1.12.0'
roboVMVersion = '2.3.20'
box2DLightsVersion = '1.5'
ashleyVersion = '1.7.4'
aiVersion = '1.8.2'
gdxControllersVersion = '2.2.1'
}
repositories {
mavenLocal()
mavenCentral()
google()
gradlePluginPortal()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
maven { url "https://jitpack.io" }
}
}
project(":desktop") {
apply plugin: "java-library"
dependencies {
implementation project(":core")
api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
api "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
api "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
api "com.github.bhlangonijr:chesslib:1.3.3"
}
}
project(":core") {
apply plugin: "java-library"
dependencies {
api "com.badlogicgames.gdx:gdx:$gdxVersion"
api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
api "com.badlogicgames.ashley:ashley:$ashleyVersion"
api "com.github.bhlangonijr:chesslib:1.3.3"
}
}
project(":android") {
apply plugin: "com.android.application"
configurations { natives }
dependencies {
implementation project(":core")
api "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
api "com.badlogicgames.ashley:ashley:$ashleyVersion"
}
}

View File

@@ -0,0 +1,6 @@
sourceCompatibility = 1.7
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.main.java.srcDirs = [ "src/" ]
eclipse.project.name = appName + "-core"

View File

@@ -0,0 +1,13 @@
package com.mygdx.game;
import com.badlogic.gdx.graphics.Color;
public class GameConfig {
public static final float WIDTH = 600f; // pixels
public static final float HEIGHT = 600f; // pixels
public static final Color background = new Color(66 / 255f, 66 / 255f, 231 / 255f, 0f);
public static final Color brown = new Color(159 / 255f, 80 / 255f, 50 / 255f, 0f);
public static final Color white = new Color(228 / 255f, 191 / 255f, 147 / 255f, 0f);
public static final Color green = new Color(50 / 255f, 160 / 255f, 50 / 255f, 0f);
}

View File

@@ -0,0 +1,93 @@
package com.mygdx.game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.utils.Array;
import java.util.Comparator;
public class GameManager {
public static GameManager I = new GameManager();
String s_e_k = "sound_effect";
public boolean soundEffect = true;
String s_p_k = "single_player";
public boolean singlePlayer = false;
String menu_vol_key = "menu_volume";
public float menuVolume = 1f;
String game_vol_key = "game_volume";
public float gameVolume = 1f;
private final Preferences PREFS;
public static class Player{
public String name;
public int score;
public Player(String n, int s){
name = n;
score = s;
}
}
String player_score = "player_score_";
String player_name = "player_name_";
public Array<Player> scores = new Array<>();
private GameManager() {
PREFS = Gdx.app.getPreferences(MyGame.class.getSimpleName());
}
public void addToScore(String name, int score){
scores.add(new Player(name, score));
scores.sort(new Comparator<Player>() {
@Override
public int compare(Player player, Player t1) {
return player.score - t1.score;
}
}
);
scores.removeIndex(scores.size - 1);
}
public void clearScores(){
for (Player e: scores ) {
e.name = "EMPTY";
e.score = 300;
}
}
void loadPref(){
menuVolume = PREFS.getFloat(menu_vol_key, 1f);
gameVolume = PREFS.getFloat(game_vol_key, 1f);
soundEffect = PREFS.getBoolean(s_e_k, true);
singlePlayer = PREFS.getBoolean(s_p_k, false);
for (int i = 0; i < 5; i ++){
Player p = new Player( PREFS.getString(player_name + i, ""),
PREFS.getInteger(player_score + i, 0));
scores.add(p);
}
}
void savePref(){
int start = scores.size - 5;
if(start < 0) start = 0;
int savepoint = 0;
for (int i = start; i < scores.size; i ++){
Player s = scores.get(i);
PREFS.putString(player_name + savepoint, s.name);
PREFS.putInteger(player_score + savepoint, s.score);
savepoint++;
}
PREFS.putFloat(menu_vol_key, menuVolume);
PREFS.putFloat(game_vol_key, gameVolume);
PREFS.putBoolean(s_e_k, soundEffect);
PREFS.putBoolean(s_p_k, singlePlayer);
PREFS.flush();
}
}

View File

@@ -0,0 +1,54 @@
package com.mygdx.game;
import com.badlogic.gdx.Application;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.mygdx.game.assets.AssetDescriptors;
import com.mygdx.game.screens.IntroScreen;
public class MyGame extends Game {
public SpriteBatch batch;
public AssetManager assetManager;
public Music menuMusic;
public Music gameMusic;
@Override
public void create () {
Gdx.app.setLogLevel(Application.LOG_DEBUG);
batch = new SpriteBatch();
assetManager = new AssetManager();
loadAssets();
GameManager.I.loadPref();
menuMusic = assetManager.get(AssetDescriptors.MENU_MUSIC);
menuMusic.setLooping(true);
menuMusic.setVolume(GameManager.I.menuVolume);
menuMusic.play();
gameMusic = assetManager.get(AssetDescriptors.GAME_MUSIC);
gameMusic.setLooping(true);
gameMusic.setVolume(GameManager.I.gameVolume);
setScreen(new IntroScreen(this));
}
void loadAssets(){
assetManager.load(AssetDescriptors.UI_SKIN);
assetManager.load(AssetDescriptors.CHESS);
assetManager.load(AssetDescriptors.MENU_MUSIC);
assetManager.load(AssetDescriptors.GAME_MUSIC);
assetManager.load(AssetDescriptors.SOUND_EFFECT);
assetManager.finishLoading(); // blocks until all assets are loaded
}
@Override
public void dispose () {
GameManager.I.savePref();
batch.dispose();
assetManager.dispose();
}
}

View File

@@ -0,0 +1,34 @@
package com.mygdx.game;
import com.github.bhlangonijr.chesslib.File;
import com.github.bhlangonijr.chesslib.Rank;
public class Utils {
public static int fileToInt(File f){
switch (f){
case FILE_A: return 0;
case FILE_B: return 1;
case FILE_C: return 2;
case FILE_D: return 3;
case FILE_E: return 4;
case FILE_F: return 5;
case FILE_G: return 6;
case FILE_H: return 7;
}
return 0;
}
public static int rankToInt(Rank f){
switch (f){
case RANK_1: return 0;
case RANK_2: return 1;
case RANK_3: return 2;
case RANK_4: return 3;
case RANK_5: return 4;
case RANK_6: return 5;
case RANK_7: return 6;
case RANK_8: return 7;
}
return 0;
}
}

View File

@@ -0,0 +1,27 @@
package com.mygdx.game.assets;
import com.badlogic.gdx.assets.AssetDescriptor;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
public class AssetDescriptors {
public static final AssetDescriptor<Skin> UI_SKIN =
new AssetDescriptor<>(AssetPaths.UI_SKIN, Skin.class);
public static final AssetDescriptor<TextureAtlas> CHESS =
new AssetDescriptor<>(AssetPaths.CHESS, TextureAtlas.class);
public static final AssetDescriptor<Music> MENU_MUSIC =
new AssetDescriptor<>(AssetPaths.MENU_MUSIC, Music.class);
public static final AssetDescriptor<Music> GAME_MUSIC =
new AssetDescriptor<>(AssetPaths.GAME_MUSIC, Music.class);
public static final AssetDescriptor<Sound> SOUND_EFFECT =
new AssetDescriptor<>(AssetPaths.SOUND_EFFECT, Sound.class);
private AssetDescriptors() {
}
}

View File

@@ -0,0 +1,15 @@
package com.mygdx.game.assets;
public class AssetPaths {
public static final String UI_SKIN = "ui/uiskin.json";
// public static final String GAMEPLAY = "gameplay/gameplay.atlas";
public static final String CHESS = "chess/chess.atlas";
public static final String MENU_MUSIC = "sound/Science_Documentary.mp3";
public static final String GAME_MUSIC = "sound/the-best-jazz-club-in-new-orleans.mp3";
public static final String SOUND_EFFECT = "sound/move-self.mp3";
private AssetPaths() {
}
}

View File

@@ -0,0 +1,20 @@
package com.mygdx.game.assets;
public class RegionNames {
public static final String bishop_b = "bishop_b";
public static final String bishop_w = "bishop_w";
public static final String king_b = "king_b";
public static final String king_w = "king_w";
public static final String knight_b = "knight_b";
public static final String knight_w = "knight_w";
public static final String pawn_b = "pawn_b";
public static final String pawn_w = "pawn_w";
public static final String queen_b = "queen_b";
public static final String queen_w = "queen_w";
public static final String rook_b = "rook_b";
public static final String rook_w = "rook_w";
private RegionNames() {
}
}

View File

@@ -0,0 +1,307 @@
package com.mygdx.game.screens;
import static com.badlogic.gdx.math.MathUtils.random;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputMultiplexer;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.Widget;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.Logger;
import com.badlogic.gdx.utils.ScreenUtils;
import com.badlogic.gdx.utils.viewport.FitViewport;
import com.badlogic.gdx.utils.viewport.Viewport;
import com.github.bhlangonijr.chesslib.Board;
import com.github.bhlangonijr.chesslib.Piece;
import com.github.bhlangonijr.chesslib.Side;
import com.github.bhlangonijr.chesslib.Square;
import com.github.bhlangonijr.chesslib.move.Move;
import com.mygdx.game.MyGame;
import com.mygdx.game.*;
import com.mygdx.game.assets.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
public class GameScreen extends ScreenAdapter {
private static final Logger log = new Logger(GameScreen.class.getSimpleName(), Logger.DEBUG);
private final MyGame game;
private ShapeRenderer shapeRenderer;
private Viewport viewport;
private Viewport hudViewport;
private Stage gameplayStage;
private Stage hudStage;
private Skin skin;
private Label turnLabel;
private Sound soundEffect;
public GameScreen(MyGame game) {
this.game = game;
game.menuMusic.pause();
game.gameMusic.play();
}
Map<Piece, TextureAtlas.AtlasRegion> regionMap;
Board board = new Board();
List<Move> moves;
void loadRegionMap(){
TextureAtlas atlas = game.assetManager.get(AssetDescriptors.CHESS);
regionMap.put(Piece.WHITE_PAWN, atlas.findRegion(RegionNames.pawn_w));
regionMap.put(Piece.WHITE_KNIGHT, atlas.findRegion(RegionNames.knight_w));
regionMap.put(Piece.WHITE_BISHOP, atlas.findRegion(RegionNames.bishop_w));
regionMap.put(Piece.WHITE_ROOK, atlas.findRegion(RegionNames.rook_w));
regionMap.put(Piece.WHITE_QUEEN, atlas.findRegion(RegionNames.queen_w));
regionMap.put(Piece.WHITE_KING, atlas.findRegion(RegionNames.king_w));
regionMap.put(Piece.BLACK_PAWN, atlas.findRegion(RegionNames.pawn_b));
regionMap.put(Piece.BLACK_KNIGHT, atlas.findRegion(RegionNames.knight_b));
regionMap.put(Piece.BLACK_BISHOP, atlas.findRegion(RegionNames.bishop_b));
regionMap.put(Piece.BLACK_ROOK, atlas.findRegion(RegionNames.rook_b));
regionMap.put(Piece.BLACK_QUEEN, atlas.findRegion(RegionNames.queen_b));
regionMap.put(Piece.BLACK_KING, atlas.findRegion(RegionNames.king_b));
}
@Override
public void show() {
viewport = new FitViewport(80f, 80f);
hudViewport = new FitViewport(GameConfig.WIDTH, GameConfig.HEIGHT);
gameplayStage = new Stage(viewport, game.batch);
hudStage = new Stage(hudViewport, game.batch);
skin = game.assetManager.get(AssetDescriptors.UI_SKIN);
soundEffect = game.assetManager.get(AssetDescriptors.SOUND_EFFECT);
shapeRenderer = new ShapeRenderer();
regionMap = new HashMap<>();
loadRegionMap();
moves = board.legalMoves();
gameplayStage.addActor(createGrid());
hudStage.addActor(createInfo());
hudStage.addActor(createBackButton());
Gdx.input.setInputProcessor(new InputMultiplexer(gameplayStage, hudStage));
}
@Override
public void resize(int width, int height) {
viewport.update(width, height, true);
hudViewport.update(width, height, true);
}
Vector<Integer> poss_int = new Vector<>();
Vector<Move> poss_mv = new Vector<>();
void clickGrid(int index){
Square clickedSq = Square.squareAt(index);
for (Move m: poss_mv) {
if(m.getTo() == clickedSq){
board.doMove(m);
boolean isMate = board.isMated();
boolean isDraw = board.isDraw();
if( isMate || isDraw ){
if(isMate){
turnLabel.setText("MATE");
}
if(isDraw){
turnLabel.setText("DRAW");
}
if(GameManager.I.singlePlayer){
if(board.getSideToMove() == Side.BLACK){
game.setScreen(new LeaderboardScreen(game, board.getMoveCounter()));
return;
}
}
}
turnLabel.setText(board.getSideToMove().toString());
moves = board.legalMoves();
poss_mv.clear();
poss_int.clear();
if(GameManager.I.soundEffect)
soundEffect.play();
if(GameManager.I.singlePlayer){
int moveC = moves.size();
float rand = random.nextFloat();
int mov = (int) (rand * moveC);
board.doMove(moves.get(mov));
moves = board.legalMoves();
}
return;
}
}
poss_mv.clear();
poss_int.clear();
for (Move m : moves) {
if (m.getFrom() == clickedSq)
{
int rank = Utils.rankToInt(m.getTo().getRank());
int file = Utils.fileToInt(m.getTo().getFile());
int in = rank * 8 + file;
poss_int.add(in);
poss_mv.add(m);
}
}
}
void drawGrid(){
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if( ( (i * 8) + j + i) % 2 == 0)
shapeRenderer.setColor(GameConfig.brown);
else
shapeRenderer.setColor(GameConfig.white);
shapeRenderer.rect(8+j * 8, 8+i*8, 8,8);
}
}
}
void drawPossibility(){
shapeRenderer.setColor(GameConfig.green);
for (Integer i : poss_int) {
int x = i % 8;
int y = i / 8;
shapeRenderer.rect(9 + x * 8, 9 + y * 8, 6,6);
}
}
void drawFigures(){
Piece[] pieces = board.boardToArray();
for (int i = 0; i < pieces.length; i++) {
if(pieces[i] == Piece.NONE) continue;
int x = i % 8;
int y = i / 8;
game.batch.draw(regionMap.get(pieces[i]), 8 + x * 8 , 8 + y * 8, 8,8);
}
}
@Override
public void render(float delta) {
ScreenUtils.clear(GameConfig.background);
shapeRenderer.setProjectionMatrix(viewport.getCamera().combined);
shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
drawGrid();
drawPossibility();
shapeRenderer.end();
game.batch.setProjectionMatrix(viewport.getCamera().combined);
game.batch.begin();
drawFigures();
game.batch.end();
// update
gameplayStage.act(delta);
hudStage.act(delta);
// draw
gameplayStage.draw();
hudStage.draw();
}
@Override
public void hide() {
dispose();
}
@Override
public void dispose() {
gameplayStage.dispose();
hudStage.dispose();
}
static class Cell extends Widget{
public int pos;
Cell(int p){
pos = p;
}
}
private Actor createGrid() {
final Table table = new Table();
table.setDebug(false); // turn on all debug lines (table, cell, and widget)
Table grid = new Table();
grid.defaults().size(8f); // all cells will be the same size
grid.setDebug(false);
for (int row = 0; row < 8; row++) {
for (int column = 0; column < 8; column++) {
int y = 8 - row - 1;
final Cell widget = new Cell(y * 8 + column);
widget.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
final Cell clickedCell = (Cell) event.getTarget(); // it will be an image for sure :-)
clickGrid(clickedCell.pos);
}
});
grid.add(widget);
}
grid.row();
}
table.add(grid).row();
table.center();
table.setFillParent(true);
table.pack();
return table;
}
private Actor createBackButton() {
final TextButton backButton = new TextButton("Back", skin);
backButton.setWidth(100);
backButton.setPosition(GameConfig.WIDTH / 2f - backButton.getWidth() / 2f, 20f);
backButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.setScreen(new MenuScreen(game));
}
});
return backButton;
}
private Actor createInfo() {
final Table table = new Table();
turnLabel = new Label(board.getSideToMove().toString(), skin);
table.add(turnLabel).row();
table.center();
table.pack();
table.setPosition(
GameConfig.WIDTH / 2f - table.getWidth() / 2f,
GameConfig.HEIGHT - table.getHeight() - 20f
);
return table;
}
}

View File

@@ -0,0 +1,122 @@
package com.mygdx.game.screens;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.ScreenUtils;
import com.badlogic.gdx.utils.viewport.FitViewport;
import com.badlogic.gdx.utils.viewport.Viewport;
import com.mygdx.game.MyGame;
import com.mygdx.game.*;
import com.mygdx.game.assets.*;
public class IntroScreen extends ScreenAdapter {
public static final float INTRO_DURATION_IN_SEC = 8f; // duration of the (intro) animation
private final MyGame game;
private Viewport viewport;
private TextureAtlas gameplayAtlas;
private float duration = 0f;
private Stage stage;
public IntroScreen(MyGame game) {
this.game = game;
}
@Override
public void show() {
viewport = new FitViewport(GameConfig.WIDTH, GameConfig.HEIGHT);
stage = new Stage(viewport, game.batch);
gameplayAtlas = game.assetManager.get(AssetDescriptors.CHESS);
for (int i = 0; i < 8; i++) {
stage.addActor(createPawnB(i));
stage.addActor(createPawnW(i));
}
}
@Override
public void resize(int width, int height) {
viewport.update(width, height, true);
}
@Override
public void render(float delta) {
ScreenUtils.clear(GameConfig.background);
duration += delta;
// go to the MenuScreen after INTRO_DURATION_IN_SEC seconds
if (duration > INTRO_DURATION_IN_SEC) {
game.setScreen(new MenuScreen(game));
}
stage.act(delta);
stage.draw();
}
@Override
public void hide() {
dispose();
}
@Override
public void dispose() {
stage.dispose();
}
private Actor createPawnB(int num) {
Image pawn = new Image(gameplayAtlas.findRegion(RegionNames.pawn_b));
// set positions x, y to center the image to the center of the window
float posX = (viewport.getWorldWidth() / 2f) - pawn.getWidth() * num + pawn.getWidth() * 3;
float posY = (viewport.getWorldHeight() / 2f) - pawn.getHeight();
pawn.setOrigin(Align.center);
pawn.addAction(
Actions.sequence(
Actions.delay(0.5f * num),
Actions.moveTo(0, posY, 1.5f),
Actions.moveTo(posX, posY, 1.5f) // // move image to the center of the window
)
);
return pawn;
}
private Actor createPawnW(int num) {
Image pawn = new Image(gameplayAtlas.findRegion(RegionNames.pawn_w));
// set positions x, y to center the image to the center of the window
float posX = (viewport.getWorldWidth() / 2f) - pawn.getWidth() * num + pawn.getWidth() * 3;
float posY = (viewport.getWorldHeight() / 2f);
pawn.setOrigin(Align.center);
pawn.addAction(
Actions.sequence(
Actions.delay(0.5f * num),
Actions.moveTo(0, posY, 1.5f),
Actions.moveTo(posX, posY, 1.5f) // // move image to the center of the window
)
);
return pawn;
}
}

View File

@@ -0,0 +1,132 @@
package com.mygdx.game.screens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.ScreenUtils;
import com.badlogic.gdx.utils.viewport.FitViewport;
import com.badlogic.gdx.utils.viewport.Viewport;
import com.mygdx.game.GameConfig;
import com.mygdx.game.GameManager;
import com.mygdx.game.MyGame;
import com.mygdx.game.assets.AssetDescriptors;
public class LeaderboardScreen extends ScreenAdapter {
private final MyGame game;
private final AssetManager assetManager;
private Viewport viewport;
private Stage stage;
int score = 0;
public LeaderboardScreen(MyGame game) {
this.game = game;
assetManager = game.assetManager;
}
public LeaderboardScreen(MyGame game, int score){
this.game = game;
assetManager = game.assetManager;
this.score = score;
}
@Override
public void show() {
viewport = new FitViewport(GameConfig.WIDTH, GameConfig.HEIGHT);
stage = new Stage(viewport, game.batch);
stage.addActor(createUi());
Gdx.input.setInputProcessor(stage);
}
@Override
public void resize(int width, int height) {
viewport.update(width, height, true);
}
@Override
public void render(float delta) {
ScreenUtils.clear(GameConfig.background);
stage.act(delta);
stage.draw();
}
@Override
public void hide() {
dispose();
}
@Override
public void dispose() {
stage.dispose();
}
private Actor createUi() {
Table table = new Table();
table.defaults().pad(20);
final Skin uiSkin = assetManager.get(AssetDescriptors.UI_SKIN);
final Table contentTable = new Table(uiSkin);
contentTable.add(new Label("Leaderboard", uiSkin)).padBottom(50).row();
final TextButton backButton = new TextButton("Back", uiSkin);
backButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.setScreen(new MenuScreen(game));
}
});
if(score > 0) {
final TextField textField = new TextField("Name", uiSkin);
textField.addListener(new InputListener() {
@Override
public boolean keyTyped(InputEvent event, char character) {
if(character == '\r' || character == '\n') {
String name = textField.getText();
GameManager.I.addToScore(name, score);
contentTable.clear();
contentTable.add(new Label("Leaderboard", uiSkin)).padBottom(50).row();
for (GameManager.Player p: GameManager.I.scores) {
contentTable.add(new Label(p.name, uiSkin));
contentTable.add(new Label(String.valueOf(p.score), uiSkin)).row();
}
contentTable.add(backButton).width(100).padTop(50).colspan(2).padBottom(50);
}
return false;
}
});
contentTable.add(textField).padBottom(50).row();
}
for (GameManager.Player p: GameManager.I.scores) {
contentTable.add(new Label(p.name, uiSkin));
contentTable.add(new Label(String.valueOf(p.score), uiSkin)).row();
}
contentTable.add(backButton).width(100).padTop(50).colspan(2).padBottom(50);
table.add(contentTable);
table.center();
table.setFillParent(true);
table.pack();
return table;
}
}

View File

@@ -0,0 +1,127 @@
package com.mygdx.game.screens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.ScreenUtils;
import com.badlogic.gdx.utils.viewport.FitViewport;
import com.badlogic.gdx.utils.viewport.Viewport;
import com.mygdx.game.MyGame;
import com.mygdx.game.*;
import com.mygdx.game.assets.*;
public class MenuScreen extends ScreenAdapter {
private final MyGame game;
private final AssetManager assetManager;
private Viewport viewport;
private Stage stage;
private Skin skin;
public MenuScreen(MyGame game) {
this.game = game;
assetManager = game.assetManager;
}
@Override
public void show() {
viewport = new FitViewport(GameConfig.WIDTH, GameConfig.HEIGHT);
stage = new Stage(viewport, game.batch);
skin = assetManager.get(AssetDescriptors.UI_SKIN);
stage.addActor(createUi());
Gdx.input.setInputProcessor(stage);
game.menuMusic.play();
game.gameMusic.pause();
}
@Override
public void resize(int width, int height) {
viewport.update(width, height, true);
}
@Override
public void render(float delta) {
ScreenUtils.clear(GameConfig.background);
stage.act(delta);
stage.draw();
}
@Override
public void hide() {
dispose();
}
@Override
public void dispose() {
stage.dispose();
}
private Actor createUi() {
Table table = new Table();
table.defaults().pad(20);
TextButton playButton = new TextButton("Play", skin);
playButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.setScreen(new GameScreen(game));
}
});
TextButton leaderboardButton = new TextButton("Leaderboard", skin);
leaderboardButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.setScreen(new LeaderboardScreen(game));
}
});
TextButton settingsButton = new TextButton("Settings", skin);
settingsButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.setScreen(new SettingsScreen(game));
}
});
TextButton quitButton = new TextButton("Quit", skin);
quitButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
Gdx.app.exit();
}
});
Table buttonTable = new Table();
buttonTable.defaults().padLeft(30).padRight(30);
buttonTable.add(playButton).padBottom(15).expandX().fill().row();
buttonTable.add(leaderboardButton).padBottom(15).fillX().row();
buttonTable.add(settingsButton).padBottom(15).fillX().row();
buttonTable.add(quitButton).fillX();
buttonTable.center();
table.add(buttonTable);
table.center();
table.setFillParent(true);
table.pack();
return table;
}
}

View File

@@ -0,0 +1,153 @@
package com.mygdx.game.screens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Slider;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.ScreenUtils;
import com.badlogic.gdx.utils.viewport.FitViewport;
import com.badlogic.gdx.utils.viewport.Viewport;
import com.mygdx.game.MyGame;
import com.mygdx.game.*;
import com.mygdx.game.assets.*;
public class SettingsScreen extends ScreenAdapter {
private final MyGame game;
private final AssetManager assetManager;
private Viewport viewport;
private Stage stage;
public SettingsScreen(MyGame game) {
this.game = game;
assetManager = game.assetManager;
}
@Override
public void show() {
viewport = new FitViewport(GameConfig.WIDTH, GameConfig.HEIGHT);
stage = new Stage(viewport, game.batch);
stage.addActor(createUi());
Gdx.input.setInputProcessor(stage);
}
@Override
public void resize(int width, int height) {
viewport.update(width, height, true);
}
@Override
public void render(float delta) {
ScreenUtils.clear(GameConfig.background);
stage.act(delta);
stage.draw();
}
@Override
public void hide() {
dispose();
}
@Override
public void dispose() {
stage.dispose();
}
private Actor createUi() {
Skin uiSkin = assetManager.get(AssetDescriptors.UI_SKIN);
Table contentTable = new Table(uiSkin);
contentTable.add(new Label("Settings", uiSkin)).padBottom(50).colspan(2).row();
CheckBox singlePlayer = new CheckBox(" Single Player", uiSkin);
singlePlayer.setChecked(GameManager.I.singlePlayer);
singlePlayer.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
CheckBox s = (CheckBox) actor;
GameManager.I.singlePlayer = s.isChecked();
}
});
contentTable.add(singlePlayer).padTop(20).colspan(2).row();
CheckBox soundEffect = new CheckBox(" Sound Effects", uiSkin);
soundEffect.setChecked(GameManager.I.soundEffect);
soundEffect.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
CheckBox s = (CheckBox) actor;
GameManager.I.soundEffect = s.isChecked();
}
});
contentTable.add(soundEffect).padTop(20).colspan(2).row();
contentTable.add(new Label("Menu Volume:", uiSkin)).padTop(20).colspan(2).row();
Slider slider = new Slider(0.0f, 1.0f, 0.01f, false,uiSkin);
slider.setValue(GameManager.I.menuVolume);
slider.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
Slider s = (Slider) actor;
GameManager.I.menuVolume = s.getValue();
game.gameMusic.pause();
game.menuMusic.play();
game.menuMusic.setVolume(s.getValue());
}
});
contentTable.add(slider).row();
contentTable.add(new Label("Game Volume:", uiSkin)).padTop(20).colspan(2).row();
slider = new Slider(0.0f, 1.0f, 0.01f, false,uiSkin);
slider.setValue(GameManager.I.gameVolume);
slider.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
Slider s = (Slider) actor;
GameManager.I.gameVolume = s.getValue();
game.menuMusic.pause();
game.gameMusic.play();
game.gameMusic.setVolume(s.getValue());
}
});
contentTable.add(slider).row();
TextButton backButton = new TextButton("Back", uiSkin);
backButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.setScreen(new MenuScreen(game));
}
});
contentTable.add(backButton).width(100).padTop(50).colspan(2).padBottom(50);
Table table = new Table();
table.defaults().pad(20);
table.add(contentTable);
table.center();
table.setFillParent(true);
table.pack();
return table;
}
}

View File

@@ -0,0 +1,49 @@
sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = [ "src/" ]
sourceSets.main.resources.srcDirs = ["../assets"]
project.ext.mainClassName = "com.mygdx.game.DesktopLauncher"
project.ext.assetsDir = new File("../assets")
import org.gradle.internal.os.OperatingSystem
tasks.register('run', JavaExec) {
dependsOn classes
mainClass = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
if (OperatingSystem.current() == OperatingSystem.MAC_OS) {
// Required to run on macOS
jvmArgs += "-XstartOnFirstThread"
}
}
tasks.register('debug', JavaExec) {
dependsOn classes
mainClass = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
debug = true
}
tasks.register('dist', Jar) {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
manifest {
attributes 'Main-Class': project.mainClassName
}
dependsOn configurations.runtimeClasspath
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
with jar
}
dist.dependsOn classes
eclipse.project.name = appName + "-desktop"

View File

@@ -0,0 +1,22 @@
package com.mygdx.game;
import com.badlogic.gdx.tools.texturepacker.TexturePacker;
public class AssetPacker {
private static final boolean DRAW_DEBUG_OUTLINE = false;
private static final String RAW_ASSETS_PATH = "assets/raw";
private static final String ASSETS_PATH = "assets";
public static void main(String[] args) {
TexturePacker.Settings settings = new TexturePacker.Settings();
settings.debug = DRAW_DEBUG_OUTLINE;
TexturePacker.process(settings,
RAW_ASSETS_PATH + "/chess", // the directory containing individual images to be packed
ASSETS_PATH + "/chess", // the directory where the pack file will be written
"chess" // the name of the pack file / atlas name
);
}
}

View File

@@ -0,0 +1,15 @@
package com.mygdx.game;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
// Please note that on macOS your application needs to be started with the -XstartOnFirstThread JVM argument
public class DesktopLauncher {
public static void main (String[] arg) {
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
config.setForegroundFPS(60);
config.setTitle("My GDX Game");
new Lwjgl3Application(new MyGame(), config);
}
}

View File

@@ -0,0 +1,7 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xms128m -Xmx1500m
org.gradle.configureondemand=false
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
android.useAndroidX=true

View File

@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -0,0 +1,240 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

View File

@@ -0,0 +1,91 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@@ -0,0 +1 @@
include 'desktop', 'core', 'android'

View File

@@ -0,0 +1,114 @@
## Java
*.class
*.war
*.ear
hs_err_pid*
## Robovm
/ios/robovm-build/
## GWT
/html/war/
/html/gwt-unitCache/
.apt_generated/
.gwt/
gwt-unitCache/
www-test/
.gwt-tmp/
## Android Studio and Intellij and Android in general
/android/libs/armeabi-v7a/
/android/libs/arm64-v8a/
/android/libs/x86/
/android/libs/x86_64/
/android/gen/
.idea/
*.ipr
*.iws
*.iml
/android/out/
com_crashlytics_export_strings.xml
## Eclipse
.classpath
.project
.metadata/
/android/bin/
/core/bin/
/desktop/bin/
/html/bin/
/ios/bin/
*.tmp
*.bak
*.swp
*~.nib
.settings/
.loadpath
.externalToolBuilders/
*.launch
## NetBeans
/nbproject/private/
/android/nbproject/private/
/core/nbproject/private/
/desktop/nbproject/private/
/html/nbproject/private/
/ios/nbproject/private/
/build/
/android/build/
/core/build/
/desktop/build/
/html/build/
/ios/build/
/nbbuild/
/android/nbbuild/
/core/nbbuild/
/desktop/nbbuild/
/html/nbbuild/
/ios/nbbuild/
/dist/
/android/dist/
/core/dist/
/desktop/dist/
/html/dist/
/ios/dist/
/nbdist/
/android/nbdist/
/core/nbdist/
/desktop/nbdist/
/html/nbdist/
/ios/nbdist/
nbactions.xml
nb-configuration.xml
## Gradle
/local.properties
.gradle/
gradle-app.setting
/build/
/android/build/
/core/build/
/desktop/build/
/html/build/
/ios/build/
## OS Specific
.DS_Store
Thumbs.db
## iOS
/ios/xcode/*.xcodeproj/*
!/ios/xcode/*.xcodeproj/xcshareddata
!/ios/xcode/*.xcodeproj/project.pbxproj
/ios/xcode/native/
/ios/IOSLauncher.app
/ios/IOSLauncher.app.dSYM

View File

@@ -0,0 +1,3 @@
To je igra kjer poskušamo preživeti najdle časa.
S tem da pobiramo metke in strelamo na slabe ljudi.
Da dobimo čim večje stevilo točk.

View File

@@ -0,0 +1,141 @@
Untitled
- Delay -
active: false
- Duration -
lowMin: 100.0
lowMax: 100.0
- Count -
min: 0
max: 200
- Emission -
lowMin: 0.0
lowMax: 0.0
highMin: 200.0
highMax: 200.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Life -
lowMin: 0.0
lowMax: 0.0
highMin: 400.0
highMax: 800.0
relative: false
scalingCount: 3
scaling0: 1.0
scaling1: 0.0
scaling2: 0.0
timelineCount: 3
timeline0: 0.0
timeline1: 0.60273975
timeline2: 0.9931507
independent: false
- Life Offset -
active: false
independent: false
- X Offset -
active: false
- Y Offset -
active: false
- Spawn Shape -
shape: point
- Spawn Width -
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Spawn Height -
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- X Scale -
lowMin: 0.0
lowMax: 0.0
highMin: 6.0
highMax: 6.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Y Scale -
active: false
- Velocity -
active: true
lowMin: 0.0
lowMax: 0.0
highMin: 3.0
highMax: 30.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Angle -
active: true
lowMin: 270.0
lowMax: 270.0
highMin: 225.0
highMax: 315.0
relative: false
scalingCount: 3
scaling0: 1.0
scaling1: 0.0
scaling2: 0.0
timelineCount: 3
timeline0: 0.0
timeline1: 0.1780822
timeline2: 1.0
- Rotation -
active: false
- Wind -
active: false
- Gravity -
active: false
- Tint -
colorsCount: 3
colors0: 0.8862745
colors1: 0.0
colors2: 0.8392157
timelineCount: 1
timeline0: 0.0
- Transparency -
lowMin: 0.0
lowMax: 0.0
highMin: 1.0
highMax: 1.0
relative: false
scalingCount: 4
scaling0: 0.0
scaling1: 1.0
scaling2: 0.75
scaling3: 0.0
timelineCount: 4
timeline0: 0.0
timeline1: 0.2
timeline2: 0.8
timeline3: 1.0
- Options -
attached: false
continuous: false
aligned: false
additive: false
behind: false
premultipliedAlpha: false
spriteMode: single
- Image Paths -
particle.png

View File

@@ -0,0 +1,141 @@
Untitled
- Delay -
active: false
- Duration -
lowMin: 100.0
lowMax: 100.0
- Count -
min: 0
max: 50
- Emission -
lowMin: 0.0
lowMax: 0.0
highMin: 500.0
highMax: 500.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Life -
lowMin: 0.0
lowMax: 0.0
highMin: 400.0
highMax: 800.0
relative: false
scalingCount: 3
scaling0: 1.0
scaling1: 1.0
scaling2: 0.3
timelineCount: 3
timeline0: 0.0
timeline1: 0.66
timeline2: 1.0
independent: false
- Life Offset -
active: false
independent: false
- X Offset -
active: false
- Y Offset -
active: false
- Spawn Shape -
shape: point
- Spawn Width -
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Spawn Height -
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- X Scale -
lowMin: 0.0
lowMax: 0.0
highMin: 6.0
highMax: 6.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Y Scale -
active: false
- Velocity -
active: true
lowMin: 0.0
lowMax: 0.0
highMin: 3.0
highMax: 30.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
- Angle -
active: true
lowMin: 90.0
lowMax: 90.0
highMin: 45.0
highMax: 135.0
relative: false
scalingCount: 3
scaling0: 1.0
scaling1: 0.0
scaling2: 0.0
timelineCount: 3
timeline0: 0.0
timeline1: 0.48630136
timeline2: 1.0
- Rotation -
active: false
- Wind -
active: false
- Gravity -
active: false
- Tint -
colorsCount: 3
colors0: 0.8862745
colors1: 0.07058824
colors2: 0.0
timelineCount: 1
timeline0: 0.0
- Transparency -
lowMin: 0.0
lowMax: 0.0
highMin: 1.0
highMax: 1.0
relative: false
scalingCount: 4
scaling0: 0.0
scaling1: 1.0
scaling2: 0.75
scaling3: 0.0
timelineCount: 4
timeline0: 0.0
timeline1: 0.2
timeline2: 0.8
timeline3: 1.0
- Options -
attached: false
continuous: false
aligned: false
additive: true
behind: false
premultipliedAlpha: false
spriteMode: single
- Image Paths -
particle.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -0,0 +1,62 @@
texture.png
size: 2048, 2048
format: RGBA8888
filter: Nearest, Nearest
repeat: none
background
rotate: false
xy: 2, 175
size: 1024, 1024
orig: 1024, 1024
offset: 0, 0
index: -1
ball
rotate: false
xy: 2, 73
size: 100, 100
orig: 100, 100
offset: 0, 0
index: -1
bullet
rotate: false
xy: 2, 2
size: 16, 16
orig: 16, 16
offset: 0, 0
index: -1
robot
rotate: false
xy: 104, 124
size: 43, 49
orig: 43, 49
offset: 0, 0
index: -1
soldier
rotate: false
xy: 1028, 1147
size: 43, 52
orig: 43, 52
offset: 0, 0
index: -1
survivor
rotate: false
xy: 2, 20
size: 43, 51
orig: 43, 51
offset: 0, 0
index: -1
u_bullet
rotate: false
xy: 1073, 1159
size: 40, 40
orig: 40, 40
offset: 0, 0
index: -1
zombie
rotate: false
xy: 1028, 1096
size: 43, 49
orig: 43, 49
offset: 0, 0
index: -1

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 578 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -0,0 +1,65 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
gradlePluginPortal()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
google()
}
dependencies {
}
}
allprojects {
apply plugin: "eclipse"
version = '1.0'
ext {
appName = "My GDX Game"
gdxVersion = '1.12.0'
roboVMVersion = '2.3.20'
box2DLightsVersion = '1.5'
ashleyVersion = '1.7.4'
aiVersion = '1.8.2'
gdxControllersVersion = '2.2.1'
}
repositories {
mavenLocal()
mavenCentral()
google()
gradlePluginPortal()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
maven { url "https://jitpack.io" }
}
}
project(":desktop") {
apply plugin: "java-library"
dependencies {
implementation project(":core")
api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
api "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
api "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
}
}
project(":core") {
apply plugin: "java-library"
dependencies {
api "com.badlogicgames.gdx:gdx:$gdxVersion"
api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
}
}

View File

@@ -0,0 +1,6 @@
sourceCompatibility = 1.7
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.main.java.srcDirs = [ "src/" ]
eclipse.project.name = appName + "-core"

View File

@@ -0,0 +1,12 @@
package com.mygdx.BouncingBalls;
import com.badlogic.gdx.graphics.Color;
public class Ball {
public int x = 0;
public int y = 0;
public int radius = 20;
public Color color;
public float speed = 0;
}

View File

@@ -0,0 +1,75 @@
package com.mygdx.BouncingBalls;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.utils.Array;
public class Game extends ApplicationAdapter {
private ShapeRenderer shapeRenderer;
private final Array<Ball> entities;
int gravity = 100;
public Game() {
entities = new Array<>();
}
@Override
public void create () {
shapeRenderer = new ShapeRenderer();
}
public void update(){
if(Gdx.input.isButtonJustPressed(Input.Buttons.LEFT)){
Ball ball = new Ball();
ball.x = Gdx.input.getX();
ball.y = Gdx.graphics.getHeight() - Gdx.input.getY();
ball.radius = MathUtils.random(20,75);
ball.color = new Color(
MathUtils.random(), // Random red component
MathUtils.random(), // Random green component
MathUtils.random(), // Random blue component
1 // Alpha (opacity) set to 1 for full opacity
);
entities.add(ball);
}
for (Ball ball : entities) {
ball.speed *= 0.9999;
ball.speed += gravity * Gdx.graphics.getDeltaTime();
ball.y -= ball.speed;
if (ball.y - ball.radius < 0) {
ball.y = ball.radius;
ball.speed = -ball.speed;
}
}
}
public void draw(){
for (Ball ball : entities) {
shapeRenderer.setColor(ball.color);
shapeRenderer.circle(ball.x, ball.y, ball.radius);
}
}
@Override
public void render () {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
update();
shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
draw();
shapeRenderer.end();
}
@Override
public void dispose () {
shapeRenderer.dispose();
}
}

View File

@@ -0,0 +1,57 @@
package com.mygdx.RotatingBall;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
public class Game extends ApplicationAdapter {
private SpriteBatch batch;
private Texture background;
private Sprite ball;
private Texture ballT;
float pi = 3.14159265359f;
float posX = 0;
float speed = 200;
@Override
public void create () {
batch = new SpriteBatch();
background = new Texture("background.png");
ballT = new Texture("raw/ball.png");
ball = new Sprite( ballT );
}
public void update(){
posX += speed * Gdx.graphics.getDeltaTime();
if(posX + 100 > Gdx.graphics.getWidth()) speed = -speed;
if(posX < 0) speed = -speed;
float Alpha = posX * 360/(2*pi*50);
ball.setRotation(-Alpha);
ball.setPosition(posX, 0);
}
public void draw(){
ball.draw(batch);
}
@Override
public void render () {
update();
batch.begin();
batch.draw(background, 0, 0);
draw();
batch.end();
}
@Override
public void dispose () {
batch.dispose();
background.dispose();
ballT.dispose();
}
}

View File

@@ -0,0 +1,98 @@
package com.mygdx.game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.TimeUtils;
import java.util.Iterator;
public class Boost implements Entity {
public Array<Rectangle> entities = new Array<>();
public float lastSpawnTime;
public float spawnTime;
public float width;
public float height;
public float speed;
float lastX = 0;
TextureAtlas.AtlasRegion region;
ParticleEffect particleEffect;
boolean spawn_bull = false;
public Boost(float spawnTime, float speed, float width, float height, TextureAtlas.AtlasRegion region){
this.region = region;
this.spawnTime = spawnTime;
this.width = width;
this.height = height;
this.speed = speed;
particleEffect = new ParticleEffect();
particleEffect.load(Gdx.files.internal("effects/Boost.p"), Gdx.files.internal("effects"));
}
public void checkIfSpawn(float time){
if(!spawn_bull) {
if (time - lastSpawnTime > spawnTime) {
spawn_bull = true;
lastX = MathUtils.random(0f, Global.WIDTH - width);
particleEffect.setPosition(lastX, Global.HEIGHT);
particleEffect.start();
}
}
if(spawn_bull){
if(particleEffect.isComplete()){
spawn();
spawn_bull = false;
}
}
}
@Override
public void spawn(){
Rectangle rect = new Rectangle();
rect.x = lastX;
rect.y = Global.HEIGHT;
rect.width = width;
rect.height = height;
entities.add(rect);
lastSpawnTime = TimeUtils.nanosToMillis(TimeUtils.nanoTime()) / 1000f;
}
@Override
public void move(){
for (Iterator<Rectangle> it = entities.iterator(); it.hasNext(); ) {
Rectangle rect = it.next();
rect.y -= speed * Gdx.graphics.getDeltaTime();
if (rect.y + rect.height < 0) {
it.remove();
}
}
}
@Override
public void draw(SpriteBatch batch){
for (Rectangle rect: entities) {
batch.draw(region, rect.x, rect.y, rect.width, rect.height);
}
particleEffect.draw(batch, Gdx.graphics.getDeltaTime());
}
@Override
public void drawRect(ShapeRenderer rend){
for (Rectangle rect: entities) {
rend.rect(rect.x, rect.y, rect.width, rect.height);
}
}
public boolean hit(Rectangle r){
for (Iterator<Rectangle> it = entities.iterator(); it.hasNext(); ) {
Rectangle rect = it.next();
if (rect.overlaps(r)) {
it.remove();
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,72 @@
package com.mygdx.game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.utils.Array;
import java.util.Iterator;
public class Bullets implements Entity {
public Array<Rectangle> entities = new Array<>();
public float width;
public float height;
ParticleEffect particleEffect;
int bull_x_offset = 3;
int bull_y_offset = 20;
int par_x_offset = 6;
int par_y_offset = 35;
TextureAtlas.AtlasRegion region;
Bullets( float width, float height, TextureAtlas.AtlasRegion region){
this.region = region;
this.width = width;
this.height = height;
particleEffect = new ParticleEffect();
particleEffect.load(Gdx.files.internal("effects/Fire.p"), Gdx.files.internal("effects"));
}
@Override
public void spawn() {
Rectangle rect = new Rectangle();
rect.width = width;
rect.height = height;
rect.x = Global.mouse.x + bull_x_offset;
rect.y = bull_y_offset;
entities.add(rect);
particleEffect.setPosition(Global.mouse.x + par_x_offset, par_y_offset);
particleEffect.start();
}
@Override
public void move() {
for (Iterator<Rectangle> it = entities.iterator(); it.hasNext(); ) {
Rectangle rect = it.next();
rect.y += 200 * Gdx.graphics.getDeltaTime();
if (rect.y > Global.HEIGHT) {
it.remove();
}
}
}
@Override
public void draw(SpriteBatch batch) {
for (Rectangle rect: entities) {
batch.draw(region, rect.x, rect.y, rect.width, rect.height);
}
particleEffect.draw(batch,Gdx.graphics.getDeltaTime());
}
public void drawRect(ShapeRenderer rend){
for (Rectangle rect: entities) {
rend.rect(rect.x, rect.y, rect.width, rect.height);
}
}
}

View File

@@ -0,0 +1,11 @@
package com.mygdx.game;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
public interface Entity {
void spawn();
void move();
void draw(SpriteBatch batch);
void drawRect(ShapeRenderer rend);
}

View File

@@ -0,0 +1,81 @@
package com.mygdx.game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.TimeUtils;
import java.util.Iterator;
public class FallingEntities implements Entity {
public Array<Rectangle> entities = new Array<>();
public float lastSpawnTime;
public float spawnTime;
public float width;
public float height;
public float speed;
TextureAtlas.AtlasRegion region;
public FallingEntities( float spawnTime, float speed, float width, float height,
TextureAtlas.AtlasRegion region){
this.spawnTime = spawnTime;
this.width = width;
this.height = height;
this.speed = speed;
this.region = region;
}
public void checkIfSpawn(float time){
if(time - lastSpawnTime > spawnTime){
spawn();
}
}
@Override
public void spawn(){
Rectangle rect = new Rectangle();
rect.x = MathUtils.random(0f, Global.WIDTH - width);
rect.y = Global.HEIGHT;
rect.width = width;
rect.height = height;
entities.add(rect);
lastSpawnTime = TimeUtils.nanosToMillis(TimeUtils.nanoTime()) / 1000f;
}
@Override
public void move(){
for (Iterator<Rectangle> it = entities.iterator(); it.hasNext(); ) {
Rectangle rect = it.next();
rect.y -= speed * Gdx.graphics.getDeltaTime();
if (rect.y + rect.height < 0) {
it.remove();
}
}
}
@Override
public void draw(SpriteBatch batch){
for (Rectangle rect: entities) {
batch.draw(region, rect.x, rect.y, rect.width, rect.height);
}
}
@Override
public void drawRect(ShapeRenderer rend){
for (Rectangle rect: entities) {
rend.rect(rect.x, rect.y, rect.width, rect.height);
}
}
public boolean hit(Rectangle r){
for (Iterator<Rectangle> it = entities.iterator(); it.hasNext(); ) {
Rectangle rect = it.next();
if (rect.overlaps(r)) {
it.remove();
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,9 @@
package com.mygdx.game;
import com.badlogic.gdx.math.Vector3;
public class Global {
public static final int WIDTH = 400;
public static final int HEIGHT = 300;
public static Vector3 mouse = new Vector3(0,0,0);
}

View File

@@ -0,0 +1,287 @@
package com.mygdx.game;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.assets.AssetDescriptor;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.TimeUtils;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.utils.viewport.FitViewport;
import com.badlogic.gdx.utils.viewport.Viewport;
import java.util.Iterator;
import com.mygdx.game.util.debug.*;
import com.mygdx.game.util.ViewportUtils;
public class MyGdxGame extends ApplicationAdapter {
SpriteBatch batch;
BitmapFont font;
Texture background;
Sounds sounds;
AssetDescriptor<TextureAtlas> descriptor;
AssetManager manager;
TextureAtlas atlas;
Viewport viewport;
OrthographicCamera camera;
DebugCameraController debugCameraController;
MemoryInfo memoryInfo;
ShapeRenderer shapeRenderer;
Array<FallingEntities> enemies;
Player player;
FallingEntities u_bullets;
Bullets bullets;
Boost boost;
enum State {
PLAY,
DEAD,
PAUSE
}
State state = State.PLAY;
public boolean debug = false;
@Override
public void create () {
descriptor = new AssetDescriptor<>("packs/texture.atlas", TextureAtlas.class);
manager = new AssetManager();
atlas = new TextureAtlas();
manager.load(descriptor);
manager.finishLoading();
atlas = manager.get(descriptor);
batch = new SpriteBatch();
font = new BitmapFont();
background = new Texture("raw/background.png");
sounds = new Sounds();
camera = new OrthographicCamera();
viewport = new FitViewport(Global.WIDTH, Global.HEIGHT, camera);
debugCameraController = new DebugCameraController();
debugCameraController.setStartPosition(Global.WIDTH / 2f, Global.HEIGHT / 2f);
memoryInfo = new MemoryInfo(500);
shapeRenderer = new ShapeRenderer();
float sizeRatio = 1.5f;
enemies = new Array<>();
enemies.add(new FallingEntities( 2.3f, 200,43/sizeRatio,49/sizeRatio, atlas.findRegion("robot")));
enemies.add(new FallingEntities(4f, 200,43/sizeRatio,49/sizeRatio, atlas.findRegion("zombie")));
enemies.add(new FallingEntities( 3f, 200,43/sizeRatio,49/sizeRatio, atlas.findRegion("survivor")));
player = new Player( 43/sizeRatio, 49/sizeRatio, atlas.findRegion("soldier"));
u_bullets = new FallingEntities( 1f, 200, 10/sizeRatio, 10/sizeRatio, atlas.findRegion("u_bullet"));
boost = new Boost( 1f, 400, 5/sizeRatio,5/sizeRatio, atlas.findRegion("ball"));
bullets = new Bullets(10/sizeRatio,10/sizeRatio, atlas.findRegion("bullet"));
}
void reset(){
player.reset();
state = State.PLAY;
}
@Override
public void resize(int width, int height) {
viewport.update(width, height, true);
}
void update(){
if(Gdx.input.isKeyJustPressed(Input.Keys.R)){
reset();
}
if(Gdx.input.isKeyJustPressed(Input.Keys.P)){
if(state == State.PLAY){
state = State.PAUSE;
}else if(state == State.PAUSE){
state = State.PLAY;
}
}
if (Gdx.input.isKeyJustPressed(Input.Keys.F1)) debug = !debug;
if (debug) {
debugCameraController.handleDebugInput(Gdx.graphics.getDeltaTime());
memoryInfo.update();
}
if(state != State.PLAY) return;
float time = TimeUtils.nanosToMillis(TimeUtils.nanoTime()) / 1000f;
player.move();
boost.checkIfSpawn(time);
boost.move();
if(boost.hit(player.rect)){
player.boost = true;
sounds.yes.play();
}
if(boost.hit(player.rect)){
player.bullets += 5;
sounds.reload.play();
}
u_bullets.checkIfSpawn(time);
u_bullets.move();
if(u_bullets.hit(player.rect)){
player.bullets++;
sounds.reload.play();
}
if(Gdx.input.isButtonJustPressed(Input.Buttons.LEFT)){
if(player.bullets > 0){
bullets.spawn();
player.bullets--;
sounds.shot.play();
}
}
bullets.move();
for(FallingEntities enemy: enemies){
enemy.checkIfSpawn(time);
enemy.move();
if(enemy.hit(player.rect)){
sounds.no.play();
if(player.takeDamage()){
state = State.DEAD;
}
}
for (Iterator<Rectangle> it = bullets.entities.iterator(); it.hasNext(); ) {
Rectangle rect = it.next();
if (enemy.hit(rect)) {
it.remove();
player.score++;
sounds.yes.play();
}
}
}
}
void draw(){
player.draw(batch);
u_bullets.draw(batch);
bullets.draw(batch);
boost.draw(batch);
for(FallingEntities enemy: enemies){
enemy.draw(batch);
}
drawUI();
}
void drawUI(){
if(debug) return;
switch (state){
case DEAD:
font.setColor(Color.RED);
font.draw(batch,"GAME OVER",20f, Global.HEIGHT - 20);
break;
case PAUSE:
font.setColor(Color.YELLOW);
font.draw(batch,"PAUSE",20f, Global.HEIGHT - 20);
break;
case PLAY:
font.setColor(Color.BLUE);
font.draw(batch, "Life: " + player.life, 20f, Global.HEIGHT - 20);
font.draw(batch,"Bullets: " + player.bullets,20f, Global.HEIGHT - 40);
font.draw(batch, "Score: " + player.score, 20, Global.HEIGHT - 60);
font.draw(batch, "Boost: " + player.boost, 20, Global.HEIGHT - 80);
break;
}
}
void drawDebug(){
debugCameraController.applyTo(camera);
batch.begin();
{
// the average number of frames per second
GlyphLayout layout = new GlyphLayout(font, "FPS:" + Gdx.graphics.getFramesPerSecond());
font.setColor(Color.YELLOW);
font.draw(batch, layout, Global.WIDTH - layout.width, Global.HEIGHT - 50);
// number of rendering calls, ever; will not be reset unless set manually
font.setColor(Color.YELLOW);
font.draw(batch, "RC:" + batch.totalRenderCalls, Global.WIDTH / 2f, Global.HEIGHT - 20);
memoryInfo.render(batch, font);
}
batch.end();
batch.totalRenderCalls = 0;
ViewportUtils.drawGrid(viewport, shapeRenderer, 50);
// print rectangles
shapeRenderer.setProjectionMatrix(camera.combined);
// https://libgdx.badlogicgames.com/ci/nightlies/docs/api/com/badlogic/gdx/graphics/glutils/ShapeRenderer.html
shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
{
shapeRenderer.setColor(1, 1, 0, 1);
player.drawRect(shapeRenderer);
u_bullets.drawRect(shapeRenderer);
bullets.drawRect(shapeRenderer);
boost.drawRect(shapeRenderer);
for(FallingEntities enemy: enemies){
enemy.drawRect(shapeRenderer);
}
}
shapeRenderer.end();
}
@Override
public void render () {
update();
Gdx.gl.glClearColor(0, 0, 0f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
Global.mouse = camera.unproject(new Vector3(Gdx.input.getX(), Gdx.input.getY(), 0));
batch.setProjectionMatrix(camera.combined);
batch.begin();
batch.draw(background, 0, 0, Global.WIDTH, Global.HEIGHT);
draw();
batch.end();
if(debug){
drawDebug();
}
}
@Override
public void dispose () {
batch.dispose();
sounds.dispose();
font.dispose();
background.dispose();
}
}

View File

@@ -0,0 +1,50 @@
package com.mygdx.game;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Rectangle;
public class Player {
public Rectangle rect;
int score = 0;
int life = 5;
int bullets = 0;
boolean boost = false;
TextureAtlas.AtlasRegion region;
public Player(float width, float height, TextureAtlas.AtlasRegion region){
this.region = region;
this.rect = new Rectangle();
this.rect.x = 0;
this.rect.y = 0;
this.rect.width = width;
this.rect.height = height;
}
public void reset(){
score = 0;
life = 5;
bullets = 0;
}
public boolean takeDamage(){
if(!boost) life--;
else boost = false;
return life <= 0;
}
public void move() {
rect.x = Global.mouse.x - rect.width / 2;
}
public void draw(SpriteBatch batch){
batch.draw(region, rect.x, rect.y, rect.width, rect.height);
}
public void drawRect(ShapeRenderer rend){
rend.rect(rect.x, rect.y, rect.width, rect.height);
}
}

View File

@@ -0,0 +1,26 @@
package com.mygdx.game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.utils.Disposable;
public class Sounds implements Disposable {
public Sound no;
public Sound yes;
public Sound reload;
public Sound shot;
Sounds(){
no = Gdx.audio.newSound(Gdx.files.internal("sound/no.mp3"));
yes = Gdx.audio.newSound(Gdx.files.internal("sound/yes.mp3"));
reload = Gdx.audio.newSound(Gdx.files.internal("sound/reload.mp3"));
shot = Gdx.audio.newSound(Gdx.files.internal("sound/shot.mp3"));
}
@Override
public void dispose() {
yes.dispose();
no.dispose();
reload.dispose();
shot.dispose();
}
}

View File

@@ -0,0 +1,116 @@
package com.mygdx.game.util;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.utils.Logger;
import com.badlogic.gdx.utils.viewport.Viewport;
/**
* Utility methods for using with Viewports.
*
* @author goran on 20/08/2016.
*/
public class ViewportUtils {
private static final Logger log = new Logger(ViewportUtils.class.getName(), Logger.DEBUG);
private static final int DEFAULT_CELL_SIZE = 1;
/**
* Draws world grid for specified viewport using {@link ShapeRenderer}.
*
* @param viewport The viewports. Required.
* @param renderer ShapeRenderer that will be used for drawing. Required.
* @throws IllegalArgumentException if any param is nul..
*/
public static void drawGrid(Viewport viewport, ShapeRenderer renderer) {
drawGrid(viewport, renderer, DEFAULT_CELL_SIZE);
}
/**
* Draws world grid for specified viewport using {@link ShapeRenderer}.
*
* @param viewport The viewport. Required.
* @param renderer ShapeRenderer that will be used for drawing. Required.
* @param cellSize The size of cell in grid. If less tha 1 by default 1 will be used.
* @throws IllegalArgumentException if any param is null.
*/
public static boolean drawGrid(Viewport viewport, ShapeRenderer renderer, int cellSize) {
// validate parameters/arguments
if (viewport == null) {
return false;
}
if (renderer == null) {
return false;
}
if (cellSize < DEFAULT_CELL_SIZE) {
cellSize = DEFAULT_CELL_SIZE;
}
// copy old color from renderer
Color oldColor = new Color(renderer.getColor());
int worldWidth = (int) viewport.getWorldWidth();
int worldHeight = (int) viewport.getWorldHeight();
int doubleWorldWidth = worldWidth * 2;
int doubleWorldHeight = worldHeight * 2;
renderer.setProjectionMatrix(viewport.getCamera().combined);
renderer.begin(ShapeRenderer.ShapeType.Line);
renderer.setColor(Color.WHITE);
// draw vertical lines
for (int x = -doubleWorldWidth; x < doubleWorldWidth; x += cellSize) {
renderer.line(x, -doubleWorldHeight, x, doubleWorldHeight);
}
// draw horizontal lines
for (int y = -doubleWorldHeight; y < doubleWorldHeight; y += cellSize) {
renderer.line(-doubleWorldWidth, y, doubleWorldWidth, y);
}
// draw 0/0 lines
renderer.setColor(Color.RED);
renderer.line(0, -doubleWorldHeight, 0, doubleWorldHeight);
renderer.line(-doubleWorldWidth, 0, doubleWorldWidth, 0);
// draw world bounds
renderer.setColor(Color.GREEN);
renderer.line(0, worldHeight, worldWidth, worldHeight);
renderer.line(worldWidth, 0, worldWidth, worldHeight);
renderer.end();
renderer.setColor(oldColor);
return true;
}
/**
* Prints pixels per unit for specified Viewport.
*
* @param viewport The viewport for which we want to print pixels per unit ratio. Required.
* @throws IllegalArgumentException If viewport is null.
*/
public static boolean debugPixelsPerUnit(Viewport viewport) {
if (viewport == null) {
return false;
}
float screenWidth = viewport.getScreenWidth();
float screenHeight = viewport.getScreenHeight();
float worldWidth = viewport.getWorldWidth();
float worldHeight = viewport.getWorldHeight();
float xPPU = screenWidth / worldWidth;
float yPPU = screenHeight / worldHeight;
log.debug("x PPU = " + xPPU + " yPPU = " + yPPU);
return true;
}
private ViewportUtils() {
}
}

View File

@@ -0,0 +1,164 @@
package com.mygdx.game.util.debug;
import com.badlogic.gdx.Application;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Logger;
/**
* Controller for debugging {@link OrthographicCamera}.
*
* @author goran on 22/08/2016.
*/
public class DebugCameraController {
// == constants ==
private static final Logger log = new Logger(DebugCameraController.class.getName(), Logger.DEBUG);
// == attributes ==
private final Vector2 position = new Vector2();
private final Vector2 startPosition = new Vector2();
private float zoom = 1.0f;
private DebugCameraInfo info;
// == constructors ==
public DebugCameraController() {
init();
}
// == init ==
private void init() {
info = new DebugCameraInfo();
log.info("cameraInfo = " + info);
}
// == public methods ==
/**
* Sets start position of camera.
*
* @param x The x position.
* @param y The y position.
*/
public void setStartPosition(float x, float y) {
startPosition.set(x, y);
setPosition(x, y);
}
/**
* Applies internal position and zoom to specified camera.
* Call this method after handling debug input.
*
* @param camera camera The camera instance.
* @throws IllegalArgumentException if camera param is null.
* @see #handleDebugInput(float)
*/
public boolean applyTo(OrthographicCamera camera) {
if (camera == null) {
return false;
}
camera.position.set(position, 0);
camera.zoom = zoom;
camera.update();
return true;
}
/**
* Handles debug input. Call this in your update cycle.
*
* @param delta The delta time.
*/
public void handleDebugInput(float delta) {
if (Gdx.app.getType() != Application.ApplicationType.Desktop) {
return;
}
float moveSpeed = info.getMoveSpeed() * delta;
float zoomSpeed = info.getZoomSpeed() * delta;
// move control
if (info.isLeftPressed()) {
moveLeft(moveSpeed);
}
if (info.isRightPressed()) {
moveRight(moveSpeed);
}
if (info.isUpPressed()) {
moveUp(moveSpeed);
}
if (info.isDownPressed()) {
moveDown(moveSpeed);
}
// zoom control
if (info.isZoomInPressed()) {
zoomIn(zoomSpeed);
}
if (info.isZoomOutPressed()) {
zoomOut(zoomSpeed);
}
// reset control
if (info.isResetPressed()) {
reset();
}
// log control
if (info.isLogPressed()) {
logDebug();
}
}
// == private methods ==
private void setPosition(float x, float y) {
position.set(x, y);
}
private void setZoom(float value) {
zoom = MathUtils.clamp(value, info.getMaxZoomIn(), info.getMaxZoomOut());
}
private void moveCamera(float xSpeed, float ySpeed) {
setPosition(position.x + xSpeed, position.y + ySpeed);
}
private void moveLeft(float speed) {
moveCamera(-speed, 0);
}
private void moveRight(float speed) {
moveCamera(speed, 0);
}
private void moveUp(float speed) {
moveCamera(0, speed);
}
private void moveDown(float speed) {
moveCamera(0, -speed);
}
private void zoomIn(float zoomSpeed) {
setZoom(zoom + zoomSpeed);
}
private void zoomOut(float zoomSpeed) {
setZoom(zoom - zoomSpeed);
}
private void reset() {
position.set(startPosition);
setZoom(1.0f);
}
private void logDebug() {
log.debug("position = " + position + " zoom = " + zoom);
}
}

View File

@@ -0,0 +1,208 @@
package com.mygdx.game.util.debug;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.utils.JsonReader;
import com.badlogic.gdx.utils.JsonValue;
import com.badlogic.gdx.utils.Logger;
/**
* Info/Configuration for {@link DebugCameraController}.
* Loads configuration from file in assetsDir/debug/debug-camera.json
*
* @author goran on 22/08/2016.
*/
public class DebugCameraInfo {
// == constants ==
private static final Logger log = new Logger(DebugCameraInfo.class.getName(), Logger.DEBUG);
private static final String MAX_ZOOM_IN = "maxZoomIn";
private static final String MAX_ZOOM_OUT = "maxZoomOut";
private static final String MOVE_SPEED = "moveSpeed";
private static final String ZOOM_SPEED = "zoomSpeed";
private static final String LEFT_KEY = "leftKey";
private static final String RIGHT_KEY = "rightKey";
private static final String UP_KEY = "upKey";
private static final String DOWN_KEY = "downKey";
private static final String ZOOM_IN_KEY = "zoomInKey";
private static final String ZOOM_OUT_KEY = "zoomOutKey";
private static final String RESET_KEY = "resetKey";
private static final String LOG_KEY = "logKey";
private static final int DEFAULT_LEFT_KEY = Input.Keys.A;
private static final int DEFAULT_RIGHT_KEY = Input.Keys.D;
private static final int DEFAULT_UP_KEY = Input.Keys.W;
private static final int DEFAULT_DOWN_KEY = Input.Keys.S;
private static final int DEFAULT_ZOOM_IN_KEY = Input.Keys.COMMA;
private static final int DEFAULT_ZOOM_OUT_KEY = Input.Keys.PERIOD;
private static final int DEFAULT_RESET_KEY = Input.Keys.BACKSPACE;
private static final int DEFAULT_LOG_KEY = Input.Keys.ENTER;
private static final float DEFAULT_MOVE_SPEED = 20.0f;
private static final float DEFAULT_ZOOM_SPEED = 2.0f;
private static final float DEFAULT_MAX_ZOOM_IN = 0.25f;
private static final float DEFAULT_MAX_ZOOM_OUT = 30f;
private final String FILE_PATH = "debug/debugCameraInfo.json";
// == attributes ==
private float maxZoomIn;
private float maxZoomOut;
private float moveSpeed;
private float zoomSpeed;
private int leftKey;
private int rightKey;
private int upKey;
private int downKey;
private int zoomInKey;
private int zoomOutKey;
private int resetKey;
private int logKey;
private FileHandle fileHandle;
// == constructors ==
public DebugCameraInfo() {
init();
}
// == init ==
private void init() {
fileHandle = Gdx.files.internal(FILE_PATH);
if (fileHandle.exists()) {
load();
} else {
log.info("Using defaults file does not exist = " + FILE_PATH);
setupDefaults();
}
}
// == private methods ==
private void load() {
try {
JsonReader reader = new JsonReader();
JsonValue root = reader.parse(fileHandle);
maxZoomIn = root.getFloat(MAX_ZOOM_IN, DEFAULT_MAX_ZOOM_IN);
maxZoomOut = root.getFloat(MAX_ZOOM_OUT, DEFAULT_MAX_ZOOM_OUT);
moveSpeed = root.getFloat(MOVE_SPEED, DEFAULT_MOVE_SPEED);
zoomSpeed = root.getFloat(ZOOM_SPEED, DEFAULT_ZOOM_SPEED);
leftKey = getInputKeyValue(root, LEFT_KEY, DEFAULT_LEFT_KEY);
rightKey = getInputKeyValue(root, RIGHT_KEY, DEFAULT_RIGHT_KEY);
upKey = getInputKeyValue(root, UP_KEY, DEFAULT_UP_KEY);
downKey = getInputKeyValue(root, DOWN_KEY, DEFAULT_DOWN_KEY);
zoomInKey = getInputKeyValue(root, ZOOM_IN_KEY, DEFAULT_ZOOM_IN_KEY);
zoomOutKey = getInputKeyValue(root, ZOOM_OUT_KEY, DEFAULT_ZOOM_OUT_KEY);
resetKey = getInputKeyValue(root, RESET_KEY, DEFAULT_RESET_KEY);
logKey = getInputKeyValue(root, LOG_KEY, DEFAULT_LOG_KEY);
} catch (Exception e) {
log.error("Error loading " + FILE_PATH + " using defaults.", e);
setupDefaults();
}
}
private void setupDefaults() {
maxZoomIn = DEFAULT_MAX_ZOOM_IN;
maxZoomOut = DEFAULT_MAX_ZOOM_OUT;
moveSpeed = DEFAULT_MOVE_SPEED;
zoomSpeed = DEFAULT_ZOOM_SPEED;
leftKey = DEFAULT_LEFT_KEY;
rightKey = DEFAULT_RIGHT_KEY;
upKey = DEFAULT_UP_KEY;
downKey = DEFAULT_DOWN_KEY;
zoomInKey = DEFAULT_ZOOM_IN_KEY;
zoomOutKey = DEFAULT_ZOOM_OUT_KEY;
resetKey = DEFAULT_RESET_KEY;
logKey = DEFAULT_LOG_KEY;
}
// == public methods ==
public float getMaxZoomIn() {
return maxZoomIn;
}
public float getMaxZoomOut() {
return maxZoomOut;
}
public float getMoveSpeed() {
return moveSpeed;
}
public float getZoomSpeed() {
return zoomSpeed;
}
public boolean isLeftPressed() {
return Gdx.input.isKeyPressed(leftKey);
}
public boolean isRightPressed() {
return Gdx.input.isKeyPressed(rightKey);
}
public boolean isUpPressed() {
return Gdx.input.isKeyPressed(upKey);
}
public boolean isDownPressed() {
return Gdx.input.isKeyPressed(downKey);
}
public boolean isZoomInPressed() {
return Gdx.input.isKeyPressed(zoomInKey);
}
public boolean isZoomOutPressed() {
return Gdx.input.isKeyPressed(zoomOutKey);
}
public boolean isResetPressed() {
return Gdx.input.isKeyPressed(resetKey);
}
public boolean isLogPressed() {
return Gdx.input.isKeyPressed(logKey);
}
@Override
public String toString() {
String LS = System.getProperty("line.separator");
return "DebugCameraInfo {" + LS +
"maxZoomIn= " + maxZoomIn + LS +
"maxZoomOut= " + maxZoomOut + LS +
"moveSpeed= " + moveSpeed + LS +
"zoomSpeed= " + zoomSpeed + LS +
"leftKey= " + Input.Keys.toString(leftKey) + LS +
"rightKey= " + Input.Keys.toString(rightKey) + LS +
"upKey= " + Input.Keys.toString(upKey) + LS +
"downKey= " + Input.Keys.toString(downKey) + LS +
"zoomInKey= " + Input.Keys.toString(zoomInKey) + LS +
"zoomOutKey= " + Input.Keys.toString(zoomOutKey) + LS +
"resetKey= " + Input.Keys.toString(resetKey) + LS +
"logKey= " + Input.Keys.toString(logKey) + LS +
"}";
}
// == static methods ==
private static int getInputKeyValue(JsonValue root, String name, int defaultInputKey) {
String keyString = root.getString(name, Input.Keys.toString(defaultInputKey));
return Input.Keys.valueOf(keyString);
}
}

View File

@@ -0,0 +1,55 @@
package com.mygdx.game.util.debug;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
public class MemoryInfo {
public static final long MB = 1024 * 1024;
private final Runtime instance;
private final long updateIntervalMs;
private long lastUpdate;
private long totalMemory; // total amount of memory in the Java virtual machine
private long freeMemory; // amount of free memory in the Java Virtual Machine
private long usedMemory;
private long maxMemory; // maximum amount of memory that the Java virtual machine will attempt to use
private long javaHeap; // Java heap memory use in bytes
private long nativeHeap; // native heap memory use in bytes
public MemoryInfo(long updateIntervalMs) {
instance = Runtime.getRuntime();
this.updateIntervalMs = updateIntervalMs;
lastUpdate = 0;
update();
}
public void update() {
if ((lastUpdate + updateIntervalMs) < System.currentTimeMillis()) {
totalMemory = instance.totalMemory() / MB;
freeMemory = instance.freeMemory() / MB;
usedMemory = instance.totalMemory() / MB - freeMemory;
maxMemory = instance.maxMemory() / MB;
javaHeap = Gdx.app.getJavaHeap() / MB;
nativeHeap = Gdx.app.getNativeHeap() / MB;
lastUpdate = System.currentTimeMillis();
}
}
public void render(SpriteBatch batch, BitmapFont font) {
float positionY = 100 + font.getCapHeight();
font.setColor(Color.WHITE);
font.draw(batch, "totalMemory:" + totalMemory + " mb", 20, positionY);
positionY += font.getCapHeight() + 10;
font.draw(batch, "freeMemory :" + freeMemory + " mb", 20, positionY);
positionY += font.getCapHeight() + 10;
font.draw(batch, "usedMemory :" + usedMemory + " mb", 20, positionY);
positionY += font.getCapHeight() + 10;
font.draw(batch, "maxMemory :" + maxMemory + " mb", 20, positionY);
positionY += font.getCapHeight() + 10;
font.draw(batch, "javaHeap :" + javaHeap + " mb", 20, positionY);
positionY += font.getCapHeight() + 10;
font.draw(batch, "nativeHeap :" + nativeHeap + " mb", 20, positionY);
positionY += font.getCapHeight() + 10;
}
}

View File

@@ -0,0 +1,49 @@
sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = [ "src/" ]
sourceSets.main.resources.srcDirs = ["../assets"]
project.ext.mainClassName = "com.mygdx.game.DesktopLauncher"
project.ext.assetsDir = new File("../assets")
import org.gradle.internal.os.OperatingSystem
tasks.register('run', JavaExec) {
dependsOn classes
mainClass = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
if (OperatingSystem.current() == OperatingSystem.MAC_OS) {
// Required to run on macOS
jvmArgs += "-XstartOnFirstThread"
}
}
tasks.register('debug', JavaExec) {
dependsOn classes
mainClass = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
debug = true
}
tasks.register('dist', Jar) {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
manifest {
attributes 'Main-Class': project.mainClassName
}
dependsOn configurations.runtimeClasspath
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
with jar
}
dist.dependsOn classes
eclipse.project.name = appName + "-desktop"

Some files were not shown because too many files have changed in this diff Show More