diff --git a/Assests/DancingEngi.gif b/Assests/DancingEngi.gif new file mode 100644 index 0000000..7835446 Binary files /dev/null and b/Assests/DancingEngi.gif differ diff --git a/Assests/EnemyBoss.png b/Assests/EnemyBoss.png new file mode 100644 index 0000000..ccbbd1f Binary files /dev/null and b/Assests/EnemyBoss.png differ diff --git a/Assests/Rocket.png b/Assests/Rocket.png index 9cfd59b..e97bd07 100644 Binary files a/Assests/Rocket.png and b/Assests/Rocket.png differ diff --git a/Assests/UI/ButtonPack.atlas b/Assests/UI/ButtonPack.atlas new file mode 100644 index 0000000..7ca86f0 --- /dev/null +++ b/Assests/UI/ButtonPack.atlas @@ -0,0 +1,174 @@ + +ButtonPack.png +size: 2048,512 +format: RGBA8888 +filter: Nearest,Nearest +repeat: none +BackButtonDown + rotate: false + xy: 1381, 373 + size: 216, 50 + orig: 216, 50 + offset: 0, 0 + index: -1 +BackButtonHover + rotate: false + xy: 1270, 321 + size: 216, 50 + orig: 216, 50 + offset: 0, 0 + index: -1 +BackButtonUp + rotate: false + xy: 330, 159 + size: 216, 50 + orig: 216, 50 + offset: 0, 0 + index: -1 +ExitButtonDown + rotate: false + xy: 1806, 373 + size: 205, 50 + orig: 205, 50 + offset: 0, 0 + index: -1 +ExitButtonHover + rotate: false + xy: 1488, 321 + size: 205, 50 + orig: 205, 50 + offset: 0, 0 + index: -1 +ExitButtonUp + rotate: false + xy: 1599, 373 + size: 205, 50 + orig: 205, 50 + offset: 0, 0 + index: -1 +MainMenuButtonDown + rotate: false + xy: 1204, 425 + size: 448, 50 + orig: 448, 50 + offset: 0, 0 + index: -1 +MainMenuButtonHover + rotate: false + xy: 552, 321 + size: 448, 50 + orig: 448, 50 + offset: 0, 0 + index: -1 +MainMenuButtonUp + rotate: false + xy: 603, 373 + size: 448, 50 + orig: 448, 50 + offset: 0, 0 + index: -1 +MultiplayerButtonDown + rotate: false + xy: 604, 425 + size: 598, 50 + orig: 598, 50 + offset: 0, 0 + index: -1 +MultiplayerButtonHover + rotate: false + xy: 2, 373 + size: 599, 50 + orig: 599, 50 + offset: 0, 0 + index: -1 +MultiplayerButtonUp + rotate: false + xy: 2, 425 + size: 600, 50 + orig: 600, 50 + offset: 0, 0 + index: -1 +PlayButtonDown + rotate: false + xy: 2, 2 + size: 212, 50 + orig: 212, 50 + offset: 0, 0 + index: -1 +PlayButtonHover + rotate: false + xy: 268, 55 + size: 212, 50 + orig: 212, 50 + offset: 0, 0 + index: -1 +PlayButtonUp + rotate: false + xy: 270, 107 + size: 212, 50 + orig: 212, 50 + offset: 0, 0 + index: -1 +ResumeButtonDown + rotate: false + xy: 1654, 425 + size: 326, 50 + orig: 326, 50 + offset: 0, 0 + index: -1 +ResumeButtonHover + rotate: false + xy: 1053, 373 + size: 326, 50 + orig: 326, 50 + offset: 0, 0 + index: -1 +ResumeButtonUp + rotate: false + xy: 2, 159 + size: 326, 50 + orig: 326, 50 + offset: 0, 0 + index: -1 +RetryButtonDown + rotate: false + xy: 2, 107 + size: 266, 50 + orig: 266, 50 + offset: 0, 0 + index: -1 +RetryButtonHover + rotate: false + xy: 2, 54 + size: 264, 51 + orig: 264, 51 + offset: 0, 0 + index: -1 +RetryButtonUp + rotate: false + xy: 1002, 321 + size: 266, 50 + orig: 266, 50 + offset: 0, 0 + index: -1 +ScoreBoardButtonDown + rotate: false + xy: 2, 211 + size: 544, 52 + orig: 544, 52 + offset: 0, 0 + index: -1 +ScoreBoardButtonHover + rotate: false + xy: 2, 265 + size: 546, 52 + orig: 546, 52 + offset: 0, 0 + index: -1 +ScoreBoardButtonUp + rotate: false + xy: 2, 319 + size: 548, 52 + orig: 548, 52 + offset: 0, 0 + index: -1 diff --git a/Assests/UI/ButtonPack.json b/Assests/UI/ButtonPack.json new file mode 100644 index 0000000..4227544 --- /dev/null +++ b/Assests/UI/ButtonPack.json @@ -0,0 +1,44 @@ +{ + com.badlogic.gdx.scenes.scene2d.ui.ImageButton$ImageButtonStyle: { + default: { + up: PlayButtonUp + down: PlayButtonDown + over: PlayButtonHover + }, + Play: { + up: PlayButtonUp + down: PlayButtonDown + over: PlayButtonHover + }, + Retry: { + up: RetryButtonUp + down: RetryButtonDown + over: RetryButtonHover + } + Multiplayer: { + up: MultiplayerButtonUp + down: MultiplayerButtonDown + over: MultiplayerButtonHover + }, + ScoreBoard: { + up: ScoreBoardButtonUp + down: ScoreBoardButtonDown + over: ScoreBoardButtonHover + }, + Exit: { + up: ExitButtonUp + down: ExitButtonDown + over: ExitButtonHover + }, + Resume: { + up: ResumeButtonUp + down: ResumeButtonDown + over: ResumeButtonHover + } + MainMenu: { + up: MainMenuButtonUp + down: MainMenuButtonDown + over: MainMenuButtonHover + } + } +} \ No newline at end of file diff --git a/Assests/UI/ButtonPack.png b/Assests/UI/ButtonPack.png new file mode 100644 index 0000000..2fc7394 Binary files /dev/null and b/Assests/UI/ButtonPack.png differ diff --git a/Assests/UI/GAMEOVER.png b/Assests/UI/GAMEOVER.png new file mode 100644 index 0000000..e97a906 Binary files /dev/null and b/Assests/UI/GAMEOVER.png differ diff --git a/Assests/UI/README.md b/Assests/UI/README.md new file mode 100644 index 0000000..46aef25 --- /dev/null +++ b/Assests/UI/README.md @@ -0,0 +1,2 @@ +# UI STUFF +DOWNLOAD EVERYTHING FOR MAIN MENU CODE TO WORK diff --git a/Assests/UI/minecraft.fnt b/Assests/UI/minecraft.fnt new file mode 100644 index 0000000..4eeb839 --- /dev/null +++ b/Assests/UI/minecraft.fnt @@ -0,0 +1,102 @@ +info face="Minecraft" size=32 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=1,1,1,1 spacing=-2,-2 +common lineHeight=35 base=24 scaleW=512 scaleH=512 pages=1 packed=0 +page id=0 file="minecraft.png" +chars count=97 +char id=0 x=194 y=60 width=10 height=23 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=0 +char id=10 x=0 y=0 width=0 height=0 xoffset=-1 yoffset=0 xadvance=0 page=0 chnl=0 +char id=32 x=0 y=0 width=0 height=0 xoffset=-1 yoffset=0 xadvance=10 page=0 chnl=0 +char id=33 x=0 y=60 width=6 height=26 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=0 +char id=34 x=22 y=86 width=18 height=14 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=35 x=114 y=60 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=36 x=80 y=0 width=18 height=30 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=37 x=88 y=60 width=26 height=26 xoffset=1 yoffset=-1 xadvance=28 page=0 chnl=0 +char id=38 x=136 y=60 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=39 x=76 y=86 width=6 height=10 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=0 +char id=40 x=24 y=60 width=14 height=26 xoffset=-1 yoffset=-1 xadvance=14 page=0 chnl=0 +char id=41 x=38 y=60 width=14 height=26 xoffset=-1 yoffset=-1 xadvance=14 page=0 chnl=0 +char id=42 x=496 y=60 width=14 height=14 xoffset=-1 yoffset=-1 xadvance=14 page=0 chnl=0 +char id=43 x=478 y=60 width=18 height=18 xoffset=1 yoffset=3 xadvance=20 page=0 chnl=0 +char id=44 x=82 y=86 width=6 height=10 xoffset=-1 yoffset=19 xadvance=6 page=0 chnl=0 +char id=45 x=102 y=86 width=12 height=6 xoffset=-1 yoffset=13 xadvance=12 page=0 chnl=0 +char id=46 x=96 y=86 width=6 height=6 xoffset=-1 yoffset=19 xadvance=6 page=0 chnl=0 +char id=47 x=52 y=60 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=48 x=492 y=34 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=49 x=326 y=34 width=14 height=26 xoffset=-1 yoffset=-1 xadvance=14 page=0 chnl=0 +char id=50 x=340 y=34 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=51 x=358 y=34 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=52 x=376 y=34 width=20 height=26 xoffset=-1 yoffset=-1 xadvance=20 page=0 chnl=0 +char id=53 x=396 y=34 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=54 x=418 y=34 width=20 height=26 xoffset=-1 yoffset=-1 xadvance=20 page=0 chnl=0 +char id=55 x=438 y=34 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=56 x=456 y=34 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=57 x=474 y=34 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=58 x=420 y=60 width=6 height=20 xoffset=1 yoffset=5 xadvance=8 page=0 chnl=0 +char id=59 x=188 y=60 width=6 height=24 xoffset=1 yoffset=5 xadvance=8 page=0 chnl=0 +char id=60 x=450 y=60 width=14 height=18 xoffset=-1 yoffset=3 xadvance=14 page=0 chnl=0 +char id=61 x=58 y=86 width=18 height=14 xoffset=-1 yoffset=5 xadvance=18 page=0 chnl=0 +char id=62 x=464 y=60 width=14 height=18 xoffset=-1 yoffset=3 xadvance=14 page=0 chnl=0 +char id=63 x=6 y=60 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=64 x=50 y=0 width=30 height=32 xoffset=-1 yoffset=-1 xadvance=30 page=0 chnl=0 +char id=65 x=116 y=0 width=20 height=26 xoffset=-1 yoffset=-1 xadvance=20 page=0 chnl=0 +char id=66 x=136 y=0 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=67 x=158 y=0 width=24 height=26 xoffset=-1 yoffset=-1 xadvance=24 page=0 chnl=0 +char id=68 x=182 y=0 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=69 x=204 y=0 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=70 x=226 y=0 width=20 height=26 xoffset=-1 yoffset=-1 xadvance=20 page=0 chnl=0 +char id=71 x=246 y=0 width=24 height=26 xoffset=-1 yoffset=-1 xadvance=24 page=0 chnl=0 +char id=72 x=270 y=0 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=73 x=292 y=0 width=10 height=26 xoffset=1 yoffset=-1 xadvance=12 page=0 chnl=0 +char id=74 x=302 y=0 width=16 height=26 xoffset=-1 yoffset=-1 xadvance=16 page=0 chnl=0 +char id=75 x=318 y=0 width=20 height=26 xoffset=-1 yoffset=-1 xadvance=20 page=0 chnl=0 +char id=76 x=338 y=0 width=20 height=26 xoffset=-1 yoffset=-1 xadvance=20 page=0 chnl=0 +char id=77 x=358 y=0 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=78 x=380 y=0 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=79 x=402 y=0 width=26 height=26 xoffset=-1 yoffset=-1 xadvance=26 page=0 chnl=0 +char id=80 x=428 y=0 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=81 x=450 y=0 width=26 height=26 xoffset=-1 yoffset=-1 xadvance=26 page=0 chnl=0 +char id=82 x=476 y=0 width=26 height=26 xoffset=-1 yoffset=-1 xadvance=26 page=0 chnl=0 +char id=83 x=0 y=34 width=20 height=26 xoffset=-1 yoffset=-1 xadvance=20 page=0 chnl=0 +char id=84 x=20 y=34 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=85 x=42 y=34 width=20 height=26 xoffset=1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=86 x=62 y=34 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=87 x=84 y=34 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=88 x=106 y=34 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=89 x=128 y=34 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=90 x=150 y=34 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=91 x=30 y=0 width=10 height=32 xoffset=-1 yoffset=-1 xadvance=10 page=0 chnl=0 +char id=92 x=70 y=60 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=93 x=40 y=0 width=10 height=32 xoffset=-1 yoffset=-1 xadvance=10 page=0 chnl=0 +char id=94 x=40 y=86 width=18 height=14 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=95 x=136 y=86 width=20 height=4 xoffset=-1 yoffset=21 xadvance=20 page=0 chnl=0 +char id=96 x=88 y=86 width=8 height=8 xoffset=1 yoffset=-1 xadvance=10 page=0 chnl=0 +char id=97 x=260 y=60 width=20 height=20 xoffset=-1 yoffset=5 xadvance=20 page=0 chnl=0 +char id=98 x=172 y=34 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=99 x=280 y=60 width=20 height=20 xoffset=-1 yoffset=5 xadvance=20 page=0 chnl=0 +char id=100 x=194 y=34 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=101 x=300 y=60 width=18 height=20 xoffset=-1 yoffset=5 xadvance=18 page=0 chnl=0 +char id=102 x=212 y=34 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=103 x=98 y=0 width=18 height=28 xoffset=-1 yoffset=5 xadvance=18 page=0 chnl=0 +char id=104 x=230 y=34 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=105 x=502 y=0 width=6 height=26 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=0 +char id=106 x=248 y=34 width=16 height=26 xoffset=-1 yoffset=3 xadvance=16 page=0 chnl=0 +char id=107 x=264 y=34 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=108 x=282 y=34 width=6 height=26 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=0 +char id=109 x=318 y=60 width=30 height=20 xoffset=-1 yoffset=5 xadvance=30 page=0 chnl=0 +char id=110 x=348 y=60 width=20 height=20 xoffset=-1 yoffset=5 xadvance=20 page=0 chnl=0 +char id=111 x=368 y=60 width=18 height=20 xoffset=-1 yoffset=5 xadvance=18 page=0 chnl=0 +char id=112 x=288 y=34 width=20 height=26 xoffset=-1 yoffset=5 xadvance=20 page=0 chnl=0 +char id=113 x=308 y=34 width=18 height=26 xoffset=-1 yoffset=5 xadvance=18 page=0 chnl=0 +char id=114 x=386 y=60 width=16 height=20 xoffset=-1 yoffset=5 xadvance=16 page=0 chnl=0 +char id=115 x=204 y=60 width=16 height=22 xoffset=-1 yoffset=3 xadvance=16 page=0 chnl=0 +char id=116 x=158 y=60 width=12 height=24 xoffset=-1 yoffset=1 xadvance=12 page=0 chnl=0 +char id=117 x=402 y=60 width=18 height=20 xoffset=-1 yoffset=5 xadvance=18 page=0 chnl=0 +char id=118 x=0 y=86 width=22 height=16 xoffset=-1 yoffset=9 xadvance=22 page=0 chnl=0 +char id=119 x=426 y=60 width=24 height=18 xoffset=-1 yoffset=7 xadvance=24 page=0 chnl=0 +char id=120 x=220 y=60 width=22 height=22 xoffset=-1 yoffset=3 xadvance=22 page=0 chnl=0 +char id=121 x=170 y=60 width=18 height=24 xoffset=-1 yoffset=5 xadvance=18 page=0 chnl=0 +char id=122 x=242 y=60 width=18 height=22 xoffset=-1 yoffset=3 xadvance=18 page=0 chnl=0 +char id=123 x=0 y=0 width=12 height=34 xoffset=-1 yoffset=-1 xadvance=12 page=0 chnl=0 +char id=124 x=24 y=0 width=6 height=34 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=0 +char id=125 x=12 y=0 width=12 height=34 xoffset=-1 yoffset=-1 xadvance=12 page=0 chnl=0 +char id=126 x=114 y=86 width=22 height=6 xoffset=-1 yoffset=9 xadvance=22 page=0 chnl=0 +kernings count=0 diff --git a/Assests/UI/minecraft.png b/Assests/UI/minecraft.png new file mode 100644 index 0000000..128908f Binary files /dev/null and b/Assests/UI/minecraft.png differ diff --git a/Assests/blank.png b/Assests/blank.png new file mode 100644 index 0000000..6e438b2 Binary files /dev/null and b/Assests/blank.png differ diff --git a/Assests/blankBG.png b/Assests/blankBG.png new file mode 100644 index 0000000..dcf0201 Binary files /dev/null and b/Assests/blankBG.png differ diff --git a/Assests/blankHP.png b/Assests/blankHP.png new file mode 100644 index 0000000..7a6b8a6 Binary files /dev/null and b/Assests/blankHP.png differ diff --git a/Assests/coffindance.gif b/Assests/coffindance.gif new file mode 100644 index 0000000..ed4a967 Binary files /dev/null and b/Assests/coffindance.gif differ diff --git a/Game/core/assets/Audio/Astronomia.mp3 b/Game/core/assets/Audio/Astronomia.mp3 new file mode 100644 index 0000000..0d84e9e Binary files /dev/null and b/Game/core/assets/Audio/Astronomia.mp3 differ diff --git a/Game/core/assets/Audio/GiornoTheme.mp3 b/Game/core/assets/Audio/GiornoTheme.mp3 new file mode 100644 index 0000000..4d2e107 Binary files /dev/null and b/Game/core/assets/Audio/GiornoTheme.mp3 differ diff --git a/Game/core/assets/Audio/README.md b/Game/core/assets/Audio/README.md new file mode 100644 index 0000000..45d50c5 --- /dev/null +++ b/Game/core/assets/Audio/README.md @@ -0,0 +1 @@ +# For sounds and stuff diff --git a/Game/core/assets/Audio/ZA-WARUDO.mp3 b/Game/core/assets/Audio/ZA-WARUDO.mp3 new file mode 100644 index 0000000..79299cd Binary files /dev/null and b/Game/core/assets/Audio/ZA-WARUDO.mp3 differ diff --git a/Game/core/assets/ExploRegion3.png b/Game/core/assets/ExploRegion3.png new file mode 100644 index 0000000..5f47ee5 Binary files /dev/null and b/Game/core/assets/ExploRegion3.png differ diff --git a/Game/core/assets/Gif/README.md b/Game/core/assets/Gif/README.md new file mode 100644 index 0000000..8044c20 --- /dev/null +++ b/Game/core/assets/Gif/README.md @@ -0,0 +1 @@ +GIF diff --git a/Game/core/assets/Gif/coffindance.gif b/Game/core/assets/Gif/coffindance.gif new file mode 100644 index 0000000..ed4a967 Binary files /dev/null and b/Game/core/assets/Gif/coffindance.gif differ diff --git a/Game/core/assets/Texture/Boss/EnemyBoss.png b/Game/core/assets/Texture/Boss/EnemyBoss.png new file mode 100644 index 0000000..ccbbd1f Binary files /dev/null and b/Game/core/assets/Texture/Boss/EnemyBoss.png differ diff --git a/Game/core/assets/Texture/Boss/README.md b/Game/core/assets/Texture/Boss/README.md new file mode 100644 index 0000000..18f355c --- /dev/null +++ b/Game/core/assets/Texture/Boss/README.md @@ -0,0 +1 @@ +# BOSS TEXTURE diff --git a/Game/core/assets/Texture/Boss/blank.png b/Game/core/assets/Texture/Boss/blank.png new file mode 100644 index 0000000..6e438b2 Binary files /dev/null and b/Game/core/assets/Texture/Boss/blank.png differ diff --git a/Game/core/assets/Texture/Boss/blankBG.png b/Game/core/assets/Texture/Boss/blankBG.png new file mode 100644 index 0000000..dcf0201 Binary files /dev/null and b/Game/core/assets/Texture/Boss/blankBG.png differ diff --git a/Game/core/assets/Texture/Boss/blankHP.png b/Game/core/assets/Texture/Boss/blankHP.png new file mode 100644 index 0000000..7a6b8a6 Binary files /dev/null and b/Game/core/assets/Texture/Boss/blankHP.png differ diff --git a/Game/core/assets/skin/ArcadeClassic.fnt b/Game/core/assets/skin/ArcadeClassic.fnt new file mode 100644 index 0000000..8a15da1 --- /dev/null +++ b/Game/core/assets/skin/ArcadeClassic.fnt @@ -0,0 +1,71 @@ +info face="ArcadeClassic" size=32 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=1,1,1,1 spacing=-2,-2 +common lineHeight=33 base=26 scaleW=512 scaleH=512 pages=1 packed=0 +page id=0 file="ArcadeClassic.png" +chars count=66 +char id=10 x=0 y=0 width=15 height=28 xoffset=1 yoffset=-1 xadvance=16 page=0 chnl=0 +char id=32 x=0 y=0 width=0 height=0 xoffset=-1 yoffset=25 xadvance=4 page=0 chnl=0 +char id=33 x=146 y=28 width=13 height=18 xoffset=0 yoffset=7 xadvance=22 page=0 chnl=0 +char id=34 x=0 y=0 width=15 height=28 xoffset=1 yoffset=-1 xadvance=16 page=0 chnl=0 +char id=48 x=127 y=28 width=19 height=18 xoffset=-1 yoffset=7 xadvance=18 page=0 chnl=0 +char id=49 x=475 y=0 width=16 height=18 xoffset=1 yoffset=7 xadvance=18 page=0 chnl=0 +char id=50 x=491 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=51 x=0 y=28 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=52 x=18 y=28 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=53 x=36 y=28 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=54 x=54 y=28 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=55 x=72 y=28 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=56 x=90 y=28 width=19 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=57 x=109 y=28 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=65 x=15 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=66 x=33 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=67 x=51 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=68 x=69 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=69 x=87 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=18 page=0 chnl=0 +char id=70 x=105 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=71 x=123 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=72 x=141 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=73 x=159 y=0 width=16 height=18 xoffset=0 yoffset=7 xadvance=17 page=0 chnl=0 +char id=74 x=175 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=75 x=193 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=76 x=211 y=0 width=16 height=18 xoffset=-2 yoffset=7 xadvance=18 page=0 chnl=0 +char id=77 x=227 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=78 x=245 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=79 x=263 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=80 x=281 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=81 x=299 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=82 x=317 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=83 x=335 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=84 x=353 y=0 width=16 height=18 xoffset=-3 yoffset=7 xadvance=17 page=0 chnl=0 +char id=85 x=369 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=86 x=387 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=18 page=0 chnl=0 +char id=87 x=405 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=88 x=423 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=89 x=441 y=0 width=16 height=18 xoffset=0 yoffset=7 xadvance=17 page=0 chnl=0 +char id=90 x=457 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=97 x=15 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=98 x=33 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=99 x=51 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=100 x=69 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=101 x=87 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=18 page=0 chnl=0 +char id=102 x=105 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=103 x=123 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=104 x=141 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=105 x=159 y=0 width=16 height=18 xoffset=0 yoffset=7 xadvance=17 page=0 chnl=0 +char id=106 x=175 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=107 x=193 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=108 x=211 y=0 width=16 height=18 xoffset=-2 yoffset=7 xadvance=18 page=0 chnl=0 +char id=109 x=227 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=110 x=245 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=111 x=263 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=112 x=281 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=113 x=299 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=114 x=317 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=115 x=335 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=116 x=353 y=0 width=16 height=18 xoffset=-3 yoffset=7 xadvance=17 page=0 chnl=0 +char id=117 x=369 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=118 x=387 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=18 page=0 chnl=0 +char id=119 x=405 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=120 x=423 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +char id=121 x=441 y=0 width=16 height=18 xoffset=0 yoffset=7 xadvance=17 page=0 chnl=0 +char id=122 x=457 y=0 width=18 height=18 xoffset=0 yoffset=7 xadvance=19 page=0 chnl=0 +kernings count=0 diff --git a/Game/core/assets/skin/ArcadeClassic.png b/Game/core/assets/skin/ArcadeClassic.png new file mode 100644 index 0000000..475c9d6 Binary files /dev/null and b/Game/core/assets/skin/ArcadeClassic.png differ diff --git a/Game/core/assets/skin/ButtonPack.atlas b/Game/core/assets/skin/ButtonPack.atlas new file mode 100644 index 0000000..da41543 --- /dev/null +++ b/Game/core/assets/skin/ButtonPack.atlas @@ -0,0 +1,195 @@ + +ButtonPack.png +size: 2048,512 +format: RGBA8888 +filter: Nearest,Nearest +repeat: none +BackButtonDown + rotate: false + xy: 1330, 269 + size: 216, 50 + orig: 216, 50 + offset: 0, 0 + index: -1 +BackButtonHover + rotate: false + xy: 270, 55 + size: 216, 50 + orig: 216, 50 + offset: 0, 0 + index: -1 +BackButtonUp + rotate: false + xy: 330, 107 + size: 216, 50 + orig: 216, 50 + offset: 0, 0 + index: -1 +ExitButtonDown + rotate: false + xy: 759, 217 + size: 205, 50 + orig: 205, 50 + offset: 0, 0 + index: -1 +ExitButtonHover + rotate: false + xy: 552, 217 + size: 205, 50 + orig: 205, 50 + offset: 0, 0 + index: -1 +ExitButtonUp + rotate: false + xy: 1548, 269 + size: 205, 50 + orig: 205, 50 + offset: 0, 0 + index: -1 +MainMenuButtonDown + rotate: false + xy: 1262, 373 + size: 448, 50 + orig: 448, 50 + offset: 0, 0 + index: -1 +MainMenuButtonHover + rotate: false + xy: 552, 269 + size: 448, 50 + orig: 448, 50 + offset: 0, 0 + index: -1 +MainMenuButtonUp + rotate: false + xy: 604, 321 + size: 448, 50 + orig: 448, 50 + offset: 0, 0 + index: -1 +MultiplayerButtonDown + rotate: false + xy: 1323, 425 + size: 598, 50 + orig: 598, 50 + offset: 0, 0 + index: -1 +MultiplayerButtonHover + rotate: false + xy: 661, 373 + size: 599, 50 + orig: 599, 50 + offset: 0, 0 + index: -1 +MultiplayerButtonUp + rotate: false + xy: 2, 321 + size: 600, 50 + orig: 600, 50 + offset: 0, 0 + index: -1 +PlayButtonDown + rotate: false + xy: 1712, 373 + size: 212, 50 + orig: 212, 50 + offset: 0, 0 + index: -1 +PlayButtonHover + rotate: false + xy: 1650, 321 + size: 212, 50 + orig: 212, 50 + offset: 0, 0 + index: -1 +PlayButtonUp + rotate: false + xy: 268, 3 + size: 212, 50 + orig: 212, 50 + offset: 0, 0 + index: -1 +ResumeButtonDown + rotate: false + xy: 1002, 269 + size: 326, 50 + orig: 326, 50 + offset: 0, 0 + index: -1 +ResumeButtonHover + rotate: false + xy: 1054, 321 + size: 326, 50 + orig: 326, 50 + offset: 0, 0 + index: -1 +ResumeButtonUp + rotate: false + xy: 2, 107 + size: 326, 50 + orig: 326, 50 + offset: 0, 0 + index: -1 +RetryButtonDown + rotate: false + xy: 1382, 321 + size: 266, 50 + orig: 266, 50 + offset: 0, 0 + index: -1 +RetryButtonHover + rotate: false + xy: 2, 2 + size: 264, 51 + orig: 264, 51 + offset: 0, 0 + index: -1 +RetryButtonUp + rotate: false + xy: 2, 55 + size: 266, 50 + orig: 266, 50 + offset: 0, 0 + index: -1 +ScoreboardButtonDown + rotate: false + xy: 2, 159 + size: 544, 52 + orig: 544, 52 + offset: 0, 0 + index: -1 +ScoreboardButtonHover + rotate: false + xy: 2, 213 + size: 546, 52 + orig: 546, 52 + offset: 0, 0 + index: -1 +ScoreboardButtonUp + rotate: false + xy: 2, 267 + size: 548, 52 + orig: 548, 52 + offset: 0, 0 + index: -1 +SingleplayerButtonDown + rotate: false + xy: 2, 425 + size: 660, 50 + orig: 660, 50 + offset: 0, 0 + index: -1 +SingleplayerButtonHover + rotate: false + xy: 664, 425 + size: 657, 50 + orig: 657, 50 + offset: 0, 0 + index: -1 +SingleplayerButtonUp + rotate: false + xy: 2, 373 + size: 657, 50 + orig: 657, 50 + offset: 0, 0 + index: -1 diff --git a/Game/core/assets/skin/ButtonPack.json b/Game/core/assets/skin/ButtonPack.json new file mode 100644 index 0000000..ad863b2 --- /dev/null +++ b/Game/core/assets/skin/ButtonPack.json @@ -0,0 +1,55 @@ +{ + com.badlogic.gdx.scenes.scene2d.ui.ImageButton$ImageButtonStyle: { + default: { + up: PlayButtonUp + down: PlayButtonDown + over: PlayButtonHover + }, + Play: { + up: PlayButtonUp + down: PlayButtonDown + over: PlayButtonHover + }, + Singleplayer: { + up: SingleplayerButtonUp + down: SingleplayerButtonDown + over: SingleplayerButtonHover + }, + Retry: { + up: RetryButtonUp + down: RetryButtonDown + over: RetryButtonHover + } + Multiplayer: { + up: MultiplayerButtonUp + down: MultiplayerButtonDown + over: MultiplayerButtonHover + }, + ScoreBoard: { + up: ScoreboardButtonUp + down: ScoreboardButtonDown + over: ScoreboardButtonHover + }, + Exit: { + up: ExitButtonUp + down: ExitButtonDown + over: ExitButtonHover + }, + Resume: { + up: ResumeButtonUp + down: ResumeButtonDown + over: ResumeButtonHover + } + MainMenu: { + up: MainMenuButtonUp + down: MainMenuButtonDown + over: MainMenuButtonHover + } + Back: + { + up: BackButtonUp + down: BackButtonDown + over: BackButtonHover + } + } +} \ No newline at end of file diff --git a/Game/core/assets/skin/ButtonPack.png b/Game/core/assets/skin/ButtonPack.png new file mode 100644 index 0000000..cf4125a Binary files /dev/null and b/Game/core/assets/skin/ButtonPack.png differ diff --git a/Game/core/assets/skin/GAMEOVER.png b/Game/core/assets/skin/GAMEOVER.png new file mode 100644 index 0000000..e97a906 Binary files /dev/null and b/Game/core/assets/skin/GAMEOVER.png differ diff --git a/Game/core/assets/skin/GameTitle.png b/Game/core/assets/skin/GameTitle.png new file mode 100644 index 0000000..62b55b6 Binary files /dev/null and b/Game/core/assets/skin/GameTitle.png differ diff --git a/Game/core/assets/skin/Pause.png b/Game/core/assets/skin/Pause.png new file mode 100644 index 0000000..171044e Binary files /dev/null and b/Game/core/assets/skin/Pause.png differ diff --git a/Game/core/assets/skin/README.md b/Game/core/assets/skin/README.md new file mode 100644 index 0000000..7ed66f0 --- /dev/null +++ b/Game/core/assets/skin/README.md @@ -0,0 +1 @@ +# Skin stuff diff --git a/Game/core/assets/skin/Rectangle 1.png b/Game/core/assets/skin/Rectangle 1.png new file mode 100644 index 0000000..28f6afe Binary files /dev/null and b/Game/core/assets/skin/Rectangle 1.png differ diff --git a/Game/core/assets/skin/Textfield.atlas b/Game/core/assets/skin/Textfield.atlas new file mode 100644 index 0000000..8d3142f --- /dev/null +++ b/Game/core/assets/skin/Textfield.atlas @@ -0,0 +1,82 @@ +Textfield.png +size: 2048,2048 +format: RGBA8888 +filter: Linear,Linear +repeat: none +Background_mainmenu + rotate: false + xy: 1, 1243 + size: 1280, 720 + orig: 1280, 720 + offset: 0, 0 + index: -1 +ExitButtonDown + rotate: false + xy: 1283, 1634 + size: 296, 134 + orig: 296, 134 + offset: 0, 0 + index: -1 +ExitButtonHover + rotate: false + xy: 1, 398 + size: 296, 134 + orig: 296, 134 + offset: 0, 0 + index: -1 +ExitButtonUp + rotate: false + xy: 1283, 1498 + size: 296, 134 + orig: 296, 134 + offset: 0, 0 + index: -1 +Group 1 + rotate: false + xy: 1, 1048 + size: 682, 193 + orig: 682, 193 + offset: 0, 0 + index: -1 +PlayButtonDown + rotate: false + xy: 1581, 1634 + size: 296, 134 + orig: 296, 134 + offset: 0, 0 + index: -1 +PlayButtonHover + rotate: false + xy: 1, 262 + size: 296, 134 + orig: 296, 134 + offset: 0, 0 + index: -1 +PlayButtonUp + rotate: false + xy: 1283, 1362 + size: 296, 134 + orig: 296, 134 + offset: 0, 0 + index: -1 +Rectangle 1 + rotate: false + xy: 685, 1151 + size: 489, 90 + orig: 489, 90 + offset: 0, 0 + index: -1 +clicked + rotate: false + xy: 1283, 1770 + size: 682, 193 + orig: 682, 193 + offset: 0, 0 + index: -1 +minecraft + rotate: false + xy: 1, 534 + size: 512, 512 + orig: 512, 512 + offset: 0, 0 + index: -1 \ No newline at end of file diff --git a/Game/core/assets/skin/Textfield.json b/Game/core/assets/skin/Textfield.json new file mode 100644 index 0000000..09fc62d --- /dev/null +++ b/Game/core/assets/skin/Textfield.json @@ -0,0 +1,57 @@ +{ + com.badlogic.gdx.graphics.g2d.BitmapFont: { + minecraft: { + file: minecraft.fnt + } + } + com.badlogic.gdx.graphics.Color: { + RGBA_255_255_255_255: { + r: 1 + g: 1 + b: 1 + a: 1 + } + } + com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable: { + Group 1: { + region: Group 1 + minWidth: 13 + minHeight: 3 + } + } + com.badlogic.gdx.scenes.scene2d.ui.ImageButton$ImageButtonStyle: { + default: { + up: PlayButtonUp + down: PlayButtonDown + over: PlayButtonHover + } + Play: { + up: PlayButtonUp + down: PlayButtonDown + over: PlayButtonHover + } + Exit: { + up: ExitButtonUp + down: ExitButtonDown + over: ExitButtonHover + } + } + com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle: { + default: { + font: minecraft + fontColor: RGBA_255_255_255_255 + } + } + com.badlogic.gdx.scenes.scene2d.ui.TextField$TextFieldStyle: { + default: { + font: minecraft + fontColor: RGBA_255_255_255_255 + background: Rectangle 1 + } + } + com.badlogic.gdx.scenes.scene2d.ui.TextTooltip$TextTooltipStyle: { + default: { + label: default + } + } +} \ No newline at end of file diff --git a/Game/core/assets/skin/Textfield.png b/Game/core/assets/skin/Textfield.png new file mode 100644 index 0000000..d44f513 Binary files /dev/null and b/Game/core/assets/skin/Textfield.png differ diff --git a/Game/core/assets/skin/minecraft.fnt b/Game/core/assets/skin/minecraft.fnt new file mode 100644 index 0000000..4eeb839 --- /dev/null +++ b/Game/core/assets/skin/minecraft.fnt @@ -0,0 +1,102 @@ +info face="Minecraft" size=32 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=1,1,1,1 spacing=-2,-2 +common lineHeight=35 base=24 scaleW=512 scaleH=512 pages=1 packed=0 +page id=0 file="minecraft.png" +chars count=97 +char id=0 x=194 y=60 width=10 height=23 xoffset=0 yoffset=2 xadvance=12 page=0 chnl=0 +char id=10 x=0 y=0 width=0 height=0 xoffset=-1 yoffset=0 xadvance=0 page=0 chnl=0 +char id=32 x=0 y=0 width=0 height=0 xoffset=-1 yoffset=0 xadvance=10 page=0 chnl=0 +char id=33 x=0 y=60 width=6 height=26 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=0 +char id=34 x=22 y=86 width=18 height=14 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=35 x=114 y=60 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=36 x=80 y=0 width=18 height=30 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=37 x=88 y=60 width=26 height=26 xoffset=1 yoffset=-1 xadvance=28 page=0 chnl=0 +char id=38 x=136 y=60 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=39 x=76 y=86 width=6 height=10 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=0 +char id=40 x=24 y=60 width=14 height=26 xoffset=-1 yoffset=-1 xadvance=14 page=0 chnl=0 +char id=41 x=38 y=60 width=14 height=26 xoffset=-1 yoffset=-1 xadvance=14 page=0 chnl=0 +char id=42 x=496 y=60 width=14 height=14 xoffset=-1 yoffset=-1 xadvance=14 page=0 chnl=0 +char id=43 x=478 y=60 width=18 height=18 xoffset=1 yoffset=3 xadvance=20 page=0 chnl=0 +char id=44 x=82 y=86 width=6 height=10 xoffset=-1 yoffset=19 xadvance=6 page=0 chnl=0 +char id=45 x=102 y=86 width=12 height=6 xoffset=-1 yoffset=13 xadvance=12 page=0 chnl=0 +char id=46 x=96 y=86 width=6 height=6 xoffset=-1 yoffset=19 xadvance=6 page=0 chnl=0 +char id=47 x=52 y=60 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=48 x=492 y=34 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=49 x=326 y=34 width=14 height=26 xoffset=-1 yoffset=-1 xadvance=14 page=0 chnl=0 +char id=50 x=340 y=34 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=51 x=358 y=34 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=52 x=376 y=34 width=20 height=26 xoffset=-1 yoffset=-1 xadvance=20 page=0 chnl=0 +char id=53 x=396 y=34 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=54 x=418 y=34 width=20 height=26 xoffset=-1 yoffset=-1 xadvance=20 page=0 chnl=0 +char id=55 x=438 y=34 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=56 x=456 y=34 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=57 x=474 y=34 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=58 x=420 y=60 width=6 height=20 xoffset=1 yoffset=5 xadvance=8 page=0 chnl=0 +char id=59 x=188 y=60 width=6 height=24 xoffset=1 yoffset=5 xadvance=8 page=0 chnl=0 +char id=60 x=450 y=60 width=14 height=18 xoffset=-1 yoffset=3 xadvance=14 page=0 chnl=0 +char id=61 x=58 y=86 width=18 height=14 xoffset=-1 yoffset=5 xadvance=18 page=0 chnl=0 +char id=62 x=464 y=60 width=14 height=18 xoffset=-1 yoffset=3 xadvance=14 page=0 chnl=0 +char id=63 x=6 y=60 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=64 x=50 y=0 width=30 height=32 xoffset=-1 yoffset=-1 xadvance=30 page=0 chnl=0 +char id=65 x=116 y=0 width=20 height=26 xoffset=-1 yoffset=-1 xadvance=20 page=0 chnl=0 +char id=66 x=136 y=0 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=67 x=158 y=0 width=24 height=26 xoffset=-1 yoffset=-1 xadvance=24 page=0 chnl=0 +char id=68 x=182 y=0 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=69 x=204 y=0 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=70 x=226 y=0 width=20 height=26 xoffset=-1 yoffset=-1 xadvance=20 page=0 chnl=0 +char id=71 x=246 y=0 width=24 height=26 xoffset=-1 yoffset=-1 xadvance=24 page=0 chnl=0 +char id=72 x=270 y=0 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=73 x=292 y=0 width=10 height=26 xoffset=1 yoffset=-1 xadvance=12 page=0 chnl=0 +char id=74 x=302 y=0 width=16 height=26 xoffset=-1 yoffset=-1 xadvance=16 page=0 chnl=0 +char id=75 x=318 y=0 width=20 height=26 xoffset=-1 yoffset=-1 xadvance=20 page=0 chnl=0 +char id=76 x=338 y=0 width=20 height=26 xoffset=-1 yoffset=-1 xadvance=20 page=0 chnl=0 +char id=77 x=358 y=0 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=78 x=380 y=0 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=79 x=402 y=0 width=26 height=26 xoffset=-1 yoffset=-1 xadvance=26 page=0 chnl=0 +char id=80 x=428 y=0 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=81 x=450 y=0 width=26 height=26 xoffset=-1 yoffset=-1 xadvance=26 page=0 chnl=0 +char id=82 x=476 y=0 width=26 height=26 xoffset=-1 yoffset=-1 xadvance=26 page=0 chnl=0 +char id=83 x=0 y=34 width=20 height=26 xoffset=-1 yoffset=-1 xadvance=20 page=0 chnl=0 +char id=84 x=20 y=34 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=85 x=42 y=34 width=20 height=26 xoffset=1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=86 x=62 y=34 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=87 x=84 y=34 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=88 x=106 y=34 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=89 x=128 y=34 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=90 x=150 y=34 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=91 x=30 y=0 width=10 height=32 xoffset=-1 yoffset=-1 xadvance=10 page=0 chnl=0 +char id=92 x=70 y=60 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=93 x=40 y=0 width=10 height=32 xoffset=-1 yoffset=-1 xadvance=10 page=0 chnl=0 +char id=94 x=40 y=86 width=18 height=14 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=95 x=136 y=86 width=20 height=4 xoffset=-1 yoffset=21 xadvance=20 page=0 chnl=0 +char id=96 x=88 y=86 width=8 height=8 xoffset=1 yoffset=-1 xadvance=10 page=0 chnl=0 +char id=97 x=260 y=60 width=20 height=20 xoffset=-1 yoffset=5 xadvance=20 page=0 chnl=0 +char id=98 x=172 y=34 width=22 height=26 xoffset=-1 yoffset=-1 xadvance=22 page=0 chnl=0 +char id=99 x=280 y=60 width=20 height=20 xoffset=-1 yoffset=5 xadvance=20 page=0 chnl=0 +char id=100 x=194 y=34 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=101 x=300 y=60 width=18 height=20 xoffset=-1 yoffset=5 xadvance=18 page=0 chnl=0 +char id=102 x=212 y=34 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=103 x=98 y=0 width=18 height=28 xoffset=-1 yoffset=5 xadvance=18 page=0 chnl=0 +char id=104 x=230 y=34 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=105 x=502 y=0 width=6 height=26 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=0 +char id=106 x=248 y=34 width=16 height=26 xoffset=-1 yoffset=3 xadvance=16 page=0 chnl=0 +char id=107 x=264 y=34 width=18 height=26 xoffset=-1 yoffset=-1 xadvance=18 page=0 chnl=0 +char id=108 x=282 y=34 width=6 height=26 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=0 +char id=109 x=318 y=60 width=30 height=20 xoffset=-1 yoffset=5 xadvance=30 page=0 chnl=0 +char id=110 x=348 y=60 width=20 height=20 xoffset=-1 yoffset=5 xadvance=20 page=0 chnl=0 +char id=111 x=368 y=60 width=18 height=20 xoffset=-1 yoffset=5 xadvance=18 page=0 chnl=0 +char id=112 x=288 y=34 width=20 height=26 xoffset=-1 yoffset=5 xadvance=20 page=0 chnl=0 +char id=113 x=308 y=34 width=18 height=26 xoffset=-1 yoffset=5 xadvance=18 page=0 chnl=0 +char id=114 x=386 y=60 width=16 height=20 xoffset=-1 yoffset=5 xadvance=16 page=0 chnl=0 +char id=115 x=204 y=60 width=16 height=22 xoffset=-1 yoffset=3 xadvance=16 page=0 chnl=0 +char id=116 x=158 y=60 width=12 height=24 xoffset=-1 yoffset=1 xadvance=12 page=0 chnl=0 +char id=117 x=402 y=60 width=18 height=20 xoffset=-1 yoffset=5 xadvance=18 page=0 chnl=0 +char id=118 x=0 y=86 width=22 height=16 xoffset=-1 yoffset=9 xadvance=22 page=0 chnl=0 +char id=119 x=426 y=60 width=24 height=18 xoffset=-1 yoffset=7 xadvance=24 page=0 chnl=0 +char id=120 x=220 y=60 width=22 height=22 xoffset=-1 yoffset=3 xadvance=22 page=0 chnl=0 +char id=121 x=170 y=60 width=18 height=24 xoffset=-1 yoffset=5 xadvance=18 page=0 chnl=0 +char id=122 x=242 y=60 width=18 height=22 xoffset=-1 yoffset=3 xadvance=18 page=0 chnl=0 +char id=123 x=0 y=0 width=12 height=34 xoffset=-1 yoffset=-1 xadvance=12 page=0 chnl=0 +char id=124 x=24 y=0 width=6 height=34 xoffset=-1 yoffset=-1 xadvance=6 page=0 chnl=0 +char id=125 x=12 y=0 width=12 height=34 xoffset=-1 yoffset=-1 xadvance=12 page=0 chnl=0 +char id=126 x=114 y=86 width=22 height=6 xoffset=-1 yoffset=9 xadvance=22 page=0 chnl=0 +kernings count=0 diff --git a/Game/core/assets/skin/minecraft.png b/Game/core/assets/skin/minecraft.png new file mode 100644 index 0000000..128908f Binary files /dev/null and b/Game/core/assets/skin/minecraft.png differ diff --git a/Game/core/assets/skin/testingfont.atlas b/Game/core/assets/skin/testingfont.atlas new file mode 100644 index 0000000..2fc2692 --- /dev/null +++ b/Game/core/assets/skin/testingfont.atlas @@ -0,0 +1,13 @@ + +testingfont.png +size: 1024,1024 +format: RGBA8888 +filter: Nearest,Nearest +repeat: none +minecraft + rotate: false + xy: 2, 2 + size: 512, 512 + orig: 512, 512 + offset: 0, 0 + index: -1 diff --git a/Game/core/assets/skin/testingfont.json b/Game/core/assets/skin/testingfont.json new file mode 100644 index 0000000..9691d10 --- /dev/null +++ b/Game/core/assets/skin/testingfont.json @@ -0,0 +1,27 @@ +{ + com.badlogic.gdx.graphics.g2d.BitmapFont: { + minecraft: { + file: minecraft.fnt + } + } + com.badlogic.gdx.graphics.Color: { + RGBA_255_255_255_255: { + r: 1 + g: 1 + b: 1 + a: 1 + } + } + com.badlogic.gdx.scenes.scene2d.ui.TextField$TextFieldStyle: { + default: { + font: minecraft + fontColor: RGBA_255_255_255_255 + } + }, + "com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle": { + "default": { + font: minecraft + fontColor: RGBA_255_255_255_255 + } + } +} \ No newline at end of file diff --git a/Game/core/assets/skin/testingfont.png b/Game/core/assets/skin/testingfont.png new file mode 100644 index 0000000..d903fb5 Binary files /dev/null and b/Game/core/assets/skin/testingfont.png differ diff --git a/Game/core/src/com/mygdx/game/Assets.java b/Game/core/src/com/mygdx/game/Assets.java new file mode 100644 index 0000000..b95a1c8 --- /dev/null +++ b/Game/core/src/com/mygdx/game/Assets.java @@ -0,0 +1,23 @@ +package com.mygdx.game; + +import com.badlogic.gdx.graphics.Texture; + +import com.badlogic.gdx.graphics.Texture; + +public class Assets { + public static Texture texture_bullet; + public static Texture texture_plane; + public static Texture texture_enemy; + public static Texture texture_item; + public static Texture texture_boss; + public static Texture texture_rocket; + + public void load(){ + texture_bullet = new Texture("Texture/Bullets/Bullet.png"); + texture_plane = new Texture("Texture/Player/Spacefighter.png"); + texture_enemy = new Texture("Texture/Enemy/Enemy.png"); + texture_item = new Texture("Texture/Items/Item.png"); + texture_boss = new Texture("Texture/Boss/EnemyBoss.png"); + texture_rocket = new Texture("Texture/Bullets/Rocket.png"); + } +} diff --git a/Game/core/src/com/mygdx/game/Background.java b/Game/core/src/com/mygdx/game/Background.java new file mode 100644 index 0000000..9fa18b7 --- /dev/null +++ b/Game/core/src/com/mygdx/game/Background.java @@ -0,0 +1,89 @@ +package com.mygdx.game; + +import com.badlogic.gdx.ApplicationAdapter; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Camera; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.OrthographicCamera; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.utils.viewport.StretchViewport; +import com.badlogic.gdx.utils.viewport.Viewport; + +public class Background { + + //Screen + private Camera camera; + private Viewport viewport; + + //Graphics + SpriteBatch batch; + Texture[] background; + + //Background movement + private float[] backgroundOffset = {0,0,0,0}; + private float speed; + + //World parameters (Based on the game resolution) + private final int WORLD_WIDTH = 1280; + private final int WORLD_HEIGHT = 720; + + public int getWORLD_WIDTH() {return WORLD_WIDTH;} + public int getWORLD_HEIGHT(){return WORLD_HEIGHT;} + + public void create () { + background = new Texture[4]; + camera = new OrthographicCamera(); + viewport = new StretchViewport(WORLD_WIDTH, WORLD_HEIGHT, camera); + + speed = WORLD_HEIGHT / 2; + + batch = new SpriteBatch(); + + background[0] = new Texture("Texture/Background/Star0.png"); + background[1] = new Texture("Texture/Background/Star1.png"); + background[2] = new Texture("Texture/Background/Star2.png"); + background[3] = new Texture("Texture/Background/Star3.png"); + + } + + public void render () { + float deltaTime = Gdx.graphics.getDeltaTime(); //Time between frames + + batch.begin(); + + MoveBackground(deltaTime); + + batch.end(); + } + + public void MoveBackground(float deltaTime) + { + backgroundOffset[0] += speed/8 * deltaTime; + backgroundOffset[1] += speed/4 * deltaTime; + backgroundOffset[2] += speed/2 * deltaTime; + backgroundOffset[3] += speed * deltaTime; + + for(int i = 0; i < background.length; i++) + { + backgroundOffset[i]++; + if(backgroundOffset[i] > WORLD_HEIGHT) + backgroundOffset[i] = 0; + batch.draw(background[i], 0, -backgroundOffset[i], WORLD_WIDTH, WORLD_HEIGHT); + batch.draw(background[i], 0, -backgroundOffset[i] + WORLD_HEIGHT, WORLD_WIDTH, WORLD_HEIGHT); + } + } + + + public void resize(int width, int height) { + viewport.update(width, height, true); + batch.setProjectionMatrix(camera.combined); + } + + + public void dispose () { + batch.dispose(); + for(int i = 0; i < background.length; i++) + background[i].dispose(); + } +} diff --git a/Game/core/src/com/mygdx/game/Boss.java b/Game/core/src/com/mygdx/game/Boss.java new file mode 100644 index 0000000..38f74c5 --- /dev/null +++ b/Game/core/src/com/mygdx/game/Boss.java @@ -0,0 +1,257 @@ +package com.mygdx.game; + +import UI.GameOverScreen; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.audio.Sound; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.Sprite; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; + +import java.util.ArrayList; +import java.util.Random; + +public class Boss extends GameObj{ + private SpriteBatch batch; + private Sprite sprite; + + public float WORLD_WIDTH; + public float WORLD_HEIGHT; + + //Boss movement + private static float speed = 100f; + + private float des_x, des_y; + private GameObj[] wayPoints; + + private boolean arrived = false; + Random random; + private int posIndex; + + //Player position + private GameObj playerPos = new GameObj(); + ///////////////////////// + + //Boss stats + private float HP = 1; + private int score = 100; + + private float hitBoxWidth; + private float hitBoxHeight; + + private Texture HPTexture, HPBackground; + private float offset_y; + private boolean isDead = false; + ////////////////////////// + + //How fast the boss shoot + private float fireRate = 3f; + private float timeSinceLastFire = 0f; + ArrayList rocketList; + /////////////////////////// + + private Sound sound= Gdx.audio.newSound(Gdx.files.internal("Audio/Explosion3.mp3")); + + public Boss() + { + WORLD_HEIGHT = Gdx.graphics.getHeight(); + WORLD_WIDTH = Gdx.graphics.getWidth(); + + batch = new SpriteBatch(); + + State = true; + + //Setting up boss texture to draw + sprite = new Sprite(Assets.texture_boss); + + //Setting up Hitbox + hitBoxHeight = sprite.getHeight(); + hitBoxWidth = sprite.getWidth(); + + //HPTexture && HPBackground are same size + HPTexture = new Texture(Gdx.files.internal("Texture/Boss/blankHP.png")); + HPBackground = new Texture(Gdx.files.internal("Texture/Boss/blankBG.png")); + + offset_y = HPTexture.getHeight(); + + //Draw boss on top of screen + x = WORLD_WIDTH/2 - sprite.getWidth()/2; + y = WORLD_HEIGHT + sprite.getHeight(); + + //Waypoints for boss movement + wayPoints = new GameObj[3]; + for(int i = 0; i < wayPoints.length; i++) + { + wayPoints[i] = new GameObj(); + wayPoints[i].x = (WORLD_WIDTH/2 - sprite.getWidth()/2) * i; + wayPoints[i].y = WORLD_HEIGHT/2 + sprite.getHeight()/2 * i/2; + } + + random = new Random(); + posIndex = random.nextInt(wayPoints.length); //Index to decide where to go next + des_x = wayPoints[1].x; + des_y = wayPoints[1].y; + + setHitBoxRadius(); + + rocketList = new ArrayList<>(); + + } + + public void render() + { + if(HP > 0) + { + sprite.setPosition(x,y); + + batch.begin(); + sprite.draw(batch); + + //Draw boss's HP bar + batch.draw(HPBackground, WORLD_WIDTH/4, WORLD_HEIGHT - offset_y*100, + WORLD_WIDTH/2 + 2, 22); + + batch.draw(HPTexture, WORLD_WIDTH/4, WORLD_HEIGHT - offset_y*100, + WORLD_WIDTH/2 * HP, 20); + + batch.end(); + + moveBoss(); + shootRocket(); + + for(int i = 0; i < rocketList.size(); i++) + { + rocketList.get(i).render(); + rocketList.get(i).getPlayerPos(playerPos.x, playerPos.y); + } + + timeSinceLastFire += Gdx.graphics.getDeltaTime(); + checkRocket(); + } + + } + + private void moveBoss() + { + if(y > des_y) + y -= speed * Gdx.graphics.getDeltaTime(); + else if(y < des_y) + y += speed * Gdx.graphics.getDeltaTime(); + + if(x > des_x) + x -= speed * Gdx.graphics.getDeltaTime(); + else if(x < des_x) + x += speed * Gdx.graphics.getDeltaTime(); + + if(des_x % x <= 0.1 & des_y % y <= 0.1) + { + arrived = true; + setDes(); + } + else + arrived = false; + } + + private void setDes() + { + posIndex = random.nextInt(3); + des_x = wayPoints[posIndex].x; + des_y = wayPoints[posIndex].y; + } + + public void checkCollision(){ + if (State) + { + checksCollision(); + checkHP(); + } + } + + public void checksCollision(){ + for (int i=0;i= x) && + (Bullet.bullet_arr.elementAt(i).getX() <= x+hitBoxWidth) && + (Bullet.bullet_arr.elementAt(i).getY() >= y) && + (Bullet.bullet_arr.elementAt(i).getY() <= y+hitBoxHeight)) + { + System.out.println("HIT"); + value-=Bullet.bullet_arr.elementAt(i).getValue(); + Bullet.bullet_arr.elementAt(i).Execute(); + HP -= 0.001f; + checkHP(); + } + } + } + } + + public void checkCollisionWithPlayer() + { + if((playerPos.x >= x) && + (playerPos.x <= x+hitBoxWidth) && + (playerPos.y >= y) && + (playerPos.y <= y+hitBoxHeight)) + { + MyGdxGame.player.State = false; + MyGdxGame.player.id = 0; + } + } + + private void checkHP() + { + if(HP <= 0) + { + Execute(); + } + } + + private void Execute() + { + sound.dispose(); + State=false; + id=0; + GameOverScreen.score += score; + } + + private void setHitBoxRadius() + { + hitboxRadius = sprite.getHeight()/2; + } + + public void getPlayerPos(float x, float y) + { + playerPos.x = x; + playerPos.y = y; + } + + public void shootRocket() { + if (timeSinceLastFire >= fireRate) + { + rocketList.add(new Rocket(x, y)); + rocketList.add(new Rocket(x+sprite.getWidth(), y)); + + System.out.println(rocketList.size()); + timeSinceLastFire = 0f; + } + } + + private void checkRocket() + { + for(int i = 0; i < rocketList.size(); i++) + { + if(!rocketList.get(i).State) + { + sound.play(); + rocketList.remove(i); + System.out.println("DEAD"); + } + } + } + + public void dispose() + { + sound.dispose(); + batch.dispose(); + } +} diff --git a/Game/core/src/com/mygdx/game/Bullet.java b/Game/core/src/com/mygdx/game/Bullet.java new file mode 100644 index 0000000..718a6ec --- /dev/null +++ b/Game/core/src/com/mygdx/game/Bullet.java @@ -0,0 +1,179 @@ +package com.mygdx.game; + +import com.badlogic.gdx.ApplicationAdapter; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; + +import java.util.Vector; +import java.lang.Math; + +public class Bullet extends GameObj { + private SpriteBatch batch; + private long t=0l; + private static Bullet fakebase=new Bullet(0,0,0); + public static Vector bullet_arr=new Vector<>(); + + private Bullet(float x_c, float y_c, float xfromhost, float yfromhost, int Id) { + x = x_c + xfromhost; + x_b = x_c; + y = y_c + yfromhost; + y_b = y_c; + moveId = Id*100; + id=Id; + State=true; + t=System.currentTimeMillis(); + } + + private Bullet(float x_c, float y_c, int Id) { + x = x_c; + x_b = x_c; + y = y_c; + y_b = y_c; + id = Id; + } + + public static void resetfakebase(){ + fakebase.x_b=MyGdxGame.player.getX(); + fakebase.y_b=MyGdxGame.player.getY(); + } + + public void setX_move(float x_move) { this.x_move = x_move; } + + public void setY_move(float y_move) { + this.y_move = y_move; + } + + private void create() { + batch = new SpriteBatch(); + } + + private void renders() { // loop + batch.begin(); + batch.draw(Assets.texture_bullet, (int)(x- (Assets.texture_bullet.getWidth()*scale/2)),(int)(y- (Assets.texture_bullet.getHeight()*scale/2)),Assets.texture_bullet.getWidth()*scale,Assets.texture_bullet.getHeight()*scale); + batch.end(); + y += y_move; + x += x_move; + } + + public static void render() { + for (int i = 0; i < bullet_arr.size(); i++) { + if (bullet_arr.elementAt(i).State) { + bullet_arr.elementAt(i).setMove(); + bullet_arr.elementAt(i).renders(); + } + } + } + + public void dispose() { + batch.dispose(); + } + + public static void Bullet_Reallo(float x_c, float y_c, float x_offset, float y_offset,int id) { + int BulletGen = 0; + loop: while (BulletGen == 0) { + // need change to replace DED value with ALIVE value in order for the vector not to be too long, waste of memory + for (int i = 0; i < bullet_arr.size(); i++) { //there exists at least an element in the array + if (bullet_arr.elementAt(i).isDed()) { // there is 1 dead bullet + bullet_arr.elementAt(i).Revive(x_c, y_c, x_offset,y_offset,id);//revive it as a new bullet + BulletGen = 1; + + /*Gdx.app.log("Log", "Bullet number "+i+" revived");*/ + continue loop; + } + } + // if the code get here, there is NO dead bullet in the array + bullet_arr.addElement(new Bullet(x_c, y_c,x_offset,y_offset,id));// create a new bullet + bullet_arr.lastElement().setParam(); + bullet_arr.lastElement().create(); + BulletGen = 1; + } + } + + public boolean isDed() { + return !State; + } + + private void Revive(float x_c,float y_c, float x_offset, float y_offset,int id){ + this.x_b=x_c; + this.y_b=y_c; + this.x=x_c+x_offset; + this.y=y_c+y_offset; + this.id=id; + this.moveId=id*100; + this.State=true; + setHitboxRadius(); + setValue(); + t=System.currentTimeMillis(); + } + + public void Execute(){ + State=false; + id=0; + } + + /* ---------------------------------------------------------------------- + * ---------------------------------------------------------------------- + * --------------------------Edit - add more----------------------------- + * -------------------Bullets' hitbox, value, orbit---------------------- + * ---------------------------------------------------------------------- + * ----------------------------------------------------------------------*/ + + private void setHitboxRadius() { + switch (id){ + case -1: + case -2: + case -3: + case 1: + hitboxRadius=((float)Assets.texture_bullet.getHeight()+(float)Assets.texture_bullet.getWidth())/4; + break; + } + } + + private void setValue(){ + value=1; + } + + private void setMove() { //Furthermore edit bullet orbit here + X = x - x_b; + Y = y - y_b; + D = Math.sqrt((double) X * (double) X + (double) Y * (double) Y); + switch (moveId) { + case -100://straight + speed=10; + moveId=1; + break; + case -200://spin around host + speed=10/(float)Math.sqrt(D); + moveId=2; + break; + case -300: + x_b=fakebase.x_b; + y_b=fakebase.y_b; + moveId=-100; + break; + case 100: + speed=3; + moveId+=1; + break; + } + switch (moveId%10) { // Default and simple move + case 1: //straight + setX_move(speed * X / (float) D); + setY_move(speed * Y / (float) D); + if((x>1280)||(x<0)||(y<0)||(y>720)) Execute(); + break; + case 2: //spin and keep distance + setX_move(((Y-X*0.1f)*speed/(float)D)); + setY_move(((-X-Y*0.1f)*speed/(float)D)); + if (System.currentTimeMillis()-t>5000) Execute(); + break; + case 3: //spin and spread + setX_move(((Y+X*0.3f)*speed/(float)D)); + setY_move(((-X+Y*0.3f)*speed/(float)D)); + break; + } + } +} diff --git a/Game/core/src/com/mygdx/game/Enemy.java b/Game/core/src/com/mygdx/game/Enemy.java new file mode 100644 index 0000000..1904840 --- /dev/null +++ b/Game/core/src/com/mygdx/game/Enemy.java @@ -0,0 +1,267 @@ +package com.mygdx.game; + +import UI.GameOverScreen; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; + +import java.util.ArrayList; +import java.util.Random; +import java.util.Vector; + +public class Enemy extends GameObj { + private SpriteBatch batch; + private long t=0; + private long t1=0; + private long point; + private long Wave; + public static Vector enemy_arr=new Vector<>(); + + private Random randPara= new Random(); + + public Explosion explosion; + + private int score; + public boolean isDead = false; + + public Enemy(float x_c, float y_c, int Id, int Wave) { + x = x_c; + x_b = x_c; + y = y_c; + y_b = y_c; + id = Id; + moveId=Id; + + State=true; + this.Wave=Wave; + setPoint(); + setValue(); + setHitboxRadius(); + t=t1=System.currentTimeMillis(); + + explosion = new Explosion(); + } + + public void create() { + batch = new SpriteBatch(); + } + + public static void render() { + for (int i = 0; i < enemy_arr.size(); i++) { + if (enemy_arr.elementAt(i).State) { + enemy_arr.elementAt(i).setMove(); + enemy_arr.elementAt(i).renders(); + } + } + } + public void setX_move(float x_move){this.x_move=x_move;} + public void setY_move(float y_move){this.y_move=y_move;} + + public boolean isDed() { + return !State; + } + + public boolean isExecuted() { + if ((value<0)&&State){ + State=false; + return true; + } + return false; + } + + public void renders() { // loop + System.out.println(id); + + batch.begin(); + batch.draw(Assets.texture_enemy, (int)(x- (Assets.texture_enemy.getWidth()*scale)),(int)(y- (Assets.texture_enemy.getHeight()*scale)),Assets.texture_enemy.getWidth(),Assets.texture_enemy.getHeight()); + batch.end(); + y += y_move; + x += x_move; + explosion.setPos(x,y); +// if(!State) +// explosion.draw(x,y); + } + + public static void fire(){ + for (int i=0; i800)) x_move=-x_move; + if ((y+y_move<480)||(y+y_move>720)) y_move=-y_move; + if ((System.currentTimeMillis()-t1>10000)&&(x>640)) x_move=2; + if ((System.currentTimeMillis()-t1>10000)&&(x<640)) x_move=-2; + if ((x<0)||(x>1280)) State=false; + break; + case 2: + x_move=0; + y_move=-1; + if(System.currentTimeMillis()-t1>2000) y_move=0; + if(System.currentTimeMillis()-t1>7000) y_move=1; + if(System.currentTimeMillis()-t1>10000) State=false; + break; + case 3: + x_move=2; + y_move=0; + if(x>1280) State=false; + break; + } + } + //Furthermore edit enemy move here + + private void Bullet_Call() { //Furthermore edit here + X = x - MyGdxGame.player.x; + Y = y - MyGdxGame.player.y; + D = Math.sqrt((double) X * (double) X + (double) Y * (double) Y); + switch (id) { + case 1: + if ((System.currentTimeMillis() - t) > 1000 - Wave * 10) { + Bullet.Bullet_Reallo(x, y, -X / (float) D, -Y / (float) D, 1); + Bullet.Bullet_Reallo(x - 10, y, -X / (float) D, -Y / (float) D, 1); + Bullet.Bullet_Reallo(x + 10, y, -X / (float) D, -Y / (float) D, 1); + t = System.currentTimeMillis(); + } + break; + case 2: + case 3: + if ((System.currentTimeMillis() - t) > 1000) { + Bullet.Bullet_Reallo(x, y, -X / (float) D, -Y / (float) D, 1); + Bullet.Bullet_Reallo(x - 20, y, -(X - 20) / (float) D, -Y / (float) D, 1); + Bullet.Bullet_Reallo(x + 20, y, -(X + 20) / (float) D, -Y / (float) D, 1); + t=System.currentTimeMillis(); + } + break; + } + } + //edit enemy shooting + + public void setValue(){ + switch (id) { + case 1: + value=10+Wave*2; + break; + case 2: + value=5+Wave; + break; + case 3: + value=10+Wave; + break; + } + } + //set enemy HP base on id + + public void setPoint(){ + switch (id){ + case 1: + case 2: + case 3: + point=1; + break; + } + } + //set enemy point base on id + + public void setHitboxRadius(){ + switch (id){ + case 1: + case 2: + case 3: + hitboxRadius=20; + break; + } + } + //set enemy hitbox base on id + +} diff --git a/Game/core/src/com/mygdx/game/Explosion.java b/Game/core/src/com/mygdx/game/Explosion.java new file mode 100644 index 0000000..1d545b2 --- /dev/null +++ b/Game/core/src/com/mygdx/game/Explosion.java @@ -0,0 +1,60 @@ +package com.mygdx.game; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.Animation; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.g2d.TextureRegion; + +public class Explosion { + SpriteBatch batch; + Texture img; + TextureRegion[] animationFrame; + Animation animation; + + public float elapsedTime = 0; + public float frameDuration = 0.1f; + + private float offset = 40; + + public float x,y; + public boolean isDone = false; + + public Explosion () { + batch = new SpriteBatch(); + img = new Texture("ExploRegion3.png"); + + animationFrame = new TextureRegion[4]; // animation with 4 frame + TextureRegion[][] tempFrame = TextureRegion.split(img, 70,71); //Dividing the .png into a grid + + int temp = 0; + for(int i = 0; i < 2; i++) + { + for(int j = 0; j < 2; j++) + animationFrame[temp++] = tempFrame[i][j]; //Fill up the animation frame with frames + } + + animation = new Animation(frameDuration, animationFrame); + } + + public void draw() { + elapsedTime += Gdx.graphics.getDeltaTime(); + System.out.println("DRAW"); + batch.begin(); + batch.draw((TextureRegion) animation.getKeyFrame(elapsedTime, false), x - offset, y - offset); + batch.end(); + isDone = animation.isAnimationFinished(elapsedTime); + } + + public void setPos(float x, float y) + { + this.x = x; + this.y = y; + } + + public void dispose () { + batch.dispose(); + img.dispose(); + } +} diff --git a/Game/core/src/com/mygdx/game/GameObj.java b/Game/core/src/com/mygdx/game/GameObj.java new file mode 100644 index 0000000..62d87ed --- /dev/null +++ b/Game/core/src/com/mygdx/game/GameObj.java @@ -0,0 +1,57 @@ +package com.mygdx.game; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.Texture; + +import java.util.Random; + +public class GameObj { + protected float x; + protected float y; + private Background bg=new Background(); + protected float cali_x=bg.getWORLD_WIDTH()/1280; + protected float cali_y=bg.getWORLD_HEIGHT()/720; + protected float x_b; + protected float y_b; + protected float x_move; + protected float y_move; + protected float X; + protected float Y; + protected double D; + public int S_width; + public int S_height; + protected float scale = 0.3f; + Texture art; + protected int id; //negative for player, positive for enemy + protected int moveId; + protected boolean State; + protected long value; + protected float hitboxRadius; + protected float speed; + protected Random randPara= new Random(); + + + + public void setParam(){ + this.S_width=Gdx.graphics.getWidth(); + this.S_height=Gdx.graphics.getHeight(); + } + public void setScale(float scale){ + this.scale = scale; + } + + public float getX() { + return x; + } + + public float getY() { + return y; + } + + public long getValue() { return value;} + public void dispose(){ + + art.dispose(); + + } +} diff --git a/Game/core/src/com/mygdx/game/GifDecoder.java b/Game/core/src/com/mygdx/game/GifDecoder.java new file mode 100644 index 0000000..851c77a --- /dev/null +++ b/Game/core/src/com/mygdx/game/GifDecoder.java @@ -0,0 +1,735 @@ +package UI; + +import com.badlogic.gdx.graphics.Pixmap; +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.TextureRegion; +import com.badlogic.gdx.utils.Array; + +import java.io.InputStream; +import java.util.Vector; + +public class GifDecoder { + /** + * File read status: No errors. + */ + public static final int STATUS_OK = 0; + /** + * File read status: Error decoding file (may be partially decoded) + */ + public static final int STATUS_FORMAT_ERROR = 1; + /** + * File read status: Unable to open source. + */ + public static final int STATUS_OPEN_ERROR = 2; + /** max decoder pixel stack size */ + protected static final int MAX_STACK_SIZE = 4096; + protected InputStream in; + protected int status; + protected int width; // full image width + protected int height; // full image height + protected boolean gctFlag; // global color table used + protected int gctSize; // size of global color table + protected int loopCount = 1; // iterations; 0 = repeat forever + protected int[] gct; // global color table + protected int[] lct; // local color table + protected int[] act; // active color table + protected int bgIndex; // background color index + protected int bgColor; // background color + protected int lastBgColor; // previous bg color + protected int pixelAspect; // pixel aspect ratio + protected boolean lctFlag; // local color table flag + protected boolean interlace; // interlace flag + protected int lctSize; // local color table size + protected int ix, iy, iw, ih; // current image rectangle + protected int lrx, lry, lrw, lrh; + protected DixieMap image; // current frame + protected DixieMap lastPixmap; // previous frame + protected byte[] block = new byte[256]; // current data block + protected int blockSize = 0; // block size last graphic control extension info + protected int dispose = 0; // 0=no action; 1=leave in place; 2=restore to bg; 3=restore to prev + protected int lastDispose = 0; + protected boolean transparency = false; // use transparent color + protected int delay = 0; // delay in milliseconds + protected int transIndex; // transparent color index + // LZW decoder working arrays + protected short[] prefix; + protected byte[] suffix; + protected byte[] pixelStack; + protected byte[] pixels; + protected Vector frames; // frames read from current file + protected int frameCount; + + private static class DixieMap extends Pixmap { + DixieMap(int w, int h, Format f) { + super(w, h, f); + } + + DixieMap(int[] data, int w, int h, Format f) { + super(w, h, f); + + int x, y; + + for(y = 0; y < h; y++) { + for(x = 0; x < w; x++) { + int pxl_ARGB8888 = data[x + y * w]; + int pxl_RGBA8888 = + ((pxl_ARGB8888 >> 24) & 0x000000ff) | ((pxl_ARGB8888 << 8) & 0xffffff00); + // convert ARGB8888 > RGBA8888 + drawPixel(x, y, pxl_RGBA8888); + } + } + } + + void getPixels(int[] pixels, int offset, int stride, int x, int y, int width, int height) { + java.nio.ByteBuffer bb = getPixels(); + + int k, l; + + for(k = y; k < y + height; k++) { + int _offset = offset; + for(l = x; l < x + width; l++) { + int pxl = bb.getInt(4 * (l + k * width)); + + // convert RGBA8888 > ARGB8888 + pixels[_offset++] = ((pxl >> 8) & 0x00ffffff) | ((pxl << 24) & 0xff000000); + } + offset += stride; + } + } + } + + private static class GifFrame { + public GifFrame(DixieMap im, int del) { + image = im; + delay = del; + } + + public DixieMap image; + public int delay; + } + + /** + * Gets display duration for specified frame. + * + * @param n + * int index of frame + * @return delay in milliseconds + */ + public int getDelay(int n) { + delay = -1; + if ((n >= 0) && (n < frameCount)) { + delay = frames.elementAt(n).delay; + } + return delay; + } + + /** + * Gets the number of frames read from file. + * + * @return frame count + */ + public int getFrameCount() { + return frameCount; + } + + /** + * Gets the first (or only) image read. + * + * @return BufferedPixmap containing first frame, or null if none. + */ + public Pixmap getPixmap() { + return getFrame(0); + } + + /** + * Gets the "Netscape" iteration count, if any. A count of 0 means repeat indefinitely. + * + * @return iteration count if one was specified, else 1. + */ + public int getLoopCount() { + return loopCount; + } + + /** + * Creates new frame image from current data (and previous frames as specified by their disposition codes). + */ + protected void setPixels() { + // expose destination image's pixels as int array + int[] dest = new int[width * height]; + // fill in starting image contents based on last image's dispose code + if (lastDispose > 0) { + if (lastDispose == 3) { + // use image before last + int n = frameCount - 2; + if (n > 0) { + lastPixmap = getFrame(n - 1); + } else { + lastPixmap = null; + } + } + if (lastPixmap != null) { + lastPixmap.getPixels(dest, 0, width, 0, 0, width, height); + // copy pixels + if (lastDispose == 2) { + // fill last image rect area with background color + int c = 0; + if (!transparency) { + c = lastBgColor; + } + for (int i = 0; i < lrh; i++) { + int n1 = (lry + i) * width + lrx; + int n2 = n1 + lrw; + for (int k = n1; k < n2; k++) { + dest[k] = c; + } + } + } + } + } + // copy each source line to the appropriate place in the destination + int pass = 1; + int inc = 8; + int iline = 0; + for (int i = 0; i < ih; i++) { + int line = i; + if (interlace) { + if (iline >= ih) { + pass++; + switch (pass) { + case 2: + iline = 4; + break; + case 3: + iline = 2; + inc = 4; + break; + case 4: + iline = 1; + inc = 2; + break; + default: + break; + } + } + line = iline; + iline += inc; + } + line += iy; + if (line < height) { + int k = line * width; + int dx = k + ix; // start of line in dest + int dlim = dx + iw; // end of dest line + if ((k + width) < dlim) { + dlim = k + width; // past dest edge + } + int sx = i * iw; // start of line in source + while (dx < dlim) { + // map color and insert in destination + int index = ((int) pixels[sx++]) & 0xff; + int c = act[index]; + if (c != 0) { + dest[dx] = c; + } + dx++; + } + } + } + image = new DixieMap(dest, width, height, Pixmap.Format.RGBA8888); + //Pixmap.createPixmap(dest, width, height, Config.ARGB_4444); + } + + /** + * Gets the image contents of frame n. + * + * @return BufferedPixmap representation of frame, or null if n is invalid. + */ + public DixieMap getFrame(int n) { + if (frameCount <= 0) + return null; + n = n % frameCount; + return ((GifFrame) frames.elementAt(n)).image; + } + + /** + * Reads GIF image from stream + * + * @param is + * containing GIF file. + * @return read status code (0 = no errors) + */ + public int read(InputStream is) { + init(); + if (is != null) { + in = is; + readHeader(); + if (!err()) { + readContents(); + if (frameCount < 0) { + status = STATUS_FORMAT_ERROR; + } + } + } else { + status = STATUS_OPEN_ERROR; + } + try { + is.close(); + } catch (Exception e) { + } + return status; + } + + /** + * Decodes LZW image data into pixel array. Adapted from John Cristy's BitmapMagick. + */ + protected void decodeBitmapData() { + int nullCode = -1; + int npix = iw * ih; + int available, clear, code_mask, code_size, end_of_information, in_code, old_code, bits, code, count, i, datum, data_size, first, top, bi, pi; + if ((pixels == null) || (pixels.length < npix)) { + pixels = new byte[npix]; // allocate new pixel array + } + if (prefix == null) { + prefix = new short[MAX_STACK_SIZE]; + } + if (suffix == null) { + suffix = new byte[MAX_STACK_SIZE]; + } + if (pixelStack == null) { + pixelStack = new byte[MAX_STACK_SIZE + 1]; + } + // Initialize GIF data stream decoder. + data_size = read(); + clear = 1 << data_size; + end_of_information = clear + 1; + available = clear + 2; + old_code = nullCode; + code_size = data_size + 1; + code_mask = (1 << code_size) - 1; + for (code = 0; code < clear; code++) { + prefix[code] = 0; // XXX ArrayIndexOutOfBoundsException + suffix[code] = (byte) code; + } + // Decode GIF pixel stream. + datum = bits = count = first = top = pi = bi = 0; + for (i = 0; i < npix;) { + if (top == 0) { + if (bits < code_size) { + // Load bytes until there are enough bits for a code. + if (count == 0) { + // Read a new data block. + count = readBlock(); + if (count <= 0) { + break; + } + bi = 0; + } + datum += (((int) block[bi]) & 0xff) << bits; + bits += 8; + bi++; + count--; + continue; + } + // Get the next code. + code = datum & code_mask; + datum >>= code_size; + bits -= code_size; + // Interpret the code + if ((code > available) || (code == end_of_information)) { + break; + } + if (code == clear) { + // Reset decoder. + code_size = data_size + 1; + code_mask = (1 << code_size) - 1; + available = clear + 2; + old_code = nullCode; + continue; + } + if (old_code == nullCode) { + pixelStack[top++] = suffix[code]; + old_code = code; + first = code; + continue; + } + in_code = code; + if (code == available) { + pixelStack[top++] = (byte) first; + code = old_code; + } + while (code > clear) { + pixelStack[top++] = suffix[code]; + code = prefix[code]; + } + first = ((int) suffix[code]) & 0xff; + // Add a new string to the string table, + if (available >= MAX_STACK_SIZE) { + break; + } + pixelStack[top++] = (byte) first; + prefix[available] = (short) old_code; + suffix[available] = (byte) first; + available++; + if (((available & code_mask) == 0) && (available < MAX_STACK_SIZE)) { + code_size++; + code_mask += available; + } + old_code = in_code; + } + // Pop a pixel off the pixel stack. + top--; + pixels[pi++] = pixelStack[top]; + i++; + } + for (i = pi; i < npix; i++) { + pixels[i] = 0; // clear missing pixels + } + } + + /** + * Returns true if an error was encountered during reading/decoding + */ + protected boolean err() { + return status != STATUS_OK; + } + + /** + * Initializes or re-initializes reader + */ + protected void init() { + status = STATUS_OK; + frameCount = 0; + frames = new Vector(); + gct = null; + lct = null; + } + + /** + * Reads a single byte from the input stream. + */ + protected int read() { + int curByte = 0; + try { + curByte = in.read(); + } catch (Exception e) { + status = STATUS_FORMAT_ERROR; + } + return curByte; + } + + /** + * Reads next variable length block from input. + * + * @return number of bytes stored in "buffer" + */ + protected int readBlock() { + blockSize = read(); + int n = 0; + if (blockSize > 0) { + try { + int count = 0; + while (n < blockSize) { + count = in.read(block, n, blockSize - n); + if (count == -1) { + break; + } + n += count; + } + } catch (Exception e) { + e.printStackTrace(); + } + if (n < blockSize) { + status = STATUS_FORMAT_ERROR; + } + } + return n; + } + + /** + * Reads color table as 256 RGB integer values + * + * @param ncolors + * int number of colors to read + * @return int array containing 256 colors (packed ARGB with full alpha) + */ + protected int[] readColorTable(int ncolors) { + int nbytes = 3 * ncolors; + int[] tab = null; + byte[] c = new byte[nbytes]; + int n = 0; + try { + n = in.read(c); + } catch (Exception e) { + e.printStackTrace(); + } + if (n < nbytes) { + status = STATUS_FORMAT_ERROR; + } else { + tab = new int[256]; // max size to avoid bounds checks + int i = 0; + int j = 0; + while (i < ncolors) { + int r = ((int) c[j++]) & 0xff; + int g = ((int) c[j++]) & 0xff; + int b = ((int) c[j++]) & 0xff; + tab[i++] = 0xff000000 | (r << 16) | (g << 8) | b; + } + } + return tab; + } + + /** + * Main file parser. Reads GIF content blocks. + */ + protected void readContents() { + // read GIF file content blocks + boolean done = false; + while (!(done || err())) { + int code = read(); + switch (code) { + case 0x2C: // image separator + readBitmap(); + break; + case 0x21: // extension + code = read(); + switch (code) { + case 0xf9: // graphics control extension + readGraphicControlExt(); + break; + case 0xff: // application extension + readBlock(); + String app = ""; + for (int i = 0; i < 11; i++) { + app += (char) block[i]; + } + if (app.equals("NETSCAPE2.0")) { + readNetscapeExt(); + } else { + skip(); // don't care + } + break; + case 0xfe:// comment extension + skip(); + break; + case 0x01:// plain text extension + skip(); + break; + default: // uninteresting extension + skip(); + } + break; + case 0x3b: // terminator + done = true; + break; + case 0x00: // bad byte, but keep going and see what happens break; + default: + status = STATUS_FORMAT_ERROR; + } + } + } + + /** + * Reads Graphics Control Extension values + */ + protected void readGraphicControlExt() { + read(); // block size + int packed = read(); // packed fields + dispose = (packed & 0x1c) >> 2; // disposal method + if (dispose == 0) { + dispose = 1; // elect to keep old image if discretionary + } + transparency = (packed & 1) != 0; + delay = readShort() * 10; // delay in milliseconds + transIndex = read(); // transparent color index + read(); // block terminator + } + + /** + * Reads GIF file header information. + */ + protected void readHeader() { + String id = ""; + for (int i = 0; i < 6; i++) { + id += (char) read(); + } + if (!id.startsWith("GIF")) { + status = STATUS_FORMAT_ERROR; + return; + } + readLSD(); + if (gctFlag && !err()) { + gct = readColorTable(gctSize); + bgColor = gct[bgIndex]; + } + } + + /** + * Reads next frame image + */ + protected void readBitmap() { + ix = readShort(); // (sub)image position & size + iy = readShort(); + iw = readShort(); + ih = readShort(); + int packed = read(); + lctFlag = (packed & 0x80) != 0; // 1 - local color table flag interlace + lctSize = (int) Math.pow(2, (packed & 0x07) + 1); + // 3 - sort flag + // 4-5 - reserved lctSize = 2 << (packed & 7); // 6-8 - local color + // table size + interlace = (packed & 0x40) != 0; + if (lctFlag) { + lct = readColorTable(lctSize); // read table + act = lct; // make local table active + } else { + act = gct; // make global table active + if (bgIndex == transIndex) { + bgColor = 0; + } + } + int save = 0; + if (transparency) { + save = act[transIndex]; + act[transIndex] = 0; // set transparent color if specified + } + if (act == null) { + status = STATUS_FORMAT_ERROR; // no color table defined + } + if (err()) { + return; + } + decodeBitmapData(); // decode pixel data + skip(); + if (err()) { + return; + } + frameCount++; + // create new image to receive frame data + image = new DixieMap(width, height, Pixmap.Format.RGBA8888); + setPixels(); // transfer pixel data to image + frames.addElement(new GifFrame(image, delay)); // add image to frame + // list + if (transparency) { + act[transIndex] = save; + } + resetFrame(); + } + + /** + * Reads Logical Screen Descriptor + */ + protected void readLSD() { + // logical screen size + width = readShort(); + height = readShort(); + // packed fields + int packed = read(); + gctFlag = (packed & 0x80) != 0; // 1 : global color table flag + // 2-4 : color resolution + // 5 : gct sort flag + gctSize = 2 << (packed & 7); // 6-8 : gct size + bgIndex = read(); // background color index + pixelAspect = read(); // pixel aspect ratio + } + + /** + * Reads Netscape extenstion to obtain iteration count + */ + protected void readNetscapeExt() { + do { + readBlock(); + if (block[0] == 1) { + // loop count sub-block + int b1 = ((int) block[1]) & 0xff; + int b2 = ((int) block[2]) & 0xff; + loopCount = (b2 << 8) | b1; + } + } while ((blockSize > 0) && !err()); + } + + /** + * Reads next 16-bit value, LSB first + */ + protected int readShort() { + // read 16-bit value, LSB first + return read() | (read() << 8); + } + + /** + * Resets frame state for reading next image. + */ + protected void resetFrame() { + lastDispose = dispose; + lrx = ix; + lry = iy; + lrw = iw; + lrh = ih; + lastPixmap = image; + lastBgColor = bgColor; + dispose = 0; + transparency = false; + delay = 0; + lct = null; + } + + /** + * Skips variable length blocks up to and including next zero length block. + */ + protected void skip() { + do { + readBlock(); + } while ((blockSize > 0) && !err()); + } + + public Animation getAnimation(PlayMode playMode) { + int nrFrames = getFrameCount(); + Pixmap frame = getFrame(0); + int width = frame.getWidth(); + int height = frame.getHeight(); + int vzones = (int)Math.sqrt((double)nrFrames); + int hzones = vzones; + + while(vzones * hzones < nrFrames) vzones++; + + int v, h; + + Pixmap target = new Pixmap(width * hzones, height * vzones, Pixmap.Format.RGBA8888); + + for(h = 0; h < hzones; h++) { + for(v = 0; v < vzones; v++) { + int frameID = v + h * vzones; + if(frameID < nrFrames) { + frame = getFrame(frameID); + target.drawPixmap(frame, h * width, v * height); + } + } + } + + Texture texture = new Texture(target); + Array texReg = new Array(); + + for(h = 0; h < hzones; h++) { + for(v = 0; v < vzones; v++) { + int frameID = v + h * vzones; + if(frameID < nrFrames) { + TextureRegion tr = new TextureRegion(texture, h * width, v * height, width, height); + texReg.add(tr); + } + } + } + float frameDuration = (float)getDelay(0); + frameDuration /= 1000; // convert milliseconds into seconds + Animation result = new Animation(frameDuration, texReg, playMode); + + return result; + } + + public static Animation loadGIFAnimation(PlayMode playMode, InputStream is) { + GifDecoder gdec = new GifDecoder(); + gdec.read(is); + return gdec.getAnimation(playMode); + } +} + + diff --git a/Game/core/src/com/mygdx/game/Item.java b/Game/core/src/com/mygdx/game/Item.java new file mode 100644 index 0000000..1c072f4 --- /dev/null +++ b/Game/core/src/com/mygdx/game/Item.java @@ -0,0 +1,149 @@ +package com.mygdx.game; + +import com.badlogic.gdx.Game; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; + +import java.util.Vector; + +public class Item extends GameObj { + + private SpriteBatch batch; + private long t; + public static Vector item_arr=new Vector<>(); + + private Item(float x_c, float y_c, int id, int moveId) { + this.x = x_c; + this.y = y_c; + this.moveId = moveId; + this.id=id; + State=true; + setHitboxRadius(); + setMove(); + t=System.currentTimeMillis(); + } + + public void setX_move(float x_move) { this.x_move = x_move; } + + public void setY_move(float y_move) { + this.y_move = y_move; + } + + public void create() { + + batch = new SpriteBatch(); + State=true; + } + + public void renders() { // loop + batch.begin(); + batch.draw(Assets.texture_item, x-10,y-10,20,20); + batch.end(); + y += y_move; + x += x_move; + } + + public static void render() { + for (int i = 0; i < item_arr.size(); i++) { + if (item_arr.elementAt(i).State) { + item_arr.elementAt(i).setMove(); + item_arr.elementAt(i).renders(); + item_arr.elementAt(i).isCollected(); + } + } + } + + public void dispose() { + batch.dispose(); + } + + public static void Item_Reallo(float x_c, float y_c,int id, int moveId) { + int BulletGen = 0; + loop: while (BulletGen == 0) { + for (int i = 0; i < item_arr.size(); i++) { //there exists at least an element in the array + if (item_arr.elementAt(i).isDed()) { + item_arr.elementAt(i).Revive(x_c, y_c, id, moveId); + BulletGen = 1; + continue loop; + } + } + item_arr.addElement(new Item(x_c, y_c,id, moveId)); + item_arr.lastElement().setParam(); + item_arr.lastElement().create(); + BulletGen = 1; + } + } + + public boolean isDed() { + return !State; + } + + private void Revive(float x_c,float y_c, int id, int moveId){ + this.x=x_c; + this.y=y_c; + this.id=id; + this.moveId=moveId; + this.State=true; + setHitboxRadius(); + setMove(); + t=System.currentTimeMillis(); + } + + private void setMove() { + switch (moveId){ + case 0: + setX_move(0); + setY_move(-3); + if (y<0) Execute(); + break; + case 1: + setX_move(0); + setY_move(3); + moveId+=2; + break; + case 2: + setX_move(randPara.nextFloat()-0.5f); + setY_move((float)randPara.nextInt(10)); + moveId+=1; + break; + case 3: + if (System.currentTimeMillis()-t>100) moveId=0; + break; + } + } + + public void Execute(){ + State=false; + id=0; + } + + /* ---------------------------------------------------------------------- + * ---------------------------------------------------------------------- + * --------------------------Edit - add more----------------------------- + * -------------------Bullets' hitbox, value, orbit---------------------- + * ---------------------------------------------------------------------- + * ----------------------------------------------------------------------*/ + + private void setHitboxRadius() { + hitboxRadius=5; + } + + private void isCollected(){ + if (Math.sqrt(Math.pow((double)x-MyGdxGame.player.x,2.0)+ + Math.pow((double)y-MyGdxGame.player.y,2.0))< + (double)hitboxRadius+MyGdxGame.player.hitboxRadius) { + switch (id) { + case 1: + MyGdxGame.player.setPower(MyGdxGame.player.getPower() + 0.01); + break; + } + Execute(); + } + } + + public static void drop(float x, float y, int id){ +// switch (id) { +// +// } + Item_Reallo(x,y,1,1); + } +} diff --git a/Game/core/src/com/mygdx/game/Launcher.java b/Game/core/src/com/mygdx/game/Launcher.java deleted file mode 100644 index 84ef3ff..0000000 --- a/Game/core/src/com/mygdx/game/Launcher.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.mygdx.game; - -import com.badlogic.gdx.ApplicationAdapter; -import com.badlogic.gdx.Gdx; -import com.badlogic.gdx.graphics.GL20; -import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.SpriteBatch; - -public class Launcher extends ApplicationAdapter { - SpriteBatch batch; - Texture img; - - @Override - public void create () { - batch = new SpriteBatch(); - img = new Texture("badlogic.jpg"); - } - - @Override - public void render () { - Gdx.gl.glClearColor(1, 1, 0, 1); - Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); - batch.begin(); - batch.draw(img, 4, 0); - batch.end(); - } - - @Override - public void dispose () { - batch.dispose(); - img.dispose(); - } -} diff --git a/Game/core/src/com/mygdx/game/MyGdxGame.java b/Game/core/src/com/mygdx/game/MyGdxGame.java new file mode 100644 index 0000000..ba5f119 --- /dev/null +++ b/Game/core/src/com/mygdx/game/MyGdxGame.java @@ -0,0 +1,166 @@ +package com.mygdx.game; + +import UI.GameOverScreen; +import UI.MainClass; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input; +import com.badlogic.gdx.Screen; +import com.badlogic.gdx.audio.Sound; + +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.ui.Label; +import com.badlogic.gdx.scenes.scene2d.ui.Skin; + +public class MyGdxGame implements Screen { + + //Player player; // null obj which not consist any method. --> it just save a variable __> different from c++. + // In later we have to player = new Player() in somewhere--> but not remove new Player() + + static Player player = new Player(); + Assets assets = new Assets(); + + static Boss boss; + + Background background = new Background(); + + Label label_point = new Label("0",new Skin(Gdx.files.internal("skin/Textfield.json"))); + + static int Wave=0; + private Stage stage; + + Sound sound = Gdx.audio.newSound(Gdx.files.internal("Audio/ZA-WARUDO.mp3"));; + + boolean pauseGame = false; + MainClass mainClass; + + PlayerData playerData; + + public int bossWave = 3; + + // Texture sprite_bullet; +// //Input in; // interface class --> abstract class --> we cannot call obj of this class. + public MyGdxGame(MainClass mainClass){ + stage = new Stage(); + + playerData = new PlayerData(); + + label_point.setText(GameOverScreen.score); + label_point.setFontScale(2f); + label_point.setPosition(0,Gdx.graphics.getHeight()-50); + stage.addActor(label_point); + + this.mainClass = mainClass; + assets.load(); + player.create(); + background.create(); + background.resize(Gdx.graphics.getWidth(),Gdx.graphics.getHeight()); + + boss = new Boss(); + } + + @Override + public void show() { + pauseGame=false; + System.out.println("Show"); + } + + public void render(float delta){ + + if(!pauseGame){ + + background.render(); + + player.render_player(); + if(player.fire()){ + player.Bullet_Call(); + } + + + if(Waves.Wave < bossWave) + { + Waves.Wave_Come(); + + Enemy.render(); + Enemy.fire(); + Enemy.checkCollision(); + } + + Bullet.render(); + + if(Waves.Wave >= bossWave) + { + boss.getPlayerPos(player.x, player.y); + boss.render(); + boss.shootRocket(); + boss.checkCollision(); + boss.checkCollisionWithPlayer(); + Enemy.killAll(); + } + + player.checkCollisionwthBullet(); + player.checkCollisionwthEnemy(); + + +// Gdx.app.log("FPS", Integer.toString(Gdx.graphics.getFramesPerSecond())); + System.out.println(Waves.Wave); + + label_point.setText(GameOverScreen.score); + + stage.act(); + stage.draw(); + + + if(Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE)){ + pauseGame = true; + long id = sound.play(1f); + sound.setPitch(id, 1f); + sound.setLooping(id,false); + mainClass.setPauseScreen(); + } + + if(!player.State){ + mainClass.setGameOverScreen(); + Waves.reset(); + player.x = 0; + player.y = 0; + Wave=0; + } + if(!boss.State) + { + mainClass.setWinScreen(); + Waves.reset(); + player.x = 0; + player.y = 0; + Wave=0; + } + + } + } + + @Override + public void resize(int width, int height) { + + } + + @Override + public void pause() { + System.out.println("Pause"); + pauseGame=true; // pause is 1 + } + + @Override + public void resume() { + + } + + @Override + public void hide() { + pauseGame=true; + } + + public void dispose(){ + player.dispose(); + boss.dispose(); + System.out.println("out"); + } +} diff --git a/Game/core/src/com/mygdx/game/Player.java b/Game/core/src/com/mygdx/game/Player.java new file mode 100644 index 0000000..190d69c --- /dev/null +++ b/Game/core/src/com/mygdx/game/Player.java @@ -0,0 +1,155 @@ +package com.mygdx.game; + +import com.badlogic.gdx.ApplicationAdapter; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; + +import java.util.Vector; + +public class Player extends GameObj{ + private SpriteBatch batch; + private int loaded=0; + private long t=System.currentTimeMillis()-200; + private long rapidity; + private double power; + + public void create(){ + scale = 0.4f; + batch = new SpriteBatch(); + hitboxRadius=10; + State=true; + setId(1); + } + + public void setId(int id){ + this.id=-id; + } + public float getX(){ + return x; + } + public float getY(){ + return y; + } + public boolean fire(){ + if (Gdx.input.isKeyJustPressed(Input.Keys.SHIFT_LEFT)) Bullet.resetfakebase(); + if (Gdx.input.isKeyPressed(Input.Keys.Z)) { + if (System.currentTimeMillis() - t > rapidity) { + t = System.currentTimeMillis(); + return true; + } return false; + + } + else return false; + + } + + public void render_player () { // loop + if (State) { + batch.begin(); + batch.draw(Assets.texture_plane, (x - 20), (y - 20), 40, 40); + batch.end(); + } + input(); + + } + public void dispose () { + batch.dispose(); + } + + public static void checkCollisionwthBullet(){ + for (int i=0;iGdx.graphics.getWidth()) x=Gdx.graphics.getWidth(); + if (Gdx.input.isKeyPressed(Input.Keys.UP)) y+=speed; + if (y>Gdx.graphics.getHeight()) y=Gdx.graphics.getHeight(); + if (Gdx.input.isKeyPressed(Input.Keys.DOWN)) y-=speed; + if (y<0) y=0; + } + + public void Bullet_Call() { //Furthermore edit here + switch (Math.abs(id)) { + case 0: + { + Bullet.Bullet_Reallo(getX(), getY(), 0, 30, -2); + Bullet.Bullet_Reallo(getX(), getY(), 0, -30, -2); + Bullet.Bullet_Reallo(getX(), getY(), 30, 0, -2); + Bullet.Bullet_Reallo(getX(), getY(), -30, 0, -2); + break; + } + case 1: + /* bullet_arr.addElement(new Bullet(getX(), getY(), 0, 30, 1));*/ + { + if (Gdx.input.isKeyPressed(Input.Keys.SHIFT_LEFT)) { + Bullet.Bullet_Reallo(getX(), getY(), 0, 30, -3); + Bullet.Bullet_Reallo(getX(), getY(), -5, 29, -3); + Bullet.Bullet_Reallo(getX(), getY(), 5, 29, -3); + Bullet.Bullet_Reallo(getX(), getY(), 0, 25, -3); + Bullet.Bullet_Reallo(getX(), getY(), -10, 28, -3); + Bullet.Bullet_Reallo(getX(), getY(), 10, 28, -3); + } + else { + Bullet.Bullet_Reallo(getX(), getY(), 0, 30, -1); + Bullet.Bullet_Reallo(getX()-3, getY(), -2, 29, -1); + Bullet.Bullet_Reallo(getX()+3, getY(), 2, 29, -1); + Bullet.Bullet_Reallo(getX()-5, getY(), -5, 28, -1); + Bullet.Bullet_Reallo(getX()+5, getY(), 5, 28, -1); + } + } + break; + } + } +} + diff --git a/Game/core/src/com/mygdx/game/PlayerData.java b/Game/core/src/com/mygdx/game/PlayerData.java new file mode 100644 index 0000000..f698843 --- /dev/null +++ b/Game/core/src/com/mygdx/game/PlayerData.java @@ -0,0 +1,23 @@ +package com.mygdx.game; + +public class PlayerData { + public String name; + public int score; + + public PlayerData() + { + + } + + public PlayerData(String name, int score) + { + this.name = name; + + this.score = score; + } + + public void printData() + { + System.out.println(name + score); + } +} diff --git a/Game/core/src/com/mygdx/game/Rocket.java b/Game/core/src/com/mygdx/game/Rocket.java new file mode 100644 index 0000000..53de9c6 --- /dev/null +++ b/Game/core/src/com/mygdx/game/Rocket.java @@ -0,0 +1,132 @@ +package com.mygdx.game; + +import com.badlogic.gdx.Audio; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.audio.Sound; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.Sprite; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.math.MathUtils; + +import java.util.ArrayList; + +public class Rocket extends GameObj{ + private Sprite sprite; + private SpriteBatch batch; + + private float speed = 100f; + + //Player position + private GameObj playerPos = new GameObj(); + + private float degree = 0; + + public Explosion explosion; + private float fuseTime = 5f; + float lifeTime; + +// private Sound sound= Gdx.audio.newSound(Gdx.files.internal("Audio/Explosion3.mp3")); + + public Rocket(float x, float y) + { + batch = new SpriteBatch(); + sprite = new Sprite(Assets.texture_rocket); + + this.x = x; + this.y = y; + + explosion = new Explosion(); + State = true; + + hitboxRadius = (sprite.getHeight() + sprite.getWidth())/4; + } + + public void render() { + + sprite.setPosition(x, y); + + batch.begin(); + sprite.draw(batch); + batch.end(); + + rotateRocket(); + moveRocket(); + + explosion.setPos(x, y); + lifeTime += Gdx.graphics.getDeltaTime(); + checkFuse(); + checkCollision(); + } + + private void checkCollision() + { +// if(x <= MyGdxGame.player.x + MyGdxGame.player.hitboxRadius && x >= MyGdxGame.player.x +// && y <= MyGdxGame.player.y + MyGdxGame.player.hitboxRadius && y >= MyGdxGame.player.y) +// { +// Execute(); +// MyGdxGame.player.State = false; +// } + +// if(MyGdxGame.player.x % x <= 0.1 & MyGdxGame.player.y % y <= 0.1) +// { +// Execute(); +// } + + if(Math.sqrt(Math.pow(MyGdxGame.player.x - x, 2) + Math.pow(MyGdxGame.player.y - y, 2)) < + hitboxRadius + MyGdxGame.player.hitboxRadius) + { + Execute(); + MyGdxGame.player.Execute(); + } + } + + private void checkFuse() + { + if(lifeTime >= fuseTime) + { + explosion.draw(); +// sound.play(); + if(explosion.isDone) + Execute(); + } + } + + public void getPlayerPos(float x, float y) + { + playerPos.x = x; + playerPos.y = y; + } + + public void moveRocket() + { + if(y > playerPos.y) + y -= speed * Gdx.graphics.getDeltaTime(); + else if(y < playerPos.y) + y += speed * Gdx.graphics.getDeltaTime(); + + if(x > playerPos.x) + x -= speed * Gdx.graphics.getDeltaTime(); + else if(x < playerPos.x) + x += speed * Gdx.graphics.getDeltaTime(); + } + + private void rotateRocket() + { + degree = (float) Math.atan2(y - playerPos.y, x - playerPos.x) * MathUtils.radDeg; + + sprite.setOriginCenter(); + sprite.setRotation(degree - 90f); + } + + public void Execute() + { + State=false; + id=0; + lifeTime = 0; + } + + public void dispose() + { + batch.dispose(); + } +} diff --git a/Game/core/src/com/mygdx/game/UI/GameModesMenu.java b/Game/core/src/com/mygdx/game/UI/GameModesMenu.java new file mode 100644 index 0000000..5b7f275 --- /dev/null +++ b/Game/core/src/com/mygdx/game/UI/GameModesMenu.java @@ -0,0 +1,130 @@ +package UI; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Screen; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.actions.Actions; +import com.badlogic.gdx.scenes.scene2d.ui.*; +import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; +import com.badlogic.gdx.utils.Align; +import com.badlogic.gdx.utils.viewport.ScreenViewport; +import com.mygdx.game.Background; + +public class GameModesMenu implements Screen { + private SpriteBatch batch; + private ImageButton SingleplayerButton; + private ImageButton MultiplayerButton; + private ImageButton BackButton; + + private Skin skin; + private Skin skin2; + + private Image image; + + private MainClass mainClass; + + private Table table; + private Background background; + + private Stage stage; + + public GameModesMenu(final MainClass mainClass){ + this.mainClass = mainClass; + batch = new SpriteBatch(); + + image = new Image(new Texture(Gdx.files.internal("skin/GameTitle.png"))); + + background = new Background(); + background.create(); + background.resize(Gdx.graphics.getWidth(),Gdx.graphics.getHeight()); + + stage = new Stage(new ScreenViewport()); + + skin = new Skin(Gdx.files.internal("skin/ButtonPack.json")); + skin2 = new Skin(Gdx.files.internal("skin/Textfield.json")); + + // table will be affected by size of stage. + table = new Table(); + table.setWidth(stage.getWidth()); + table.align(Align.center|Align.top); + + + SingleplayerButton = new ImageButton(skin, "Singleplayer"); + SingleplayerButton.addListener(new ClickListener(){ + @Override + public void clicked(InputEvent event, float x, float y) { + mainClass.setNewGameScreen(); + } + }); + + MultiplayerButton = new ImageButton(skin, "Multiplayer"); + MultiplayerButton.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + System.out.println("COMING SOON"); + } + }); + + BackButton = new ImageButton(skin, "Back"); + BackButton.addListener(new ClickListener(){ + @Override + public void clicked(InputEvent event, float x, float y) { + Gdx.app.log("Exit Game", "BEEP"); + Gdx.app.exit(); + } + }); + + table.pad(30); + table.add(SingleplayerButton).pad(30).align(Align.left); + table.row(); + table.add(MultiplayerButton).pad(30).align(Align.left); + table.row(); + table.add(BackButton).pad(30).align(Align.left); + table.setPosition(0, Gdx.graphics.getHeight()/2+table.getMinHeight()/2); + + stage.addActor(table); + } + + public void show() { + stage.addAction(Actions.fadeIn(1)); + Gdx.input.setInputProcessor(stage); // kieu nhu no add input vao thang render. -- call before render each frame. + } + + public void render (float delta) { + background.render(); + + stage.act(); + stage.draw(); + } + + + public void resize(int width, int height) { + stage.getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true); // this line is important. update size of stage = current screen size. + table.setWidth(stage.getWidth()); + table.align(Align.center|Align.top); + table.setPosition(0, Gdx.graphics.getHeight()/2+table.getMinHeight()/2); + } + + public void pause() { + SingleplayerButton.setDisabled(true); + } + + public void resume() { + + } + + public void hide() { + Gdx.input.setInputProcessor(null); + } + + + public void dispose() { + stage.dispose(); + batch.dispose(); + skin.dispose(); + } +} diff --git a/Game/core/src/com/mygdx/game/UI/GameOverScreen.java b/Game/core/src/com/mygdx/game/UI/GameOverScreen.java new file mode 100644 index 0000000..31e945a --- /dev/null +++ b/Game/core/src/com/mygdx/game/UI/GameOverScreen.java @@ -0,0 +1,208 @@ +package UI; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Preferences; +import com.badlogic.gdx.Screen; +import com.badlogic.gdx.audio.Music; +import com.badlogic.gdx.audio.Sound; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.*; +import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.actions.Actions; +import com.badlogic.gdx.scenes.scene2d.ui.*; +import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; +import com.badlogic.gdx.utils.Align; +import com.badlogic.gdx.utils.viewport.ScreenViewport; +import com.mygdx.game.Player; +import com.mygdx.game.PlayerData; + +public class GameOverScreen implements Screen { + private SpriteBatch batch; + + private ImageButton RetryButton; + private ImageButton ExitButton; + private ImageButton MainMenuButton; + private Skin skin; + private MainClass mainClass; + private Table table; + + private Stage stage; + + float tableY = Gdx.graphics.getHeight()/2; + + public static int score, highscore; + GlyphLayout scorelayout, highscorelayout; + + Animation animation; + float elapsed; + + BitmapFont scoreFont; + private Label label; + private Skin textSkin; + + Sound sound = Gdx.audio.newSound(Gdx.files.internal("Audio/Astronomia.mp3")); +// Music music = Gdx.audio.newMusic(Gdx.files.internal("Audio/Astronomia.mp3")); + + public GameOverScreen(final MainClass mainClass) { + this.mainClass = mainClass; + + batch = new SpriteBatch(); + + animation = GifDecoder.loadGIFAnimation(Animation.PlayMode.LOOP, Gdx.files.internal("Texture/Gif/coffindance.gif").read()); + + Preferences preferences = Gdx.app.getPreferences("GameScore"); //Create file to store score + highscore = preferences.getInteger("highscore", score); + + if(score > highscore) + { + preferences.putInteger("highscore", score); + preferences.flush(); //Flush will save file + } + + scoreFont = new BitmapFont(Gdx.files.internal("skin/minecraft.fnt")); + + skin = new Skin(Gdx.files.internal("skin/ButtonPack.json")); + + stage = new Stage(new ScreenViewport()); + + textSkin = new Skin(Gdx.files.internal("skin/testingfont.json")); + label = new Label("GAME OVER", textSkin); + + label.setAlignment(Align.center | Align.top); + label.setColor(Color.RED); + label.setFontScale(3f); + + CreateTable(stage); + } + + public void CreateTable(final Stage stage) + { + table = new Table(); + table.setWidth(stage.getWidth()); + table.align(Align.center | Align.top); + table.setPosition(0, tableY); + + RetryButton = new ImageButton(skin, "Retry"); + RetryButton.addListener(new ClickListener(){ + @Override + public void clicked(InputEvent event, float x, float y) { + stage.addAction(Actions.sequence(Actions.fadeOut(1), Actions.run(new Runnable() { + @Override + public void run() { + mainClass.setNewGameScreen(); + sound.stop(); + } + }))); + } + }); + + MainMenuButton = new ImageButton(skin, "MainMenu"); + MainMenuButton.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + stage.addAction(Actions.sequence(Actions.fadeOut(1), Actions.run(new Runnable() { + @Override + public void run() { + mainClass.setMenuScreen(); + sound.stop(); + } + }))); + } + }); + + ExitButton = new ImageButton(skin, "Exit"); + ExitButton.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + Gdx.app.log("Exit Game", "BEEP"); + Gdx.app.exit(); + } + }); + + table.pad(30); + table.add(label).size(500,100); + table.row(); + table.add(RetryButton).pad(30); + table.row(); + table.add(MainMenuButton).pad(30); + table.row(); + table.add(ExitButton).pad(30); + + stage.addActor(table); + } + + private void playSong() + { + long id = sound.play(1f); + sound.setPitch(id, 1f); + sound.setVolume(id, 0.5f); + sound.setLooping(id,true); + } + + public void show() { + stage.addAction(Actions.fadeIn(1)); + Gdx.input.setInputProcessor(stage); // kieu nhu no add input vao thang render. -- call before render each frame. + playSong(); + } + + public void render(float delta) { + elapsed += Gdx.graphics.getDeltaTime(); //Get time frame + + Gdx.gl.glClearColor(0, 0, 0, 1); + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + batch.begin(); + batch.draw(animation.getKeyFrame(elapsed), 20,20); //Draw the gif + + //Score text + scorelayout = new GlyphLayout(scoreFont, "Score: \n" + score, Color.WHITE, 0, Align.left, false); + highscorelayout = new GlyphLayout(scoreFont, "High Score: \n" + highscore, Color.WHITE, 0, Align.left, false); + + scoreFont.draw(batch, scorelayout, 20, tableY + label.getHeight()*2); + scoreFont.draw(batch, highscorelayout, 20, tableY + label.getHeight()); + + batch.end(); + + stage.act(); + stage.draw(); + } + + public int getScore() + { + return score; + } + + @Override + public void resize(int width, int height) { + stage.getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true); // this line is important. update size of stage = current screen size. + table.setWidth(stage.getWidth()); + table.align(Align.center|Align.top); + table.setPosition(0, tableY +table.getMinHeight()/2); + } + + @Override + public void pause() { + + } + + @Override + public void resume() { + + } + + @Override + public void hide() { + Gdx.input.setInputProcessor(null); + } + + + public void dispose() { + stage.dispose(); + batch.dispose(); + skin.dispose(); + scoreFont.dispose(); + sound.dispose(); + } +} diff --git a/Game/core/src/com/mygdx/game/UI/GifDecoder.java b/Game/core/src/com/mygdx/game/UI/GifDecoder.java new file mode 100644 index 0000000..a541166 --- /dev/null +++ b/Game/core/src/com/mygdx/game/UI/GifDecoder.java @@ -0,0 +1,735 @@ +package UI; + +import com.badlogic.gdx.graphics.Pixmap; +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.TextureRegion; +import com.badlogic.gdx.utils.Array; + +import java.io.InputStream; +import java.util.Vector; + +public class GifDecoder { + /** + * File read status: No errors. + */ + public static final int STATUS_OK = 0; + /** + * File read status: Error decoding file (may be partially decoded) + */ + public static final int STATUS_FORMAT_ERROR = 1; + /** + * File read status: Unable to open source. + */ + public static final int STATUS_OPEN_ERROR = 2; + /** max decoder pixel stack size */ + protected static final int MAX_STACK_SIZE = 4096; + protected InputStream in; + protected int status; + protected int width; // full image width + protected int height; // full image height + protected boolean gctFlag; // global color table used + protected int gctSize; // size of global color table + protected int loopCount = 1; // iterations; 0 = repeat forever + protected int[] gct; // global color table + protected int[] lct; // local color table + protected int[] act; // active color table + protected int bgIndex; // background color index + protected int bgColor; // background color + protected int lastBgColor; // previous bg color + protected int pixelAspect; // pixel aspect ratio + protected boolean lctFlag; // local color table flag + protected boolean interlace; // interlace flag + protected int lctSize; // local color table size + protected int ix, iy, iw, ih; // current image rectangle + protected int lrx, lry, lrw, lrh; + protected DixieMap image; // current frame + protected DixieMap lastPixmap; // previous frame + protected byte[] block = new byte[256]; // current data block + protected int blockSize = 0; // block size last graphic control extension info + protected int dispose = 0; // 0=no action; 1=leave in place; 2=restore to bg; 3=restore to prev + protected int lastDispose = 0; + protected boolean transparency = false; // use transparent color + protected int delay = 0; // delay in milliseconds + protected int transIndex; // transparent color index + // LZW decoder working arrays + protected short[] prefix; + protected byte[] suffix; + protected byte[] pixelStack; + protected byte[] pixels; + protected Vector frames; // frames read from current file + protected int frameCount; + + private static class DixieMap extends Pixmap { + DixieMap(int w, int h, Format f) { + super(w, h, f); + } + + DixieMap(int[] data, int w, int h, Format f) { + super(w, h, f); + + int x, y; + + for(y = 0; y < h; y++) { + for(x = 0; x < w; x++) { + int pxl_ARGB8888 = data[x + y * w]; + int pxl_RGBA8888 = + ((pxl_ARGB8888 >> 24) & 0x000000ff) | ((pxl_ARGB8888 << 8) & 0xffffff00); + // convert ARGB8888 > RGBA8888 + drawPixel(x, y, pxl_RGBA8888); + } + } + } + + void getPixels(int[] pixels, int offset, int stride, int x, int y, int width, int height) { + java.nio.ByteBuffer bb = getPixels(); + + int k, l; + + for(k = y; k < y + height; k++) { + int _offset = offset; + for(l = x; l < x + width; l++) { + int pxl = bb.getInt(4 * (l + k * width)); + + // convert RGBA8888 > ARGB8888 + pixels[_offset++] = ((pxl >> 8) & 0x00ffffff) | ((pxl << 24) & 0xff000000); + } + offset += stride; + } + } + } + + private static class GifFrame { + public GifFrame(DixieMap im, int del) { + image = im; + delay = del; + } + + public DixieMap image; + public int delay; + } + + /** + * Gets display duration for specified frame. + * + * @param n + * int index of frame + * @return delay in milliseconds + */ + public int getDelay(int n) { + delay = -1; + if ((n >= 0) && (n < frameCount)) { + delay = frames.elementAt(n).delay; + } + return delay; + } + + /** + * Gets the number of frames read from file. + * + * @return frame count + */ + public int getFrameCount() { + return frameCount; + } + + /** + * Gets the first (or only) image read. + * + * @return BufferedPixmap containing first frame, or null if none. + */ + public Pixmap getPixmap() { + return getFrame(0); + } + + /** + * Gets the "Netscape" iteration count, if any. A count of 0 means repeat indefinitely. + * + * @return iteration count if one was specified, else 1. + */ + public int getLoopCount() { + return loopCount; + } + + /** + * Creates new frame image from current data (and previous frames as specified by their disposition codes). + */ + protected void setPixels() { + // expose destination image's pixels as int array + int[] dest = new int[width * height]; + // fill in starting image contents based on last image's dispose code + if (lastDispose > 0) { + if (lastDispose == 3) { + // use image before last + int n = frameCount - 2; + if (n > 0) { + lastPixmap = getFrame(n - 1); + } else { + lastPixmap = null; + } + } + if (lastPixmap != null) { + lastPixmap.getPixels(dest, 0, width, 0, 0, width, height); + // copy pixels + if (lastDispose == 2) { + // fill last image rect area with background color + int c = 0; + if (!transparency) { + c = lastBgColor; + } + for (int i = 0; i < lrh; i++) { + int n1 = (lry + i) * width + lrx; + int n2 = n1 + lrw; + for (int k = n1; k < n2; k++) { + dest[k] = c; + } + } + } + } + } + // copy each source line to the appropriate place in the destination + int pass = 1; + int inc = 8; + int iline = 0; + for (int i = 0; i < ih; i++) { + int line = i; + if (interlace) { + if (iline >= ih) { + pass++; + switch (pass) { + case 2: + iline = 4; + break; + case 3: + iline = 2; + inc = 4; + break; + case 4: + iline = 1; + inc = 2; + break; + default: + break; + } + } + line = iline; + iline += inc; + } + line += iy; + if (line < height) { + int k = line * width; + int dx = k + ix; // start of line in dest + int dlim = dx + iw; // end of dest line + if ((k + width) < dlim) { + dlim = k + width; // past dest edge + } + int sx = i * iw; // start of line in source + while (dx < dlim) { + // map color and insert in destination + int index = ((int) pixels[sx++]) & 0xff; + int c = act[index]; + if (c != 0) { + dest[dx] = c; + } + dx++; + } + } + } + image = new DixieMap(dest, width, height, Pixmap.Format.RGBA8888); + //Pixmap.createPixmap(dest, width, height, Config.ARGB_4444); + } + + /** + * Gets the image contents of frame n. + * + * @return BufferedPixmap representation of frame, or null if n is invalid. + */ + public DixieMap getFrame(int n) { + if (frameCount <= 0) + return null; + n = n % frameCount; + return ((GifFrame) frames.elementAt(n)).image; + } + + /** + * Reads GIF image from stream + * + * @param is + * containing GIF file. + * @return read status code (0 = no errors) + */ + public int read(InputStream is) { + init(); + if (is != null) { + in = is; + readHeader(); + if (!err()) { + readContents(); + if (frameCount < 0) { + status = STATUS_FORMAT_ERROR; + } + } + } else { + status = STATUS_OPEN_ERROR; + } + try { + is.close(); + } catch (Exception e) { + } + return status; + } + + /** + * Decodes LZW image data into pixel array. Adapted from John Cristy's BitmapMagick. + */ + protected void decodeBitmapData() { + int nullCode = -1; + int npix = iw * ih; + int available, clear, code_mask, code_size, end_of_information, in_code, old_code, bits, code, count, i, datum, data_size, first, top, bi, pi; + if ((pixels == null) || (pixels.length < npix)) { + pixels = new byte[npix]; // allocate new pixel array + } + if (prefix == null) { + prefix = new short[MAX_STACK_SIZE]; + } + if (suffix == null) { + suffix = new byte[MAX_STACK_SIZE]; + } + if (pixelStack == null) { + pixelStack = new byte[MAX_STACK_SIZE + 1]; + } + // Initialize GIF data stream decoder. + data_size = read(); + clear = 1 << data_size; + end_of_information = clear + 1; + available = clear + 2; + old_code = nullCode; + code_size = data_size + 1; + code_mask = (1 << code_size) - 1; + for (code = 0; code < clear; code++) { + prefix[code] = 0; // XXX ArrayIndexOutOfBoundsException + suffix[code] = (byte) code; + } + // Decode GIF pixel stream. + datum = bits = count = first = top = pi = bi = 0; + for (i = 0; i < npix;) { + if (top == 0) { + if (bits < code_size) { + // Load bytes until there are enough bits for a code. + if (count == 0) { + // Read a new data block. + count = readBlock(); + if (count <= 0) { + break; + } + bi = 0; + } + datum += (((int) block[bi]) & 0xff) << bits; + bits += 8; + bi++; + count--; + continue; + } + // Get the next code. + code = datum & code_mask; + datum >>= code_size; + bits -= code_size; + // Interpret the code + if ((code > available) || (code == end_of_information)) { + break; + } + if (code == clear) { + // Reset decoder. + code_size = data_size + 1; + code_mask = (1 << code_size) - 1; + available = clear + 2; + old_code = nullCode; + continue; + } + if (old_code == nullCode) { + pixelStack[top++] = suffix[code]; + old_code = code; + first = code; + continue; + } + in_code = code; + if (code == available) { + pixelStack[top++] = (byte) first; + code = old_code; + } + while (code > clear) { + pixelStack[top++] = suffix[code]; + code = prefix[code]; + } + first = ((int) suffix[code]) & 0xff; + // Add a new string to the string table, + if (available >= MAX_STACK_SIZE) { + break; + } + pixelStack[top++] = (byte) first; + prefix[available] = (short) old_code; + suffix[available] = (byte) first; + available++; + if (((available & code_mask) == 0) && (available < MAX_STACK_SIZE)) { + code_size++; + code_mask += available; + } + old_code = in_code; + } + // Pop a pixel off the pixel stack. + top--; + pixels[pi++] = pixelStack[top]; + i++; + } + for (i = pi; i < npix; i++) { + pixels[i] = 0; // clear missing pixels + } + } + + /** + * Returns true if an error was encountered during reading/decoding + */ + protected boolean err() { + return status != STATUS_OK; + } + + /** + * Initializes or re-initializes reader + */ + protected void init() { + status = STATUS_OK; + frameCount = 0; + frames = new Vector(); + gct = null; + lct = null; + } + + /** + * Reads a single byte from the input stream. + */ + protected int read() { + int curByte = 0; + try { + curByte = in.read(); + } catch (Exception e) { + status = STATUS_FORMAT_ERROR; + } + return curByte; + } + + /** + * Reads next variable length block from input. + * + * @return number of bytes stored in "buffer" + */ + protected int readBlock() { + blockSize = read(); + int n = 0; + if (blockSize > 0) { + try { + int count = 0; + while (n < blockSize) { + count = in.read(block, n, blockSize - n); + if (count == -1) { + break; + } + n += count; + } + } catch (Exception e) { + e.printStackTrace(); + } + if (n < blockSize) { + status = STATUS_FORMAT_ERROR; + } + } + return n; + } + + /** + * Reads color table as 256 RGB integer values + * + * @param ncolors + * int number of colors to read + * @return int array containing 256 colors (packed ARGB with full alpha) + */ + protected int[] readColorTable(int ncolors) { + int nbytes = 3 * ncolors; + int[] tab = null; + byte[] c = new byte[nbytes]; + int n = 0; + try { + n = in.read(c); + } catch (Exception e) { + e.printStackTrace(); + } + if (n < nbytes) { + status = STATUS_FORMAT_ERROR; + } else { + tab = new int[256]; // max size to avoid bounds checks + int i = 0; + int j = 0; + while (i < ncolors) { + int r = ((int) c[j++]) & 0xff; + int g = ((int) c[j++]) & 0xff; + int b = ((int) c[j++]) & 0xff; + tab[i++] = 0xff000000 | (r << 16) | (g << 8) | b; + } + } + return tab; + } + + /** + * Main file parser. Reads GIF content blocks. + */ + protected void readContents() { + // read GIF file content blocks + boolean done = false; + while (!(done || err())) { + int code = read(); + switch (code) { + case 0x2C: // image separator + readBitmap(); + break; + case 0x21: // extension + code = read(); + switch (code) { + case 0xf9: // graphics control extension + readGraphicControlExt(); + break; + case 0xff: // application extension + readBlock(); + String app = ""; + for (int i = 0; i < 11; i++) { + app += (char) block[i]; + } + if (app.equals("NETSCAPE2.0")) { + readNetscapeExt(); + } else { + skip(); // don't care + } + break; + case 0xfe:// comment extension + skip(); + break; + case 0x01:// plain text extension + skip(); + break; + default: // uninteresting extension + skip(); + } + break; + case 0x3b: // terminator + done = true; + break; + case 0x00: // bad byte, but keep going and see what happens break; + default: + status = STATUS_FORMAT_ERROR; + } + } + } + + /** + * Reads Graphics Control Extension values + */ + protected void readGraphicControlExt() { + read(); // block size + int packed = read(); // packed fields + dispose = (packed & 0x1c) >> 2; // disposal method + if (dispose == 0) { + dispose = 1; // elect to keep old image if discretionary + } + transparency = (packed & 1) != 0; + delay = readShort() * 10; // delay in milliseconds + transIndex = read(); // transparent color index + read(); // block terminator + } + + /** + * Reads GIF file header information. + */ + protected void readHeader() { + String id = ""; + for (int i = 0; i < 6; i++) { + id += (char) read(); + } + if (!id.startsWith("GIF")) { + status = STATUS_FORMAT_ERROR; + return; + } + readLSD(); + if (gctFlag && !err()) { + gct = readColorTable(gctSize); + bgColor = gct[bgIndex]; + } + } + + /** + * Reads next frame image + */ + protected void readBitmap() { + ix = readShort(); // (sub)image position & size + iy = readShort(); + iw = readShort(); + ih = readShort(); + int packed = read(); + lctFlag = (packed & 0x80) != 0; // 1 - local color table flag interlace + lctSize = (int) Math.pow(2, (packed & 0x07) + 1); + // 3 - sort flag + // 4-5 - reserved lctSize = 2 << (packed & 7); // 6-8 - local color + // table size + interlace = (packed & 0x40) != 0; + if (lctFlag) { + lct = readColorTable(lctSize); // read table + act = lct; // make local table active + } else { + act = gct; // make global table active + if (bgIndex == transIndex) { + bgColor = 0; + } + } + int save = 0; + if (transparency) { + save = act[transIndex]; + act[transIndex] = 0; // set transparent color if specified + } + if (act == null) { + status = STATUS_FORMAT_ERROR; // no color table defined + } + if (err()) { + return; + } + decodeBitmapData(); // decode pixel data + skip(); + if (err()) { + return; + } + frameCount++; + // create new image to receive frame data + image = new DixieMap(width, height, Pixmap.Format.RGBA8888); + setPixels(); // transfer pixel data to image + frames.addElement(new GifFrame(image, delay)); // add image to frame + // list + if (transparency) { + act[transIndex] = save; + } + resetFrame(); + } + + /** + * Reads Logical Screen Descriptor + */ + protected void readLSD() { + // logical screen size + width = readShort(); + height = readShort(); + // packed fields + int packed = read(); + gctFlag = (packed & 0x80) != 0; // 1 : global color table flag + // 2-4 : color resolution + // 5 : gct sort flag + gctSize = 2 << (packed & 7); // 6-8 : gct size + bgIndex = read(); // background color index + pixelAspect = read(); // pixel aspect ratio + } + + /** + * Reads Netscape extenstion to obtain iteration count + */ + protected void readNetscapeExt() { + do { + readBlock(); + if (block[0] == 1) { + // loop count sub-block + int b1 = ((int) block[1]) & 0xff; + int b2 = ((int) block[2]) & 0xff; + loopCount = (b2 << 8) | b1; + } + } while ((blockSize > 0) && !err()); + } + + /** + * Reads next 16-bit value, LSB first + */ + protected int readShort() { + // read 16-bit value, LSB first + return read() | (read() << 8); + } + + /** + * Resets frame state for reading next image. + */ + protected void resetFrame() { + lastDispose = dispose; + lrx = ix; + lry = iy; + lrw = iw; + lrh = ih; + lastPixmap = image; + lastBgColor = bgColor; + dispose = 0; + transparency = false; + delay = 0; + lct = null; + } + + /** + * Skips variable length blocks up to and including next zero length block. + */ + protected void skip() { + do { + readBlock(); + } while ((blockSize > 0) && !err()); + } + + public Animation getAnimation(PlayMode playMode) { + int nrFrames = getFrameCount(); + Pixmap frame = getFrame(0); + int width = frame.getWidth(); + int height = frame.getHeight(); + int vzones = (int)Math.sqrt((double)nrFrames); + int hzones = vzones; + + while(vzones * hzones < nrFrames) vzones++; + + int v, h; + + Pixmap target = new Pixmap(width * hzones, height * vzones, Pixmap.Format.RGBA8888); + + for(h = 0; h < hzones; h++) { + for(v = 0; v < vzones; v++) { + int frameID = v + h * vzones; + if(frameID < nrFrames) { + frame = getFrame(frameID); + target.drawPixmap(frame, h * width, v * height); + } + } + } + + Texture texture = new Texture(target); + Array texReg = new Array(); + + for(h = 0; h < hzones; h++) { + for(v = 0; v < vzones; v++) { + int frameID = v + h * vzones; + if(frameID < nrFrames) { + TextureRegion tr = new TextureRegion(texture, h * width, v * height, width, height); + texReg.add(tr); + } + } + } + float frameDuration = (float)getDelay(0); + frameDuration /= 1000; // convert milliseconds into seconds + Animation result = new Animation(frameDuration, texReg, playMode); + + return result; + } + + public static Animation loadGIFAnimation(PlayMode playMode, InputStream is) { + GifDecoder gdec = new GifDecoder(); + gdec.read(is); + return gdec.getAnimation(playMode); + } +} + + diff --git a/Game/core/src/com/mygdx/game/UI/MainClass.java b/Game/core/src/com/mygdx/game/UI/MainClass.java new file mode 100644 index 0000000..581b239 --- /dev/null +++ b/Game/core/src/com/mygdx/game/UI/MainClass.java @@ -0,0 +1,109 @@ +package UI; + +import com.badlogic.gdx.*; +import com.mygdx.game.MyGdxGame; +import com.mygdx.game.PlayerData; + +public class MainClass extends Game implements ApplicationListener { + + private MyGdxGame gameScreen; + private MainMenu mainMenu; + private PauseScreen pauseScreen; + private GameOverScreen gameOver; + private ScoreBoardScreen scoreBoardScreen; + private Multiplay_WinScreen winScreen; + private Multiplay_LostScreen lostScreen; + private GameModesMenu gameModesMenu; + + public int score; + public String name; + + @Override + public void create() { + gameScreen=new MyGdxGame(this); + + mainMenu = new MainMenu(this); + pauseScreen = new PauseScreen(this); + gameOver = new GameOverScreen(this); + gameModesMenu = new GameModesMenu(this); + + setMenuScreen(); + } + + public void setGameModeScreen() + { + setScreen(gameModesMenu); + gameScreen.pause();; + } + + public void setNewGameScreen(){ + gameScreen=new MyGdxGame(this); + setScreen(gameScreen); + } + + public void setMenuScreen() + { + setScreen(mainMenu); + gameScreen.pause(); + } + public void setPauseScreen() + { + setScreen(pauseScreen); + gameScreen.pause(); + } + public void setGameOverScreen() + { + score = gameOver.getScore(); + setScreen(gameOver); + gameScreen.pause(); + } + public void setScoreBoardScreen() + { + scoreBoardScreen = new ScoreBoardScreen(new PlayerData(name, score), this); + setScreen(scoreBoardScreen); + gameScreen.pause(); + } + public void setWinScreen() + { + winScreen = new Multiplay_WinScreen(this); + setScreen(winScreen); + } + public void setLostScreen() + { + lostScreen = new Multiplay_LostScreen(this); + setScreen(lostScreen); + } + + + @Override + public void dispose() { + super.dispose(); + gameScreen.dispose(); + pauseScreen.dispose(); + mainMenu.dispose(); + scoreBoardScreen.dispose(); + winScreen.dispose(); + gameOver.dispose(); + } + + @Override + public void render() { + super.render(); + } + + @Override + public void resize(int width, int height) { + + super.resize(width, height); + } + + @Override + public void pause() { + super.pause(); + } + + @Override + public void resume() { + super.resume(); + } +} diff --git a/Game/core/src/com/mygdx/game/UI/MainMenu.java b/Game/core/src/com/mygdx/game/UI/MainMenu.java new file mode 100644 index 0000000..7d4efb4 --- /dev/null +++ b/Game/core/src/com/mygdx/game/UI/MainMenu.java @@ -0,0 +1,221 @@ +package UI; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Screen; +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.GlyphLayout; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.actions.Actions; +import com.badlogic.gdx.scenes.scene2d.ui.*; +import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; +import com.badlogic.gdx.utils.Align; +import com.badlogic.gdx.utils.viewport.ScreenViewport; +import com.mygdx.game.Background; +import com.mygdx.game.Player; +import com.mygdx.game.PlayerData; + +public class MainMenu implements Screen { + private SpriteBatch batch; + private ImageButton PlayButton; + private ImageButton ExitButton; + private ImageButton MultiplayerButton; + private ImageButton ScoreBoardButton; + private Skin skin; + private Skin skin2; + + private Image image; + + private MainClass mainClass; + + private Table table; + private Background background; + private Label label; + + BitmapFont font; + + TextField textfield; + float widthTextField; + float xTextField; + + FileHandle file; + public String PlayerName; + + private Stage stage; + + public MainMenu(final MainClass mainClass){ + this.mainClass = mainClass; + batch = new SpriteBatch(); + +// playerData = new PlayerData(); + + font = new BitmapFont(Gdx.files.internal("skin/minecraft.fnt")); + + image = new Image(new Texture(Gdx.files.internal("skin/GameTitle.png"))); + + file = Gdx.files.local("Scores.json"); + + background = new Background(); + background.create(); + background.resize(Gdx.graphics.getWidth(),Gdx.graphics.getHeight()); + + stage = new Stage(new ScreenViewport()); + + skin = new Skin(Gdx.files.internal("skin/ButtonPack.json")); + skin2 = new Skin(Gdx.files.internal("skin/Textfield.json")); + + label = new Label("SPACESHOOTER",skin2); + label.setFontScale(1.5f); + + textfield = new TextField("Input your name here", skin2); + + resizeTextField(); + + + // table will be affected by size of stage. + table = new Table(); + table.setWidth(stage.getWidth()); + table.align(Align.center|Align.top); + + + PlayButton = new ImageButton(skin, "Play"); + PlayButton.addListener(new ClickListener(){ + @Override + public void clicked(InputEvent event, float x, float y) { + PlayerName = textfield.getText(); + + stage.addAction(Actions.sequence(Actions.fadeOut(1), Actions.run(new Runnable() { + @Override + public void run() { + mainClass.setGameModeScreen(); + } + }))); + } + }); + +// MultiplayerButton = new ImageButton(skin, "Multiplayer"); +// MultiplayerButton.addListener(new ClickListener() { +// @Override +// public void clicked(InputEvent event, float x, float y) { +// System.out.println("COMING SOON"); +// } +// }); + + ScoreBoardButton = new ImageButton(skin, "ScoreBoard"); + ScoreBoardButton.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + stage.addAction(Actions.sequence(Actions.fadeOut(1), Actions.run(new Runnable() { + @Override + public void run() { + mainClass.setScoreBoardScreen(); + } + }))); + } + }); + + ExitButton = new ImageButton(skin, "Exit"); + ExitButton.addListener(new ClickListener(){ + @Override + public void clicked(InputEvent event, float x, float y) { + Gdx.app.log("Exit Game", "BEEP"); + Gdx.app.exit(); + } + }); + + textfield.addListener(new ClickListener(){ + public void clicked(InputEvent event, float x, float y){ + Gdx.app.log("Text Field", "BEEP"); + textfield.setText(""); + resizeTextField(); + } + }); + + table.pad(30); + table.add(label); + table.row(); + table.add(textfield); + table.row(); + table.add(PlayButton).pad(30); +// table.row(); +// table.add(MultiplayerButton).pad(30); + table.row(); + table.add(ScoreBoardButton).pad(30); + table.row(); + table.add(ExitButton).pad(30); + table.setPosition(0, Gdx.graphics.getHeight()/2+table.getMinHeight()/2); + + + stage.addActor(table); + } + + public void resizeTextField(){ // phan biet giua them space va giam bot spacce. + widthTextField = textfield.getText().length()*20; + + xTextField = Gdx.graphics.getWidth()/2 - widthTextField/2; + + if(widthTextField==0){ + textfield.setX(xTextField); + textfield.setSize(20,40); + } + else{ + textfield.setX(xTextField); + textfield.setSize(widthTextField,40); + } + } + + public String getName() + { + return PlayerName; + } + + @Override + public void show() { + stage.addAction(Actions.fadeIn(1)); + Gdx.input.setInputProcessor(stage); // kieu nhu no add input vao thang render. -- call before render each frame. + } + + public void render (float delta) { + background.render(); + + stage.act(); + stage.draw(); + + resizeTextField(); + } + + + @Override + public void resize(int width, int height) { + stage.getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true); // this line is important. update size of stage = current screen size. + table.setWidth(stage.getWidth()); + table.align(Align.center|Align.top); + table.setPosition(0, Gdx.graphics.getHeight()/2+table.getMinHeight()/2); + } + + @Override + public void pause() { + PlayButton.setDisabled(true); + } + + @Override + public void resume() { + + } + + @Override + public void hide() { + Gdx.input.setInputProcessor(null); + } + + + public void dispose() { + stage.dispose(); + batch.dispose(); + skin.dispose(); + font.dispose(); + } +} diff --git a/Game/core/src/com/mygdx/game/UI/Multiplay_LostScreen.java b/Game/core/src/com/mygdx/game/UI/Multiplay_LostScreen.java new file mode 100644 index 0000000..e1d54f1 --- /dev/null +++ b/Game/core/src/com/mygdx/game/UI/Multiplay_LostScreen.java @@ -0,0 +1,171 @@ +package UI; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Preferences; +import com.badlogic.gdx.Screen; +import com.badlogic.gdx.audio.Sound; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.g2d.*; +import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.actions.Actions; +import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; +import com.badlogic.gdx.scenes.scene2d.ui.Label; +import com.badlogic.gdx.scenes.scene2d.ui.Skin; +import com.badlogic.gdx.scenes.scene2d.ui.Table; +import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; +import com.badlogic.gdx.utils.Align; +import com.badlogic.gdx.utils.viewport.ScreenViewport; + +public class Multiplay_LostScreen implements Screen { + private SpriteBatch batch; + + private ImageButton RetryButton; + private ImageButton ExitButton; + private ImageButton MainMenuButton; + private Skin skin; + private MainClass mainClass; + private Table table; + + private Stage stage; + + private float tableY = Gdx.graphics.getHeight()/2; + + private Sound sound = Gdx.audio.newSound(Gdx.files.internal("Audio/Astronomia.mp3")); + + private Label label; + private Skin textSkin; + + Animation animation; + float elapsed; + + public Multiplay_LostScreen(final MainClass mainClass) { + this.mainClass = mainClass; + + animation = GifDecoder.loadGIFAnimation(Animation.PlayMode.LOOP, Gdx.files.internal("Texture/Gif/coffindance.gif").read()); + + batch = new SpriteBatch(); + + skin = new Skin(Gdx.files.internal("skin/ButtonPack.json")); + + stage = new Stage(new ScreenViewport()); + + textSkin = new Skin(Gdx.files.internal("skin/testingfont.json")); + label = new Label("DEFEAT", textSkin); + + label.setAlignment(Align.center | Align.top); + label.setColor(Color.RED); + label.setFontScale(3f); + + CreateTable(stage); + } + + public void CreateTable(final Stage stage) + { + table = new Table(); + table.setWidth(stage.getWidth()); + table.align(Align.center | Align.top); + table.setPosition(0, tableY); + + RetryButton = new ImageButton(skin, "Retry"); + RetryButton.addListener(new ClickListener(){ + @Override + public void clicked(InputEvent event, float x, float y) { + stage.addAction(Actions.sequence(Actions.fadeOut(1), Actions.run(new Runnable() { + @Override + public void run() { + mainClass.setNewGameScreen(); + } + }))); + } + }); + + MainMenuButton = new ImageButton(skin, "MainMenu"); + MainMenuButton.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + stage.addAction(Actions.sequence(Actions.fadeOut(1), Actions.run(new Runnable() { + @Override + public void run() { + mainClass.setMenuScreen(); + } + }))); + } + }); + + ExitButton = new ImageButton(skin, "Exit"); + ExitButton.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + Gdx.app.log("Exit Game", "BEEP"); + Gdx.app.exit(); + } + }); + + table.add(label).size(500,100).pad(30); + table.row(); + table.add(RetryButton).pad(30); + table.row(); + table.add(MainMenuButton).pad(30); + table.row(); + table.add(ExitButton).pad(30); + + stage.addActor(table); + } + + private void playSong() + { + long id = sound.play(1f); + sound.setPitch(id, 1f); + sound.setVolume(id, 0.5f); + sound.setLooping(id,true); + } + + public void show() { + stage.addAction(Actions.fadeIn(1)); + playSong(); + Gdx.input.setInputProcessor(stage); // kieu nhu no add input vao thang render. -- call before render each frame. + } + + public void render(float delta) { + elapsed += Gdx.graphics.getDeltaTime(); //Get time frame + + Gdx.gl.glClearColor(0, 0, 0, 1); + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + + batch.begin(); + batch.draw(animation.getKeyFrame(elapsed), 20,20); //Draw the gif + batch.end(); + + stage.act(); + stage.draw(); + } + + public void resize(int width, int height) { + stage.getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true); // this line is important. update size of stage = current screen size. + table.setWidth(stage.getWidth()); + table.align(Align.center|Align.top); + table.setPosition(0, tableY +table.getMinHeight()/2); + } + + public void pause() { + + } + + public void resume() { + + } + + public void hide() { + + } + + + public void dispose() { + stage.dispose(); + batch.dispose(); + skin.dispose(); + sound.dispose(); + } +} \ No newline at end of file diff --git a/Game/core/src/com/mygdx/game/UI/Multiplay_WinScreen.java b/Game/core/src/com/mygdx/game/UI/Multiplay_WinScreen.java new file mode 100644 index 0000000..2288e05 --- /dev/null +++ b/Game/core/src/com/mygdx/game/UI/Multiplay_WinScreen.java @@ -0,0 +1,176 @@ +package UI; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Preferences; +import com.badlogic.gdx.Screen; +import com.badlogic.gdx.audio.Sound; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.g2d.*; +import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.actions.Actions; +import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; +import com.badlogic.gdx.scenes.scene2d.ui.Label; +import com.badlogic.gdx.scenes.scene2d.ui.Skin; +import com.badlogic.gdx.scenes.scene2d.ui.Table; +import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; +import com.badlogic.gdx.utils.Align; +import com.badlogic.gdx.utils.viewport.ScreenViewport; + +public class Multiplay_WinScreen implements Screen{ + private SpriteBatch batch; + + private ImageButton RetryButton; + private ImageButton ExitButton; + private ImageButton MainMenuButton; + private Skin skin; + private MainClass mainClass; + private Table table; + + private Stage stage; + + private float tableY = Gdx.graphics.getHeight()/2; + + private Sound sound = Gdx.audio.newSound(Gdx.files.internal("Audio/GiornoTheme.mp3")); + + private BitmapFont scoreFont; + private Label label; + private Skin textSkin; + + Animation animation; + float elapsed; + + public Multiplay_WinScreen(final MainClass mainClass) { + this.mainClass = mainClass; + + animation = GifDecoder.loadGIFAnimation(Animation.PlayMode.LOOP, Gdx.files.internal("Texture/Gif/DancingEngi.gif").read()); + + batch = new SpriteBatch(); + + scoreFont = new BitmapFont(Gdx.files.internal("skin/minecraft.fnt")); + + skin = new Skin(Gdx.files.internal("skin/ButtonPack.json")); + + stage = new Stage(new ScreenViewport()); + + textSkin = new Skin(Gdx.files.internal("skin/testingfont.json")); + label = new Label("VICTORY", textSkin); + + label.setAlignment(Align.center | Align.top); + label.setColor(Color.GOLD); + label.setFontScale(3f); + + CreateTable(stage); + } + + public void CreateTable(final Stage stage) + { + table = new Table(); + table.setWidth(stage.getWidth()); + table.align(Align.center | Align.top); + table.setPosition(0, tableY); + + RetryButton = new ImageButton(skin, "Retry"); + RetryButton.addListener(new ClickListener(){ + @Override + public void clicked(InputEvent event, float x, float y) { + stage.addAction(Actions.sequence(Actions.fadeOut(1), Actions.run(new Runnable() { + @Override + public void run() { + mainClass.setNewGameScreen(); + sound.stop(); + } + }))); + } + }); + + MainMenuButton = new ImageButton(skin, "MainMenu"); + MainMenuButton.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + stage.addAction(Actions.sequence(Actions.fadeOut(1), Actions.run(new Runnable() { + @Override + public void run() { + mainClass.setMenuScreen(); + sound.stop(); + } + }))); + } + }); + + ExitButton = new ImageButton(skin, "Exit"); + ExitButton.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + Gdx.app.log("Exit Game", "BEEP"); + Gdx.app.exit(); + } + }); + + table.add(label).size(500,100).pad(30); + table.row(); + table.add(RetryButton).pad(30); + table.row(); + table.add(MainMenuButton).pad(30); + table.row(); + table.add(ExitButton).pad(30); + + stage.addActor(table); + } + + private void playSong() + { + long id = sound.play(1f); + sound.setPitch(id, 1f); + sound.setVolume(id, 0.5f); + sound.setLooping(id,true); + } + + public void show() { + stage.addAction(Actions.fadeIn(1)); + playSong(); + Gdx.input.setInputProcessor(stage); // kieu nhu no add input vao thang render. -- call before render each frame. + } + + public void render(float delta) { + elapsed += Gdx.graphics.getDeltaTime(); //Get time frame + + Gdx.gl.glClearColor(0, 0, 0, 1); + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + + batch.begin(); + batch.draw(animation.getKeyFrame(elapsed), 20,20); //Draw the gif + batch.end(); + + stage.act(); + stage.draw(); + } + + public void resize(int width, int height) { + stage.getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true); // this line is important. update size of stage = current screen size. + table.setWidth(stage.getWidth()); + table.align(Align.center|Align.top); + table.setPosition(0, tableY +table.getMinHeight()/2); + } + + public void pause() { + + } + + public void resume() { + + } + + public void hide() { + + } + + + public void dispose() { + stage.dispose(); + batch.dispose(); + skin.dispose(); + scoreFont.dispose(); + } +} diff --git a/Game/core/src/com/mygdx/game/UI/PauseScreen.java b/Game/core/src/com/mygdx/game/UI/PauseScreen.java new file mode 100644 index 0000000..c3003e8 --- /dev/null +++ b/Game/core/src/com/mygdx/game/UI/PauseScreen.java @@ -0,0 +1,129 @@ +package UI; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Screen; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.GlyphLayout; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.actions.Actions; +import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; +import com.badlogic.gdx.scenes.scene2d.ui.Skin; +import com.badlogic.gdx.scenes.scene2d.ui.Table; +import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; +import com.badlogic.gdx.utils.Align; +import com.badlogic.gdx.utils.viewport.ScreenViewport; +import com.mygdx.game.Background; + +public class PauseScreen implements Screen { + private SpriteBatch batch; + private static Texture PauseTitle; + + private ImageButton ResumeButton; + private ImageButton ExitButton; + private Skin skin; + private MainClass mainClass; + private Table table; + private Background background; + + BitmapFont font; + GlyphLayout layout; + + private Stage stage; + + + public PauseScreen(final MainClass mainClass) { + this.mainClass = mainClass; + batch = new SpriteBatch(); + PauseTitle = new Texture("skin/Pause.png"); + + background = new Background(); + background.create(); + background.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); + + skin = new Skin(Gdx.files.internal("skin/ButtonPack.json")); + font = new BitmapFont(Gdx.files.internal("skin/minecraft.fnt")); + + layout = new GlyphLayout(); + layout.setText(font, "PAUSE"); + + stage = new Stage(new ScreenViewport()); + + table = new Table(); + table.setWidth(stage.getWidth()); + table.align(Align.center | Align.top); + table.setPosition(0, Gdx.graphics.getHeight() / 2); + + ResumeButton = new ImageButton(skin, "Resume"); + ResumeButton.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + Gdx.app.log("Resume Game", "BEEP"); + mainClass.setNewGameScreen(); + } + }); + + ExitButton = new ImageButton(skin, "Exit"); + ExitButton.addListener(new ClickListener() { + @Override + public void clicked(InputEvent event, float x, float y) { + Gdx.app.log("Exit Game", "BEEP"); + Gdx.app.exit(); + } + }); + + table.pad(30); + table.add(ResumeButton).pad(30); + table.row(); + table.add(ExitButton).pad(30); + + stage.addActor(table); + + } + + public void show() { + Gdx.input.setInputProcessor(stage); + stage.addAction(Actions.fadeIn(1)); + // kieu nhu no add input vao thang render. -- call before render each frame. + } + + public void render(float delta) { + background.render(); + + stage.act(); + stage.draw(); + + batch.begin(); + batch.draw(PauseTitle, Gdx.graphics.getWidth()/2 - PauseTitle.getWidth()/2, Gdx.graphics.getHeight()/2); + batch.end(); + } + + @Override + public void resize(int width, int height) { + + } + + @Override + public void pause() { + + } + + @Override + public void resume() { + + } + + @Override + public void hide() { + Gdx.input.setInputProcessor(null); + } + + + public void dispose() { + stage.dispose(); + batch.dispose(); + skin.dispose(); + } +} diff --git a/Game/core/src/com/mygdx/game/UI/README.md b/Game/core/src/com/mygdx/game/UI/README.md new file mode 100644 index 0000000..211dc4d --- /dev/null +++ b/Game/core/src/com/mygdx/game/UI/README.md @@ -0,0 +1 @@ +#### UI Scripts diff --git a/Game/core/src/com/mygdx/game/UI/ScoreBoardScreen.java b/Game/core/src/com/mygdx/game/UI/ScoreBoardScreen.java new file mode 100644 index 0000000..9cf2da2 --- /dev/null +++ b/Game/core/src/com/mygdx/game/UI/ScoreBoardScreen.java @@ -0,0 +1,194 @@ +package UI; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Screen; +import com.badlogic.gdx.files.FileHandle; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.GlyphLayout; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.scenes.scene2d.InputEvent; +import com.badlogic.gdx.scenes.scene2d.Stage; +import com.badlogic.gdx.scenes.scene2d.ui.ImageButton; +import com.badlogic.gdx.scenes.scene2d.ui.Skin; +import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; +import com.badlogic.gdx.utils.Json; +import com.badlogic.gdx.utils.viewport.ScreenViewport; +import com.mygdx.game.PlayerData; + +public class ScoreBoardScreen implements Screen { + SpriteBatch batch; + + MainClass mainClass; + + private BitmapFont font; + + private ImageButton backButton; + private Skin skin; + private Stage stage; + + int maxPlayer = 10; + PlayerData[] list; + PlayerData playerData; + + Json json; + + FileHandle file; + + public ScoreBoardScreen(PlayerData data, final MainClass mainClass) + { + this.mainClass = mainClass; + + stage = new Stage(new ScreenViewport()); + + batch = new SpriteBatch(); + json = new Json(); + font = new BitmapFont(Gdx.files.internal("skin/minecraft.fnt")); + + list = new PlayerData[maxPlayer]; + + this.playerData = data; + + System.out.println(Gdx.files.internal("Scores.json").exists()); + + if(Gdx.files.internal("Scores.json").exists()) + { + file = Gdx.files.local("Scores.json"); + + list = json.fromJson(PlayerData[].class, PlayerData.class, file.readString()); + + System.out.println(json.prettyPrint(list)); + + if(playerData != null) + { + for(int i = list.length-1; i >= 0; i--) + { + if(playerData.score > list[i].score) + list[i] = playerData; + break; + } + list = sortBoard(list); + String text = json.toJson(list); + + file = Gdx.files.local("Scores.json"); + file.writeString(text, false); + } + System.out.println(json.prettyPrint(list)); + } + else + { + System.out.println("BEEP"); + for(int i = 0; i < maxPlayer; i++) + { + list[i] = new PlayerData("---", 10); + } + + System.out.println(json.prettyPrint(list)); + String text = json.toJson(list); + + list = json.fromJson(PlayerData[].class, text); + + file = Gdx.files.local("Scores.json"); + file.writeString(text, false); + } + + skin = new Skin(Gdx.files.internal("skin/ButtonPack.json")); + backButton = new ImageButton(skin, "Back"); + + backButton.addListener(new ClickListener() + { + @Override + public void clicked(InputEvent event, float x, float y) { + mainClass.setMenuScreen(); + } + }); + + stage.addActor(backButton); + } + + public PlayerData[] sortBoard(PlayerData[] players) + { + for(int i = 0; i < players.length; i++) + { + for(int j = players.length-1; j > i; j--) + { + if(players[i].score < players[j].score) + { + PlayerData temp; + temp = players[i]; + players[i] = players[j]; + players[j] = temp; + } + } + } + + return players; + } + + @Override + public void show() { + Gdx.input.setInputProcessor(stage); + System.out.println("SCORE"); + } + + @Override + public void render(float delta) { + Gdx.gl.glClearColor(0, 0, 0, 1); + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + batch.begin(); + + GlyphLayout layout; + + float width, height; + String title = "HighScore"; + + layout = new GlyphLayout(); + layout.setText(font, title); + + width = layout.width; + height = layout.height; + float DrawY = Gdx.graphics.getHeight() - 100; + font.draw(batch, layout, (Gdx.graphics.getWidth() - width)/2, DrawY); + + for(int i = 0; i < maxPlayer; i++) + { + float w, h; + title = String.format("%2d. %3s : %d", i+1, list[i].name, list[i].score); + layout.setText(font, title); + w = layout.width; + h = layout.height; + font.draw(batch, layout, (Gdx.graphics.getWidth() - w)/2, DrawY - height*2 - i * 2*h); + } + + stage.act(); + stage.draw(); + + batch.end(); + } + + @Override + public void resize(int width, int height) { + + } + + @Override + public void pause() { + + } + + @Override + public void resume() { + + } + + @Override + public void hide() { + + } + + public void dispose () { + batch.dispose(); + font.dispose(); + } + +} diff --git a/Game/core/src/com/mygdx/game/Waves.java b/Game/core/src/com/mygdx/game/Waves.java new file mode 100644 index 0000000..75a11c1 --- /dev/null +++ b/Game/core/src/com/mygdx/game/Waves.java @@ -0,0 +1,89 @@ +package com.mygdx.game; + +import java.lang.Object; +import java.util.Random; +import java.util.Vector; +import java.util.concurrent.TimeUnit; + +public class Waves { + private static Random waveid=new Random(); + private static long wavetime=0; + private static long t=System.currentTimeMillis(); + // private static long t1=System.currentTimeMillis(); + private static boolean Loadwave; + private static int enemies=0; + private static int id; + private static boolean isAllEGone; + private static Object obj=new Object(); + + public static int Wave = 0; + + public static void Wave_Come() { + if (System.currentTimeMillis() - t > wavetime) { + t = System.currentTimeMillis(); + Loadwave = true; + id=waveid.nextInt(4); + enemies=0; + } + if (System.currentTimeMillis() - t <= wavetime){ + if (Loadwave) { + Wave_Call(); + } + /*if (!Loadwave){ + isAllEGone=false; + for (int i=0;i20000) wavetime=20000; + MyGdxGame.Wave++; + if (Wave>10) + Wave=10; + for (int i=0; i1000){ + for (int i=0;i<(Wave/10+1);i++) { + Enemy.Enemy_Reallo(0, (float) (waveid.nextInt(160) + 560-80*i), 3, Wave); + t = System.currentTimeMillis(); + enemies++; + } + } + if ((enemies>=Wave+1)||(enemies>=30)) { + Loadwave=false; + MyGdxGame.Wave++; + } + break; + } + } +}