commit 11e955cc5672167085f180e279df989f919b0004 Author: Jalen Winslow Date: Mon Nov 6 10:09:43 2017 -0700 Added project diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..bdb0cab --- /dev/null +++ b/.gitattributes @@ -0,0 +1,17 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5814594 --- /dev/null +++ b/.gitignore @@ -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 diff --git a/.nb-gradle/private/cache/DodgeGame-d41d8cd98f00b204e9800998ecf8427e b/.nb-gradle/private/cache/DodgeGame-d41d8cd98f00b204e9800998ecf8427e new file mode 100644 index 0000000..b891a8f Binary files /dev/null and b/.nb-gradle/private/cache/DodgeGame-d41d8cd98f00b204e9800998ecf8427e differ diff --git a/.nb-gradle/private/cache/core-fb83b73eb3c879b18d343675f32aca61 b/.nb-gradle/private/cache/core-fb83b73eb3c879b18d343675f32aca61 new file mode 100644 index 0000000..0037c2f Binary files /dev/null and b/.nb-gradle/private/cache/core-fb83b73eb3c879b18d343675f32aca61 differ diff --git a/.nb-gradle/private/cache/desktop-9bccb601584b92d9c041663102aef73f b/.nb-gradle/private/cache/desktop-9bccb601584b92d9c041663102aef73f new file mode 100644 index 0000000..daa1ccc Binary files /dev/null and b/.nb-gradle/private/cache/desktop-9bccb601584b92d9c041663102aef73f differ diff --git a/.nb-gradle/profiles/private/aux-config b/.nb-gradle/profiles/private/aux-config new file mode 100644 index 0000000..c0eb7a9 --- /dev/null +++ b/.nb-gradle/profiles/private/aux-config @@ -0,0 +1,16 @@ + + + + + + + + + + + + file:/C:/Users/jalen/Programming/Netbeans%20Workspace/Summer%202017/DodgeGame/desktop/src/com/jalenwinslow/game/desktop/DesktopLauncher.java + + + + diff --git a/HELP.txt b/HELP.txt new file mode 100644 index 0000000..c34c613 --- /dev/null +++ b/HELP.txt @@ -0,0 +1,15 @@ +Dodge Game + +A 2d black-and-white pixel art game, in which you dodge arrows, while collecting wood to build small +wood walls to help you survive longer. + +Controls +-------- +W, A, S, D = Up, Left, Down, Right +E -> Hold down to destroy wood or build walls. (In menu, you use it to select choices.) +Space -> When you have 7 pieces of wood you can create a wall. +-------- + +There are executables in "/desktop/build/libs/". Latest build DodgeGame_1.2.jar. + +Created using libgdx. \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..9291d47 --- /dev/null +++ b/build.gradle @@ -0,0 +1,61 @@ +buildscript { + repositories { + mavenLocal() + mavenCentral() + maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } + jcenter() + } + dependencies { + } +} + +allprojects { + apply plugin: "eclipse" + apply plugin: "idea" + + version = '1.0' + ext { + appName = "DodgeGame" + 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" + compile "com.badlogicgames.gdx:gdx-controllers-desktop:$gdxVersion" + compile "com.badlogicgames.gdx:gdx-controllers-platform:$gdxVersion:natives-desktop" + } +} + +project(":core") { + apply plugin: "java" + + + dependencies { + compile "com.badlogicgames.gdx:gdx:$gdxVersion" + compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion" + compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion" + } +} + +tasks.eclipse.doLast { + delete ".project" +} \ No newline at end of file diff --git a/core/assets/DodgeGame_boundsMask.png b/core/assets/DodgeGame_boundsMask.png new file mode 100644 index 0000000..d856d1f Binary files /dev/null and b/core/assets/DodgeGame_boundsMask.png differ diff --git a/core/assets/b&w_DodgeGame_GameOver.png b/core/assets/b&w_DodgeGame_GameOver.png new file mode 100644 index 0000000..092a746 Binary files /dev/null and b/core/assets/b&w_DodgeGame_GameOver.png differ diff --git a/core/assets/b&w_DodgeGame_arrow.png b/core/assets/b&w_DodgeGame_arrow.png new file mode 100644 index 0000000..d6a428a Binary files /dev/null and b/core/assets/b&w_DodgeGame_arrow.png differ diff --git a/core/assets/b&w_DodgeGame_background1.png b/core/assets/b&w_DodgeGame_background1.png new file mode 100644 index 0000000..70878cd Binary files /dev/null and b/core/assets/b&w_DodgeGame_background1.png differ diff --git a/core/assets/b&w_DodgeGame_background2.png b/core/assets/b&w_DodgeGame_background2.png new file mode 100644 index 0000000..0ec8174 Binary files /dev/null and b/core/assets/b&w_DodgeGame_background2.png differ diff --git a/core/assets/b&w_DodgeGame_block.png b/core/assets/b&w_DodgeGame_block.png new file mode 100644 index 0000000..4c6d7d2 Binary files /dev/null and b/core/assets/b&w_DodgeGame_block.png differ diff --git a/core/assets/b&w_DodgeGame_buttons1.png b/core/assets/b&w_DodgeGame_buttons1.png new file mode 100644 index 0000000..a84add5 Binary files /dev/null and b/core/assets/b&w_DodgeGame_buttons1.png differ diff --git a/core/assets/b&w_DodgeGame_font1.fnt b/core/assets/b&w_DodgeGame_font1.fnt new file mode 100644 index 0000000..fab0fac Binary files /dev/null and b/core/assets/b&w_DodgeGame_font1.fnt differ diff --git a/core/assets/b&w_DodgeGame_font1.png b/core/assets/b&w_DodgeGame_font1.png new file mode 100644 index 0000000..fab0fac Binary files /dev/null and b/core/assets/b&w_DodgeGame_font1.png differ diff --git a/core/assets/b&w_DodgeGame_gamePaused.png b/core/assets/b&w_DodgeGame_gamePaused.png new file mode 100644 index 0000000..4c8eeed Binary files /dev/null and b/core/assets/b&w_DodgeGame_gamePaused.png differ diff --git a/core/assets/b&w_DodgeGame_health1.png b/core/assets/b&w_DodgeGame_health1.png new file mode 100644 index 0000000..667332f Binary files /dev/null and b/core/assets/b&w_DodgeGame_health1.png differ diff --git a/core/assets/b&w_DodgeGame_man1.png b/core/assets/b&w_DodgeGame_man1.png new file mode 100644 index 0000000..06b334c Binary files /dev/null and b/core/assets/b&w_DodgeGame_man1.png differ diff --git a/core/assets/b&w_DodgeGame_manTest.png b/core/assets/b&w_DodgeGame_manTest.png new file mode 100644 index 0000000..d6db740 Binary files /dev/null and b/core/assets/b&w_DodgeGame_manTest.png differ diff --git a/core/assets/b&w_DodgeGame_originalGameOver.png b/core/assets/b&w_DodgeGame_originalGameOver.png new file mode 100644 index 0000000..89a11bc Binary files /dev/null and b/core/assets/b&w_DodgeGame_originalGameOver.png differ diff --git a/core/assets/b&w_DodgeGame_playButton.png b/core/assets/b&w_DodgeGame_playButton.png new file mode 100644 index 0000000..44c05d8 Binary files /dev/null and b/core/assets/b&w_DodgeGame_playButton.png differ diff --git a/core/assets/b&w_DodgeGame_scoreBoard.png b/core/assets/b&w_DodgeGame_scoreBoard.png new file mode 100644 index 0000000..0db885b Binary files /dev/null and b/core/assets/b&w_DodgeGame_scoreBoard.png differ diff --git a/core/assets/b&w_DodgeGame_tallWall1.png b/core/assets/b&w_DodgeGame_tallWall1.png new file mode 100644 index 0000000..5ffe4e4 Binary files /dev/null and b/core/assets/b&w_DodgeGame_tallWall1.png differ diff --git a/core/assets/b&w_DodgeGame_timerCase.png b/core/assets/b&w_DodgeGame_timerCase.png new file mode 100644 index 0000000..fb47768 Binary files /dev/null and b/core/assets/b&w_DodgeGame_timerCase.png differ diff --git a/core/assets/b&w_DodgeGame_wall1.png b/core/assets/b&w_DodgeGame_wall1.png new file mode 100644 index 0000000..e4dbc44 Binary files /dev/null and b/core/assets/b&w_DodgeGame_wall1.png differ diff --git a/core/assets/b&w_DodgeGame_wood1.png b/core/assets/b&w_DodgeGame_wood1.png new file mode 100644 index 0000000..06f5ceb Binary files /dev/null and b/core/assets/b&w_DodgeGame_wood1.png differ diff --git a/core/assets/badlogic.jpg b/core/assets/badlogic.jpg new file mode 100644 index 0000000..4390da6 Binary files /dev/null and b/core/assets/badlogic.jpg differ diff --git a/core/assets/customFont1.fnt b/core/assets/customFont1.fnt new file mode 100644 index 0000000..186dc75 --- /dev/null +++ b/core/assets/customFont1.fnt @@ -0,0 +1,57 @@ +info face="Arial" size=12 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=0 aa=1 padding=1,1,1,1 spacing=2,2 outline=0 +common lineHeight=12 base=9 scaleW=256 scaleH=256 pages=1 packed=0 alphaChnl=0 redChnl=3 greenChnl=3 blueChnl=3 +page id=0 file="customFont1_0.png" +chars count=37 +char id=48 x=40 y=11 width=6 height=9 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=15 +char id=49 x=48 y=11 width=4 height=9 xoffset=0 yoffset=1 xadvance=5 page=0 chnl=15 +char id=50 x=191 y=0 width=6 height=9 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=15 +char id=51 x=199 y=0 width=6 height=9 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=15 +char id=52 x=83 y=0 width=7 height=9 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=15 +char id=53 x=207 y=0 width=6 height=9 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=15 +char id=54 x=215 y=0 width=6 height=9 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=15 +char id=55 x=223 y=0 width=6 height=9 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=15 +char id=56 x=231 y=0 width=6 height=9 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=15 +char id=57 x=239 y=0 width=6 height=9 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=15 +char id=58 x=60 y=11 width=3 height=7 xoffset=0 yoffset=3 xadvance=3 page=0 chnl=15 +char id=65 x=24 y=0 width=9 height=9 xoffset=-1 yoffset=1 xadvance=6 page=0 chnl=15 +char id=66 x=16 y=11 width=6 height=9 xoffset=1 yoffset=1 xadvance=6 page=0 chnl=15 +char id=67 x=137 y=0 width=7 height=9 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=15 +char id=68 x=146 y=0 width=7 height=9 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=15 +char id=69 x=155 y=0 width=7 height=9 xoffset=0 yoffset=1 xadvance=6 page=0 chnl=15 +char id=70 x=247 y=0 width=6 height=9 xoffset=0 yoffset=1 xadvance=6 page=0 chnl=15 +char id=71 x=164 y=0 width=7 height=9 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=15 +char id=72 x=173 y=0 width=7 height=9 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=15 +char id=73 x=54 y=11 width=6 height=9 xoffset=-1 yoffset=1 xadvance=3 page=0 chnl=15 +char id=74 x=8 y=11 width=6 height=9 xoffset=0 yoffset=1 xadvance=5 page=0 chnl=15 +char id=75 x=182 y=0 width=7 height=9 xoffset=0 yoffset=1 xadvance=6 page=0 chnl=15 +char id=76 x=32 y=11 width=6 height=9 xoffset=0 yoffset=1 xadvance=5 page=0 chnl=15 +char id=77 x=13 y=0 width=9 height=9 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=15 +char id=78 x=55 y=0 width=8 height=9 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=15 +char id=79 x=65 y=0 width=7 height=9 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=15 +char id=80 x=24 y=11 width=6 height=9 xoffset=0 yoffset=1 xadvance=6 page=0 chnl=15 +char id=81 x=74 y=0 width=7 height=9 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=15 +char id=82 x=92 y=0 width=7 height=9 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=15 +char id=83 x=0 y=11 width=6 height=9 xoffset=0 yoffset=1 xadvance=6 page=0 chnl=15 +char id=84 x=101 y=0 width=7 height=9 xoffset=0 yoffset=1 xadvance=5 page=0 chnl=15 +char id=85 x=110 y=0 width=7 height=9 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=15 +char id=86 x=35 y=0 width=9 height=9 xoffset=-1 yoffset=1 xadvance=6 page=0 chnl=15 +char id=87 x=0 y=0 width=11 height=9 xoffset=0 yoffset=1 xadvance=9 page=0 chnl=15 +char id=88 x=119 y=0 width=7 height=9 xoffset=1 yoffset=1 xadvance=5 page=0 chnl=15 +char id=89 x=128 y=0 width=7 height=9 xoffset=2 yoffset=1 xadvance=7 page=0 chnl=15 +char id=90 x=46 y=0 width=8 height=9 xoffset=1 yoffset=1 xadvance=6 page=0 chnl=15 +kernings count=15 +kerning first=89 second=65 amount=-1 +kerning first=89 second=58 amount=-1 +kerning first=86 second=65 amount=-1 +kerning first=84 second=65 amount=-1 +kerning first=84 second=58 amount=-1 +kerning first=80 second=65 amount=-1 +kerning first=76 second=89 amount=-1 +kerning first=76 second=87 amount=-1 +kerning first=76 second=86 amount=-1 +kerning first=76 second=84 amount=-1 +kerning first=49 second=49 amount=-1 +kerning first=70 second=65 amount=-1 +kerning first=65 second=84 amount=-1 +kerning first=65 second=86 amount=-1 +kerning first=65 second=89 amount=-1 diff --git a/core/assets/customFont1_0.png b/core/assets/customFont1_0.png new file mode 100644 index 0000000..09af3b0 Binary files /dev/null and b/core/assets/customFont1_0.png differ diff --git a/core/assets/customFont2.fnt b/core/assets/customFont2.fnt new file mode 100644 index 0000000..fa528c9 --- /dev/null +++ b/core/assets/customFont2.fnt @@ -0,0 +1,57 @@ +info face="Arial" size=12 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=0 aa=1 padding=1,1,1,1 spacing=2,2 outline=0 +common lineHeight=12 base=9 scaleW=256 scaleH=256 pages=1 packed=0 alphaChnl=0 redChnl=4 greenChnl=4 blueChnl=4 +page id=0 file="customFont2_0.png" +chars count=37 +char id=48 x=40 y=11 width=6 height=9 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=15 +char id=49 x=48 y=11 width=4 height=9 xoffset=0 yoffset=1 xadvance=5 page=0 chnl=15 +char id=50 x=191 y=0 width=6 height=9 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=15 +char id=51 x=199 y=0 width=6 height=9 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=15 +char id=52 x=83 y=0 width=7 height=9 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=15 +char id=53 x=207 y=0 width=6 height=9 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=15 +char id=54 x=215 y=0 width=6 height=9 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=15 +char id=55 x=223 y=0 width=6 height=9 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=15 +char id=56 x=231 y=0 width=6 height=9 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=15 +char id=57 x=239 y=0 width=6 height=9 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=15 +char id=58 x=59 y=11 width=3 height=7 xoffset=0 yoffset=3 xadvance=3 page=0 chnl=15 +char id=65 x=24 y=0 width=9 height=9 xoffset=-1 yoffset=1 xadvance=6 page=0 chnl=15 +char id=66 x=16 y=11 width=6 height=9 xoffset=0 yoffset=1 xadvance=6 page=0 chnl=15 +char id=67 x=137 y=0 width=7 height=9 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=15 +char id=68 x=146 y=0 width=7 height=9 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=15 +char id=69 x=155 y=0 width=7 height=9 xoffset=0 yoffset=1 xadvance=6 page=0 chnl=15 +char id=70 x=247 y=0 width=6 height=9 xoffset=0 yoffset=1 xadvance=6 page=0 chnl=15 +char id=71 x=164 y=0 width=7 height=9 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=15 +char id=72 x=173 y=0 width=7 height=9 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=15 +char id=73 x=54 y=11 width=3 height=9 xoffset=0 yoffset=1 xadvance=3 page=0 chnl=15 +char id=74 x=8 y=11 width=6 height=9 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=15 +char id=75 x=182 y=0 width=7 height=9 xoffset=0 yoffset=1 xadvance=6 page=0 chnl=15 +char id=76 x=32 y=11 width=6 height=9 xoffset=0 yoffset=1 xadvance=5 page=0 chnl=15 +char id=77 x=13 y=0 width=9 height=9 xoffset=-1 yoffset=1 xadvance=7 page=0 chnl=15 +char id=78 x=56 y=0 width=7 height=9 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=15 +char id=79 x=65 y=0 width=7 height=9 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=15 +char id=80 x=24 y=11 width=6 height=9 xoffset=0 yoffset=1 xadvance=6 page=0 chnl=15 +char id=81 x=74 y=0 width=7 height=9 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=15 +char id=82 x=92 y=0 width=7 height=9 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=15 +char id=83 x=0 y=11 width=6 height=9 xoffset=0 yoffset=1 xadvance=6 page=0 chnl=15 +char id=84 x=101 y=0 width=7 height=9 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=15 +char id=85 x=110 y=0 width=7 height=9 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=15 +char id=86 x=35 y=0 width=9 height=9 xoffset=-1 yoffset=1 xadvance=6 page=0 chnl=15 +char id=87 x=0 y=0 width=11 height=9 xoffset=-1 yoffset=1 xadvance=9 page=0 chnl=15 +char id=88 x=119 y=0 width=7 height=9 xoffset=-1 yoffset=1 xadvance=5 page=0 chnl=15 +char id=89 x=128 y=0 width=7 height=9 xoffset=0 yoffset=1 xadvance=7 page=0 chnl=15 +char id=90 x=46 y=0 width=8 height=9 xoffset=-1 yoffset=1 xadvance=6 page=0 chnl=15 +kernings count=15 +kerning first=89 second=65 amount=-1 +kerning first=89 second=58 amount=-1 +kerning first=86 second=65 amount=-1 +kerning first=84 second=65 amount=-1 +kerning first=84 second=58 amount=-1 +kerning first=80 second=65 amount=-1 +kerning first=76 second=89 amount=-1 +kerning first=76 second=87 amount=-1 +kerning first=76 second=86 amount=-1 +kerning first=76 second=84 amount=-1 +kerning first=49 second=49 amount=-1 +kerning first=70 second=65 amount=-1 +kerning first=65 second=84 amount=-1 +kerning first=65 second=86 amount=-1 +kerning first=65 second=89 amount=-1 diff --git a/core/assets/customFont2_0.png b/core/assets/customFont2_0.png new file mode 100644 index 0000000..fa0278c Binary files /dev/null and b/core/assets/customFont2_0.png differ diff --git a/core/assets/customFont3.fnt b/core/assets/customFont3.fnt new file mode 100644 index 0000000..9e7cc80 --- /dev/null +++ b/core/assets/customFont3.fnt @@ -0,0 +1,42 @@ +info face="Arial" size=10 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=0 aa=1 padding=1,1,1,1 spacing=2,2 outline=0 +common lineHeight=10 base=8 scaleW=256 scaleH=32 pages=1 packed=0 alphaChnl=0 redChnl=0 greenChnl=0 blueChnl=0 +page id=0 file="customFont3_0.png" +chars count=26 +char id=65 x=11 y=0 width=7 height=12 xoffset=-1 yoffset=-1 xadvance=5 page=0 chnl=15 +char id=66 x=180 y=0 width=7 height=12 xoffset=0 yoffset=-1 xadvance=5 page=0 chnl=15 +char id=67 x=20 y=0 width=7 height=12 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15 +char id=68 x=129 y=0 width=7 height=12 xoffset=0 yoffset=-1 xadvance=6 page=0 chnl=15 +char id=69 x=138 y=0 width=6 height=12 xoffset=0 yoffset=-1 xadvance=5 page=0 chnl=15 +char id=70 x=189 y=0 width=6 height=12 xoffset=0 yoffset=-1 xadvance=5 page=0 chnl=15 +char id=71 x=29 y=0 width=7 height=12 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15 +char id=72 x=146 y=0 width=6 height=12 xoffset=0 yoffset=-1 xadvance=6 page=0 chnl=15 +char id=73 x=221 y=0 width=6 height=12 xoffset=0 yoffset=-1 xadvance=5 page=0 chnl=15 +char id=74 x=197 y=0 width=6 height=12 xoffset=-1 yoffset=-1 xadvance=4 page=0 chnl=15 +char id=75 x=38 y=0 width=7 height=12 xoffset=0 yoffset=-1 xadvance=5 page=0 chnl=15 +char id=76 x=205 y=0 width=6 height=12 xoffset=0 yoffset=-1 xadvance=4 page=0 chnl=15 +char id=77 x=47 y=0 width=8 height=12 xoffset=0 yoffset=-1 xadvance=7 page=0 chnl=15 +char id=78 x=154 y=0 width=7 height=12 xoffset=0 yoffset=-1 xadvance=6 page=0 chnl=15 +char id=79 x=57 y=0 width=7 height=12 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15 +char id=80 x=213 y=0 width=6 height=12 xoffset=0 yoffset=-1 xadvance=5 page=0 chnl=15 +char id=81 x=66 y=0 width=7 height=12 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=15 +char id=82 x=163 y=0 width=6 height=12 xoffset=0 yoffset=-1 xadvance=6 page=0 chnl=15 +char id=83 x=75 y=0 width=7 height=12 xoffset=-1 yoffset=-1 xadvance=5 page=0 chnl=15 +char id=84 x=84 y=0 width=7 height=12 xoffset=0 yoffset=-1 xadvance=6 page=0 chnl=15 +char id=85 x=171 y=0 width=7 height=12 xoffset=0 yoffset=-1 xadvance=6 page=0 chnl=15 +char id=86 x=93 y=0 width=7 height=12 xoffset=-1 yoffset=-1 xadvance=5 page=0 chnl=15 +char id=87 x=0 y=0 width=9 height=12 xoffset=-1 yoffset=-1 xadvance=7 page=0 chnl=15 +char id=88 x=102 y=0 width=7 height=12 xoffset=-1 yoffset=-1 xadvance=5 page=0 chnl=15 +char id=89 x=111 y=0 width=7 height=12 xoffset=-1 yoffset=-1 xadvance=5 page=0 chnl=15 +char id=90 x=120 y=0 width=7 height=12 xoffset=-1 yoffset=-1 xadvance=5 page=0 chnl=15 +kernings count=11 +kerning first=89 second=65 amount=-1 +kerning first=86 second=65 amount=-1 +kerning first=84 second=65 amount=-1 +kerning first=80 second=65 amount=-1 +kerning first=76 second=89 amount=-1 +kerning first=76 second=87 amount=-1 +kerning first=76 second=86 amount=-1 +kerning first=76 second=84 amount=-1 +kerning first=65 second=89 amount=-1 +kerning first=65 second=86 amount=-1 +kerning first=65 second=84 amount=-1 diff --git a/core/assets/customFont3_0.png b/core/assets/customFont3_0.png new file mode 100644 index 0000000..64095aa Binary files /dev/null and b/core/assets/customFont3_0.png differ diff --git a/core/assets/customFont4.fnt b/core/assets/customFont4.fnt new file mode 100644 index 0000000..d91ffc5 --- /dev/null +++ b/core/assets/customFont4.fnt @@ -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 diff --git a/core/assets/customFont4_0.png b/core/assets/customFont4_0.png new file mode 100644 index 0000000..173a232 Binary files /dev/null and b/core/assets/customFont4_0.png differ diff --git a/core/assets/scores.txt b/core/assets/scores.txt new file mode 100644 index 0000000..b20930c --- /dev/null +++ b/core/assets/scores.txt @@ -0,0 +1,11 @@ +19 +209 +314 +11 +8 +3 +6 +2 +2 +0 +4 \ No newline at end of file diff --git a/core/assets/testScores.txt b/core/assets/testScores.txt new file mode 100644 index 0000000..e69de29 diff --git a/core/build.gradle b/core/build.gradle new file mode 100644 index 0000000..03cd1be --- /dev/null +++ b/core/build.gradle @@ -0,0 +1,11 @@ +apply plugin: "java" + +sourceCompatibility = 1.6 +[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' + +sourceSets.main.java.srcDirs = [ "src/" ] + + +eclipse.project { + name = appName + "-core" +} diff --git a/core/src/com/jalenwinslow/game/Handler.java b/core/src/com/jalenwinslow/game/Handler.java new file mode 100644 index 0000000..de625b0 --- /dev/null +++ b/core/src/com/jalenwinslow/game/Handler.java @@ -0,0 +1,112 @@ +package com.jalenwinslow.game; + +import com.badlogic.gdx.files.FileHandle; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.jalenwinslow.game.gameobjects.GameObjectHandler; +import com.jalenwinslow.game.states.*; +import com.jalenwinslow.game.utils.Score; +import java.io.File; +import java.io.IOException; + +public class Handler { + + //--- Propreties + private FileHandle scoreFile; + private Score score; + + private State menuState, gameState, gameOverState, pauseState, exitState; + private GameObjectHandler gameObjectHandler; + + private BitmapFont font; + private String message = ""; + + //--- Constructor + public Handler() { + + } + + + //--- Methods + public void init() { + score = new Score(this); + + menuState = new MenuState(this); + gameState = new GameState(this); + gameOverState = new GameOverState(this); + pauseState = new PauseState(this); + exitState = new ExitState(this); + + gameObjectHandler = new GameObjectHandler(this); + + font = new BitmapFont(); + font.setColor(Color.RED); + + createScoreFile(); + + State.setCurrenState(menuState); + State.getCurrentState().init(); + + } + + public void update(float dt) { + if (State.getCurrentState() != null) { + State.getCurrentState().update(dt); + } + } + + public void render(SpriteBatch batch) { + if (State.getCurrentState() != null) { + State.getCurrentState().render(batch); + } + font.draw(batch, message, 32, 32); + } + + public void dispose() { + gameState.dispose(); + menuState.dispose(); + gameOverState.dispose(); + gameObjectHandler.dispose(); + + font.dispose(); + } + + private void createScoreFile() { + File file = new File("scores.txt"); + try { + file.createNewFile(); + } catch (IOException ex) { + ex.printStackTrace(); + } + scoreFile = new FileHandle(file); + if (scoreFile.readString().equals("")) { + String scoreString = "0\n"+ + "0\n" + + "0\n" + + "0\n" + + "0\n" + + "0\n" + + "0\n" + + "0\n" + + "0\n" + + "0\n" + + "0"; + scoreFile.writeString(scoreString, false); + } + score.getScoresFromFile(); + } + + //--- Getters and Setters + public GameState getGameState() {return (GameState)gameState;} + public MenuState getMenuState() {return (MenuState)menuState;} + public State getGameOverState() {return gameOverState;} + public PauseState getPauseState() {return (PauseState)pauseState;} + public ExitState getExitState() {return (ExitState)exitState;} + public GameObjectHandler getGameObjectHandler() {return gameObjectHandler;} + public FileHandle getScoreFile() {return scoreFile;} + public Score getScore() {return score;} + + public String getMessage() {return message;} + public void setMessage(String message) {this.message = message;} +} diff --git a/core/src/com/jalenwinslow/game/Main.java b/core/src/com/jalenwinslow/game/Main.java new file mode 100644 index 0000000..120f00f --- /dev/null +++ b/core/src/com/jalenwinslow/game/Main.java @@ -0,0 +1,48 @@ +package com.jalenwinslow.game; + +import com.badlogic.gdx.ApplicationAdapter; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.files.FileHandle; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.g2d.TextureRegion; + +public class Main extends ApplicationAdapter { + public static final int WIDTH = 640, HEIGHT = 640; + + SpriteBatch batch; + Handler handler; + //BitmapFont bf; + + @Override + public void create () { + batch = new SpriteBatch(); + handler = new Handler(); + handler.init(); + //bf = new BitmapFont(Gdx.files.internal("b&w_DodgeGame_font1.fnt"), new TextureRegion(new Texture("b&w_DodgeGame_font1.png"))); + } + + @Override + public void render () { + //Update + handler.update(Gdx.graphics.getDeltaTime()); + + + //Render + batch.begin(); + + handler.render(batch); + //bf.draw(batch, "Hello", 32, 32); + //bf.draw(batch, str, WIDTH, WIDTH, WIDTH, HEIGHT, true) + batch.end(); + + + } + + @Override + public void dispose () { + batch.dispose(); + handler.dispose(); + } +} diff --git a/core/src/com/jalenwinslow/game/gameobjects/Arrow.java b/core/src/com/jalenwinslow/game/gameobjects/Arrow.java new file mode 100644 index 0000000..8eefbcc --- /dev/null +++ b/core/src/com/jalenwinslow/game/gameobjects/Arrow.java @@ -0,0 +1,109 @@ +package com.jalenwinslow.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.jalenwinslow.game.Handler; +import com.jalenwinslow.game.Main; +import com.jalenwinslow.game.states.State; + +public class Arrow extends GameObject { + + //--- Propreties + public static final double MAX_SPEED = 4; + public static final double MIN_SPEED = 2.5; //normal -> maxSpeed: 4 && minSpeed: 2.5 + + private int dir; + private double speed; + private double vecX, vecY; + //private static Texture boundsTexture = new Texture("DodgeGame_boundsMask.png"); + + //--- Constructor + public Arrow(Handler handler, double x, double y, TextureRegion image, int dir) { + super(handler, x, y, image); + this.dir = dir; + speed = MIN_SPEED; + vecX = 0; + vecY = 0; + bounds = new Rectangle((int)x, (int)y, Main.WIDTH/40, Main.HEIGHT/40); + } + + + //--- Methods + @Override + public void update(float dt) { + isArrowVisible(); + updateSpeed(); + if (dir == 0) vecX = speed; + if (dir == 1) vecY = speed; + if (dir == 2) vecX = -speed; + if (dir == 3) vecY = -speed; + x += vecX; + y += vecY; + if (y < 96) depth = 0; + else depth = (int)y + Main.HEIGHT/20; + setBoundsPosition(); + checkCollision(); + } + + @Override + public void render(SpriteBatch batch) { + batch.draw(image, (int)x, (int)y, Main.WIDTH/10, Main.HEIGHT/10); + //batch.draw(boundsTexture, bounds.x, bounds.y, bounds.width, bounds.height); + } + + @Override + public void dispose() { + + } + + private void isArrowVisible() { + if (x < -128 || x > Main.WIDTH + Main.WIDTH/5 || + y < -128 || y > Main.HEIGHT + Main.HEIGHT/5) { + //handler.getGameState().getArrowGen().getArrows().removeValue(this, false); + handler.getGameState().getArrowGen().getArrows().removeValue(this, false); + } + } + + private void updateSpeed() { + int modifier = handler.getGameState().getTimer().getTime() / 60; + speed = MIN_SPEED + (0.05 * modifier); + if (speed >= MAX_SPEED) speed = MAX_SPEED; + } + + private void setBoundsPosition() { + switch (dir) { + case 0: bounds.setPosition((float)x + 48, (float)y + 26); break; + case 1: bounds.setPosition((float) x + 26, (float)y + 48); break; + case 2: bounds.setPosition((float)x, (float)y + 26); break; + case 3: bounds.setPosition((float)x + 26, (float)y);break; + } + } + + private void checkCollision() { + if (bounds.overlaps(handler.getGameState().getPlayer().getBounds())) { + handler.getGameState().getTimer().stop(); + State.setCurrenState(handler.getGameOverState()); + State.getCurrentState().init(); + handler.getGameObjectHandler().dispose(); + handler.getGameState().dispose(); + } + for (int i = 0; i < handler.getGameObjectHandler().getGameObjects().size; i++) { + if (handler.getGameObjectHandler().getGameObjects().get(i).toString().equalsIgnoreCase("TallWall")) { + TallWall wall = (TallWall)handler.getGameObjectHandler().getGameObjects().get(i); + if (bounds.overlaps(wall.getNoArrowBounds())) { + wall.setHitPoints(wall.getHitPoints() - 6); + handler.getGameState().getArrowGen().getArrows().removeValue(this, false); + } + } + } + } + + @Override + public String toString() {return "Arrow";} + + //--- Getters and Setters + + +} diff --git a/core/src/com/jalenwinslow/game/gameobjects/ArrowGenerator.java b/core/src/com/jalenwinslow/game/gameobjects/ArrowGenerator.java new file mode 100644 index 0000000..552fcc5 --- /dev/null +++ b/core/src/com/jalenwinslow/game/gameobjects/ArrowGenerator.java @@ -0,0 +1,120 @@ + package com.jalenwinslow.game.gameobjects; + +import com.badlogic.gdx.graphics.Color; +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.utils.Array; +import com.jalenwinslow.game.Handler; +import com.jalenwinslow.game.Main; +import java.util.Random; + +public class ArrowGenerator extends GameObject { + + //--- Propreties + private static final int MAX_ARROW_LIMIT = 40, MIN_ARROW_LIMIT = 5; // max: 40, min: 5 + private static final double ARROW_DEPLOY_END_TIME = 0.07, ARROW_DEPLOY_START_TIME = 0.5; // endTime: 0.07, startTime: 0.5 + + private int currentArrowLimit; + private double currentDeployTime; + private int highestAmountOfArrowsAtOnce; + private int amountOfArrowsCreated; + + private Random rand; + private TextureRegion[][] arrowTextures; + private Array arrows; + private float elapsedTime; + //private BitmapFont font; + + //--- Constructor + public ArrowGenerator(Handler handler, double x, double y, TextureRegion image) { + super(handler, x, y, image); + + currentArrowLimit = MIN_ARROW_LIMIT; + currentDeployTime = ARROW_DEPLOY_START_TIME; + highestAmountOfArrowsAtOnce = 0; + amountOfArrowsCreated = 0; + + rand = new Random(); + arrowTextures = image.split(16, 16); + arrows = new Array(); + elapsedTime = -3; + //font = new BitmapFont(); + //font.setColor(Color.RED); + } + + + //--- Methods + @Override + public void update(float dt) { + elapsedTime += dt; + updateArrows(); + if (arrows.size < currentArrowLimit && elapsedTime >= currentDeployTime) { + addArrow(); + amountOfArrowsCreated++; + if (arrows.size > highestAmountOfArrowsAtOnce) highestAmountOfArrowsAtOnce = arrows.size; + } + for (Arrow arrow : arrows) arrow.update(dt); + } + + @Override + public void render(SpriteBatch batch) { + for (Arrow arrow : arrows) { + arrow.render(batch); + } + //font.draw(batch, "Current amount of arrows: " + String.valueOf(arrows.size), 64, 64); + } + + @Override + public void dispose() { + //font.dispose(); + } + + @Override + public String toString() {return "ArrowGenerator";} + + private void updateArrows() { + int modifier = handler.getGameState().getTimer().getTime() / 30; + currentArrowLimit = MIN_ARROW_LIMIT + (1 * modifier); + if (currentArrowLimit > MAX_ARROW_LIMIT) currentArrowLimit = MAX_ARROW_LIMIT; + if (currentArrowLimit > 10 && handler.getGameState().getTimer().getTime() % 40 == 0) { + currentDeployTime -= 0.1; + if (currentDeployTime < ARROW_DEPLOY_END_TIME) currentDeployTime = ARROW_DEPLOY_END_TIME; + } + } + + private void addArrow() { + int dir = rand.nextInt(4); + TextureRegion texture = arrowTextures[0][dir]; + int xx = Main.WIDTH, yy = Main.HEIGHT; + if (dir == 0 || dir == 2) { + if (dir == 0) { + xx = -96; + } + if (dir == 2) { + xx = Main.WIDTH + 32; + } + yy = rand.nextInt(Main.HEIGHT - 160) + 64; + } + else { + + if (dir == 1) { + yy = -96; + } + if (dir == 3) { + yy = Main.HEIGHT + 32; + } + xx = rand.nextInt(Main.WIDTH - 160) + 64; + } + + //handler.getGameObjectHandler().add(new Arrow(handler, xx, yy, texture, dir)); + arrows.add(new Arrow(handler, xx, yy, texture, dir)); + elapsedTime = 0; + } + + //--- Getters and Setters + public Array getArrows() {return arrows;} + public int getAmountOfArrowsCreated() {return amountOfArrowsCreated;} + public int getHighestAmountOfArrowsAtOnce() {return highestAmountOfArrowsAtOnce;} + +} diff --git a/core/src/com/jalenwinslow/game/gameobjects/Button.java b/core/src/com/jalenwinslow/game/gameobjects/Button.java new file mode 100644 index 0000000..aaaec15 --- /dev/null +++ b/core/src/com/jalenwinslow/game/gameobjects/Button.java @@ -0,0 +1,105 @@ +package com.jalenwinslow.game.gameobjects; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input.Keys; +import com.badlogic.gdx.graphics.Color; +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.jalenwinslow.game.Handler; +import com.jalenwinslow.game.Main; +import com.jalenwinslow.game.states.State; + +public class Button extends GameObject { + + //--- Propreties + private TextureRegion[][] images; + private BitmapFont font; + private String message; + private int imageIndex; + private boolean drawHealth; + private HealthBar health; + private int hitPoints; + + //--- Constructor + public Button(Handler handler, double x, double y, TextureRegion image, String message, int scale) { + super(handler, x, y, image); + bounds = new Rectangle((int)x, (int)y, Main.WIDTH/4+32, Main.HEIGHT/8); + images = image.split(112, 48); + font = new BitmapFont(Gdx.files.internal("customFont4.fnt")); + font.getData().setScale(scale); + font.setColor(Color.BLACK); + this.message = message; + imageIndex = 0; + drawHealth = false; + hitPoints = 60; + health = new HealthBar(handler, x, y, new TextureRegion(handler.getMenuState().getHealthTexture()), hitPoints); + health.setHealth(0); + } + + + //--- Methods + @Override + public void update(float dt) { + //checkIfMouseWithin(); + checkPlayerCollision(); + if (hitPoints < 0) {hitPoints = 0;} + health.setHealth(hitPoints); + if (hitPoints >= 60) { + buttonAction(); + } + } + + @Override + public void render(SpriteBatch batch) { + batch.draw(images[imageIndex][0], bounds.x, bounds.y, bounds.width, bounds.height); + font.draw(batch, message, bounds.x+bounds.width/2, bounds.y+bounds.height, 0, Align.center, false); + if (drawHealth) health.render(batch); + } + + @Override + public void dispose() { + font.dispose(); + } + + @Override + public String toString() {return "Button";} + + private void buttonAction() { + if (message.equalsIgnoreCase("play")) { + State.setCurrenState(handler.getGameState()); + handler.getGameObjectHandler().dispose(); + handler.getGameState().init(); + handler.getMenuState().dispose(); + } else if (message.equalsIgnoreCase("Stats")) { + handler.getMenuState().setSubState(1); + } else if (message.equalsIgnoreCase("Exit")) { + State.setCurrenState(handler.getExitState()); + handler.getGameObjectHandler().dispose(); + State.getCurrentState().init(); + handler.getMenuState().dispose(); + } else if (message.equalsIgnoreCase("back")) { + handler.getMenuState().setSubState(0); + } + } + + private void checkPlayerCollision() { + if (bounds.overlaps(handler.getMenuState().getPlayer().getBounds())) { + drawHealth = true; + imageIndex = 1; + if (Gdx.input.isKeyPressed(Keys.E)) { + hitPoints++; + } else {hitPoints--;} + } else { + drawHealth = false; + imageIndex = 0; + hitPoints--; + } + } + + //--- Getters and Setters + + +} diff --git a/core/src/com/jalenwinslow/game/gameobjects/GameObject.java b/core/src/com/jalenwinslow/game/gameobjects/GameObject.java new file mode 100644 index 0000000..554e2ae --- /dev/null +++ b/core/src/com/jalenwinslow/game/gameobjects/GameObject.java @@ -0,0 +1,48 @@ +package com.jalenwinslow.game.gameobjects; + +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.math.Rectangle; +import com.jalenwinslow.game.Handler; + +public abstract class GameObject { + + //--- Propreties + protected Handler handler; + protected double x, y; + protected int depth; + protected TextureRegion image; + protected Rectangle bounds; + + //--- Constructor + public GameObject(Handler handler, double x, double y, TextureRegion image) { + this.handler = handler; + this.x = x; + this.y = y; + this.depth = 0; + this.image = image; + } + + + //--- Methods + public abstract void update(float dt); + + public abstract void render(SpriteBatch batch); + + public abstract void dispose(); + + @Override + public abstract String toString(); + + public boolean getCollision(double x, double y) { + return (x <= bounds.x + bounds.width && x >= bounds.x && y >= bounds.y && y <= bounds.y + bounds.height); + } + + //--- Getters and Setters + public double getX() {return x;} + public double getY() {return y;} + public int getDepth() {return depth;} + public Rectangle getBounds() {return bounds;} + + +} diff --git a/core/src/com/jalenwinslow/game/gameobjects/GameObjectHandler.java b/core/src/com/jalenwinslow/game/gameobjects/GameObjectHandler.java new file mode 100644 index 0000000..4b3a525 --- /dev/null +++ b/core/src/com/jalenwinslow/game/gameobjects/GameObjectHandler.java @@ -0,0 +1,78 @@ +package com.jalenwinslow.game.gameobjects; + +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.utils.Array; +import com.jalenwinslow.game.Handler; + +public class GameObjectHandler { + + //--- Propreties + private Handler handler; + private Array gameObjects; + private int numberOfShortWalls; + private int numberOfTallWalls; + private int highestNumberOfShortWallsAtOnce; + private int highestNumberOfTallWallsAtOnce; + + //--- Constructor + public GameObjectHandler(Handler handler) { + this.handler = handler; + this.gameObjects = new Array(); + numberOfShortWalls = 0; + numberOfTallWalls = 0; + highestNumberOfShortWallsAtOnce = 0; + highestNumberOfTallWallsAtOnce = 0; + } + + + //--- Methods + public void update(float dt) { + sort(); + numberOfShortWalls = 0; + numberOfTallWalls = 0; + for (int i = 0; i < gameObjects.size; i++) { + //System.out.println(gameObjects.get(i).getClass().toString()); + //if (gameObjects.get(i).toString().equalsIgnoreCase("TallWall")) {handler.setMessage("Its here");} + if (gameObjects.get(i).toString().equalsIgnoreCase("ShortWall")) {numberOfShortWalls++;} + if (gameObjects.get(i).toString().equalsIgnoreCase("TallWall")) numberOfTallWalls++; + gameObjects.get(i).update(dt); + } + numberOfShortWalls -= 10; + if (numberOfShortWalls > highestNumberOfShortWallsAtOnce) highestNumberOfShortWallsAtOnce = numberOfShortWalls; + if (numberOfTallWalls > highestNumberOfTallWallsAtOnce) highestNumberOfTallWallsAtOnce = numberOfTallWalls; + //handler.setMessage("number of short walls: " + numberOfShortWalls); + } + + public void render(SpriteBatch batch) { + + for (GameObject gameObj : gameObjects) { + gameObj.render(batch); + } + + } + + public void dispose() { + gameObjects.clear(); + } + + public void sort() { + for (int i = 0; i < gameObjects.size - 1; i++) { + if (gameObjects.get(i).depth <= gameObjects.get(i+1).depth) { + gameObjects.swap(i, i+1); + } + } + } + + public void add(GameObject gameObject) { + gameObjects.add(gameObject); + } + + //--- Getters and Setters + public Array getGameObjects() {return gameObjects;} + public int getNumberOfShortWalls() {return numberOfShortWalls;} + public int getHighestNumberOfShortWallsAtOnce() {return highestNumberOfShortWallsAtOnce;} + public int getHighestNumberOfTallWallsAtOnce() {return highestNumberOfTallWallsAtOnce;} + + public void setGameObjects(Array array) {this.gameObjects = array;} + +} diff --git a/core/src/com/jalenwinslow/game/gameobjects/HealthBar.java b/core/src/com/jalenwinslow/game/gameobjects/HealthBar.java new file mode 100644 index 0000000..54a5924 --- /dev/null +++ b/core/src/com/jalenwinslow/game/gameobjects/HealthBar.java @@ -0,0 +1,57 @@ +package com.jalenwinslow.game.gameobjects; + +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.math.Rectangle; +import com.jalenwinslow.game.Handler; +import com.jalenwinslow.game.Main; + +public class HealthBar extends GameObject { + + //--- Propreties + private TextureRegion backHealth; + private TextureRegion healthArea; + + private float health; + private float totalHealth; + + //--- Constructor + public HealthBar(Handler handler, double x, double y, TextureRegion image, int totalHealth) { + super(handler, x, y, image); + bounds = new Rectangle((int)x, (int)y, Main.WIDTH/10, Main.HEIGHT/40); + TextureRegion[][] images = image.split(16, 4); + backHealth = images[0][0]; + healthArea = images[1][0]; + this.totalHealth = totalHealth; + this.health = this.totalHealth; + } + + + //--- Methods + @Override + public void update(float dt) { + + } + + @Override + public void render(SpriteBatch batch) { + batch.draw(backHealth, bounds.x, bounds.y, bounds.width, bounds.height); + batch.draw(healthArea, bounds.x + 4, bounds.y + 4, (bounds.width - 8) * (health/totalHealth), bounds.height - 8); + } + + @Override + public void dispose() { + + } + + @Override + public String toString() {return "HealthBar";} + + //--- Getters and Setters + public float getHealth() {return health;} + public float getTotalHealth() {return totalHealth;} + + public void setHealth(float health) {this.health = health;} + public void setTotalHealth(float totalHealth) {this.totalHealth = totalHealth;} + +} diff --git a/core/src/com/jalenwinslow/game/gameobjects/PlayButton.java b/core/src/com/jalenwinslow/game/gameobjects/PlayButton.java new file mode 100644 index 0000000..69047a3 --- /dev/null +++ b/core/src/com/jalenwinslow/game/gameobjects/PlayButton.java @@ -0,0 +1,68 @@ +package com.jalenwinslow.game.gameobjects; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.math.Rectangle; +import com.jalenwinslow.game.Handler; +import com.jalenwinslow.game.Main; +import com.jalenwinslow.game.states.State; + +public class PlayButton extends GameObject { + + //--- Propreties + TextureRegion[][] btnImages; + TextureRegion currentTexture; + + //--- Constructor + public PlayButton(Handler handler, double x, double y, TextureRegion image) { + super(handler, x, y, image); + btnImages = image.split(image.getRegionWidth(), 48);//image.getRegionHeight()/3); + currentTexture = btnImages[0][0]; + bounds = new Rectangle((int)x - Main.WIDTH/8, (int)y - Main.HEIGHT/16, Main.WIDTH/4, Main.HEIGHT/8); + } + + + //--- Methods + @Override + public void update(float dt) { + handleAnimation(); + if (Gdx.input.justTouched() && Gdx.input.getX() < bounds.x + bounds.width && Gdx.input.getX() > bounds.x && + Gdx.input.getY() < bounds.y + bounds.height && Gdx.input.getY() > bounds.y) { + State.setCurrenState(handler.getGameState()); + handler.getGameState().init(); + handler.getMenuState().dispose(); + } + } + + @Override + public void render(SpriteBatch batch) { + batch.draw(currentTexture, (int)bounds.x, (int)bounds.y, Main.WIDTH/4, Main.HEIGHT/8); + } + + @Override + public void dispose() { + + } + + @Override + public String toString() {return "PlayButton";} + + public void handleAnimation() { + if (Gdx.input.getX() < bounds.x + bounds.width && Gdx.input.getX() > bounds.x && + Gdx.input.getY() < bounds.y + bounds.height && Gdx.input.getY() > bounds.y) { + if (Gdx.input.isTouched()) { + currentTexture = btnImages[2][0]; + } else { + currentTexture = btnImages[1][0]; + } + } else { + currentTexture = btnImages[0][0]; + } + + } + + //--- Getters and Setters + + +} diff --git a/core/src/com/jalenwinslow/game/gameobjects/Player.java b/core/src/com/jalenwinslow/game/gameobjects/Player.java new file mode 100644 index 0000000..c54a18c --- /dev/null +++ b/core/src/com/jalenwinslow/game/gameobjects/Player.java @@ -0,0 +1,258 @@ +package com.jalenwinslow.game.gameobjects; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input.Keys; +import com.badlogic.gdx.graphics.Texture; +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.math.Rectangle; +import com.badlogic.gdx.utils.Array; +import com.jalenwinslow.game.Handler; +import com.jalenwinslow.game.Main; +import com.jalenwinslow.game.gameobjects.TallWall.TallWallStates; + +public class Player extends GameObject { + + //--- Propreties + public static final double SPEED = 3.0; + + private int dir; + private double vecX, vecY; + private int wood; + private int highestNumberOfTallWallsCreated; + private int highestNumberOfTallWallsDestroyed; + private int numberOfWoodPickedUp; + + private Animation animDown, animUp, animRight; + private TextureRegion texture; + private float elapsedTime = 0; + private Rectangle boundsFeet; + + //private Texture boundsTexture = new Texture("DodgeGame_boundsMask.png"); + + //--- Constructor + public Player(Handler handler, double x, double y, TextureRegion image) { + super(handler, x, y, image); + + dir = 3; + vecX = 0; + vecY = 0; + wood = 0; + highestNumberOfTallWallsCreated = 0; + highestNumberOfTallWallsDestroyed = 0; + numberOfWoodPickedUp = 0; + createAnimation(); + bounds = new Rectangle((int)x, (int)y, Main.WIDTH/10 - 40, Main.HEIGHT/10 - 24); + boundsFeet = new Rectangle((int)x, (int)y, Main.WIDTH/10-40, Main.HEIGHT/10 -48); + } + + + //--- Methods + @Override + public void update(float dt) { + elapsedTime += dt; + handleInput(); + handleCollision(); + handleAnimation(); + x += vecX; + y += vecY; + depth = (int)y + Main.HEIGHT/20; + bounds.setPosition((float)x + 20, (float)y + 8); + boundsFeet.setPosition((float)x + 20, (float)y); + checks(); + } + + @Override + public void render(SpriteBatch batch) { + batch.draw(texture, (int)x, (int)y, Main.WIDTH/10, Main.HEIGHT/10); + //batch.draw(boundsTexture, bounds.x, bounds.y, bounds.width, bounds.height); + } + + @Override + public void dispose() { + //image.dispose(); + //boundsTexture.dispose(); + } + + private void createAnimation() { + TextureRegion[][] splitTexture = image.split(16, 16); + Array array = new Array(splitTexture.length * splitTexture[0].length); + for (int i = 0; i < splitTexture[0].length; i++) { + array.add(splitTexture[0][i]); + } + animDown = new Animation(0.1f, array, PlayMode.LOOP); + array.clear(); + + for (TextureRegion t : splitTexture[1]) { + array.add(t); + } + animUp = new Animation(0.1f, array, PlayMode.LOOP); + array.clear(); + + for (TextureRegion t : splitTexture[2]) { + array.add(t); + } + animRight = new Animation(0.1f, array, PlayMode.LOOP); + array.clear(); + texture = animDown.getKeyFrame(elapsedTime); + } + + private void handleInput() { + if ( (Gdx.input.isKeyPressed(Keys.W) && Gdx.input.isKeyPressed(Keys.S)) || + (!Gdx.input.isKeyPressed(Keys.W) && !Gdx.input.isKeyPressed(Keys.S)) ) { + vecY = 0; + } else if (Gdx.input.isKeyPressed(Keys.W)) { + vecY = SPEED; + dir = 1; + } else if (Gdx.input.isKeyPressed(Keys.S)) { + vecY = -SPEED; + dir = 3; + } + + if ( (Gdx.input.isKeyPressed(Keys.A) && Gdx.input.isKeyPressed(Keys.D)) || + (!Gdx.input.isKeyPressed(Keys.A) && !Gdx.input.isKeyPressed(Keys.D)) ) { + vecX = 0; + } else if (Gdx.input.isKeyPressed(Keys.A)) { + vecX = -SPEED; + dir = 2; + } else if (Gdx.input.isKeyPressed(Keys.D)) { + vecX = SPEED; + dir = 0; + } + + if ( (Gdx.input.isKeyJustPressed(Keys.SPACE)) && wood >= 7) { + int arrayX = ((int)(boundsFeet.x + (boundsFeet.width/2))/64); + int arrayY = ((int)(boundsFeet.y + (boundsFeet.height/2))/64); + handler.getGameState().getGrid().setFree(false, arrayX, arrayY); + handler.getGameObjectHandler().add(new TallWall(handler, arrayX * 64, arrayY *64, new TextureRegion(handler.getGameState().getTallWallTexture())) ); + wood -= 7; + } + + } + + private void handleCollision() { + if (boundsFeet.x + boundsFeet.width + vecX >= Main.WIDTH-64) {vecX = 0;} + if (boundsFeet.x + vecX <= 64) vecX = 0; + if (boundsFeet.y + boundsFeet.height + vecY >= Main.HEIGHT-64) vecY = 0; + if (boundsFeet.y + vecY <= 0) {vecY = 0;} + + handleWallCollision(); + } + + private void handleWallCollision() {// Also breaking walls + + for (int i = 0; i < handler.getGameObjectHandler().getGameObjects().size; i++) { + if (handler.getGameObjectHandler().getGameObjects().get(i).toString().equalsIgnoreCase("ShortWall")) { + ShortWall wall = (ShortWall)handler.getGameObjectHandler().getGameObjects().get(i); + if (wall.getShowHealthBounds() != null && boundsFeet.overlaps(wall.getShowHealthBounds()) && Gdx.input.isKeyPressed(Keys.E)) { + if (wall.getHitPoints() > 0) { + wall.setHitPoints(wall.getHitPoints() - 1); + } + } + if (vecX < 0) { + if (wall.getCollision(boundsFeet.x + vecX, boundsFeet.y) || + wall.getCollision(boundsFeet.x + vecX, boundsFeet.y + boundsFeet.height)) { + vecX = 0; + } + } else if (vecX > 0) { + if (wall.getCollision(boundsFeet.x + boundsFeet.width + vecX, boundsFeet.y) || + wall.getCollision(boundsFeet.x + boundsFeet.width + vecX, boundsFeet.y + boundsFeet.height)) { + vecX = 0; + } + } + + if (vecY < 0) { + if (wall.getCollision(boundsFeet.x, boundsFeet.y + vecY) || + wall.getCollision(boundsFeet.x + boundsFeet.width, boundsFeet.y + vecY)) { + vecY = 0; + } + } else if (vecY > 0) { + if (wall.getCollision(boundsFeet.x, boundsFeet.y + boundsFeet.height + vecY) || + wall.getCollision(boundsFeet.x + boundsFeet.width, boundsFeet.y + boundsFeet.height + vecY)) { + vecY = 0; + } + } + } + if (handler.getGameObjectHandler().getGameObjects().get(i).toString().equalsIgnoreCase("TallWall")) { + TallWall wall = (TallWall)handler.getGameObjectHandler().getGameObjects().get(i); + if (wall.getState() == TallWallStates.startCreation) { + if (wall.getShowHealthBounds() != null && boundsFeet.overlaps(wall.getShowHealthBounds()) && Gdx.input.isKeyPressed(Keys.E)) { + if (wall.getHitPoints() < wall.getTotalHitPoints()) { + wall.setHitPoints(wall.getHitPoints() + 1); + } + } + } + + if (vecX < 0) { + if (wall.getCollision(boundsFeet.x + vecX, boundsFeet.y) || + wall.getCollision(boundsFeet.x + vecX, boundsFeet.y + boundsFeet.height)) { + vecX = 0; + } + } else if (vecX > 0) { + if (wall.getCollision(boundsFeet.x + boundsFeet.width + vecX, boundsFeet.y) || + wall.getCollision(boundsFeet.x + boundsFeet.width + vecX, boundsFeet.y + boundsFeet.height)) { + vecX = 0; + } + } + + if (vecY < 0) { + if (wall.getCollision(boundsFeet.x, boundsFeet.y + vecY) || + wall.getCollision(boundsFeet.x + boundsFeet.width, boundsFeet.y + vecY)) { + vecY = 0; + } + } else if (vecY > 0) { + if (wall.getCollision(boundsFeet.x, boundsFeet.y + boundsFeet.height + vecY) || + wall.getCollision(boundsFeet.x + boundsFeet.width, boundsFeet.y + boundsFeet.height + vecY)) { + vecY = 0; + } + } + } + } + } + + private void handleAnimation() { + Animation currentAnimation; + if (vecY > 0) dir = 1; + else if (vecY < 0) dir = 3; + else if (vecX > 0) dir = 0; + else if (vecX < 0) dir = 2; + + switch (dir) { + case 0: currentAnimation = animRight; break; + case 1: currentAnimation = animUp; break; + case 2: currentAnimation = animRight; break; + case 3: currentAnimation = animDown; break; + default: currentAnimation = animDown; break; + } + + if (vecX != 0 || vecY != 0) + texture = currentAnimation.getKeyFrame(elapsedTime); + else texture = currentAnimation.getKeyFrame(0); + + if (texture.isFlipX()) texture.flip(true, false); + if (dir == 2 && !texture.isFlipX()) texture.flip(true, false); + } + + private void checks() { + if (wood < 0) wood = 0; + if (wood > 20) wood = 20; + } + + @Override + public String toString() {return "Player";} + + //--- Getters and Setters + public Rectangle getBoundsFeet() {return boundsFeet;} + public int getWood() {return wood;} + public int getHighestNumberOfTallWallsCreated() {return highestNumberOfTallWallsCreated;} + public int getHighestNumberOfTallWallsDestroyed() {return highestNumberOfTallWallsDestroyed;} + public int getNumberOfWoodPickedUp() {return numberOfWoodPickedUp;} + + public void setWood(int wood) {this.wood = wood;} + public void setHighestNumberOfTallWallsCreated(int tallWalls) {this.highestNumberOfTallWallsCreated = tallWalls;} + public void setHighestNumberOfTallWallsDestroyed(int tallWalls) {this.highestNumberOfTallWallsDestroyed = tallWalls;} + public void setNumberOfWoodPickedUp(int wood) {this.numberOfWoodPickedUp = wood;} + +} diff --git a/core/src/com/jalenwinslow/game/gameobjects/ScoreBoard.java b/core/src/com/jalenwinslow/game/gameobjects/ScoreBoard.java new file mode 100644 index 0000000..c9627b1 --- /dev/null +++ b/core/src/com/jalenwinslow/game/gameobjects/ScoreBoard.java @@ -0,0 +1,78 @@ +package com.jalenwinslow.game.gameobjects; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.math.Rectangle; +import com.badlogic.gdx.utils.Align; +import com.jalenwinslow.game.Handler; +import com.jalenwinslow.game.Main; + +public class ScoreBoard extends GameObject { + + //--- Propreties + private BitmapFont font; + private String message1; + private String messageOfScores; + + //--- Constructor + public ScoreBoard(Handler handler, double x, double y, TextureRegion image) { + super(handler, x, y, image); + bounds = new Rectangle((int)x, (int)y, Main.WIDTH*3/4, Main.HEIGHT/2 ); + font = new BitmapFont(Gdx.files.internal("customFont4.fnt")); + font.getData().setScale(2f); + font.getData().down = -20.0f; + font.setColor(Color.BLACK); + message1 = "Seconds survived in last round\n" + + "Longest survived in game\n\n" + + "Highest amount of\n" + + " arrows created\n" + + " arrows shot at once\n" + + " Short Walls created\n" + + " Short Walls at once\n" + + " Short Walls destroyed\n" + + " Tall Walls created\n" + + " Tall Walls at once\n" + + " Tall Walls destroyed\n" + + " wood picked up\n"; + messageOfScores = "" + handler.getScore().currentSecSurvived + "\n" + + handler.getScore().highestSecSurvived + "\n\n\n" + + handler.getScore().highestNumberOfArrowsCreated + "\n" + + handler.getScore().highestNumberOfArrowsShotAtOnce + "\n" + + handler.getScore().highestNumberOfShortWallsCreated + "\n" + + handler.getScore().highestNumberOfShortWallsAtOnce + "\n" + + handler.getScore().highestNumberOfShortWallsDestroyed + "\n" + + handler.getScore().highestNumberOfTallWallsCreated + "\n" + + handler.getScore().highestNumberOfTallWallsAtOnce + "\n" + + handler.getScore().highestNumberOfTallWallsDestroyed + "\n" + + handler.getScore().highestNumberOfWoodPickedUp; + } + + + //--- Methods + @Override + public void update(float dt) { + + } + + @Override + public void render(SpriteBatch batch) { + batch.draw(image, bounds.x, bounds.y, bounds.width, bounds.height); + font.draw(batch, message1, bounds.x+bounds.width/20, bounds.y+bounds.height-8, 0, Align.topLeft, false); + font.draw(batch, messageOfScores, bounds.x + bounds.width - bounds.width/20, bounds.y+bounds.height-8, 0, Align.right,false); + } + + @Override + public void dispose() { + font.dispose(); + } + + @Override + public String toString() {return "ScoreBoard";} + + //--- Getters and Setters + + +} diff --git a/core/src/com/jalenwinslow/game/gameobjects/ShortWall.java b/core/src/com/jalenwinslow/game/gameobjects/ShortWall.java new file mode 100644 index 0000000..a1be368 --- /dev/null +++ b/core/src/com/jalenwinslow/game/gameobjects/ShortWall.java @@ -0,0 +1,170 @@ +package com.jalenwinslow.game.gameobjects; + +import com.badlogic.gdx.Gdx; +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.jalenwinslow.game.Handler; +import com.jalenwinslow.game.Main; +import com.jalenwinslow.game.states.State; +import java.util.Random; + +public class ShortWall extends Wall { + + //--- Propreties + enum ShortWallStates { + creation, + normal, + standard + } + + private Random rand; + private ShortWallStates state; + private TextureRegion texture; + private Rectangle deathBounds; + private Rectangle showHealthBounds; + private Rectangle noPlayerBounds; + + private int hitPoints; + private HealthBar health; + private boolean breakable; + private boolean drawHealth; + private float timer; + private float elapsedTime; + private float alpha; + //Texture boundsTexture = new Texture("DodgeGame_boundsMask.png"); + + //--- Constructor + public ShortWall(Handler handler, double x, double y, TextureRegion image) { + super(handler, x, y, image); + bounds = new Rectangle((int)x, (int)y, Main.WIDTH/10, Main.HEIGHT/10); + rand = new Random(); + chooseImage(); + depth = (int)y + Main.HEIGHT/20; + hitPoints = 1; + this.breakable = false; + drawHealth = false; + timer = 0; + elapsedTime = 0; + alpha = 1; + state = ShortWallStates.standard; + } + + public ShortWall(Handler handler, double x, double y, TextureRegion image, boolean breakable) { + super(handler, x, y, image); + bounds = new Rectangle(); + noPlayerBounds = new Rectangle((int)x, (int)y, Main.WIDTH/10, Main.HEIGHT/10); + rand = new Random(); + deathBounds = new Rectangle(); + showHealthBounds = new Rectangle(); + chooseImage(); + depth = (int) y + Main.HEIGHT/20; + hitPoints = 900; + health = new HealthBar(handler, x, y, new TextureRegion(handler.getGameState().getHealthTexture()), hitPoints); + this.breakable = breakable; + drawHealth = false; + timer = 0; + elapsedTime = 0; + alpha = 0; + state = ShortWallStates.creation; + } + + + //--- Methods + @Override + public void update(float dt) { + + switch (state) { + case creation: + elapsedTime += dt; + if (!noPlayerBounds.overlaps(handler.getGameState().getPlayer().getBoundsFeet())) { + bounds = new Rectangle(noPlayerBounds); + } + if (elapsedTime >= 0.25 && timer <= 2) { + timer += 0.25; + elapsedTime -= 0.25; + if (alpha == 0) alpha = 1; + else alpha = 0; + } + if (timer > 2) { + alpha = 1; + if (bounds == null) { + bounds = new Rectangle((int)x, (int)y, Main.WIDTH/10, Main.HEIGHT/10); + } + deathBounds = new Rectangle((int)x+8, (int)y+8, Main.WIDTH/10-16, Main.HEIGHT/10-16); + showHealthBounds = new Rectangle((int)x-8, (int)y-8, Main.WIDTH/10+16, Main.HEIGHT/10+16); + health.bounds.x = bounds.x; + health.bounds.y = bounds.y + bounds.height + (Main.HEIGHT/40) + 4; + state = ShortWallStates.normal; + } + break; + case normal: + boundCollisions(); + health.setHealth(hitPoints); + if (hitPoints <= 0) { + for (int i = 0; i < handler.getGameObjectHandler().getGameObjects().size; i++) { + if (handler.getGameObjectHandler().getGameObjects().get(i).equals(this)) { + handler.getGameState().getPlayer().setWood(handler.getGameState().getPlayer().getWood()+2); + handler.getGameState().getGrid().setFree(true, (int)(x / handler.getGameState().getGrid().getAreaWidth()), (int)(y / handler.getGameState().getGrid().getAreaHeight())); + handler.getGameState().getWallGen().setHighestNumberOfShortWallsDestroyed(handler.getGameState().getWallGen().getHighestNumberOfShortWallsDestroyed() + 1); + handler.getGameObjectHandler().getGameObjects().removeValue(this, false); + } + } + } + break; + case standard: + + break; + default: + + break; + } + + } + + @Override + public void render(SpriteBatch batch) { + batch.setColor(1, 1, 1, alpha); + batch.draw(texture, (int)x, (int)y, Main.WIDTH/10, Main.HEIGHT/10+(Main.HEIGHT/40)); + batch.setColor(1, 1, 1, 1); + + if (drawHealth) { + health.render(batch); + } + } + + @Override + public void dispose() { + //boundsTexture.dispose(); + } + + @Override + public String toString() {return "ShortWall";} + + private void chooseImage() { + TextureRegion[][] images = image.split(16, 20); + texture = images[0][rand.nextInt(images[0].length)]; + } + + private void boundCollisions() { + if (deathBounds.overlaps(handler.getGameState().getPlayer().getBoundsFeet())) { + handler.getGameState().getTimer().stop(); + State.setCurrenState(handler.getGameOverState()); + State.getCurrentState().init(); + handler.getGameObjectHandler().dispose(); + handler.getGameState().dispose(); + } + drawHealth = (showHealthBounds.overlaps(handler.getGameState().getPlayer().getBoundsFeet())); + } + + //--- Getters and Setters + public boolean isBreakable() {return breakable;} + public int getHitPoints() {return hitPoints;} + public Rectangle getDeathBounds() {return deathBounds;} + public Rectangle getShowHealthBounds() {return showHealthBounds;} + + public void setBreakable(boolean breakable) {this.breakable = breakable;} + public void setHitPoints(int hitPoints) {this.hitPoints = hitPoints;} + +} diff --git a/core/src/com/jalenwinslow/game/gameobjects/TallWall.java b/core/src/com/jalenwinslow/game/gameobjects/TallWall.java new file mode 100644 index 0000000..5740944 --- /dev/null +++ b/core/src/com/jalenwinslow/game/gameobjects/TallWall.java @@ -0,0 +1,128 @@ +package com.jalenwinslow.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.jalenwinslow.game.Handler; +import com.jalenwinslow.game.Main; + +public class TallWall extends Wall { + + //--- Propreties + enum TallWallStates{ + waitingCreation, + startCreation, + normal + } + + private TextureRegion[][] texture; + private TallWallStates state; + private int imageIndex; + private int hitPoints; + private int totalHitPoints; + private boolean drawHealth; + private HealthBar health; + + private Rectangle showHealthBounds; + private Rectangle noPlayerBounds; + private Rectangle noArrowBounds; + + //private Texture boundsTexture = new Texture("DodgeGame_boundsMask.png"); + + //--- Constructor + public TallWall(Handler handler, double x, double y, TextureRegion image) { + super(handler, x, y, image); + bounds = new Rectangle(); + depth = (int)y + Main.HEIGHT/20; + texture = image.split(16, 24); + state = TallWallStates.waitingCreation; + imageIndex = 2; + hitPoints = 0; + totalHitPoints = 600; + drawHealth = false; + health = new HealthBar(handler, x, y, new TextureRegion(handler.getGameState().getHealthTexture()), totalHitPoints); + health.setHealth(hitPoints); + showHealthBounds = new Rectangle(); + noPlayerBounds = new Rectangle((int)x, (int)y, Main.WIDTH/10, Main.HEIGHT/10); + noArrowBounds = new Rectangle(); + } + + + //--- Methods + @Override + public void update(float dt) { + switch (state) { + case waitingCreation: + if (!noPlayerBounds.overlaps(handler.getGameState().getPlayer().getBoundsFeet())) { + state = TallWallStates.startCreation; + bounds = new Rectangle(noPlayerBounds); + showHealthBounds = new Rectangle((int)x-8, (int)y-8, bounds.width+16, bounds.height+16); + health.bounds.y = bounds.y+bounds.height+(Main.HEIGHT/20)+4; + imageIndex = 1; + } + break; + case startCreation: + boundCollisions(); + health.setHealth(hitPoints); + if (hitPoints >= totalHitPoints) { + state = TallWallStates.normal; + noArrowBounds = new Rectangle(bounds); + noArrowBounds.width += 8; + noArrowBounds.y += 16; + imageIndex = 0; + handler.getGameState().getPlayer().setHighestNumberOfTallWallsCreated(handler.getGameState().getPlayer().getHighestNumberOfTallWallsCreated() + 1); + } + break; + case normal: + boundCollisions(); + health.setHealth(hitPoints); + if (hitPoints <= 0) { + for (int i = 0; i < handler.getGameObjectHandler().getGameObjects().size; i++) { + if (handler.getGameObjectHandler().getGameObjects().get(i).equals(this)) { + handler.getGameState().getGrid().setFree(true, (int)(x / handler.getGameState().getGrid().getAreaWidth()), (int)(y / handler.getGameState().getGrid().getAreaHeight())); + handler.getGameState().getPlayer().setHighestNumberOfTallWallsDestroyed(handler.getGameState().getPlayer().getHighestNumberOfTallWallsDestroyed()+1); + handler.getGameObjectHandler().getGameObjects().removeValue(this, false); + } + } + } + break; + default: + + break; + } + } + + @Override + public void render(SpriteBatch batch) { + batch.draw(texture[0][imageIndex], noPlayerBounds.x, noPlayerBounds.y, noPlayerBounds.width, noPlayerBounds.height + (noPlayerBounds.height/2)); + //batch.draw(boundsTexture, noArrowBounds.x, noArrowBounds.y, noArrowBounds.width, noArrowBounds.height); + if (drawHealth) { + health.render(batch); + } + } + + @Override + public void dispose() { + //boundsTexture.dispose(); + } + + @Override + public String toString() {return "TallWall";} + + public void boundCollisions() { + drawHealth = (showHealthBounds.overlaps(handler.getGameState().getPlayer().getBoundsFeet())); + } + + //--- Getters and Setters + public int getHitPoints() {return hitPoints;} + public int getTotalHitPoints() {return totalHitPoints;} + public Rectangle getShowHealthBounds() {return showHealthBounds;} + public Rectangle getNoPlayerBounds() {return noPlayerBounds;} + public Rectangle getNoArrowBounds() {return noArrowBounds;} + public TallWallStates getState() {return state;} + + public void setHitPoints(int hitPoints) {this.hitPoints = hitPoints;} + public void setState(TallWallStates state) {this.state = state;} + +} diff --git a/core/src/com/jalenwinslow/game/gameobjects/Timer.java b/core/src/com/jalenwinslow/game/gameobjects/Timer.java new file mode 100644 index 0000000..8780aeb --- /dev/null +++ b/core/src/com/jalenwinslow/game/gameobjects/Timer.java @@ -0,0 +1,77 @@ +package com.jalenwinslow.game.gameobjects; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.scenes.scene2d.ui.Label; +import com.badlogic.gdx.utils.Align; +import com.jalenwinslow.game.Handler; +import com.jalenwinslow.game.Main; + +public class Timer extends GameObject { + + //--- Propreties + private int time; + private float elapsedTime; + private BitmapFont font; + //private Label label; + private boolean playing; + private Texture timerCaseTexture; + + //--- Constructor + public Timer(Handler handler, double x, double y, TextureRegion image) { + super(handler, x, y, image); + time = 0; + elapsedTime = 0; + + font = new BitmapFont(Gdx.files.internal("customFont4.fnt")); + font.getData().setScale(3, 3); + font.setColor(Color.BLACK); + + playing = true; + timerCaseTexture = new Texture("b&w_DodgeGame_timerCase.png"); + } + + + //--- Methods + @Override + public void update(float dt) { + if (playing) { + elapsedTime += dt; + if (elapsedTime >= 1) { + time++; + elapsedTime = 0; + } + } + } + + @Override + public void render(SpriteBatch batch) { + batch.draw(timerCaseTexture, Main.WIDTH/2-(Main.WIDTH/12), Main.HEIGHT-Main.HEIGHT/20, Main.WIDTH/6, Main.HEIGHT/20); + font.draw(batch, String.valueOf(time), Main.WIDTH/2, Main.HEIGHT+4, 0, Align.center, false); + } + + @Override + public void dispose() { + timerCaseTexture.dispose(); + font.dispose(); + } + + @Override + public String toString() {return "Timer";} + + public void stop() { + playing = false; + } + + //--- Getters and Setters + public int getTime() {return time;} + public boolean isPlaying() {return playing;} + + public void setTime(int time) {this.time = time;} + public void setPlaying(boolean playing) {this.playing = playing;} + +} diff --git a/core/src/com/jalenwinslow/game/gameobjects/Wall.java b/core/src/com/jalenwinslow/game/gameobjects/Wall.java new file mode 100644 index 0000000..96060c9 --- /dev/null +++ b/core/src/com/jalenwinslow/game/gameobjects/Wall.java @@ -0,0 +1,25 @@ +package com.jalenwinslow.game.gameobjects; + +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.jalenwinslow.game.Handler; + +public abstract class Wall extends GameObject { + + //--- Propreties + + + //--- Constructor + public Wall(Handler handler, double x, double y, TextureRegion image) { + super(handler, x, y, image); + } + + + //--- Methods + public boolean hasCollided(double x, double y) { + return (x >= bounds.x && y >= bounds.y && x <= bounds.x + bounds.width && y <= bounds.y + bounds.height); + } + + //--- Getters and Setters + + +} diff --git a/core/src/com/jalenwinslow/game/gameobjects/WallGenerator.java b/core/src/com/jalenwinslow/game/gameobjects/WallGenerator.java new file mode 100644 index 0000000..f626d82 --- /dev/null +++ b/core/src/com/jalenwinslow/game/gameobjects/WallGenerator.java @@ -0,0 +1,116 @@ +package com.jalenwinslow.game.gameobjects; + +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.jalenwinslow.game.Handler; +import java.util.Random; + +public class WallGenerator extends GameObject { + + //--- Propreties + public static final byte MIN_WALL_COUNT = 5, MAX_WALL_COUNT = 30; + public static final int END_DEPLOY_TIME = 15, START_DEPLOY_TIME = 30; + + private Random rand; + + private int wallLimit; + private int baseTimeCount; + private int timeCount; + private int timer; + private float elapsedTime; + private int highestNumberOfShortWallsCreated; + private int highestNumberOfShortWallsDestroyed; + + //--- Constructor + public WallGenerator(Handler handler, double x, double y, TextureRegion image) { + super(handler, x, y, image); + + rand = new Random(); + + wallLimit = MAX_WALL_COUNT; + baseTimeCount = START_DEPLOY_TIME; + timeCount = baseTimeCount + (rand.nextInt(7) - 3); + timer = 0; + elapsedTime = 0; + highestNumberOfShortWallsCreated = 0; + highestNumberOfShortWallsDestroyed = 0; + + for (int i = 0; i < 3; i++) {addWall();} + } + + + //--- Methods + @Override + public void update(float dt) { + elapsedTime += dt; + if (elapsedTime >= 1) { + timer++; + elapsedTime--; + } + if (timer >= timeCount && (handler.getGameObjectHandler().getNumberOfShortWalls() - 10) < wallLimit) { + if (rand.nextInt(100)+1 <= 75) { + addWall(); + } + timer = 0; + if (baseTimeCount > END_DEPLOY_TIME) baseTimeCount--; + timeCount = baseTimeCount + (rand.nextInt(7)-3); + } + + + } + + @Override + public void render(SpriteBatch batch) { + + } + + @Override + public void dispose() { + + } + + @Override + public String toString() {return "WallGenerator";} + + public void updateWallStats() { + + } + + private void addWall() { + int arrayX = rand.nextInt(8)+1; + int arrayY = rand.nextInt(8)+1; + while (true) { + if (handler.getGameState().getGrid().isFree()[arrayY][arrayX] == true) { + break; + } else { + if (arrayX < 8) arrayX++; + else { + if (arrayY < 8) { + arrayY++; + arrayX = 1; + } else { + arrayY = 1; + arrayX = 1; + } + } + } + } + + handler.getGameState().getGrid().setFree(false, arrayX, arrayY); + + int xx = handler.getGameState().getGrid().getAreaWidth() * (arrayX); + int yy = handler.getGameState().getGrid().getAreaHeight() * (arrayY); + + handler.getGameObjectHandler().add(new ShortWall(handler, xx, yy, image, true)); + + highestNumberOfShortWallsCreated++; + } + + + //--- Getters and Setters + public int getHighestNumberOfShortWallsCreated() {return highestNumberOfShortWallsCreated;} + public int getHighestNumberOfShortWallsDestroyed() {return highestNumberOfShortWallsDestroyed;} + + public void setHighestNumberOfShortWallsDestroyed(int number) {this.highestNumberOfShortWallsDestroyed = number;} + +} diff --git a/core/src/com/jalenwinslow/game/gameobjects/Wood.java b/core/src/com/jalenwinslow/game/gameobjects/Wood.java new file mode 100644 index 0000000..f226a7f --- /dev/null +++ b/core/src/com/jalenwinslow/game/gameobjects/Wood.java @@ -0,0 +1,76 @@ +package com.jalenwinslow.game.gameobjects; + +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.math.Rectangle; +import com.jalenwinslow.game.Handler; +import com.jalenwinslow.game.Main; +import java.util.Random; + +public class Wood extends GameObject { + + //--- Propreties + private float timer; + private float elapsedTime; + private float alpha; + + //--- Constructor + public Wood(Handler handler, double x, double y, TextureRegion image) { + super(handler, x, y, image); + bounds = new Rectangle((int)x+16, (int)y+16, Main.WIDTH/20, Main.HEIGHT/20); + depth = (int)bounds.y + (int)bounds.width/2; + timer = 0; + elapsedTime = 0; + alpha = 1; + } + + + //--- Methods + @Override + public void update(float dt) { + elapsedTime += dt; + boundCollision(); + if (timer >= 10) { + if (elapsedTime >= 0.25) { + if (alpha == 1) alpha = 0; + else alpha = 1; + } + if (timer >= 13) { + handler.getGameObjectHandler().getGameObjects().removeValue(this, false); + } + } + if (elapsedTime >= 0.25) { + timer += 0.25; + elapsedTime -= 0.25; + } + + } + + @Override + public void render(SpriteBatch batch) { + batch.setColor(1, 1, 1, alpha); + batch.draw(image, (int)x, (int)y, Main.WIDTH/10, Main.HEIGHT/10); + batch.setColor(1, 1, 1, 1); + } + + @Override + public void dispose() { + + } + + @Override + public String toString() {return "Wood";} + + public void boundCollision() { + if (bounds.overlaps(handler.getGameState().getPlayer().getBounds())) { + handler.getGameState().getPlayer().setWood(handler.getGameState().getPlayer().getWood() + 1); + handler.getGameState().getPlayer().setNumberOfWoodPickedUp(handler.getGameState().getPlayer().getNumberOfWoodPickedUp() + 1); + handler.getGameObjectHandler().getGameObjects().removeValue(this, false); + } + } + + + //--- Getters and Setters + + +} diff --git a/core/src/com/jalenwinslow/game/gameobjects/WoodGUI.java b/core/src/com/jalenwinslow/game/gameobjects/WoodGUI.java new file mode 100644 index 0000000..b418af5 --- /dev/null +++ b/core/src/com/jalenwinslow/game/gameobjects/WoodGUI.java @@ -0,0 +1,60 @@ +package com.jalenwinslow.game.gameobjects; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.Texture; +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.jalenwinslow.game.Handler; +import com.jalenwinslow.game.Main; + +public class WoodGUI extends GameObject { + + //--- Propreties + private BitmapFont font; + private TextureRegion[][] texture; + private TextureRegion backTexture; + + private Texture boundsTexture = new Texture("DodgeGame_boundsMask.png"); + + //--- Constructor + public WoodGUI(Handler handler, double x, double y, TextureRegion image) { + super(handler, x, y, image); + bounds = new Rectangle((int)x, (int)y, Main.WIDTH/5, Main.HEIGHT/20); + font = new BitmapFont(Gdx.files.internal("customFont4.fnt")); + font.getData().setScale(3, 3); + font.setColor(Color.WHITE); + backTexture = new TextureRegion(handler.getGameState().getHealthTexture()).split(16, 4)[0][0]; + texture = image.split(16, 16); + } + + + //--- Methods + @Override + public void update(float dt) { + + } + + @Override + public void render(SpriteBatch batch) { + batch.draw(backTexture, bounds.x-bounds.width, bounds.y, bounds.width, bounds.height); + font.draw(batch, "x " + handler.getGameState().getPlayer().getWood(), bounds.x-64, bounds.y+Main.HEIGHT/20, 0, Align.left, false); + batch.draw(texture[0][0], bounds.x-bounds.width+16, bounds.y-4, Main.WIDTH/16, Main.HEIGHT/16); + } + + @Override + public void dispose() { + font.dispose(); + boundsTexture.dispose(); + } + + @Override + public String toString() {return "WoodGUI";} + + //--- Getters and Setters + + +} diff --git a/core/src/com/jalenwinslow/game/gameobjects/WoodGenerator.java b/core/src/com/jalenwinslow/game/gameobjects/WoodGenerator.java new file mode 100644 index 0000000..7a02495 --- /dev/null +++ b/core/src/com/jalenwinslow/game/gameobjects/WoodGenerator.java @@ -0,0 +1,92 @@ +package com.jalenwinslow.game.gameobjects; + +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.jalenwinslow.game.Handler; +import java.util.Random; + +public class WoodGenerator extends GameObject { + + //--- Propreties + private Random rand; + private int timer; + private float elapsedTime; + private int baseTime; + private int countDown; + private int numberOfWoodCreated; + private TextureRegion[][] images; + + //--- Constructor + public WoodGenerator(Handler handler, double x, double y, TextureRegion image) { + super(handler, x, y, image); + rand = new Random(); + timer = 0; + elapsedTime = 0; + baseTime = 20; + countDown = baseTime + rand.nextInt(11); + numberOfWoodCreated = 0; + images = image.split(16, 16); + } + + + //--- Methods + @Override + public void update(float dt) { + elapsedTime += dt; + if (elapsedTime >= 1) { + timer++; + elapsedTime--; + } + if (timer >= countDown) { + if (rand.nextInt(10)+1 <= 6) { + int arrayX = rand.nextInt(8)+1; + int arrayY = rand.nextInt(8)+1; + + while (true) { + if (handler.getGameState().getGrid().isFree()[arrayY][arrayX]) { + break; + } else { + if (arrayX < 8) arrayX++; + else { + if (arrayY < 8) { + arrayY++; + arrayX = 1; + } + else { + arrayX = 1; + arrayY = 1; + } + } + } + } + + handler.getGameState().getGrid().setFree(false, arrayX, arrayY); + + int xx = handler.getGameState().getGrid().getAreaWidth() * arrayX; + int yy = handler.getGameState().getGrid().getAreaHeight() * arrayY; + + handler.getGameObjectHandler().add(new Wood(handler, xx, yy, images[0][rand.nextInt(8)])); + numberOfWoodCreated = 0; + } + timer = 0; + countDown = 20 + rand.nextInt(11); + } + } + + @Override + public void render(SpriteBatch batch) { + + } + + @Override + public void dispose() { + + } + + @Override + public String toString() {return "WoodGenerator";} + + //--- Getters and Setters + public int getNumberOfWoodCreated() {return numberOfWoodCreated;} + +} diff --git a/core/src/com/jalenwinslow/game/states/ExitState.java b/core/src/com/jalenwinslow/game/states/ExitState.java new file mode 100644 index 0000000..a6c2add --- /dev/null +++ b/core/src/com/jalenwinslow/game/states/ExitState.java @@ -0,0 +1,66 @@ +package com.jalenwinslow.game.states; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.utils.Align; +import com.jalenwinslow.game.Handler; +import com.jalenwinslow.game.Main; + +public class ExitState extends State { + + //--- Propreties + BitmapFont font; + Texture texture; + float elapsedTime; + float timer; + String dots; + + //--- Constructor + public ExitState(Handler handler) { + super(handler); + } + + + //--- Methods + @Override + public void init() { + font = new BitmapFont(Gdx.files.internal("customFont4.fnt")); + font.getData().setScale(6); + font.setColor(Color.WHITE); + texture = new Texture("b&w_DodgeGame_gamePaused.png"); + elapsedTime = 0; + timer = 0; + dots = ""; + } + + @Override + public void update(float dt) { + elapsedTime += dt; + if (elapsedTime >= 1) { + timer++; + elapsedTime--; + } + if (timer >= 2) { + Gdx.app.exit(); + } + } + + @Override + public void render(SpriteBatch batch) { + batch.draw(texture, 0, 0, Main.WIDTH, Main.HEIGHT); + font.draw(batch, "Exiting", Main.WIDTH/2, Main.HEIGHT/2, 0, Align.center, false); + } + + @Override + public void dispose() { + font.dispose(); + texture.dispose(); + } + + //--- Getters and Setters + + +} diff --git a/core/src/com/jalenwinslow/game/states/GameOverState.java b/core/src/com/jalenwinslow/game/states/GameOverState.java new file mode 100644 index 0000000..ba1c057 --- /dev/null +++ b/core/src/com/jalenwinslow/game/states/GameOverState.java @@ -0,0 +1,62 @@ +package com.jalenwinslow.game.states; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.utils.Align; +import com.jalenwinslow.game.Handler; +import com.jalenwinslow.game.Main; + +public class GameOverState extends State { + + //--- Propreties + private Texture gameOverTexture; + private BitmapFont font; + + //--- Constructor + public GameOverState(Handler handler) { + super(handler); + } + + + //--- Methods + @Override + public void init() { + handler.getScore().updateScores(); + handler.getScore().updateScoreFile(); + handler.getGameObjectHandler().dispose(); + handler.getGameState().dispose(); + gameOverTexture = new Texture("b&w_DodgeGame_GameOver.png"); + font = new BitmapFont(Gdx.files.internal("customFont4.fnt")); + font.getData().setScale(3, 3); + font.setColor(Color.WHITE); + } + + @Override + public void update(float dt) { + if (Gdx.input.justTouched()) { + State.setCurrenState(handler.getMenuState()); + State.getCurrentState().init(); + dispose(); + } + } + + @Override + public void render(SpriteBatch batch) { + batch.draw(gameOverTexture, 0, 0, Main.WIDTH, Main.HEIGHT); + font.draw(batch, "CLICK LEFT TO CONTINUE", 16, Main.HEIGHT-16); + font.draw(batch, "SURVIVED FOR " + String.valueOf(handler.getGameState().getTimer().getTime()) + " SEC", Main.WIDTH/2, Main.HEIGHT/2 - 64, 0, Align.center, false); + } + + @Override + public void dispose() { + if (gameOverTexture != null) gameOverTexture.dispose(); + if (font != null) font.dispose(); + } + + //--- Getters and Setters + + +} diff --git a/core/src/com/jalenwinslow/game/states/GameState.java b/core/src/com/jalenwinslow/game/states/GameState.java new file mode 100644 index 0000000..beea938 --- /dev/null +++ b/core/src/com/jalenwinslow/game/states/GameState.java @@ -0,0 +1,117 @@ +package com.jalenwinslow.game.states; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input.Keys; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.jalenwinslow.game.Handler; +import com.jalenwinslow.game.Main; +import com.jalenwinslow.game.gameobjects.*; +import com.jalenwinslow.game.utils.Grid; +import java.util.Random; + +public class GameState extends State{ + + //--- Propreties + Texture background; + Texture playerTexture; + Texture woodTexture; + Texture arrowTexture; + Texture wallTexture; + Texture tallWallTexture; + Texture healthTexture; + + private Player player; + private WoodGUI woodGui; + private Grid grid; + private ArrowGenerator arrowGen; + private WallGenerator wallGen; + private WoodGenerator woodGen; + private Wall[] bottomWalls; + private Timer timer; + private Random rand; + + //--- Constructor + public GameState(Handler handler) { + super(handler); + } + + + //--- Methods + @Override + public void init() { + background = new Texture("b&w_DodgeGame_background2.png"); + playerTexture = new Texture("b&w_DodgeGame_man1.png"); + woodTexture = new Texture("b&w_DodgeGame_wood1.png"); + arrowTexture = new Texture("b&w_DodgeGame_arrow.png"); + wallTexture = new Texture("b&w_DodgeGame_wall1.png"); + tallWallTexture = new Texture("b&w_DodgeGame_tallWall1.png"); + healthTexture = new Texture("b&w_DodgeGame_health1.png"); + player = new Player(handler, Main.WIDTH/2, Main.HEIGHT/2, new TextureRegion(playerTexture)); + woodGui = new WoodGUI(handler, Main.WIDTH, 0, new TextureRegion(woodTexture)); + grid = new Grid(handler); + arrowGen = new ArrowGenerator(handler, 0, 0, new TextureRegion(arrowTexture)); + wallGen = new WallGenerator(handler, 0, 0, new TextureRegion(wallTexture)); + woodGen = new WoodGenerator(handler, 0, 0, new TextureRegion(woodTexture)); + bottomWalls = new Wall[Main.WIDTH/64]; + for (int i = 0; i < Main.WIDTH/64; i++) { + bottomWalls[i] = new ShortWall(handler, 64*i, 0, new TextureRegion(wallTexture)); + } + timer = new Timer(handler, Main.WIDTH/2, Main.HEIGHT-(Main.HEIGHT/10+32), null); + + handler.getGameObjectHandler().add(player); + handler.getGameObjectHandler().getGameObjects().addAll(bottomWalls, 0, bottomWalls.length); + } + + @Override + public void update(float dt) { + handler.getGameObjectHandler().update(dt); + arrowGen.update(dt); + wallGen.update(dt); + woodGen.update(dt); + timer.update(dt); + woodGui.update(dt); + if (Gdx.input.isKeyJustPressed(Keys.P)) { + State.setCurrenState(handler.getPauseState()); + State.getCurrentState().init(); + } + } + + @Override + public void render(SpriteBatch batch) { + batch.draw(background, 0, 0, Main.WIDTH, Main.HEIGHT); + handler.getGameObjectHandler().render(batch); + arrowGen.render(batch); + wallGen.render(batch); + woodGen.render(batch); + timer.render(batch); + woodGui.render(batch); + } + + @Override + public void dispose() { + if (background != null) background.dispose(); + if (playerTexture != null) playerTexture.dispose(); + if (arrowTexture != null) arrowTexture.dispose(); + if (wallTexture != null) wallTexture.dispose(); + if (woodTexture != null) woodTexture.dispose(); + if (tallWallTexture != null) tallWallTexture.dispose(); + if (healthTexture != null) healthTexture.dispose(); + if (timer != null) timer.dispose(); + if (woodGui != null) woodGui.dispose(); + } + + //--- Getters and Setters + public Texture getHealthTexture() {return healthTexture;} + public Texture getTallWallTexture() {return tallWallTexture;} + + public Player getPlayer() {return player;} + public Grid getGrid() {return grid;} + public ArrowGenerator getArrowGen() {return arrowGen;} + public WallGenerator getWallGen() {return wallGen;} + public WoodGenerator getWoodGen() {return woodGen;} + public Wall[] getBottomWalls() {return bottomWalls;} + public Timer getTimer() {return timer;} + +} diff --git a/core/src/com/jalenwinslow/game/states/MenuState.java b/core/src/com/jalenwinslow/game/states/MenuState.java new file mode 100644 index 0000000..9b5cea6 --- /dev/null +++ b/core/src/com/jalenwinslow/game/states/MenuState.java @@ -0,0 +1,131 @@ +package com.jalenwinslow.game.states; + +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.jalenwinslow.game.Handler; +import com.jalenwinslow.game.Main; +import com.jalenwinslow.game.gameobjects.Button; +import com.jalenwinslow.game.gameobjects.Player; +import com.jalenwinslow.game.gameobjects.ScoreBoard; +import com.jalenwinslow.game.gameobjects.ShortWall; +import com.jalenwinslow.game.gameobjects.Wall; + +public class MenuState extends State{ + + //--- Propreties + private int subState; + + Texture menuBg; + //Texture playButtonTexture; + Texture buttonTexture; + Texture playerTexture; + Texture wallTexture; + Texture healthTexture; + Texture scoreBoardTexture; + + private Button[] buttons; + private Button backButton; + private Player player; + private Wall[] bottomWalls; + private ScoreBoard scoreBoard; + //private PlayButton playBtn; + + //--- Constructor + public MenuState(Handler handler) { + super(handler); + } + + + //--- Methods + @Override + public void init() { + subState = 0; + + menuBg = new Texture("b&w_DodgeGame_background2.png"); + //playButtonTexture = new Texture("b&w_DodgeGame_playButton.png"); + buttonTexture = new Texture("b&w_DodgeGame_buttons1.png"); + playerTexture = new Texture("b&w_DodgeGame_man1.png"); + wallTexture = new Texture("b&w_DodgeGame_wall1.png"); + healthTexture = new Texture("b&w_DodgeGame_health1.png"); + scoreBoardTexture = new Texture("b&w_DodgeGame_scoreBoard.png"); + buttons = new Button[3]; + buttons[0] = new Button(handler, Main.WIDTH/4-64, Main.HEIGHT*3/4-96, new TextureRegion(buttonTexture), "PLAY", 6); + buttons[1] = new Button(handler, Main.WIDTH*3/4-(64*2), Main.HEIGHT*3/4-96, new TextureRegion(buttonTexture), "STATS", 6); + buttons[2] = new Button(handler, Main.WIDTH/4-64, Main.HEIGHT/4+32, new TextureRegion(buttonTexture), "EXIT", 6 ); + player = new Player(handler, Main.WIDTH/2, Main.HEIGHT/2, new TextureRegion(playerTexture)); + backButton = new Button(handler, Main.WIDTH/2-96, Main.HEIGHT/4-64, new TextureRegion(buttonTexture), "BACK", 6); + bottomWalls = new Wall[Main.WIDTH/64]; + for (int i = 0; i < bottomWalls.length; i++) { + bottomWalls[i] = new ShortWall(handler, 64*i, 0, new TextureRegion(wallTexture)); + } + scoreBoard = new ScoreBoard(handler, Main.WIDTH/8, Main.HEIGHT*3/8, new TextureRegion(scoreBoardTexture)); + handler.getGameObjectHandler().add(player); + handler.getGameObjectHandler().getGameObjects().addAll(bottomWalls, 0, bottomWalls.length); + //playBtn = new PlayButton(handler, Main.WIDTH/2, Main.HEIGHT/2, new TextureRegion(playButtonTexture)); + } + + @Override + public void update(float dt) { + switch (subState) { + case 0: + for (Button button : buttons) { + if (button != null) button.update(dt); + } + break; + case 1: + backButton.update(dt); + break; + default: + + break; + } + handler.getGameObjectHandler().update(dt); + } + + @Override + public void render(SpriteBatch batch) { + batch.draw(menuBg, 0, 0, Main.WIDTH, Main.HEIGHT); + switch (subState) { + case 0: + for (Button button : buttons) { + if (button != null) button.render(batch); + } + break; + case 1: + scoreBoard.render(batch); + backButton.render(batch); + break; + default: + + break; + } + handler.getGameObjectHandler().render(batch); + + } + + @Override + public void dispose() { + menuBg.dispose(); + buttonTexture.dispose(); + playerTexture.dispose(); + wallTexture.dispose(); + healthTexture.dispose(); + scoreBoardTexture.dispose(); + scoreBoard.dispose(); + for (Button button: buttons) {button.dispose();} + backButton.dispose(); + //playButtonTexture.dispose(); + //player = null; + //buttons = null; + //bottomWalls = null; + } + + //--- Getters and Setters + public Player getPlayer() {return player;} + public Texture getHealthTexture() {return healthTexture;} + public int getSubState() {return subState;} + + public void setSubState(int subState) {this.subState = subState;} + +} diff --git a/core/src/com/jalenwinslow/game/states/PauseState.java b/core/src/com/jalenwinslow/game/states/PauseState.java new file mode 100644 index 0000000..00462a7 --- /dev/null +++ b/core/src/com/jalenwinslow/game/states/PauseState.java @@ -0,0 +1,57 @@ +package com.jalenwinslow.game.states; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input.Keys; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.utils.Align; +import com.jalenwinslow.game.Handler; +import com.jalenwinslow.game.Main; + +public class PauseState extends State { + + //--- Propreties + Texture background; + BitmapFont font; + + //--- Constructor + public PauseState(Handler handler) { + super(handler); + } + + + //--- Methods + @Override + public void init() { + background = new Texture("b&w_DodgeGame_gamePaused.png"); + font = new BitmapFont(Gdx.files.internal("customFont4.fnt")); + font.getData().setScale(6); + } + + @Override + public void update(float dt) { + if (Gdx.input.isKeyJustPressed(Keys.P)) { + State.setCurrenState(handler.getGameState()); + dispose(); + } + } + + @Override + public void render(SpriteBatch batch) { + batch.setColor(1, 1, 1, 0.2f); + batch.draw(background, 0, 0, Main.WIDTH, Main.HEIGHT); + batch.setColor(1, 1, 1, 1); + font.draw(batch, "Game Paused", Main.WIDTH/2, Main.HEIGHT/2, 0, Align.center, false); + } + + @Override + public void dispose() { + background.dispose(); + font.dispose(); + } + + //--- Getters and Setters + + +} diff --git a/core/src/com/jalenwinslow/game/states/State.java b/core/src/com/jalenwinslow/game/states/State.java new file mode 100644 index 0000000..5f46c1e --- /dev/null +++ b/core/src/com/jalenwinslow/game/states/State.java @@ -0,0 +1,32 @@ +package com.jalenwinslow.game.states; + +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.jalenwinslow.game.Handler; + +public abstract class State { + + //--- Propreties + protected static State currentState = null; + 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 setCurrenState(State state) {currentState = state;} + +} diff --git a/core/src/com/jalenwinslow/game/utils/Grid.java b/core/src/com/jalenwinslow/game/utils/Grid.java new file mode 100644 index 0000000..e459577 --- /dev/null +++ b/core/src/com/jalenwinslow/game/utils/Grid.java @@ -0,0 +1,59 @@ +package com.jalenwinslow.game.utils; + +import com.badlogic.gdx.Gdx; +import com.jalenwinslow.game.Handler; +import com.jalenwinslow.game.gameobjects.GameObject; + +public class Grid { + + //--- Propreties + private Handler handler; + private int width, height; + private int areaWidth; + private int areaHeight; + private boolean[][] free; + + //--- Constructor + public Grid(Handler handler) { + this.handler = handler; + this.width = Gdx.graphics.getWidth(); + this.height = Gdx.graphics.getHeight(); + this.areaWidth = width/10; + this.areaHeight = width/10; + this.free = new boolean[width/areaWidth][height/areaHeight]; + for (int j = 0; j < free.length; j++) { + for (int i = 0; i < free[j].length; i++) { + free[j][i] = true; + } + } + } + public Grid(Handler handler, int width, int height, int areaWidth, int areaHeight) { + this(handler); + this.width = width; + this.height = height; + this.areaWidth = areaWidth; + this.areaHeight = areaHeight; + this.free = new boolean[width/areaWidth][height/areaHeight]; + for (int j = 0; j < free.length; j++) { + for (int i = 0; i < free[j].length; i++) { + free[j][i] = true; + } + } + } + + + //--- Methods + + + //--- Getters and Setters + public int getWidth() {return width;} + public int getHeight() {return height;} + public int getAreaWidth() {return areaWidth;} + public int getAreaHeight() {return areaHeight;} + public boolean[][] isFree() {return free;} + + public void setFree(boolean free, int i, int j) { + this.free[j][i] = free; + } + +} diff --git a/core/src/com/jalenwinslow/game/utils/Score.java b/core/src/com/jalenwinslow/game/utils/Score.java new file mode 100644 index 0000000..fdd7f6f --- /dev/null +++ b/core/src/com/jalenwinslow/game/utils/Score.java @@ -0,0 +1,83 @@ +package com.jalenwinslow.game.utils; + +import com.jalenwinslow.game.Handler; + +public class Score { + + //--- Propreties + private Handler handler; + + public int currentSecSurvived; + public int highestSecSurvived; + public int highestNumberOfArrowsCreated, highestNumberOfArrowsShotAtOnce; + public int highestNumberOfShortWallsCreated, highestNumberOfShortWallsAtOnce, highestNumberOfShortWallsDestroyed; + public int highestNumberOfTallWallsCreated, highestNumberOfTallWallsAtOnce, highestNumberOfTallWallsDestroyed; + public int highestNumberOfWoodPickedUp; + + + //--- Constructor + public Score(Handler handler) { + this.handler = handler; + } + + + //--- Methods + public void updateScores() { + currentSecSurvived = handler.getGameState().getTimer().getTime(); + if (currentSecSurvived > highestSecSurvived) highestSecSurvived = currentSecSurvived; + + if (handler.getGameState().getArrowGen().getAmountOfArrowsCreated() > highestNumberOfArrowsCreated) + highestNumberOfArrowsCreated = handler.getGameState().getArrowGen().getAmountOfArrowsCreated(); + if (handler.getGameState().getArrowGen().getHighestAmountOfArrowsAtOnce() > highestNumberOfArrowsShotAtOnce) + highestNumberOfArrowsShotAtOnce = handler.getGameState().getArrowGen().getHighestAmountOfArrowsAtOnce(); + + if (handler.getGameState().getWallGen().getHighestNumberOfShortWallsCreated() > highestNumberOfShortWallsCreated) + highestNumberOfShortWallsCreated = handler.getGameState().getWallGen().getHighestNumberOfShortWallsCreated(); + if (handler.getGameObjectHandler().getHighestNumberOfShortWallsAtOnce() > highestNumberOfShortWallsAtOnce) + highestNumberOfShortWallsAtOnce = handler.getGameObjectHandler().getHighestNumberOfShortWallsAtOnce(); + if (handler.getGameState().getWallGen().getHighestNumberOfShortWallsDestroyed() > highestNumberOfShortWallsDestroyed) + highestNumberOfShortWallsDestroyed = handler.getGameState().getWallGen().getHighestNumberOfShortWallsDestroyed(); + + if (handler.getGameState().getPlayer().getHighestNumberOfTallWallsCreated() > highestNumberOfTallWallsCreated) + highestNumberOfTallWallsCreated = handler.getGameState().getPlayer().getHighestNumberOfTallWallsCreated(); + if (handler.getGameObjectHandler().getHighestNumberOfTallWallsAtOnce() > highestNumberOfTallWallsAtOnce) + highestNumberOfTallWallsAtOnce = handler.getGameObjectHandler().getHighestNumberOfTallWallsAtOnce(); + if (handler.getGameState().getPlayer().getHighestNumberOfTallWallsDestroyed() > highestNumberOfTallWallsDestroyed) + highestNumberOfTallWallsDestroyed = handler.getGameState().getPlayer().getHighestNumberOfTallWallsDestroyed(); + + if (handler.getGameState().getPlayer().getNumberOfWoodPickedUp() > highestNumberOfWoodPickedUp) + highestNumberOfWoodPickedUp = handler.getGameState().getPlayer().getNumberOfWoodPickedUp(); + } + + public void getScoresFromFile() { + String[] strings = handler.getScoreFile().readString().split("\n"); + currentSecSurvived = Integer.valueOf(strings[0]); + highestSecSurvived = Integer.valueOf(strings[1]); + + highestNumberOfArrowsCreated = Integer.valueOf(strings[2]); + highestNumberOfArrowsShotAtOnce = Integer.valueOf(strings[3]); + + highestNumberOfShortWallsCreated = Integer.valueOf(strings[4]); + highestNumberOfShortWallsAtOnce = Integer.valueOf(strings[5]); + highestNumberOfShortWallsDestroyed = Integer.valueOf(strings[6]); + + highestNumberOfTallWallsCreated = Integer.valueOf(strings[7]); + highestNumberOfTallWallsAtOnce = Integer.valueOf(strings[8]); + highestNumberOfTallWallsDestroyed = Integer.valueOf(strings[9]); + + highestNumberOfWoodPickedUp = Integer.valueOf(strings[10]); + } + + public void updateScoreFile() { + String message = currentSecSurvived + "\n" + highestSecSurvived + "\n" + + highestNumberOfArrowsCreated + "\n" + highestNumberOfArrowsShotAtOnce + "\n" + + highestNumberOfShortWallsCreated + "\n" + highestNumberOfShortWallsAtOnce + "\n" + highestNumberOfShortWallsDestroyed + "\n" + + highestNumberOfTallWallsCreated + "\n" + highestNumberOfTallWallsAtOnce + "\n" + highestNumberOfTallWallsDestroyed + "\n" + + highestNumberOfWoodPickedUp; + handler.getScoreFile().writeString(message, false); + } + + //--- Getters and Setters + + +} diff --git a/desktop/build.gradle b/desktop/build.gradle new file mode 100644 index 0000000..1790403 --- /dev/null +++ b/desktop/build.gradle @@ -0,0 +1,55 @@ +apply plugin: "java" + +sourceCompatibility = 1.6 +sourceSets.main.java.srcDirs = [ "src/" ] + +project.ext.mainClassName = "com.jalenwinslow.game.desktop.DesktopLauncher" +project.ext.assetsDir = new File("../core/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/core/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) + } +} diff --git a/desktop/src/com/jalenwinslow/game/desktop/DesktopLauncher.java b/desktop/src/com/jalenwinslow/game/desktop/DesktopLauncher.java new file mode 100644 index 0000000..6722223 --- /dev/null +++ b/desktop/src/com/jalenwinslow/game/desktop/DesktopLauncher.java @@ -0,0 +1,15 @@ + package com.jalenwinslow.game.desktop; + +import com.badlogic.gdx.backends.lwjgl.LwjglApplication; +import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; +import com.jalenwinslow.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); + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..339fa15 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.daemon=true +org.gradle.jvmargs=-Xms128m -Xmx1500m +org.gradle.configureondemand=true diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..bafc550 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..0eb9142 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jun 09 23:06:52 EDT 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..4453cce --- /dev/null +++ b/gradlew @@ -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" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..f955316 --- /dev/null +++ b/gradlew.bat @@ -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 diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..74fc652 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include 'desktop', 'core' \ No newline at end of file