Adding TestUDPGame to git

This commit is contained in:
Jalen Winslow 2018-01-26 10:51:09 -07:00
commit e769a3ba09
74 changed files with 3794 additions and 0 deletions

114
.gitignore vendored Normal file
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/
/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/
/ios-moe/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/
/ios-moe/nbproject/private/
/build/
/android/build/
/core/build/
/desktop/build/
/html/build/
/ios/build/
/ios-moe/build/
/nbbuild/
/android/nbbuild/
/core/nbbuild/
/desktop/nbbuild/
/html/nbbuild/
/ios/nbbuild/
/ios-moe/nbbuild/
/dist/
/android/dist/
/core/dist/
/desktop/dist/
/html/dist/
/ios/dist/
/ios-moe/dist/
/nbdist/
/android/nbdist/
/core/nbdist/
/desktop/nbdist/
/html/nbdist/
/ios/nbdist/
/ios-moe/nbdist/
nbactions.xml
nb-configuration.xml
## Gradle
/local.properties
.gradle/
gradle-app.setting
/build/
/android/build/
/core/build/
/desktop/build/
/html/build/
/ios/build/
/ios-moe/build/
## OS Specific
.DS_Store
Thumbs.db

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<gradle-project-properties>
<!--DO NOT EDIT THIS FILE! - Used by the Gradle plugin of NetBeans.-->
<auxiliary>
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/C:/Users/jalen/Programming/Netbeans%20Workspace/2017%20Winter/TestUDPGame/core/src/com/jwinslow/game/Main.java</file>
<file>file:/C:/Users/jalen/Programming/Netbeans%20Workspace/2017%20Winter/TestUDPGame/core/src/com/jwinslow/game/states/MenuState.java</file>
<file>file:/C:/Users/jalen/Programming/Netbeans%20Workspace/2017%20Winter/TestUDPGame/core/src/com/jwinslow/game/utils/ButtonEffects.java</file>
<file>file:/C:/Users/jalen/Programming/Netbeans%20Workspace/2017%20Winter/TestUDPGame/core/src/com/jwinslow/game/Handler.java</file>
<file>file:/C:/Users/jalen/Programming/Netbeans%20Workspace/2017%20Winter/TestUDPGame/core/src/com/jwinslow/game/states/InitState.java</file>
<file>file:/C:/Users/jalen/Programming/Netbeans%20Workspace/2017%20Winter/TestUDPGame/core/src/com/jwinslow/game/sprites/PlayerSprite.java</file>
<file>file:/C:/Users/jalen/Programming/Netbeans%20Workspace/2017%20Winter/TestUDPGame/core/src/com/jwinslow/game/utils/Assets.java</file>
<file>file:/C:/Users/jalen/Programming/Netbeans%20Workspace/2017%20Winter/TestUDPGame/core/src/com/jwinslow/game/states/GameState.java</file>
<file>file:/C:/Users/jalen/Programming/Netbeans%20Workspace/2017%20Winter/TestUDPGame/core/src/com/jwinslow/game/ui/UIButton.java</file>
</group>
</open-files>
<editor-bookmarks lastBookmarkId="0" xmlns="http://www.netbeans.org/ns/editor-bookmarks/2"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group/>
</open-files>
</auxiliary>
</gradle-project-properties>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jwinslow.game" >
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="26" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/GdxTheme" >
<activity
android:name="com.jwinslow.game.AndroidLauncher"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 741 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

BIN
android/assets/badlogic.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

View File

@ -0,0 +1,66 @@
info face="MS Gothic" size=-10 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=0 aa=1 padding=1,2,1,2 spacing=2,2 outline=0
common lineHeight=10 base=9 scaleW=256 scaleH=64 pages=1 packed=0 alphaChnl=0 redChnl=0 greenChnl=0 blueChnl=0
page id=0 file="customFont4_0.png"
chars count=62
char id=48 x=200 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=49 x=79 y=28 width=6 height=12 xoffset=-1 yoffset=-1 xadvance=5 page=0 chnl=15
char id=50 x=40 y=28 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=51 x=77 y=0 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=52 x=44 y=0 width=9 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=53 x=87 y=0 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=54 x=97 y=0 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=55 x=107 y=0 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=56 x=117 y=0 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=57 x=127 y=0 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=65 x=137 y=0 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=66 x=147 y=0 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=67 x=157 y=0 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=68 x=167 y=0 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=69 x=177 y=0 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=70 x=187 y=0 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=71 x=197 y=0 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=72 x=207 y=0 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=73 x=87 y=28 width=5 height=12 xoffset=-1 yoffset=-1 xadvance=5 page=0 chnl=15
char id=74 x=217 y=0 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=75 x=227 y=0 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=76 x=237 y=0 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=77 x=0 y=0 width=9 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=78 x=0 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=79 x=70 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=80 x=10 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=81 x=20 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=82 x=30 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=83 x=40 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=84 x=50 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=85 x=60 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=86 x=33 y=0 width=9 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=87 x=22 y=0 width=9 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=88 x=80 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=89 x=11 y=0 width=9 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=90 x=90 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=97 x=100 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=98 x=110 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=99 x=120 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=100 x=130 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=101 x=140 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=102 x=150 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=103 x=160 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=104 x=170 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=105 x=94 y=28 width=5 height=12 xoffset=0 yoffset=-1 xadvance=5 page=0 chnl=15
char id=106 x=70 y=28 width=7 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=107 x=180 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=108 x=101 y=28 width=5 height=12 xoffset=0 yoffset=-1 xadvance=5 page=0 chnl=15
char id=109 x=55 y=0 width=9 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=110 x=210 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=111 x=220 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=112 x=230 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=113 x=240 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=114 x=247 y=0 width=7 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=115 x=190 y=14 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=116 x=10 y=28 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=117 x=20 y=28 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=118 x=30 y=28 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=119 x=66 y=0 width=9 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=120 x=50 y=28 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=121 x=60 y=28 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15
char id=122 x=0 y=28 width=8 height=12 xoffset=-2 yoffset=-1 xadvance=5 page=0 chnl=15

Binary file not shown.

After

Width:  |  Height:  |  Size: 879 B

View File

@ -0,0 +1,98 @@
info face="Consolas" size=-11 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=0 aa=1 padding=1,2,1,2 spacing=2,2 outline=0
common lineHeight=13 base=10 scaleW=256 scaleH=96 pages=1 packed=0 alphaChnl=0 redChnl=0 greenChnl=0 blueChnl=0
page id=0 file="customPixelFont1_0.png"
chars count=94
char id=32 x=150 y=51 width=7 height=15 xoffset=-3 yoffset=-1 xadvance=6 page=0 chnl=15
char id=33 x=206 y=51 width=5 height=15 xoffset=0 yoffset=-1 xadvance=6 page=0 chnl=15
char id=34 x=78 y=51 width=7 height=15 xoffset=0 yoffset=-1 xadvance=6 page=0 chnl=15
char id=35 x=45 y=0 width=10 height=15 xoffset=-2 yoffset=-1 xadvance=6 page=0 chnl=15
char id=36 x=223 y=0 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=37 x=70 y=0 width=10 height=15 xoffset=-2 yoffset=-1 xadvance=6 page=0 chnl=15
char id=38 x=82 y=0 width=10 height=15 xoffset=-2 yoffset=-1 xadvance=6 page=0 chnl=15
char id=39 x=199 y=51 width=5 height=15 xoffset=0 yoffset=-1 xadvance=6 page=0 chnl=15
char id=40 x=87 y=51 width=7 height=15 xoffset=0 yoffset=-1 xadvance=6 page=0 chnl=15
char id=41 x=96 y=51 width=7 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=42 x=22 y=17 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=43 x=190 y=0 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=44 x=69 y=51 width=7 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=45 x=105 y=51 width=7 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=46 x=245 y=0 width=6 height=15 xoffset=0 yoffset=-1 xadvance=6 page=0 chnl=15
char id=47 x=77 y=17 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=48 x=88 y=17 width=9 height=15 xoffset=-2 yoffset=-1 xadvance=6 page=0 chnl=15
char id=49 x=99 y=17 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=50 x=110 y=17 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=51 x=168 y=34 width=8 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=52 x=94 y=0 width=10 height=15 xoffset=-2 yoffset=-1 xadvance=6 page=0 chnl=15
char id=53 x=178 y=34 width=8 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=54 x=33 y=17 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=55 x=154 y=17 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=56 x=165 y=17 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=57 x=176 y=17 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=58 x=247 y=34 width=6 height=15 xoffset=0 yoffset=-1 xadvance=6 page=0 chnl=15
char id=59 x=114 y=51 width=7 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=60 x=123 y=51 width=7 height=15 xoffset=0 yoffset=-1 xadvance=6 page=0 chnl=15
char id=61 x=220 y=17 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=62 x=132 y=51 width=7 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=63 x=188 y=51 width=9 height=15 xoffset=0 yoffset=-1 xadvance=6 page=0 chnl=15
char id=64 x=57 y=0 width=11 height=15 xoffset=-2 yoffset=-1 xadvance=6 page=0 chnl=15
char id=65 x=242 y=17 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=66 x=0 y=34 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=67 x=208 y=34 width=8 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=68 x=33 y=34 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=69 x=198 y=34 width=8 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=70 x=20 y=51 width=8 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=71 x=11 y=34 width=9 height=15 xoffset=-2 yoffset=-1 xadvance=6 page=0 chnl=15
char id=72 x=10 y=51 width=8 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=73 x=22 y=34 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=74 x=138 y=34 width=8 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=75 x=148 y=34 width=8 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=76 x=108 y=34 width=8 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=77 x=166 y=0 width=10 height=15 xoffset=-2 yoffset=-1 xadvance=6 page=0 chnl=15
char id=78 x=237 y=34 width=8 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=79 x=130 y=0 width=10 height=15 xoffset=-2 yoffset=-1 xadvance=6 page=0 chnl=15
char id=80 x=44 y=34 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=81 x=55 y=34 width=9 height=15 xoffset=-2 yoffset=-1 xadvance=6 page=0 chnl=15
char id=82 x=66 y=34 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=83 x=77 y=34 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=84 x=201 y=0 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=85 x=212 y=0 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=86 x=234 y=0 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=87 x=11 y=0 width=10 height=15 xoffset=-2 yoffset=-1 xadvance=6 page=0 chnl=15
char id=88 x=106 y=0 width=10 height=15 xoffset=-2 yoffset=-1 xadvance=6 page=0 chnl=15
char id=89 x=0 y=0 width=9 height=15 xoffset=-2 yoffset=-1 xadvance=6 page=0 chnl=15
char id=90 x=0 y=17 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=91 x=179 y=51 width=7 height=15 xoffset=0 yoffset=-1 xadvance=6 page=0 chnl=15
char id=93 x=141 y=51 width=7 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=94 x=168 y=51 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=95 x=23 y=0 width=9 height=15 xoffset=-2 yoffset=-1 xadvance=6 page=0 chnl=15
char id=96 x=159 y=51 width=7 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=97 x=11 y=17 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=98 x=44 y=17 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=99 x=188 y=34 width=8 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=100 x=55 y=17 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=101 x=66 y=17 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=102 x=178 y=0 width=10 height=15 xoffset=-2 yoffset=-1 xadvance=6 page=0 chnl=15
char id=103 x=154 y=0 width=10 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=104 x=128 y=34 width=8 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=105 x=39 y=51 width=8 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=106 x=0 y=51 width=8 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=107 x=59 y=51 width=8 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=108 x=88 y=34 width=8 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=109 x=132 y=17 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=110 x=98 y=34 width=8 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=111 x=143 y=17 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=112 x=187 y=17 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=113 x=198 y=17 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=114 x=118 y=34 width=8 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=115 x=49 y=51 width=8 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=116 x=209 y=17 width=9 height=15 xoffset=-2 yoffset=-1 xadvance=6 page=0 chnl=15
char id=117 x=158 y=34 width=8 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=118 x=231 y=17 width=9 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=119 x=142 y=0 width=10 height=15 xoffset=-2 yoffset=-1 xadvance=6 page=0 chnl=15
char id=120 x=118 y=0 width=10 height=15 xoffset=-2 yoffset=-1 xadvance=6 page=0 chnl=15
char id=121 x=34 y=0 width=9 height=15 xoffset=-2 yoffset=-1 xadvance=6 page=0 chnl=15
char id=122 x=218 y=34 width=8 height=15 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=123 x=228 y=34 width=7 height=15 xoffset=-2 yoffset=-1 xadvance=6 page=0 chnl=15
char id=124 x=213 y=51 width=5 height=15 xoffset=1 yoffset=-1 xadvance=6 page=0 chnl=15
char id=125 x=30 y=51 width=7 height=15 xoffset=0 yoffset=-1 xadvance=6 page=0 chnl=15
char id=126 x=121 y=17 width=9 height=15 xoffset=-2 yoffset=-1 xadvance=6 page=0 chnl=15

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 B

137
android/build.gradle Normal file
View File

@ -0,0 +1,137 @@
android {
buildToolsVersion '26'
compileSdkVersion 26
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
instrumentTest.setRoot('tests')
}
packagingOptions {
exclude 'META-INF/robovm/ios/robovm.xml'
}
defaultConfig {
applicationId "com.jwinslow.game"
minSdkVersion 9
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
// called every time gradle gets executed, takes the native dependencies of
// the natives configuration, and extracts them to the proper libs/ folders
// so they get packed with the APK.
task copyAndroidNatives() {
file("libs/armeabi/").mkdirs();
file("libs/armeabi-v7a/").mkdirs();
file("libs/arm64-v8a/").mkdirs();
file("libs/x86_64/").mkdirs();
file("libs/x86/").mkdirs();
configurations.natives.files.each { jar ->
def outputDir = null
if(jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
if(jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
if(outputDir != null) {
copy {
from zipTree(jar)
into outputDir
include "*.so"
}
}
}
}
task run(type: Exec) {
def path
def localProperties = project.file("../local.properties")
if (localProperties.exists()) {
Properties properties = new Properties()
localProperties.withInputStream { instr ->
properties.load(instr)
}
def sdkDir = properties.getProperty('sdk.dir')
if (sdkDir) {
path = sdkDir
} else {
path = "$System.env.ANDROID_HOME"
}
} else {
path = "$System.env.ANDROID_HOME"
}
def adb = path + "/platform-tools/adb"
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.jwinslow.game/com.jwinslow.game.AndroidLauncher'
}
// sets up the Android Eclipse project, using the old Ant based build.
eclipse {
// need to specify Java source sets explicitly, SpringSource Gradle Eclipse plugin
// ignores any nodes added in classpath.file.withXml
sourceSets {
main {
java.srcDirs "src", 'gen'
}
}
jdt {
sourceCompatibility = 1.6
targetCompatibility = 1.6
}
classpath {
plusConfigurations += [ project.configurations.compile ]
containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES'
}
project {
name = appName + "-android"
natures 'com.android.ide.eclipse.adt.AndroidNature'
buildCommands.clear();
buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder"
buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder"
buildCommand "org.eclipse.jdt.core.javabuilder"
buildCommand "com.android.ide.eclipse.adt.ApkBuilder"
}
}
// sets up the Android Idea project, using the old Ant based build.
idea {
module {
sourceDirs += file("src");
scopes = [ COMPILE: [plus:[project.configurations.compile]]]
iml {
withXml {
def node = it.asNode()
def builder = NodeBuilder.newInstance();
builder.current = node;
builder.component(name: "FacetManager") {
facet(type: "android", name: "Android") {
configuration {
option(name: "UPDATE_PROPERTY_FILES", value:"true")
}
}
}
}
}
}
}

BIN
android/ic_launcher-web.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
<system systemId="http://schemas.android.com/apk/res/android" uri="schemas.android.com/apk/res/android"/>
</catalog>

View File

@ -0,0 +1 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><meta http-equiv="refresh" content="0;url=http://finder.cableone.net/main?ParticipantID=89bdhw55rwiav67vwo6o7gbbv98p9jk4&FailedURI=http%3A%2F%2Fschemas.android.com%2Fapk%2Fres%2Fandroid&FailureMode=1&Implementation=&AddInType=4&Version=pywr1.0&ClientLocation=us"/><script type="text/javascript">url="http://finder.cableone.net/main?ParticipantID=89bdhw55rwiav67vwo6o7gbbv98p9jk4&FailedURI=http%3A%2F%2Fschemas.android.com%2Fapk%2Fres%2Fandroid&FailureMode=1&Implementation=&AddInType=4&Version=pywr1.0&ClientLocation=us";if(top.location!=location){var w=window,d=document,e=d.documentElement,b=d.body,x=w.innerWidth||e.clientWidth||b.clientWidth,y=w.innerHeight||e.clientHeight||b.clientHeight;url+="&w="+x+"&h="+y;}window.location.replace(url);</script></head><body></body></html>

45
android/proguard-rules.pro vendored Normal file
View File

@ -0,0 +1,45 @@
# 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 android.support.**
-dontwarn com.badlogic.gdx.backends.android.AndroidFragmentApplication
-dontwarn com.badlogic.gdx.utils.GdxBuild
-dontwarn com.badlogic.gdx.physics.box2d.utils.Box2DBuild
-dontwarn com.badlogic.gdx.jnigen.BuildTarget*
-dontwarn com.badlogic.gdx.graphics.g2d.freetype.FreetypeBuild
-keep class com.badlogic.gdx.controllers.android.AndroidControllers
-keepclassmembers class com.badlogic.gdx.backends.android.AndroidInput* {
<init>(com.badlogic.gdx.Application, android.content.Context, java.lang.Object, com.badlogic.gdx.backends.android.AndroidApplicationConfiguration);
}
-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

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>
<string name="app_name">TestUDPGame</string>
</resources>

View File

@ -0,0 +1,12 @@
<resources>
<style name="GdxTheme" parent="android:Theme">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowAnimationStyle">@android:style/Animation</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowFullscreen">true</item>
</style>
</resources>

View File

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

81
build.gradle Normal file
View File

@ -0,0 +1,81 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = "TestUDPGame"
gdxVersion = '1.9.6'
roboVMVersion = '2.3.1'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
project(":desktop") {
apply plugin: "java"
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
}
}
project(":android") {
apply plugin: "android"
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
}
}
project(":core") {
apply plugin: "java"
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
}
}
tasks.eclipse.doLast {
delete ".project"
}

11
core/build.gradle Normal file
View File

@ -0,0 +1,11 @@
apply plugin: "java"
sourceCompatibility = 1.6
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
sourceSets.main.java.srcDirs = [ "src/" ]
eclipse.project {
name = appName + "-core"
}

View File

@ -0,0 +1,127 @@
package com.jwinslow.game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.utils.Array;
import com.jwinslow.game.gameobjects.GameObject;
import com.jwinslow.game.gameobjects.GameObjectHandler;
import com.jwinslow.game.gameobjects.Player;
import com.jwinslow.game.net.Connection;
import com.jwinslow.game.states.*;
import com.jwinslow.game.ui.UIDebug;
import com.jwinslow.game.utils.Assets;
import com.jwinslow.game.utils.ButtonEffects;
import com.jwinslow.game.utils.CameraHandler;
import com.jwinslow.game.utils.Controls;
import com.jwinslow.game.utils.Fonts;
import com.jwinslow.game.utils.TextInputListener;
public class Handler {
//--- Propreties
private float elapsedTime;
public UIDebug debugger;
private TextInputListener til;
private CameraHandler camHandler;
private GameObjectHandler gameObjectHandler;
private State initState;
private State gameState;
private State menuState;
private State pauseState;
private State connectState;
private Main main;
private BitmapFont font;
public String message;
//--- Constructor
public Handler(Main main) {
this.main = main;
font = new BitmapFont(Gdx.files.internal("customPixelFont1.fnt"));
font.setColor(Color.RED);
font.getData().scale(0.01f);
message = "";
elapsedTime = 0;
}
//--- Methods
public void init() {
debugger = new UIDebug(this);
getStage().addActor(debugger);
debugger.msg = "Debugger:";
Connection.init(this);
til = new TextInputListener(this);
camHandler = new CameraHandler(this, main.getCam());
gameObjectHandler = new GameObjectHandler(this);
initState = new InitState(this);
gameState = new GameState(this);
menuState = new MenuState(this);
pauseState = new PauseState(this);
connectState = new ConnectState(this, -1);
State.setCurrentState(initState);
State.getCurrentState().init();
Controls.initControls();
Controls.setControllerType(Controls.TOUCH);
ButtonEffects.init(this);
Fonts.init(this);
}
public void update(float dt) {
Connection.update(dt);
elapsedTime += dt;
//message = "" + Gdx.graphics.getWidth();//(int) elapsedTime;
debugger.update(dt);
Controls.update();
camHandler.update(dt);
if (State.getCurrentState() != null) State.getCurrentState().update(dt);
//main.stage.act(dt);
}
public void render(SpriteBatch batch) {
if (State.getCurrentState() != null) State.getCurrentState().render(batch);
font.draw(batch, message, getCam().position.x-main.cam.viewportWidth/2+2, getCam().position.y-main.cam.viewportHeight/2+15);
}
public void dispose() {
gameObjectHandler.dispose();
System.out.println("Disposing of textures.");
initState.dispose();
gameState.dispose();
menuState.dispose();
pauseState.dispose();
connectState.dispose();
Assets.disposeAllTextures();
font.dispose();
Fonts.dispose();
debugger.dispose();
Connection.dispose();
}
public void addGameObject(GameObject o) {
gameObjectHandler.add(o);
}
//--- Getters and Setters
public Main getMain() {return main;}
public InitState getInitState() {return (InitState)initState;}
public GameState getGameState() {return (GameState) gameState;}
public MenuState getMenuState() {return (MenuState) menuState;}
public PauseState getPauseState() {return (PauseState) pauseState;}
public ConnectState getConnectState() {return (ConnectState) connectState;}
public OrthographicCamera getCam() {return main.getCam();}
public CameraHandler getCamHandler() {return camHandler;}
public GameObjectHandler getGameObjectHandler() {return gameObjectHandler;}
public Array<Player> getPlayers() {return gameObjectHandler.getPlayers();}
public Stage getStage() {return main.stage;}
public TextInputListener getTil() {return til;}
}

View File

@ -0,0 +1,71 @@
package com.jwinslow.game;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
public class Main extends ApplicationAdapter {
public static final int WIDTH = 320, HEIGHT = 480;
SpriteBatch batch;
Handler handler;
OrthographicCamera cam;
Stage stage;
@Override
public void create () {
batch = new SpriteBatch();
handler = new Handler(this);
stage = new Stage(new ScreenViewport(), batch);
stage.getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
cam = new OrthographicCamera(Main.WIDTH/4, Main.HEIGHT/4);
cam.setToOrtho(false, cam.viewportWidth, cam.viewportHeight);
handler.init();
cam.update();
}
public void resize() {
stage.getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
cam.update();
}
@Override
public void render () {
//Gdx.gl.glClearColor(1, 0, 0, 1);
float dt = Gdx.graphics.getDeltaTime();
cam.update();
batch.setProjectionMatrix(cam.combined);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
handler.update(dt);
//stage.act(dt);
batch.begin();
handler.render(batch);
batch.end();
batch.setColor(1, 1, 1, 1);
stage.draw();
}
@Override
public void dispose () {
handler.dispose();
batch.dispose();
stage.dispose();
}
public OrthographicCamera getCam() {return cam;}
public void setCam(OrthographicCamera cam) {this.cam = cam;}
}

View File

@ -0,0 +1,49 @@
package com.jwinslow.game.gameobjects;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Rectangle;
import com.jwinslow.game.Handler;
public abstract class GameObject {
//--- Propreties
protected Handler handler;
protected float x;
protected float y;
protected float depth;
protected TextureRegion image;
protected Rectangle bounds;
//--- Constructor
public GameObject(Handler handler, float x, float y, TextureRegion image) {
this.handler = handler;
this.x = x;
this.y = y;
this.depth = y;
this.image = image;
this.bounds = new Rectangle();
}
//--- Methods
public abstract void update(float dt);
public abstract void render(SpriteBatch batch);
public abstract void dispose();
//--- Getters and Setters
public float getX() {return x;}
public float getY() {return y;}
public float getDepth() {return depth;}
public Rectangle getBounds() {return bounds;}
public void setX(float x) {this.x = x;}
public void setY(float y) {this.y = y;}
public void setPosition(float x, float y) {this.x = x; this.y = y;}
public void setDepth(float depth) {this.depth = depth;}
public void setBounds(Rectangle bounds) {this.bounds = bounds;}
}

View File

@ -0,0 +1,95 @@
package com.jwinslow.game.gameobjects;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.Array;
import com.jwinslow.game.Handler;
public class GameObjectHandler {
//--- Propreties
private Handler handler;
private Array<GameObject> gameObjects;
private Array<Player> players;
//--- Constructor
public GameObjectHandler(Handler handler) {
this.handler = handler;
gameObjects = new Array<GameObject>();
players = new Array<Player>();
}
//--- Methods
public void update(float dt) {
sort();
for (GameObject o : gameObjects) {
o.update(dt);
}
//System.out.println("Updateing gameObjects.");
}
public void render(SpriteBatch batch) {
for (GameObject o : gameObjects) {
o.render(batch);
}
//System.out.println("rendering gameObjects " + gameObjects.size);
}
public void dispose() {
gameObjects.clear();
}
public void sort() {
for (int i = 0; i < gameObjects.size; i++) {
if (i+1 == gameObjects.size) break;
if (gameObjects.get(i).getDepth() < gameObjects.get(i+1).getDepth()) {
gameObjects.swap(i, i+1);
}
}
}
public void add(GameObject o) {
gameObjects.add(o);
}
public void addAll(GameObject[] objects) {
for (GameObject o: objects) {
add(o);
}
}
public void remove(GameObject o) {
gameObjects.removeValue(o, false);
}
public void addPlayer(Player player) {
players.add(player);
add(player);
/*
for (int i = 0; i < players.length; i++) {
if (players[i] != null) {
players[i] = player;
add(players[i]);
break;
}
}//*/
}
public void removePlayer(Player player) {
players.removeValue(player, false);
remove(player);/*
for (int i = 0; i < players.length; i++) {
if (players[i].equals(player)) {
remove(player);
players[i] = null;
break;
}
}//*/
}
//--- Getters and Setters
public Array<GameObject> getGameObjects() {return gameObjects;}
public Array<Player> getPlayers() {return players;}
}

View File

@ -0,0 +1,45 @@
package com.jwinslow.game.gameobjects;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.jwinslow.game.Handler;
/**
* Created by jalen on 1/12/2018.
*/
public class OnlinePlayer extends Player {
public OnlinePlayer(Handler handler, float x, float y, TextureRegion image, int pid, String name) {
super(handler, x, y, image);
this.pid = pid;
this.name = name;
}
@Override
public void update(float dt) {
handleAnimation();
bounds.x = x;
bounds.y = y;
sprite.update(dt);
}
@Override
public void handleAnimation() {
if (dir <= 45 && dir >= -45) sprite.setAnimCurrent(sprite.getAnimRight());
if (dir > 45 && dir < 135) sprite.setAnimCurrent(sprite.getAnimUp());
if (dir >= 135 && dir <= 225) sprite.setAnimCurrent(sprite.getAnimLeft());
if (dir > -135 && dir < -45) sprite.setAnimCurrent(sprite.getAnimDown());
if (idle == 1) {
sprite.setManual(true);
sprite.setCurrentFrame(sprite.getAnimCurrent().getKeyFrame(0));
} else {
sprite.setManual(false);
}
}
@Override
public String toString() {return "OnlinePlayer";}
}

View File

@ -0,0 +1,256 @@
package com.jwinslow.game.gameobjects;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.MathUtils;
import com.jwinslow.game.Handler;
import com.jwinslow.game.Main;
import com.jwinslow.game.sprites.PlayerSprite;
import com.jwinslow.game.utils.Assets;
import com.jwinslow.game.utils.Controls;
import java.text.DecimalFormat;
public class Player extends GameObject {
//--- Propreties
public static int playerid = 1;
public static final float SPEED = 0.7f;
private float vecX, vecY;
private float speed;
protected float dir;
protected PlayerSprite sprite;
protected int pid;
protected int idle;
protected String name;
//private PlayerControls Controls;
//--- Constructor
public Player(Handler handler, float x, float y, TextureRegion image) {
super(handler, x, y, image);
this.bounds = new Rectangle(x, y, 16, 16);
this.vecX = 0;
this.vecY = 0;
this.dir = 0;
this.speed = 0;
this.sprite = new PlayerSprite(handler, bounds.x, bounds.y, bounds.width, bounds.height, image, this);
this.pid = 0;
this.idle = 0;
this.name = "Player";
//this.Controls = new PlayerControls(PlayerControls.TOUCH);
}
//--- Methods
@Override
public void update(float dt) {
handleInput();
handleCollision();
handleAnimation();
x += vecX;
y += vecY;
bounds.x = x;
bounds.y = y;
depth = y;
sprite.update(dt);
}
@Override
public void render(SpriteBatch batch) {
sprite.render(batch);
}
@Override
public void dispose() {
}
@Override
public String toString() {return "Player";}
public void handleInput() {
//Controls.update();
if (Controls.getControllerType() == Controls.KEYBOARD) {
if ((Controls.left && Controls.right) || (!Controls.left && !Controls.right)) {
vecX = 0;
} else if (Controls.left) {
vecX = -SPEED;
} else if (Controls.right) {
vecX = SPEED;
}
if ((Controls.up && Controls.down) || (!Controls.up && !Controls.down)) {
vecY = 0;
} else if (Controls.up) {
vecY = SPEED;
} else if (Controls.down) {
vecY = -SPEED;
}
}
if (Controls.getControllerType() == Controls.TOUCH) {
float startX = Controls.sx;
float startY = Controls.sy;
float endX = Controls.ex;
float endY = Controls.ey;
vecX = SPEED * (endX-startX) / 50;
vecY = SPEED * (endY-startY) / 50;
float starter = 0.2f * (Gdx.graphics.getWidth()/ Main.WIDTH);
if (vecX < starter && vecX > -starter) vecX = 0;
if (vecY < starter && vecY > -starter) vecY = 0;
if (vecX > SPEED) vecX = SPEED;
else if (vecX < -SPEED) vecX = -SPEED;
if (vecY > SPEED) vecY = SPEED;
else if (vecY < -SPEED) vecY = -SPEED;
}
}
public void handleAnimation() {
if (vecX != 0 || vecY != 0)
dir = MathUtils.atan2(vecY, vecX) * MathUtils.radiansToDegrees;
if (dir <= 45 && dir >= -45) sprite.setAnimCurrent(sprite.getAnimRight());
if (dir > 45 && dir < 135) sprite.setAnimCurrent(sprite.getAnimUp());
if (dir >= 135 && dir <= 225) sprite.setAnimCurrent(sprite.getAnimLeft());
if (dir > -135 && dir < -45) sprite.setAnimCurrent(sprite.getAnimDown());
if (vecX == 0 && vecY == 0) {
idle = 1;
sprite.setManual(true);
sprite.setCurrentFrame(sprite.getAnimCurrent().getKeyFrame(0));
} else {
idle = 0;
sprite.setManual(false);
}
}
public void handleCollision() {
if (bounds.x + bounds.width + vecX > Assets.background.getWidth()) {
vecX = 0;
}
if (bounds.x + vecX < 0) vecX = 0;
if (bounds.y + bounds.height + vecY > Assets.background.getHeight() ||
bounds.y + vecY < 0) {
vecY = 0;
}
}
//--- Getters and Setters
public float getDir() {return dir;}
public int getPid() {return pid;}
public int getIdle() {return idle;}
public String getName() {return name;}
//public PlayerControls getControls() {return Controls;}
public void setDir(float dir) {this.dir = dir;}
public void setPid(int pid) {this.pid = pid;}
public void setIdle(int idle) {this.idle = idle;}
public void setName(String name) {this.name = name;}
public class PlayerControls {
public static final int KEYBOARD = 0, TOUCH = 1;
private int controlType;
public boolean up, down, left, right;
private int key_up, key_down, key_left, key_right;
public float sx, sy, ex, ey;
public float jx, jy;
private boolean touched;
public PlayerControls(int controlType) {
this.controlType = controlType;
initControls();
}
public void update() {
switch (controlType) {
case KEYBOARD:
updateKeyboard();
break;
case TOUCH:
updateTouch();
break;
default:
controlType = KEYBOARD;
break;
}
}
private void updateKeyboard() {
up = Gdx.input.isKeyPressed(key_up);
down = Gdx.input.isKeyPressed(key_down);
left = Gdx.input.isKeyPressed(key_left);
right = Gdx.input.isKeyPressed(key_right);
}
private void updateTouch() {
if (Gdx.input.isTouched()) {
if (!touched) {
sx = Gdx.input.getX();
sy = Gdx.input.getY();
ex = sx;
ey = sy;
touched = true;
} else {
ex = Gdx.input.getX();
ey = Gdx.input.getY();
}
} else {
sx = 0; sy = 0;
ex = 0; ey = 0;
touched = false;
}
if (Gdx.input.justTouched()) {
jx = Gdx.input.getX();
jy = Gdx.input.getY();
} else {
jx = -1;
jy = -1;
}
}
private void initControls() {
key_up = Keys.W;
key_down = Keys.S;
key_left = Keys.A;
key_right = Keys.D;
}
public int getControllerType() {return controlType;}
public float getSx() {return sx;}
public float getSy() {return sy;}
public float getEx() {return ex;}
public float getEy() {return ey;}
public float getJx() {return jx;}
public float getJy() {return jy;}
public boolean getUp() {return up;}
public boolean getDown() {return down;}
public boolean getLeft() {return left;}
public boolean getRight() {return right;}
public void setControllerType(int controlType) {this.controlType = controlType;}
public void setKey_up(int key) {this.key_up = key;}
public void setKey_down(int key) {this.key_down = key;}
public void setKey_left(int key) {this.key_left = key;}
public void setKey_right(int key) {this.key_right = key;}
}
}

View File

@ -0,0 +1,387 @@
package com.jwinslow.game.net;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.utils.Array;
import com.jwinslow.game.Handler;
import com.jwinslow.game.gameobjects.OnlinePlayer;
import com.jwinslow.game.gameobjects.Player;
import com.jwinslow.game.states.State;
import com.jwinslow.game.utils.Assets;
import com.jwinslow.game.utils.ButtonEffects;
import java.io.IOException;
import java.text.DecimalFormat;
/**
* Created by jalen on 12/29/2017.
*/
public class Connection {
public static final int PORT = 11321;
public enum MStates {
CREATE_PLAYER_FROM_CLIENT,
CREATE_PLAYER_FROM_SERVER,
REMOVE_PLAYER,
REMOVE_SERVER_PLAYER,
GAME,
PLAYER_NAME,
ALL_PLAYERS_GAME,
ALL_PLAYERS_INFO,
ALL_PLAYERS_CREATE,
PLAY,
WAIT
}
private static Handler handler;
public static String receivedInfo;
public static String sentInfo;
public static boolean msgReady;
public static int currentPid;
public static MStates msgState;
public static UDPServer udpServer;
public static UDPClient udpClient;
public static float elapsedTime;
//public static TCPServer tcpServer;
//public static TCPClient tcpClient;
public static void init(Handler handler) {
Connection.handler = handler;
receivedInfo = "";
sentInfo = "";
msgReady = false;
currentPid = 0;
msgState = MStates.WAIT;
elapsedTime = 0;
}
public static void create(int type) {
// 0 - UDPServer
// 1 - UDPClient
// 2 - TCPServer
// 3 - TCPClient
switch (type) {
case 0:createUDPServer();break;
case 1:createUDPClient();break;
case 2:createTCPServer();break;
case 3:createTCPClient();break;
default:
handler.debugger.msg = "No connection type.";
}
}
public static void update(float dt) {
String m = new String(getReceivedInfo());
setReceivedInfo("");
if (!m.equalsIgnoreCase("")) {
String[] message = m.split(" ");
receive(message);
}
String s = "";
elapsedTime += dt;
if (elapsedTime >= 1f/30f) {
s = send(msgState);
elapsedTime -= 1f/30f;
}
if (!s.equalsIgnoreCase("")) {
setSentInfo(s);
}
if (getMsgReady()) sendWhere();
}
public static void receive(String[] message) {
String type = message[0];
if (type.equalsIgnoreCase("cs")) {
createPlayer(currentPid = Player.playerid, message[1]);
Player.playerid++;
msgState = MStates.ALL_PLAYERS_CREATE;
} else if (type.equalsIgnoreCase("c")) {
createPlayer(Integer.parseInt(message[1]), message[2]);
} else if (type.equalsIgnoreCase("r")) {
removePlayer(currentPid = Integer.parseInt(message[1]));
msgState = MStates.REMOVE_PLAYER;
} else if (type.equalsIgnoreCase("g")) {
updatePlayer(Integer.parseInt(message[1]),
Float.parseFloat(message[2]), Float.parseFloat(message[3]),
Float.parseFloat(message[4]), Integer.parseInt(message[5]));
} else if (type.equalsIgnoreCase("p")) {
updatePlayerName(Integer.parseInt(message[1]), message[2]);
} else if (type.equalsIgnoreCase("2")) { // 2 players
int numOfPlayers = 2;
if (message[1].equalsIgnoreCase("g")) {
updateGamePlayers(numOfPlayers, message);
} else if (message[1].equalsIgnoreCase("p")) {
updateNamePlayers(numOfPlayers, message);
} else if (message[1].equalsIgnoreCase("c")) {
updateCreatePlayers(numOfPlayers, message);}
} else if (type.equalsIgnoreCase("3")) { // 3 players
int numOfPlayers = 3;
if (message[1].equalsIgnoreCase("g")) {
updateGamePlayers(numOfPlayers, message);
} else if (message[1].equalsIgnoreCase("p")) {
updateNamePlayers(numOfPlayers, message);
} else if (message[1].equalsIgnoreCase("c")) {
updateCreatePlayers(numOfPlayers, message);}
} else if (type.equalsIgnoreCase("4")) {
int numOfPlayers = 4;
if (message[1].equalsIgnoreCase("g")) {
updateGamePlayers(numOfPlayers, message);
} else if (message[1].equalsIgnoreCase("p")) {
updateNamePlayers(numOfPlayers, message);
} else if (message[1].equalsIgnoreCase("c")) {
updateCreatePlayers(numOfPlayers, message);
}
} else if (type.equalsIgnoreCase("play")){// *** Something wrong here for android
System.out.println("Playing game now.");
ButtonEffects.update(ButtonEffects.PLAY_GAME);
}
}
public static String send(MStates mState) {
String message = "";
DecimalFormat df = new DecimalFormat("#.#");
switch (mState) {
case ALL_PLAYERS_GAME:
message = handler.getPlayers().size + " g ";
for (int i = 0; i < handler.getPlayers().size; i++) {
message += handler.getPlayers().get(i).getPid() + " " +
df.format(handler.getPlayers().get(i).getX()) + " " +
df.format(handler.getPlayers().get(i).getY()) + " " +
df.format(handler.getPlayers().get(i).getDir()) + " " +
handler.getPlayers().get(i).getIdle();
if (i+1 != handler.getPlayers().size) {
message += " ";
}
}
setMsgReady(true);
break;
case ALL_PLAYERS_INFO:
message = handler.getPlayers().size + " p ";
for (int i = 0; i < handler.getPlayers().size; i++) {
message += handler.getPlayers().get(i).getPid() + " " +
handler.getPlayers().get(i).getName();
if (i+1 != handler.getPlayers().size) {
message += " ";
}
}
setMsgReady(true);
break;
case ALL_PLAYERS_CREATE:
message = handler.getPlayers().size + " c ";
for (int i = 0; i < handler.getPlayers().size; i++) {
message += handler.getPlayers().get(i).getPid() + " " +
handler.getPlayers().get(i).getName();
if (i+1 != handler.getPlayers().size) {
message += " ";
}
}
setMsgReady(true);
break;
case CREATE_PLAYER_FROM_CLIENT:
message = "cs " + handler.getPlayers().get(0).getName();
setMsgReady(true);
break;
case CREATE_PLAYER_FROM_SERVER:
for (int i = 0; i < handler.getPlayers().size; i++) {
if (currentPid == handler.getPlayers().get(i).getPid()) {
message = "c " + currentPid + " " + handler.getPlayers().get(i).getName();
break;
}
}
setMsgReady(true);
break;
case REMOVE_PLAYER:
message = "r " + currentPid;
setMsgReady(true);
break;
case REMOVE_SERVER_PLAYER:
break;
case GAME:
message = "g " + handler.getPlayers().get(0).getPid() + " " +
df.format(handler.getPlayers().get(0).getX()) + " " +
df.format(handler.getPlayers().get(0).getY()) + " " +
df.format(handler.getPlayers().get(0).getDir()) + " " +
handler.getPlayers().get(0).getIdle();
setMsgReady(true);
break;
case PLAYER_NAME:
message = "p " + handler.getPlayers().get(0).getPid() + " " +
handler.getPlayers().get(0).getName();
setMsgReady(true);
break;
case PLAY:
message = "play";
setMsgReady(true);
break;
case WAIT:
if (!getMsgReady()) message = "";
break;
default:
break;
}
if (State.getCurrentState() != handler.getGameState())
msgState = MStates.WAIT;
else if (State.getCurrentState() == handler.getGameState()) {
if (udpServer != null)
msgState = MStates.ALL_PLAYERS_GAME;
else if (udpClient != null)
msgState = MStates.GAME;
}
return message;
}
private static void sendWhere() {
try {
if (udpServer != null) udpServer.updateSend();
if (udpClient != null) udpClient.updateSend();
} catch (IOException ex) {
System.out.println("Could not send message.");
}
}
private static void createUDPServer() {
handler.debugger.msg = "UDP Server";
udpServer = new UDPServer(handler, PORT);
udpServer.start();
}
private static void createUDPClient() {
//handler.debugger.msg = "UDP Client";
udpClient = new UDPClient(handler, PORT);
udpClient.start();
}
private static void createTCPServer() {
handler.debugger.msg = "TCP Server";
}
private static void createTCPClient() {
handler.debugger.msg = "TCP Client";
}
private static void createPlayer(int pid, String name) {
boolean check = false;
for (int i = 0; i < handler.getPlayers().size; i++) {
if (handler.getPlayers().get(i).getName().equalsIgnoreCase(name)) {
handler.getPlayers().get(i).setPid(pid);
check = true;
break;
}
}
if (!check)
handler.getGameObjectHandler().addPlayer(new OnlinePlayer(handler, 0, 0, new TextureRegion(Assets.player2), pid, name));
}
private static void removePlayer(int pid) {
for (int i = 0; i < handler.getPlayers().size; i++) {
if (handler.getPlayers().get(i).getPid() == pid) {
handler.getGameObjectHandler().removePlayer(handler.getPlayers().get(i));
break;
}
}
}
private static void updatePlayer(int pid, float x, float y, float dir, int idle) {
for (int i = 0; i < handler.getPlayers().size; i++) {
if (i == 0) continue;
if (handler.getPlayers().get(i).getPid() == pid) {
handler.getPlayers().get(i).setX(x);
handler.getPlayers().get(i).setY(y);
handler.getPlayers().get(i).setDir(dir);
handler.getPlayers().get(i).setIdle(idle);
break;
}
}
}
private static void updatePlayerName(int pid, String name) {
for (int i = 0; i < handler.getPlayers().size; i++) {
if (handler.getPlayers().get(i).getPid() == pid) {
handler.getPlayers().get(i).setName(name);
break;
}
}
}
private static void updateGamePlayers(int numOfPlayers, String[] message) {
String[][] m = new String[numOfPlayers][5];
int index = 2;
for (int i = 0; i < m.length; i++) {
for (int j = 0; j < m[i].length; j++) {
m[i][j] = message[index];
index++;
}
}
for (int i = 0; i < numOfPlayers; i++) {
updatePlayer(Integer.parseInt(m[i][0]),
Float.parseFloat(m[i][1]), Float.parseFloat(m[i][2]),
Float.parseFloat(m[i][3]), Integer.parseInt(m[i][4]));
}
}
private static void updateNamePlayers(int numOfPlayers, String[] message) {
String[][] m = new String[numOfPlayers][2];
int index = 2;
for (int i = 0; i < m.length; i++) {
for (int j = 0; j < m[i].length; j++) {
m[i][j] = message[index];
index++;
}
}
for (int i = 0; i < numOfPlayers; i++) {
updatePlayerName(Integer.parseInt(m[i][0]),
m[i][1]);
}
}
private static void updateCreatePlayers(int numOfPlayers, String[] message) {
String[][] m = new String[numOfPlayers][2];
int index = 2;
for (int i = 0; i < m.length; i++) {
for (int j = 0; j < m[i].length; j++) {
m[i][j] = message[index];
index++;
}
}
for (int i = 0; i < numOfPlayers; i++) {
createPlayer(Integer.parseInt(m[i][0]),
m[i][1]);
}
}
public static void dispose() {
System.out.println("Disposing of networks.");
if (udpServer != null) {udpServer.stop();}
if (udpClient != null) {udpClient.stop();}
}
public static synchronized void setReceivedInfo(String m) {Connection.receivedInfo = m;}
public static synchronized String getReceivedInfo() {return Connection.receivedInfo;}
public static synchronized void setSentInfo(String m) {Connection.sentInfo = m;}
public static synchronized String getSentInfo() {return Connection.sentInfo;}
public static synchronized void setMsgReady(boolean ready) {Connection.msgReady = ready;}
public static synchronized boolean getMsgReady() {return Connection.msgReady;}
}

View File

@ -0,0 +1,120 @@
package com.jwinslow.game.net;
import com.jwinslow.game.Handler;
import com.jwinslow.game.gameobjects.OnlinePlayer;
import com.jwinslow.game.gameobjects.Player;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.text.DecimalFormat;
import javax.xml.crypto.Data;
/**
* Created by jalen on 1/14/2018.
*/
public class UDPClient implements Runnable {
enum States {
CONNECTING,
CONNECTED,
GAME;
}
private Handler handler;
private Thread t;
private InetAddress serverAddress;
private int port;
private States state;
private DatagramSocket socket;
private boolean bExit;
public UDPClient(Handler handler, int port) {
this.handler = handler;
this.port = port;
state = States.CONNECTING;
bExit = false;
}
@Override
public void run() {
try {
socket = new DatagramSocket(port);
serverAddress = InetAddress.getByName(handler.getConnectState().getIpAddressArea().getMessage());
while (!bExit) {
try {
if (socket.isClosed()) socket = new DatagramSocket(port);
System.out.println("Running UDP Client");
updateReceive(socket);
} catch (IOException ex) {
handler.debugger.msg = "UDP Client stopped working.";
} catch (RuntimeException ex) {
handler.debugger.msg = "UDP Client stopped working.";
}
}
socket.close();
} catch (SocketException ex) {
ex.printStackTrace();
} catch (UnknownHostException ex) {
ex.printStackTrace();
}
stop();
}
public synchronized void start() {
t = new Thread(this);
t.start();
}
public synchronized void stop() {
System.out.println("Stopping UDP Client.");
handler.debugger.msg = "Stopping UDP Client.";
bExit = true;
}
public void updateSend() throws IOException, RuntimeException {
new Thread(new Runnable() {
@Override
public void run(){
try {
DatagramSocket s = new DatagramSocket(port+1);
String data = "";
if (Connection.getMsgReady()) {
data = Connection.getSentInfo();
Connection.setSentInfo("");
Connection.setMsgReady(false);
}
if (data != null && !data.equalsIgnoreCase("")) {
System.out.println("Client-Message sent is: " + data);
s.send(new DatagramPacket(data.getBytes(), data.getBytes().length, serverAddress, port));
handler.debugger.msg = serverAddress.getHostAddress() + " " + port;
}
s.close();
} catch (SocketException ex) {
System.out.println("Could not create socket. UDPClient.updateSend()");
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}).start();
}
public void updateReceive(DatagramSocket socket) throws IOException, RuntimeException {
DatagramPacket request = new DatagramPacket(new byte[512], 512);
socket.receive(request);
String message = new String(request.getData(), 0, request.getLength());
System.out.println("Client - Message received is: " + message);
Connection.setReceivedInfo(message);
}
}

View File

@ -0,0 +1,143 @@
package com.jwinslow.game.net;
import com.badlogic.gdx.utils.Array;
import com.jwinslow.game.Handler;
import com.jwinslow.game.gameobjects.OnlinePlayer;
import com.jwinslow.game.gameobjects.Player;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.text.DecimalFormat;
/**
* Created by jalen on 1/13/2018.
*/
public class UDPServer implements Runnable {
enum States {
CONNECT,
GAME
}
enum sendStates {
CREATE_PLAYER,
REMOVE_PLAYER,
PLAYER_POS,
PLAYER_NAME,
WAIT
}
private Handler handler;
private Thread t;
private int port;
private Array<InetAddress> addresses;
private InetAddress currentAddr;
private States state;
private InetAddress ipAddress;
private DatagramSocket socket;
private boolean bExit;
public UDPServer(Handler handler, int port) {
this.handler = handler;
this.port = port;
addresses = new Array<InetAddress>();
state = States.CONNECT;
bExit = false;
}
@Override
public void run() {
try {
socket = new DatagramSocket(port);
while (!bExit) {
try {
if (socket.isClosed()) socket = new DatagramSocket(port);
handler.debugger.msg = "Running UDP server";
System.out.println("Running UDP server.");
updateReceive(socket);
} catch (IOException ex) {
handler.debugger.msg = "UDP Server stopped working. IOException";
ex.printStackTrace();
} catch (RuntimeException ex) {
handler.debugger.msg = "UDP Server stopped working. RuntimeException";
ex.printStackTrace();
}
socket.close();
}
} catch (SocketException e) {
e.printStackTrace();
}
stop();
}
public synchronized void start() {
t = new Thread(this);
t.start();
}
public synchronized void stop() {
System.out.println("Stopping UDP Server.");
handler.debugger.msg = "Stopping UDP Server.";
bExit = true;
}
public void updateReceive(DatagramSocket socket) throws IOException {
DatagramPacket request = new DatagramPacket(new byte[512], 512);
socket.receive(request);
currentAddr = request.getAddress();
if (!addresses.contains(currentAddr, false)) {
addresses.add(currentAddr);
}
String message = new String(request.getData(), 0, request.getLength());
System.out.println("Server-Message receieved is: " + message);
Connection.setReceivedInfo(message);
}
public void updateSend() throws IOException, RuntimeException {
new Thread(new Runnable() {
@Override
public void run() {
DatagramSocket s;
try {
s = new DatagramSocket(port+1);
String data = "";
if (Connection.getMsgReady()) {
data = Connection.getSentInfo();
Connection.setSentInfo("");
Connection.setMsgReady(false);
}
if (data != null && !data.equalsIgnoreCase("")) {
System.out.println("Server-Message sent is: " + data);
for (int i = 0; i < addresses.size; i++) {
s.send(new DatagramPacket(data.getBytes(), data.getBytes().length, addresses.get(i), port));
}
}
s.close();
} catch (SocketException ex) {
System.out.println("Could not create socket. UDPServer.updateSend()");
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}).start();
}
//Getters and Setters
public int getPort() {return port;}
public States getState() {return state;}
public InetAddress getIpAddress() {return ipAddress;}
public void setPort(int port) {this.port = port;}
public void setState(States state) {this.state = state;}
}

View File

@ -0,0 +1,95 @@
package com.jwinslow.game.sprites;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.Animation.PlayMode;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.utils.Array;
import com.jwinslow.game.Handler;
import com.jwinslow.game.gameobjects.GameObject;
public class PlayerSprite extends Sprite{
//--- Propreties
private Animation<TextureRegion> animLeft, animRight, animUp, animDown, animCurrent;
private boolean manual;
private float elapsedTime;
//--- Constructor
public PlayerSprite(Handler handler, float x, float y, float width, float height, TextureRegion image, GameObject obj) {
super(handler, x, y , width, height, image, obj);
this.manual = false;
createAnimation();
}
//--- Methods
@Override
public void update(float dt) {
elapsedTime += dt;
bounds.x = gameObj.getX();
bounds.y = gameObj.getY();
if (!manual)
currentFrame = animCurrent.getKeyFrame(elapsedTime);
}
@Override
public void render(SpriteBatch batch) {
batch.draw(currentFrame, bounds.x, bounds.y, bounds.width, bounds.height);
}
@Override
public void dispose() {
}
private void createAnimation() {
TextureRegion[][] images = image.split(16, 16);
frames = new TextureRegion[images.length * images[0].length];
for (int i = 0; i < images.length; i++) {
for (int j = 0; j < images[i].length; j++) {
frames[(i*images.length)+j] = images[i][j];
}
}
Array<TextureRegion> animFrames = new Array<TextureRegion>();
for (int i = 0; i < images[0].length; i++) {
animFrames.add(images[0][i]);
}
animDown = new Animation<TextureRegion>(0.1f, animFrames, PlayMode.LOOP);
animFrames.clear();
for (int i = 0; i < images[1].length; i++) {
animFrames.add(images[1][i]);
}
animUp = new Animation<TextureRegion>(0.1f, animFrames, PlayMode.LOOP);
animFrames.clear();
for (TextureRegion t : images[2]) {
animFrames.add(t);
}
animRight = new Animation<TextureRegion>(0.1f, animFrames, PlayMode.LOOP);
animFrames.clear();
for (TextureRegion t : images[3]) {
animFrames.add(t);
}
animLeft = new Animation<TextureRegion>(0.1f, animFrames, PlayMode.LOOP);
animFrames.clear();
animCurrent = animDown;
currentFrame = animCurrent.getKeyFrame(0);
}
//--- Getters and Setters
public Animation<TextureRegion> getAnimDown() {return animDown;}
public Animation<TextureRegion> getAnimUp() {return animUp;}
public Animation<TextureRegion> getAnimRight() {return animRight;}
public Animation<TextureRegion> getAnimLeft() {return animLeft;}
public Animation<TextureRegion> getAnimCurrent() {return animCurrent;}
public boolean getManual() {return manual;}
public void setAnimCurrent(Animation anim) {this.animCurrent = anim;}
public void setManual(boolean manual) {this.manual = manual;}
}

View File

@ -0,0 +1,73 @@
package com.jwinslow.game.sprites;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Rectangle;
import com.jwinslow.game.Handler;
import com.jwinslow.game.gameobjects.GameObject;
public abstract class Sprite {
//--- Propreties
protected Handler handler;
protected TextureRegion image;
protected TextureRegion currentFrame;
protected TextureRegion[] frames;
protected float x;
protected float y;
protected float width;
protected float height;
protected int currentFrameIndex;
protected int numOfFrames;
protected Rectangle bounds;
protected GameObject gameObj;
//--- Constructor
public Sprite(Handler handler, TextureRegion image) {
this.handler = handler;
this.image = image;
this.currentFrame = new TextureRegion();
this.frames = new TextureRegion[0];
this.bounds = new Rectangle();
}
public Sprite(Handler handler, float x, float y, float width, float height, TextureRegion image, GameObject obj) {
this.handler = handler;
this.image = image;
this.currentFrame = new TextureRegion();
this.frames = new TextureRegion[0];
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.bounds = new Rectangle(x, y, width, height);
this.gameObj = obj;
}
//--- Methods
public abstract void update(float dt);
public abstract void render(SpriteBatch batch);
public abstract void dispose();
//--- Getters and Setters
public TextureRegion getImage() {return image;}
public TextureRegion getCurrentFrame() {return currentFrame;}
public TextureRegion[] getFrames() {return frames;}
public float getX() {return x;}
public float getY() {return y;}
public float getWidth() {return width;}
public float getHeight() {return height;}
public int getCurrentFrameIndex() {return currentFrameIndex;}
public int getNumOfFrames() {return numOfFrames;}
public void setImage(TextureRegion image) {this.image =image;}
public void setCurrentFrame(TextureRegion frame) {this.currentFrame = frame;}
public void setX(float x) {this.x = x;}
public void setY(float y) {this.y = y;}
public void setWidth(float width) {this.width = width;}
public void setHeight(float height) {this.height = height;}
}

View File

@ -0,0 +1,156 @@
package com.jwinslow.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.utils.Array;
import com.jwinslow.game.Handler;
import com.jwinslow.game.Main;
import com.jwinslow.game.gameobjects.OnlinePlayer;
import com.jwinslow.game.gameobjects.Player;
import com.jwinslow.game.net.Connection;
import com.jwinslow.game.ui.UIButton;
import com.jwinslow.game.ui.UITextArea;
import com.jwinslow.game.utils.Assets;
import com.jwinslow.game.utils.ButtonEffects;
/**
* Created by jalen on 1/8/2018.
*/
public class ConnectState extends State {
private int connectionType;
private UIButton playButton, mainMenuButton;
private UITextArea ipAddressArea, playersArea, playerNameArea;
public ConnectState(Handler handler, int connectionType) {
super(handler);
this.connectionType = connectionType;
}
@Override
public void init() {
if (connectionType == -1) {
handler.getGameObjectHandler().addPlayer(new Player(handler, Assets.background.getWidth()/2, Assets.background.getHeight()/2,
new TextureRegion(Assets.player1)));
State.setCurrentState(handler.getGameState());
handler.getConnectState().dispose();
State.getCurrentState().init();
return;
}
Connection.init(handler);
boolean editText = false;
String ipAddress = "IP Address here.";
ButtonEffects be = ButtonEffects.CONNECT;
boolean canBePressed = true;
String buttonMessage = "No message";
switch (connectionType) {
case 0:
editText = false;
handler.getGameObjectHandler().addPlayer(new Player(handler, 0, 0,
new TextureRegion(Assets.player1)));
handler.getPlayers().get(0).setPid(Player.playerid);
Player.playerid++;
be = ButtonEffects.PLAY_GAME;
buttonMessage = "Play";
canBePressed = false;
Connection.create(connectionType);
break;
case 1:
editText = true;
handler.getGameObjectHandler().addPlayer(new Player(handler, 0, 0,
new TextureRegion(Assets.player1)));
buttonMessage = "Connect";
break;
case 2: editText = false; break;
case 3: editText = true; break;
default: break;
}
playButton = new UIButton(handler, new TextureRegion(Assets.button),
Gdx.graphics.getWidth()*3/4, Gdx.graphics.getHeight()/8, buttonMessage,
be, 0.75f, 2.5f * (Gdx.graphics.getWidth()/ Main.WIDTH), true, canBePressed);
mainMenuButton = new UIButton(handler, new TextureRegion(Assets.button),
Gdx.graphics.getWidth()/4, Gdx.graphics.getHeight()/8, "Back",
ButtonEffects.MAIN_MENU, 0.75f, 2.5f * (Gdx.graphics.getWidth()/ Main.WIDTH), true, true);
playerNameArea = new UITextArea(handler, new TextureRegion(Assets.textArea),
Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()*8/9, 1.25f, 0.2f,
2.5f * (Gdx.graphics.getWidth()/Main.WIDTH), 1, 12, "Enter Name", true);
playerNameArea.setTitle("Enter Player Name:");
playerNameArea.setHint("Name here");
ipAddressArea = new UITextArea(handler, new TextureRegion(Assets.textArea),
Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()*7/9, 1.25f, 0.2f,
2f * (Gdx.graphics.getWidth()/Main.WIDTH), 7, 15, ipAddress, editText);
ipAddressArea.setTitle("Enter IP Address:");
ipAddressArea.setHint("Ex: 192.168.0.1");
playersArea = new UITextArea(handler, new TextureRegion(Assets.textArea),
Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()*4/9, 1.5f, 0.65f,
2.5f * (Gdx.graphics.getWidth()/Main.WIDTH), false);
handler.getStage().addActor(playButton);
handler.getStage().addActor(mainMenuButton);
handler.getStage().addActor(ipAddressArea);
handler.getStage().addActor(playersArea);
handler.getStage().addActor(playerNameArea);
}
@Override
public void update(float dt) {
playButton.update(dt);
mainMenuButton.update(dt);
ipAddressArea.update(dt);
playersArea.update(dt);
playerNameArea.update(dt);
if (!playerNameArea.getMessage().equalsIgnoreCase("Enter Name") && handler.getPlayers().size != 0) {
handler.getPlayers().get(0).setName(playerNameArea.getMessage());
}
if (handler.getPlayers().size > 1) {
playButton.setCanBePressed(true);
}
String message = "Players:";
for (int i = 0; i < handler.getPlayers().size; i++) {
Player player = handler.getPlayers().get(i);
message += "\n"+player.getName();
}
playersArea.setMessage(message);
}
@Override
public void render(SpriteBatch batch) {
batch.draw(Assets.background, 0, 0);
}
@Override
public void dispose() {
if (playButton != null) playButton.dispose();
if (mainMenuButton != null) mainMenuButton.dispose();
if (ipAddressArea != null) ipAddressArea.dispose();
if (playersArea != null) playersArea.dispose();
if (playerNameArea != null) playerNameArea.dispose();
}
public void addOnlinePlayer(int pid, String name) {
handler.getGameObjectHandler().addPlayer(new OnlinePlayer(handler, Assets.background.getWidth()/2, Assets.background.getHeight()/2,
new TextureRegion(Assets.player2), pid, name));
}
//Getters and Setters
public int getConnectionType() {return connectionType;}
public UIButton getPlayButton() {return playButton;}
public UIButton getMainMenuButton() {return mainMenuButton;}
public UITextArea getIpAddressArea() {return ipAddressArea;}
public UITextArea getPlayersArea() {return playersArea;}
public UITextArea getPlayerNameArea() {return playerNameArea;}
public void setConnectionType(int type) {this.connectionType = type;}
}

View File

@ -0,0 +1,62 @@
package com.jwinslow.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.jwinslow.game.Handler;
import com.jwinslow.game.Main;
import com.jwinslow.game.gameobjects.Player;
import com.jwinslow.game.ui.PauseButton;
import com.jwinslow.game.ui.PointerAnchor;
import com.jwinslow.game.utils.Assets;
public class GameState extends State {
//--- Propreties
private PointerAnchor pointer;
private PauseButton pauseButton;
//--- Constructor
public GameState(Handler handler) {
super(handler);
}
//--- Methods
@Override
public void init() {
handler.getCamHandler().setObjOfFocus(handler.getPlayers().get(0));
pointer = new PointerAnchor(handler, new TextureRegion(Assets.touchAnchor), 0, 0, handler.getPlayers().get(0));
pauseButton = new PauseButton(handler, new TextureRegion(Assets.pauseButton));
handler.getStage().addActor(pointer);
handler.getStage().addActor(pauseButton);
System.out.println("Creating player and adding to gameObjects" + handler.getGameObjectHandler().getGameObjects().size);
}
@Override
public void update(float dt) {
handler.getGameObjectHandler().update(dt);
pointer.update(dt);
pauseButton.update(dt);
}
@Override
public void render(SpriteBatch batch) {
batch.draw(Assets.background, 0, 0);
handler.getGameObjectHandler().render(batch);
}
@Override
public void dispose() {
//if (pointer != null) pointer.dispose(); //no need for this
}
//--- Getters and Setters
public PointerAnchor getPointer() {return pointer;}
public PauseButton getPauseButton() {return pauseButton;}
}

View File

@ -0,0 +1,55 @@
package com.jwinslow.game.states;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.jwinslow.game.Handler;
import com.jwinslow.game.Main;
import com.jwinslow.game.utils.Assets;
import com.badlogic.gdx.Gdx;
public class InitState extends State{
//--- Propreties
//--- Constructor
public InitState(Handler handler) {
super(handler);
}
//--- Methods
@Override
public void init() {
Assets.loadAllTextures();
//handler.getCam().zoom = 0.5f;
handler.getCam().position.x = handler.getCam().viewportWidth/2+5;//Added 5 because it start out of collision there.
handler.getCam().position.y = handler.getCam().viewportHeight/2+5;
//State.setCurrentState(handler.getMenuState());
//State.setCurrentState(handler.getGameState());
//State.getCurrentState().init();
}
@Override
public void update(float dt) {
//handler.getMain().resize(Main.WIDTH, Main.HEIGHT);
State.setCurrentState(handler.getMenuState());
//State.setCurrentState(handler.getGameState());
State.getCurrentState().init();
}
@Override
public void render(SpriteBatch batch) {
}
@Override
public void dispose() {
}
//--- Getters and Setters
}

View File

@ -0,0 +1,82 @@
package com.jwinslow.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.jwinslow.game.Handler;
import com.jwinslow.game.Main;
import com.jwinslow.game.ui.UIButton;
import com.jwinslow.game.utils.Assets;
import com.jwinslow.game.utils.ButtonEffects;
import com.jwinslow.game.utils.Controls;
public class MenuState extends State {
//--- Propreties
private UIButton startGameButton, exitGameButton, playGameButton, backButton, changeConnectionButton;
//--- Constructor
public MenuState(Handler handler) {
super(handler);
}
//--- Methods
@Override
public void init() {
handler.getCam().position.set(Assets.background.getWidth()/2, Assets.background.getHeight()/2, 0);
startGameButton = new UIButton(handler, new TextureRegion(Assets.button),
Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2, "Start\nGame",
ButtonEffects.START, 2.5f * (Gdx.graphics.getWidth()/Main.WIDTH), true);
exitGameButton = new UIButton(handler, new TextureRegion(Assets.button),
Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/4, "Exit\nGame",
ButtonEffects.EXIT_GAME, 2.5f * (Gdx.graphics.getWidth()/Main.WIDTH), true);
playGameButton = new UIButton(handler, new TextureRegion(Assets.button),
Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2, "Play\nGame",
ButtonEffects.START_GAME, 2.5f * (Gdx.graphics.getWidth()/Main.WIDTH), false);
backButton = new UIButton(handler, new TextureRegion(Assets.button),
Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/4, "Back",
ButtonEffects.BACK, 2.5f * (Gdx.graphics.getWidth()/Main.WIDTH), false);
changeConnectionButton = new UIButton(handler, new TextureRegion(Assets.button),
Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()*3/4, "Create\nUDP Server",
ButtonEffects.NETWORK_SWITCH, 2.5f * (Gdx.graphics.getWidth()/Main.WIDTH), false);
handler.getStage().addActor(startGameButton);
handler.getStage().addActor(exitGameButton);
handler.getStage().addActor(playGameButton);
handler.getStage().addActor(backButton);
handler.getStage().addActor(changeConnectionButton);
}
@Override
public void update(float dt) {
startGameButton.update(dt);
//handler.message = "" /*+ startGameButton.getRectangle().x //*/+ ", " + Controls.sx + ", " + Controls.sy;
exitGameButton.update(dt);
playGameButton.update(dt);
backButton.update(dt);
changeConnectionButton.update(dt);
}
@Override
public void render(SpriteBatch batch) {
batch.draw(Assets.background, 0 , 0);
}
@Override
public void dispose() {
if (startGameButton != null) startGameButton.dispose();
if (exitGameButton != null) exitGameButton.dispose();
if (playGameButton != null) playGameButton.dispose();
if (backButton != null) backButton.dispose();
if (changeConnectionButton != null) changeConnectionButton.dispose();
}
//--- Getters and Setters
public UIButton getStartGameButton() {return startGameButton;}
public UIButton getExitGameButton() {return exitGameButton;}
public UIButton getPlayGameButton() {return playGameButton;}
public UIButton getBackButton() {return backButton;}
public UIButton getChangeConnectionButton() {return changeConnectionButton;}
}

View File

@ -0,0 +1,63 @@
package com.jwinslow.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.jwinslow.game.Handler;
import com.jwinslow.game.Main;
import com.jwinslow.game.ui.UIButton;
import com.jwinslow.game.utils.Assets;
import com.jwinslow.game.utils.ButtonEffects;
/**
* Created by jalen on 12/27/2017.
*/
public class PauseState extends State {
private UIButton continueButton, mainMenuButton, exitGameButton;
public PauseState(Handler handler) {
super(handler);
}
@Override
public void init() {
continueButton = new UIButton(handler, new TextureRegion(Assets.button),
Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()*3/4, "Continue",
ButtonEffects.CONTINUE_GAME, 2.5f * (Gdx.graphics.getWidth()/ Main.WIDTH), true);
mainMenuButton = new UIButton(handler, new TextureRegion(Assets.button),
Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2, "Main Menu",
ButtonEffects.MAIN_MENU, 2.5f * (Gdx.graphics.getWidth()/ Main.WIDTH), true);
exitGameButton = new UIButton(handler, new TextureRegion(Assets.button),
Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/4, "Exit\nGame",
ButtonEffects.EXIT_GAME, 2.5f * (Gdx.graphics.getWidth()/Main.WIDTH), true);
handler.getStage().addActor(continueButton);
handler.getStage().addActor(mainMenuButton);
handler.getStage().addActor(exitGameButton);
}
@Override
public void update(float dt) {
continueButton.update(dt);
mainMenuButton.update(dt);
exitGameButton.update(dt);
}
@Override
public void render(SpriteBatch batch) {
handler.message = "Pause.";
batch.setColor(1, 1, 1, 1);
batch.setColor(1, 1, 1, 0.5f);
batch.draw(Assets.background, 0 , 0);
}
@Override
public void dispose() {
handler.message = "";
if (continueButton != null) continueButton.dispose();
if (mainMenuButton != null) mainMenuButton.dispose();
if (exitGameButton != null) exitGameButton.dispose();
}
}

View File

@ -0,0 +1,32 @@
package com.jwinslow.game.states;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.jwinslow.game.Handler;
public abstract class State {
//--- Propreties
protected static State currentState;
protected Handler handler;
//--- Constructor
public State(Handler handler) {
this.handler = handler;
}
//--- Methods
public abstract void init();
public abstract void update(float dt);
public abstract void render(SpriteBatch batch);
public abstract void dispose();
//--- Getters and Setters
public static State getCurrentState() {return State.currentState;}
public static void setCurrentState(State state) {State.currentState = state;}
}

View File

@ -0,0 +1,35 @@
package com.jwinslow.game.ui;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Rectangle;
import com.jwinslow.game.Handler;
import com.jwinslow.game.utils.ButtonEffects;
import com.jwinslow.game.utils.Controls;
/**
* Created by jalen on 12/27/2017.
*/
public class PauseButton extends UIObject{
public PauseButton(Handler handler, TextureRegion image) {
super(handler, image, Gdx.graphics.getWidth()-Gdx.graphics.getWidth()/8, Gdx.graphics.getHeight()-Gdx.graphics.getWidth()/8);
bounds = new Rectangle(x, y, Gdx.graphics.getWidth()/8, Gdx.graphics.getWidth()/8);
}
@Override
public void update(float dt) {
if (bounds.contains(Controls.jx, Controls.jy)) {
ButtonEffects.update(ButtonEffects.PAUSE_GAME);
}
}
@Override
public void draw(Batch batch, float parentAlpha) {
batch.draw(image, bounds.x, bounds.y , bounds.width, bounds.height);
}
}

View File

@ -0,0 +1,64 @@
package com.jwinslow.game.ui;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.jwinslow.game.Handler;
import com.jwinslow.game.Main;
import com.jwinslow.game.gameobjects.Player;
import com.jwinslow.game.utils.Controls;
public class PointerAnchor extends Actor {
//--- Propreties
private Handler handler;
private TextureRegion image;
private float x, y;
private Rectangle bounds;
//private Player player;
//--- Constructor
public PointerAnchor(Handler handler, TextureRegion image, float x, float y, Player player) {
this.image = image;
this.handler = handler;
this.x = x;
this.y = y;
bounds = new Rectangle(x, y, Gdx.graphics.getWidth()/10, Gdx.graphics.getWidth()/10);
//this.player = player;
setVisible(false);
}
//--- Methods
public void update(float dt) {
if (Controls.sx != 0 && Controls.sy != 0) {
x = Controls.sx;
y = Controls.sy;
bounds.x = x;
bounds.y = y;
setVisible(true);
} else {
x = -1;
y = -1;
bounds.x = x;
bounds.y = y;
setVisible(false);
}
}
@Override
public void draw(Batch batch, float parentAlpha) {
//System.out.println("drawing anchor");
Color color = getColor();
batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
batch.draw(image, bounds.x - bounds.width/2, bounds.y - bounds.height/2, bounds.width, bounds.height);
}
//--- Getters and Setters
}

View File

@ -0,0 +1,96 @@
package com.jwinslow.game.ui;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.utils.Align;
import com.jwinslow.game.Handler;
import com.jwinslow.game.utils.Assets;
import com.jwinslow.game.utils.ButtonEffects;
import com.jwinslow.game.utils.Controls;
import com.jwinslow.game.utils.Fonts;
public class UIButton extends UIObject {
//--- Propreties
private static float timer = 0;
private String message;
private ButtonEffects buttonEffect;
private TextureRegion[] images;
private BitmapFont font;
private float alpha;
private boolean canBePressed;
//--- Constructor
public UIButton(Handler handler, TextureRegion image, float x, float y, String message, ButtonEffects buttonEffect, float fontScale, boolean visible) {
this(handler, image, x, y, message, buttonEffect, 1, fontScale, visible, true);
}
public UIButton(Handler handler, TextureRegion image, float x, float y, String message, ButtonEffects buttonEffect, float buttonScale, float fontScale, boolean visible, boolean canBePressed) {
super(handler, image, x, y);
this.bounds = new Rectangle(x, y, (Gdx.graphics.getWidth()*5/8)*buttonScale, (Gdx.graphics.getHeight()*5/32)*buttonScale);
this.bounds.x = this.x-this.bounds.width/2;
this.bounds.y = y - bounds.height/2;
this.message = message;
this.buttonEffect = buttonEffect;
createImages();
super.setVisible(visible);
this.font = new BitmapFont(Gdx.files.internal(Assets.pixelFontFile1));//Fonts.buttonFont;
font.getData().scale(fontScale);
font.setColor(Color.BLACK);
font.getData().down = -32 * (fontScale/2.5f);
alpha = 1;
this.canBePressed = canBePressed;
}
//--- Methods
@Override
public void update(float dt) {
if (timer > 0) timer -= dt;
if (timer <= 0 && canBePressed && isVisible() && bounds.contains(Controls.jx, Controls.jy)) {
ButtonEffects.update(buttonEffect);
timer = 1;
}
if (canBePressed) {
alpha = 1;
} else alpha = 0.5f;
}
@Override
public void draw(Batch batch, float parentAlpha) {
batch.setColor(1, 1, 1, alpha);
batch.draw(images[0], bounds.x, bounds.y, bounds.width, bounds.height);
font.draw(batch, message, x, y+bounds.height/2, 0, Align.center, true);
batch.setColor(1, 1, 1, 1);
}
private void createImages() {
TextureRegion[][] t = image.split(image.getRegionWidth(), image.getRegionHeight()/3);
images = new TextureRegion[t.length * t[0].length];
for (int j = 0; j < t.length; j++) {
for (int i = 0; i < t[j].length; i++) {
images[j] = t[j][i];
}
}
}
public void dispose() {
font.dispose();
remove();
}
//--- Getters and Setters
public String getMessage() {return message;}
public ButtonEffects getButtonEffect() {return buttonEffect;}
public boolean isCanBePressed() {return canBePressed;}
public void setMessage(String message) {this.message = message;}
public void setButtonEffect(ButtonEffects buttonEffect) {this.buttonEffect = buttonEffect;}
public void setCanBePressed(boolean pressed) {this.canBePressed = pressed;}
}

View File

@ -0,0 +1,47 @@
package com.jwinslow.game.ui;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.jwinslow.game.Handler;
/**
* Created by jalen on 1/6/2018.
*/
public class UIDebug extends UIObject {
private BitmapFont font;
public String msg;
public UIDebug(Handler handler) {
super(handler, null, 0, Gdx.graphics.getHeight());
font = new BitmapFont(Gdx.files.internal("customPixelFont1.fnt"));
font.setColor(Color.RED);
font.getData().scale(2);
msg = "";
setVisible(true);
}
@Override
public void update(float dt) {
if (getZIndex() < handler.getStage().getActors().size) {
setZIndex(getZIndex()+1);
}
}
@Override
public void draw(Batch batch , float parentAlpha) {
font.draw(batch, msg, x, y);
}
public void dispose() {
font.dispose();
remove();
}
//Getters and Setters
}

View File

@ -0,0 +1,49 @@
package com.jwinslow.game.ui;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.jwinslow.game.Handler;
public abstract class UIObject extends Actor {
//--- Propreties
protected Handler handler;
protected TextureRegion image;
protected float x, y;
protected Rectangle bounds;
//--- Constructor
public UIObject(Handler handler, TextureRegion image, float x, float y) {
this.handler = handler;
this.image = image;
this.x = x;
this.y = y;
}
//--- Methods
public abstract void update(float dt);
@Override
public abstract void draw(Batch batch, float parentAlpha);
public boolean insideBounds(float x, float y) {
return bounds.contains(x, y);
}
//--- Getters and Setters
public TextureRegion getImage() {return image;}
@Override public float getX() {return x;}
@Override public float getY() {return y;}
public Rectangle getRectangle() {return bounds;}
public void setImage(TextureRegion image) {this.image = image;}
@Override public void setX(float x) {this.x = x;}
@Override public void setY(float y) {this.y = y;}
public void setRectangle(Rectangle bounds) {this.bounds = bounds;}
}

View File

@ -0,0 +1,121 @@
package com.jwinslow.game.ui;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.utils.Align;
import com.jwinslow.game.Handler;
import com.jwinslow.game.utils.Assets;
import com.jwinslow.game.utils.Controls;
/**
* Created by jalen on 1/12/2018.
*/
public class UITextArea extends UIObject{
public static final int MAX_CHAR_LIMIT = 256, MIN_CHAR_LIMIT = 0;
private String message;
private boolean editable;
private BitmapFont font;
private float fontX, fontY;
private int maxCharLimit, minCharLimit;
private int alignment;
private String title, defaultMessage, hint;
//Constructors
public UITextArea(Handler handler, TextureRegion image, float x, float y, float widthScale, float heightScale, float fontScale, boolean editable) {
this(handler, image, x, y, widthScale, heightScale, fontScale, MIN_CHAR_LIMIT, MAX_CHAR_LIMIT, Align.center, "", editable);
}
public UITextArea(Handler handler, TextureRegion image, float x, float y, float widthScale, float heightScale,
float fontScale, String message, boolean editable) {
this(handler, image, x, y, widthScale, heightScale, fontScale, MIN_CHAR_LIMIT, MAX_CHAR_LIMIT, Align.center, message, editable);
}
public UITextArea(Handler handler, TextureRegion image, float x, float y, float widthScale, float heightScale,
float fontScale, int minCharLimit, int maxCharLimit, String message, boolean editable) {
this(handler, image, x, y, widthScale, heightScale, fontScale, minCharLimit, maxCharLimit, Align.center, message, editable);
}
public UITextArea(Handler handler, TextureRegion image, float x, float y, float widthScale, float heightScale,
float fontScale, int minCharLimit, int maxCharLimit, int alignment, String message, boolean editable) {
super(handler, image, x, y);
bounds = new Rectangle(x, y, (Gdx.graphics.getWidth()/2)*widthScale, (Gdx.graphics.getHeight()/2)*heightScale);
this.bounds.x = x - bounds.width/2;
this.bounds.y = y - bounds.height/2;
this.message = message;
this.editable = editable;
setVisible(true);
font = new BitmapFont(Gdx.files.internal(Assets.pixelFontFile1));
font.getData().scale(fontScale);
font.setColor(Color.BLACK);
font.getData().down = -32 * (fontScale/2.5f);
this.fontX = this.x;
this.fontY = this.y+this.bounds.height/2;
this.minCharLimit = minCharLimit;
this.maxCharLimit = maxCharLimit;
this.alignment = alignment;
this.title = "";
this.defaultMessage = "";
this.hint = "";
}
@Override
public void update(float dt) {
if (editable && !message.equalsIgnoreCase("") && !messageWithinLimits()) {
message = "Invalid";
}
if (editable && bounds.contains(Controls.jx, Controls.jy)) {
handler.getTil().setCurrentArea(this);
Gdx.input.getTextInput(handler.getTil(), title, defaultMessage, hint);
}
}
@Override
public void draw(Batch batch, float parentAlpha) {
batch.draw(image, bounds.x, bounds.y, bounds.width, bounds.height);
font.draw(batch, message, fontX, fontY, 0, alignment, true);
}
public boolean messageWithinLimits() {
char[] msg = message.toCharArray();
return (msg.length >= minCharLimit && msg.length <= maxCharLimit);
}
public void dispose() {
font.dispose();
remove();
}
//Getters and Setters
public String getMessage() {return message;}
public boolean isEditable() {return editable;}
public float getFontX() {return fontX;}
public float getFontY() {return fontY;}
public int getMinCharLimit() {return minCharLimit;}
public int getMaxCharLimit() {return maxCharLimit;}
public int getAlignment() {return alignment;}
public String getTitle() {return title;}
public String getDefaultMessage() {return defaultMessage;}
public String getHint() {return hint;}
public void setMessage(String message) {this.message = message;}
public void setEditable(boolean editable) {this.editable = editable;}
public void setFontX(float x) {this.fontX = x;}
public void setFontY(float y) {this.fontY = y;}
public void setMinCharLimit(int limit) {this.minCharLimit = limit;}
public void setMaxCharLimit(int limit) {this.maxCharLimit = limit;}
public void setAlignment(int align) {this.alignment = align;}
public void setTitle(String title) {this.title = title;}
public void setDefaultMessage(String message) {this.defaultMessage = message;}
public void setHint(String hint) {this.hint = hint;}
}

View File

@ -0,0 +1,48 @@
package com.jwinslow.game.utils;
import com.badlogic.gdx.graphics.Texture;
public class Assets {
//--- Propreties
public static Texture player1;
public static Texture player2;
public static Texture touchAnchor;
public static Texture background;
public static Texture button;
public static String pixelFontFile1;
public static Texture pauseButton;
public static Texture textArea;
//--- Constructor
public Assets() {
}
//--- Methods
public static void loadAllTextures() {
player1 = new Texture("b&w_DodgeGame_man1.png");
player2 = new Texture("b&w_DodgeGame_woman1.png");
touchAnchor = new Texture("touch_start.png");
background = new Texture("b&w_DodgeGame_background2.png");
button = new Texture("b&w_DodgeGame_buttons1.png");
pixelFontFile1 = "customPixelFont1.fnt";
pauseButton = new Texture("pauseButton.png");
textArea = new Texture("b&w_textArea.png");
}
public static void disposeAllTextures() {
player1.dispose();
player2.dispose();
touchAnchor.dispose();
background.dispose();
button.dispose();
pauseButton.dispose();
textArea.dispose();
}
//--- Getters and Setters
}

View File

@ -0,0 +1,128 @@
package com.jwinslow.game.utils;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.scenes.scene2d.ui.Button;
import com.jwinslow.game.Handler;
import com.jwinslow.game.net.Connection;
import com.jwinslow.game.states.State;
public enum ButtonEffects {
//--- Propreties
START,
PLAY_GAME,
START_GAME,
NETWORK_SWITCH,
EXIT_GAME,
BACK,
PAUSE_GAME,
CONTINUE_GAME,
MAIN_MENU,
CONNECT;
private static Handler handler;
//--- Constructor
//--- Methods
public static void init(Handler handler) {
ButtonEffects.handler = handler;
}
public static void update(ButtonEffects buttonEffect) {
switch (buttonEffect) {
case START:
handler.getMenuState().getStartGameButton().setVisible(false);
handler.getMenuState().getExitGameButton().setVisible(false);
handler.getMenuState().getBackButton().setVisible(true);
handler.getMenuState().getChangeConnectionButton().setVisible(true);
handler.getMenuState().getPlayGameButton().setVisible(true);
break;
case PLAY_GAME:
if (Connection.udpServer != null) Connection.msgState = Connection.MStates.PLAY;
State.setCurrentState(handler.getGameState());
handler.getConnectState().dispose();
State.getCurrentState().init();
break;
case START_GAME:
String m2 = handler.getMenuState().getChangeConnectionButton().getMessage();
int type = -1;
State.setCurrentState(handler.getConnectState());
if (m2.equalsIgnoreCase("Create\nUDP Server")) {type = 0;}
else if (m2.equalsIgnoreCase("Create\nUDP Client")) {type = 1;}
else if (m2.equalsIgnoreCase("Create\nTCP Server")) {type = 2;}
else if (m2.equalsIgnoreCase("Create\nTCP Client")) {type = 3;}
else {
//State.setCurrentState(handler.getGameState());
}
handler.getConnectState().setConnectionType(type);
handler.getMenuState().dispose();
State.getCurrentState().init();
break;
case NETWORK_SWITCH:
String s = handler.getMenuState().getChangeConnectionButton().getMessage();
if (s.equalsIgnoreCase("Create\nUDP Server"))
s = "Create\nUDP Client";
else if (s.equalsIgnoreCase("Create\nUDP Client")) {
s = "Create\nTCP Server";
} else if (s.equalsIgnoreCase("Create\nTCP Server"))
s = "Create\nTCP Client";
else if (s.equalsIgnoreCase("Create\nTCP Client"))
s = "Don't\nConnect";
else if (s.equalsIgnoreCase("Don't\nConnect"))
s = "Create\nUDP Server";
handler.getMenuState().getChangeConnectionButton().setMessage(s);
break;
case EXIT_GAME:
Gdx.app.exit();
break;
case BACK:
handler.getMenuState().getStartGameButton().setVisible(true);
handler.getMenuState().getExitGameButton().setVisible(true);
handler.getMenuState().getBackButton().setVisible(false);
handler.getMenuState().getChangeConnectionButton().setVisible(false);
handler.getMenuState().getPlayGameButton().setVisible(false);
break;
case PAUSE_GAME:
handler.getGameState().getPointer().setVisible(false);
handler.getGameState().getPauseButton().setVisible((false));
State.setCurrentState(handler.getPauseState());
State.getCurrentState().init();
break;
case CONTINUE_GAME:
handler.message = "";
State.getCurrentState().dispose();
handler.getGameState().getPointer().setVisible(true);
handler.getGameState().getPauseButton().setVisible(true);
State.setCurrentState(handler.getGameState());
break;
case MAIN_MENU:
State.getCurrentState().dispose();
handler.getGameObjectHandler().dispose();
handler.getPlayers().clear();
handler.getCamHandler().setObjOfFocus(null);
handler.getCamHandler().reset();
State.setCurrentState(handler.getMenuState());
State.getCurrentState().init();
break;
case CONNECT:
Connection.create(handler.getConnectState().getConnectionType());
try {
Thread.sleep(500);
} catch (InterruptedException ex) {ex.printStackTrace();}
Connection.msgState = Connection.MStates.CREATE_PLAYER_FROM_CLIENT;
handler.getConnectState().getPlayButton().setVisible(false);
break;
default:
break;
}
}
//--- Getters and Setters
public static void setHandler(Handler handler) {ButtonEffects.handler = handler;}
}

View File

@ -0,0 +1,130 @@
package com.jwinslow.game.utils;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.math.Rectangle;
import com.jwinslow.game.Handler;
import com.jwinslow.game.gameobjects.GameObject;
public class CameraHandler {
//--- Propreties
public static final float CAM_SPEED = 1;
private float vecX, vecY;
private Handler handler;
private Rectangle bounds;
private OrthographicCamera cam;
private GameObject objOfFocus;
//--- Constructor
public CameraHandler(Handler handler, OrthographicCamera cam) {
this.handler = handler;
this.cam = cam;
bounds = new Rectangle(cam.position.x-cam.viewportWidth/2, cam.position.y-cam.viewportHeight/2,
cam.viewportWidth, cam.viewportHeight);
objOfFocus = null;
}
public CameraHandler(Handler handler, OrthographicCamera cam, GameObject objOfFocus) {
this.handler = handler;
this.cam = cam;
bounds = new Rectangle(cam.position.x-cam.viewportWidth/2, cam.position.y-cam.viewportHeight/2,
cam.viewportWidth, cam.viewportHeight);
this.objOfFocus = objOfFocus;
}
//--- Methods
public void update(float dt) { //Actually updating the camera takes place in the Main class.
updateFocus();
bounds.x = cam.position.x-cam.viewportWidth/2;
bounds.y = cam.position.y-cam.viewportHeight/2;
outOfAreaCollision();
if (Gdx.input.isKeyJustPressed(Keys.NUM_1)) printData();
}
public void resetBounds() {
bounds.x = cam.position.x-cam.viewportWidth/2;
bounds.y = cam.position.y-cam.viewportHeight/2;
bounds.width = cam.viewportWidth;
bounds.height = cam.viewportHeight;
}
public void resetBoundsPos() {
bounds.x = cam.position.x-cam.viewportWidth/2;
bounds.y = cam.position.y-cam.viewportHeight/2;
}
public void reset() {
cam.zoom = 1;
if (objOfFocus != null) {
cam.position.x = objOfFocus.getX();
cam.position.y = objOfFocus.getY();
} else {
cam.position.x = Assets.background.getWidth()/2;
cam.position.y = Assets.background.getHeight()/2;
}
}
private void updateFocus() {
if (objOfFocus != null) {
cam.position.x = objOfFocus.getX()+objOfFocus.getBounds().width/2;
cam.position.y = objOfFocus.getY()+objOfFocus.getBounds().height/2;
if (Gdx.input.isKeyJustPressed(Keys.ENTER)) objOfFocus = null;
} else handleCam();
}
private void handleCam() {
if (Gdx.input.isKeyPressed(Keys.I)) {vecY = CAM_SPEED;}
if (Gdx.input.isKeyPressed(Keys.K)) {vecY = -CAM_SPEED;}
if (Gdx.input.isKeyPressed(Keys.J)) {vecX = -CAM_SPEED;}
if (Gdx.input.isKeyPressed(Keys.L)) {vecX = CAM_SPEED;}
cam.translate(vecX, vecY);
if (Gdx.input.isKeyPressed(Keys.U)) {cam.zoom -= 0.01; resetBounds();}
if (Gdx.input.isKeyPressed(Keys.O)) {cam.zoom += 0.01; resetBounds();}
if (Gdx.input.isKeyPressed(Keys.ENTER)) {
reset();
}
}
public void outOfAreaCollision() {
if (bounds.x + bounds.width + CAM_SPEED > Assets.background.getWidth()) {
cam.position.x = Assets.background.getWidth()-cam.viewportWidth/2;
bounds.x = cam.position.x-cam.viewportWidth/2;
}
if (bounds.x - CAM_SPEED < 0) {
//System.out.println("Hello");
cam.position.x = cam.viewportWidth/2;
bounds.x = cam.position.x-cam.viewportWidth/2;
}
if (bounds.y + bounds.height + CAM_SPEED > Assets.background.getHeight()) {
cam.position.y = Assets.background.getHeight()-cam.viewportHeight/2;
bounds.y = cam.position.y-cam.viewportHeight/2;
}
if (bounds.y - CAM_SPEED < 0) {
cam.position.y = cam.viewportHeight/2;
bounds.y = cam.position.y-cam.viewportHeight/2;
}
}
public void printData() {
String message = "Camera:\n\tX: " + cam.position.x + " Y: " + cam.position.y +
"\n\tWidth: " + cam.viewportWidth + " Height: " + cam.viewportHeight;
System.out.println(message);
}
//--- Getters and Setters
public Rectangle getBounds() {return bounds;}
public OrthographicCamera getCam() {return cam;}
public GameObject getObjOfFocus() {return objOfFocus;}
public void setBounds(Rectangle bounds) {this.bounds = bounds;}
public void setCam(OrthographicCamera cam) {this.cam = cam;}
public void setObjOfFocus(GameObject obj) {this.objOfFocus = obj;}
}

View File

@ -0,0 +1,88 @@
package com.jwinslow.game.utils;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.Input.Keys;
import com.jwinslow.game.Main;
public class Controls {
//--- Propreties
public static final int KEYBOARD = 0, TOUCH = 1;
private static int controlType;
public static boolean up, down, left, right;
private static int key_up, key_down, key_left, key_right;
public static float sx, sy, ex, ey;
public static float jx, jy;
private static boolean touched;
//--- Constructor
//--- Methods
public static void initControls() {
key_up = Keys.W;
key_down = Keys.S;
key_left = Keys.A;
key_right = Keys.D;
}
public static void update() {
switch (controlType) {
case KEYBOARD:
updateKeyboard();
updateTouch();
break;
case TOUCH:
updateTouch();
break;
default:
controlType = KEYBOARD;
break;
}
}
private static void updateKeyboard() {
up = Gdx.input.isKeyPressed(key_up);
down = Gdx.input.isKeyPressed(key_down);
left = Gdx.input.isKeyPressed(key_left);
right = Gdx.input.isKeyPressed(key_right);
}
private static void updateTouch() {
if (Gdx.input.isTouched()) {
if (!touched) {
sx = Gdx.input.getX();
sy = Gdx.graphics.getHeight()-Gdx.input.getY();
ex = sx;
ey = sy;
touched = true;
} else {
ex = Gdx.input.getX();
ey = Gdx.graphics.getHeight()-Gdx.input.getY();
}
} else {
sx = 0; sy = 0;
ex = 0; ey = 0;
touched = false;
}
if (Gdx.input.justTouched()) {
jx = Gdx.input.getX();
jy = Gdx.graphics.getHeight()-Gdx.input.getY();
} else {
jx = -1;
jy = -1;
}
}
//--- Getters and Setters
public static int getControllerType() {return controlType;}
public static void setControllerType(int controlType) {Controls.controlType = controlType;}
public static void setKey_up(int key) {Controls.key_up = key;}
public static void setKey_down(int key) {Controls.key_down = key;}
public static void setKey_left(int key) {Controls.key_left = key;}
public static void setKey_right(int key) {Controls.key_right = key;}
}

View File

@ -0,0 +1,54 @@
package com.jwinslow.game.utils;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.jwinslow.game.Handler;
public class Fonts {
//--- Propreties
private static Handler handler;
private static String message;
public static final BitmapFont
font1 = new BitmapFont(Gdx.files.internal("customFont4.fnt")),
pixelFont1 = new BitmapFont(Gdx.files.internal("customPixelFont1.fnt")),
buttonFont = new BitmapFont(Gdx.files.internal("customPixelFont1.fnt"));
//--- Constructor
public Fonts(Handler handler) {
Fonts.handler = handler;
}
//--- Methods
public static void init(Handler handler) {
Fonts.handler = handler;
message = "";
//font1 = new BitmapFont(Gdx.files.internal("customFont4.fnt"));
font1.setColor(Color.RED);
pixelFont1.setColor(Color.RED);
pixelFont1.getData().scale(1);
}
public static void write(Batch batch, BitmapFont font, String message, float x, float y) {
font.draw(batch, message, x, y);
}
public static void write(Batch batch, BitmapFont font, float x, float y) {
font.draw(batch, message, x, y);
}
public static void dispose() {
font1.dispose();
pixelFont1.dispose();
}
//--- Getters and Setters
}

View File

@ -0,0 +1,38 @@
package com.jwinslow.game.utils;
import com.badlogic.gdx.Input;
import com.jwinslow.game.Handler;
import com.jwinslow.game.ui.UITextArea;
/**
* Created by jalen on 1/12/2018.
*/
public class TextInputListener implements Input.TextInputListener {
private Handler handler;
private String input;
private UITextArea currentArea;
public TextInputListener(Handler handler) {
this.handler = handler;
this.input = "";
}
@Override
public void input(String text) {
currentArea.setMessage(text);
currentArea = null;
}
@Override
public void canceled() {
input = "";
}
public String getInput() {return input;}
public UITextArea getCurrentArea() {return currentArea;}
public void setCurrentArea(UITextArea ta) {this.currentArea = ta;}
}

55
desktop/build.gradle Normal file
View File

@ -0,0 +1,55 @@
apply plugin: "java"
sourceCompatibility = 1.6
sourceSets.main.java.srcDirs = [ "src/" ]
project.ext.mainClassName = "com.jwinslow.game.desktop.DesktopLauncher"
project.ext.assetsDir = new File("../android/assets");
task run(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
}
task debug(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
workingDir = project.assetsDir
ignoreExitValue = true
debug = true
}
task dist(type: Jar) {
from files(sourceSets.main.output.classesDir)
from files(sourceSets.main.output.resourcesDir)
from {configurations.compile.collect {zipTree(it)}}
from files(project.assetsDir);
manifest {
attributes 'Main-Class': project.mainClassName
}
}
dist.dependsOn classes
eclipse {
project {
name = appName + "-desktop"
linkedResource name: 'assets', type: '2', location: 'PARENT-1-PROJECT_LOC/android/assets'
}
}
task afterEclipseImport(description: "Post processing after project generation", group: "IDE") {
doLast {
def classpath = new XmlParser().parse(file(".classpath"))
new Node(classpath, "classpathentry", [ kind: 'src', path: 'assets' ]);
def writer = new FileWriter(file(".classpath"))
def printer = new XmlNodePrinter(new PrintWriter(writer))
printer.setPreserveWhitespace(true)
printer.print(classpath)
}
}

View File

@ -0,0 +1,15 @@
package com.jwinslow.game.desktop;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.jwinslow.game.Main;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.width = Main.WIDTH;
config.height = Main.HEIGHT;
config.resizable = false;
new LwjglApplication(new Main(), config);
}
}

3
gradle.properties Normal file
View File

@ -0,0 +1,3 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xms128m -Xmx1500m
org.gradle.configureondemand=true

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,6 @@
#Sat Dec 23 23:16:02 MST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip

172
gradlew vendored Normal file
View File

@ -0,0 +1,172 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save ( ) {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

84
gradlew.bat vendored Normal file
View File

@ -0,0 +1,84 @@
@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 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=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

1
settings.gradle Normal file
View File

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