Compare commits

...

4 Commits

13 changed files with 303 additions and 134 deletions

50
assets/maps/hut.map Normal file
View File

@@ -0,0 +1,50 @@
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 40 40 40 40 40 40 40 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 40 43 43 43 43 43 40 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 40 43 43 44 43 43 40 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 40 43 43 43 43 43 40 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 40 43 43 43 43 43 40 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 40 43 43 43 43 43 40 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 40 43 43 43 43 43 40 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 40 40 40 10 40 40 40 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41
41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41 41

50
assets/maps/world3.map Normal file
View File

@@ -0,0 +1,50 @@
12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12
12 12 12 12 12 12 12 12 12 12 12 12 12 12 13 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12
12 12 12 12 12 12 12 13 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 13 12 12 12 12 12 12 12 13 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12
12 12 12 12 13 12 12 12 12 12 12 13 12 12 12 12 12 12 13 12 12 12 12 12 12 12 12 13 12 12 12 12 12 12 12 12 12 12 12 12 12 13 12 12 12 12 12 12 12 12
12 12 12 12 12 12 12 12 12 13 12 12 12 12 12 13 12 12 12 12 12 12 12 13 12 12 12 12 12 12 12 13 12 12 13 12 12 12 13 12 12 12 12 12 12 12 12 12 12 12
12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 13 12 12 12 12 12 12 12 13 12 12 12 12 12 12 13 12 12 12 12 12 12 13 12 12 12 12 12 12
12 12 12 12 12 12 12 13 22 20 20 20 20 20 20 20 23 12 22 20 20 20 20 20 20 20 20 23 12 12 12 22 20 20 20 20 20 20 20 20 20 20 23 12 12 12 12 12 12 12
12 12 12 12 12 12 12 12 18 41 40 40 40 40 40 41 19 20 21 41 10 10 11 10 10 10 10 19 20 20 20 21 41 10 35 33 33 33 33 33 33 36 17 12 12 13 12 12 12 12
12 12 13 12 12 12 12 12 18 41 40 39 39 39 40 41 41 41 41 41 10 14 15 15 15 16 10 41 41 41 41 41 41 41 31 26 26 26 26 26 26 30 17 12 12 12 12 12 12 12
12 12 12 12 12 12 12 12 18 41 40 39 39 39 40 41 41 41 41 41 10 17 12 12 12 18 10 41 41 41 41 41 41 41 31 26 26 26 26 26 26 30 17 12 12 12 12 12 12 12
12 12 12 13 12 12 12 12 18 41 40 39 39 39 40 41 41 41 41 41 10 17 12 12 12 18 11 41 41 41 41 41 41 41 31 26 26 26 26 26 26 30 17 12 13 12 12 12 12 12
12 12 12 12 13 12 12 12 18 41 40 39 39 39 40 41 41 41 41 41 10 19 20 20 20 21 10 41 41 41 41 41 41 41 31 26 26 26 26 26 26 30 17 12 12 12 12 12 12 12
12 12 12 12 12 12 12 12 18 41 40 40 39 40 40 41 41 41 41 41 11 10 35 33 36 10 10 10 10 10 10 10 10 10 37 28 28 29 26 27 28 38 17 13 12 12 12 12 12 12
12 12 12 12 12 12 12 12 18 41 41 41 10 41 41 41 41 41 41 41 41 41 31 26 30 41 41 41 41 41 41 41 41 41 41 41 41 31 26 30 14 15 25 12 12 12 12 12 12 12
12 12 12 12 13 12 12 12 24 16 41 41 10 41 41 41 41 41 41 41 41 41 31 26 30 41 41 41 41 41 41 41 41 41 41 41 41 31 26 30 17 12 12 12 12 13 12 12 12 12
12 12 12 12 12 12 12 12 12 18 41 41 10 41 41 41 41 41 41 41 41 41 31 26 30 41 41 41 41 41 41 41 41 41 41 41 41 31 26 30 17 12 12 12 12 12 12 12 12 12
12 12 12 12 12 12 12 12 22 21 41 41 10 41 41 41 41 41 41 41 41 41 31 26 30 10 10 10 41 41 41 41 41 41 41 41 41 31 26 30 17 12 12 12 12 12 13 12 12 12
12 12 13 12 12 12 12 22 21 41 41 41 10 41 41 41 41 41 41 41 41 41 31 26 30 41 41 41 41 41 41 41 41 41 41 35 33 34 26 30 17 12 12 13 12 12 12 12 12 12
12 12 12 12 12 12 12 18 41 41 10 10 10 41 41 41 41 41 41 41 41 41 31 26 30 41 41 41 41 41 41 41 41 41 41 31 26 26 26 30 17 12 12 12 12 12 12 12 12 12
12 12 12 13 12 12 12 18 41 41 10 41 41 41 41 41 41 41 41 41 41 10 31 26 30 10 41 41 41 41 41 41 41 41 41 31 26 27 28 38 17 12 13 12 12 12 12 12 12 12
12 12 12 12 12 12 12 18 41 41 10 41 41 10 35 33 33 33 33 33 33 33 34 26 32 33 33 33 33 36 41 41 41 35 33 34 26 30 10 41 17 12 12 12 12 12 12 12 12 12
12 12 12 12 12 13 12 18 41 41 10 41 41 11 31 26 26 26 26 26 26 26 26 26 26 26 26 26 26 30 10 10 10 31 26 26 26 30 10 14 25 12 12 12 12 12 12 12 12 12
12 12 12 12 12 12 13 18 41 41 10 41 41 10 37 28 28 28 28 28 28 28 29 26 27 28 28 28 28 38 41 41 41 37 28 29 26 30 10 17 12 13 12 12 12 12 12 12 12 12
12 12 12 12 12 12 12 24 16 41 10 41 41 10 41 41 41 41 41 41 41 10 31 26 30 10 41 41 41 41 41 41 41 41 41 31 26 30 10 17 12 12 12 12 13 12 12 12 12 12
12 12 12 12 12 12 12 12 18 41 10 41 41 10 41 41 41 41 41 41 41 41 31 26 30 41 41 41 41 41 41 41 41 41 41 31 26 30 11 17 12 12 12 12 12 12 12 12 12 12
12 12 12 12 12 13 12 22 21 41 10 41 41 10 10 41 41 41 41 41 41 41 31 26 30 41 41 41 41 41 41 41 41 41 41 31 26 30 10 17 12 12 12 13 12 12 12 12 12 12
12 12 12 12 12 12 12 18 41 41 10 41 41 41 10 41 41 41 41 41 41 41 31 26 30 41 41 41 41 41 41 41 41 41 41 31 26 30 10 17 12 12 12 12 12 12 12 12 12 12
12 12 12 13 12 12 12 18 41 41 10 41 41 41 10 41 41 41 41 41 41 41 31 26 30 41 41 10 41 41 41 41 41 41 41 31 26 30 10 17 12 13 12 12 12 12 12 12 12 12
12 12 12 12 12 12 12 18 41 41 10 41 41 41 10 41 41 41 41 41 41 41 31 26 30 41 41 41 41 41 10 41 41 41 41 31 26 30 10 17 12 12 12 12 12 12 12 12 12 12
12 12 12 12 12 12 13 18 41 41 10 10 10 10 10 10 41 41 41 41 41 41 31 26 30 41 41 41 41 41 10 41 41 41 41 37 28 38 10 17 12 12 12 12 13 12 12 12 12 12
12 12 12 12 12 12 12 18 41 41 11 10 10 10 10 10 41 41 41 41 41 41 31 26 30 41 41 41 41 41 41 41 41 41 41 41 10 41 14 25 12 12 13 12 12 12 12 12 12 12
12 12 12 12 12 12 12 24 16 41 10 10 10 10 10 10 41 41 41 41 41 41 31 26 30 41 41 41 41 41 41 41 41 41 41 10 10 10 17 12 12 12 12 12 12 12 12 12 12 12
12 12 12 12 12 13 12 12 18 41 10 10 10 11 10 10 41 41 41 41 41 41 31 26 30 41 41 41 41 41 41 41 41 41 41 10 10 10 17 12 12 12 12 12 12 12 13 12 12 12
12 12 12 12 12 12 12 12 18 41 10 10 10 10 10 10 41 41 41 41 41 41 31 26 30 41 41 41 41 41 41 41 41 41 41 10 10 11 17 12 12 13 12 12 12 12 12 12 12 12
12 12 12 12 12 12 12 12 18 41 10 10 10 10 10 10 41 41 41 41 41 41 31 26 30 41 41 41 41 41 41 41 41 41 41 10 10 10 17 12 12 12 12 12 12 12 12 12 12 12
12 12 12 12 13 12 12 22 21 41 41 41 41 41 41 41 41 41 41 41 41 41 37 28 38 41 41 41 41 41 41 41 41 41 41 11 10 10 19 23 12 12 12 12 12 12 12 12 12 12
12 12 12 12 12 12 12 18 41 41 41 41 41 41 41 41 41 41 41 41 10 10 10 10 10 10 10 41 41 41 41 41 41 41 10 10 10 10 10 19 23 12 12 12 13 12 12 12 12 12
12 12 12 12 12 12 13 18 41 41 41 41 41 41 41 41 41 41 41 10 10 10 10 10 10 10 10 10 41 41 10 41 41 10 10 10 10 10 10 10 17 12 12 12 12 12 12 12 12 12
12 12 12 12 12 12 12 18 41 41 41 41 41 41 41 41 41 41 41 11 10 10 10 10 10 11 10 10 41 41 41 41 10 10 10 10 10 11 10 10 17 12 13 12 12 12 12 12 12 12
12 12 12 12 12 12 12 18 41 41 42 41 41 41 41 41 41 41 41 10 11 10 10 10 10 10 10 10 10 41 41 41 10 10 10 10 10 41 10 10 17 12 12 12 12 12 12 12 12 12
12 12 13 12 12 12 12 18 41 41 10 41 41 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 41 10 10 10 10 10 17 12 12 12 12 13 12 12 12 12
12 12 12 12 12 12 12 18 41 41 10 10 10 10 41 14 15 15 16 10 10 10 10 10 11 10 10 14 15 15 16 10 10 10 10 10 10 10 11 10 17 12 12 12 12 12 12 13 12 12
12 12 12 12 12 12 12 18 41 41 41 41 41 41 14 25 12 12 24 16 10 10 10 10 10 10 14 25 12 12 18 10 10 41 10 10 41 10 10 10 17 12 12 12 12 12 12 12 12 12
12 12 12 12 13 12 12 24 15 15 15 15 15 15 25 12 12 12 12 24 15 15 15 15 15 15 25 12 13 12 24 16 10 11 10 10 10 10 14 15 25 12 13 12 12 12 12 12 12 12
12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 13 12 12 12 12 12 12 12 12 12 12 12 12 24 15 15 15 15 15 15 25 12 12 12 12 12 12 12 13 12 12 12
12 12 12 12 12 12 12 12 12 12 12 13 12 12 12 12 13 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 13 12 12 12 12 12 12 13 12 12 12 12 12 12
12 12 12 12 12 12 13 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 13 12 12 12 12 13 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12
12 12 12 12 12 12 12 12 12 12 12 12 12 12 13 12 12 12 12 12 13 12 12 12 12 12 12 12 12 12 12 12 13 12 12 12 12 12 12 13 12 12 12 12 12 12 12 12 12 12
12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 13 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 13 12 12 12 12
12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12

View File

@@ -1,6 +1,7 @@
package de.miaurizius.jgame2d.core; package de.miaurizius.jgame2d.core;
import de.miaurizius.jgame2d.core.enums.GameState; import de.miaurizius.jgame2d.core.enums.GameState;
import de.miaurizius.jgame2d.core.enums.Map;
import de.miaurizius.jgame2d.core.handlers.*; import de.miaurizius.jgame2d.core.handlers.*;
import de.miaurizius.jgame2d.entity.Entity; import de.miaurizius.jgame2d.entity.Entity;
import de.miaurizius.jgame2d.entity.Player; import de.miaurizius.jgame2d.entity.Player;
@@ -37,7 +38,7 @@ public class GamePanel extends JPanel implements Runnable {
// WORLD SETTINGS // WORLD SETTINGS
public final int maxWorldCol = 50; public final int maxWorldCol = 50;
public final int maxWorldRow = 50; public final int maxWorldRow = 50;
public final String currentMap = "testmap2"; public Map currentMap = Map.OVERWORLD;
//FPS //FPS
final int FPS = 60; final int FPS = 60;
@@ -57,10 +58,10 @@ public class GamePanel extends JPanel implements Runnable {
// ENTITY AND OBJECT // ENTITY AND OBJECT
public Player player = new Player(this, keyH); public Player player = new Player(this, keyH);
public Entity[] obj = new Entity[20]; public Entity[][] obj = new Entity[Map.values().length][20];
public Entity[] npc = new Entity[10]; public Entity[][] npc = new Entity[Map.values().length][10];
public Entity[] monster = new Entity[20]; public Entity[][] monster = new Entity[Map.values().length][20];
public InteractiveTile[] iTile = new InteractiveTile[50]; public InteractiveTile[][] iTile = new InteractiveTile[Map.values().length][50];
public ArrayList<Entity> projectileList = new ArrayList<>(); public ArrayList<Entity> projectileList = new ArrayList<>();
public ArrayList<Entity> particleList = new ArrayList<>(); public ArrayList<Entity> particleList = new ArrayList<>();
ArrayList<Entity> entityList = new ArrayList<>(); ArrayList<Entity> entityList = new ArrayList<>();
@@ -117,14 +118,14 @@ public class GamePanel extends JPanel implements Runnable {
switch(gameState) { switch(gameState) {
case PLAY: case PLAY:
player.update(); player.update();
for(Entity entity : npc) if(entity != null) entity.update(); for(Entity entity : npc[currentMap.getIndex()]) if(entity != null) entity.update();
for(int i = 0; i < monster.length; i++) { for(int i = 0; i < monster[currentMap.getIndex()].length; i++) {
Entity m = monster[i]; Entity m = monster[currentMap.getIndex()][i];
if(m != null) { if(m != null) {
if(m.alive && !m.dying) m.update(); if(m.alive && !m.dying) m.update();
if(!m.alive) { if(!m.alive) {
monster[i].checkDrop(); monster[currentMap.getIndex()][i].checkDrop();
monster[i] = null; monster[currentMap.getIndex()][i] = null;
} }
} }
} }
@@ -142,7 +143,7 @@ public class GamePanel extends JPanel implements Runnable {
else particleList.remove(i); else particleList.remove(i);
} }
} }
for(Entity entity : iTile) if(entity != null) entity.update(); for(Entity entity : iTile[currentMap.getIndex()]) if(entity != null) entity.update();
break; break;
case PAUSE: case PAUSE:
break; break;
@@ -161,13 +162,13 @@ public class GamePanel extends JPanel implements Runnable {
// GAME // GAME
tileM.draw(fg2); tileM.draw(fg2);
for(Entity entity : iTile) if(entity != null) entity.draw(fg2); for(Entity entity : iTile[currentMap.getIndex()]) if(entity != null) entity.draw(fg2);
// ENTITY RENDER SYSTEM // ENTITY RENDER SYSTEM
entityList.add(player); entityList.add(player);
for(Entity entity : npc) if(entity != null) entityList.add(entity); for(Entity entity : npc[currentMap.getIndex()]) if(entity != null) entityList.add(entity);
for(Entity entity : obj) if(entity != null) entityList.add(entity); for(Entity entity : obj[currentMap.getIndex()]) if(entity != null) entityList.add(entity);
for(Entity entity : monster) if(entity != null) entityList.add(entity); for(Entity entity : monster[currentMap.getIndex()]) if(entity != null) entityList.add(entity);
for(Entity entity : projectileList) if(entity != null) entityList.add(entity); for(Entity entity : projectileList) if(entity != null) entityList.add(entity);
for(Entity entity : particleList) if(entity != null) entityList.add(entity); for(Entity entity : particleList) if(entity != null) entityList.add(entity);
entityList.sort(Comparator.comparingInt(o -> o.worldY)); entityList.sort(Comparator.comparingInt(o -> o.worldY));

View File

@@ -0,0 +1,23 @@
package de.miaurizius.jgame2d.core.enums;
public enum Map {
OVERWORLD("world3", 0),
HUT("hut", 1);
private final String name;
private final int index;
Map(String name, int index) {
this.name = name;
this.index = index;
}
public String getName() {
return name;
}
public int getIndex() {
return index;
}
}

View File

@@ -1,6 +1,7 @@
package de.miaurizius.jgame2d.core.handlers; package de.miaurizius.jgame2d.core.handlers;
import de.miaurizius.jgame2d.core.GamePanel; import de.miaurizius.jgame2d.core.GamePanel;
import de.miaurizius.jgame2d.core.enums.Map;
import de.miaurizius.jgame2d.entity.item.*; import de.miaurizius.jgame2d.entity.item.*;
import de.miaurizius.jgame2d.entity.npc.OldManNPC; import de.miaurizius.jgame2d.entity.npc.OldManNPC;
import de.miaurizius.jgame2d.entity.monster.GreenSlimeMON; import de.miaurizius.jgame2d.entity.monster.GreenSlimeMON;
@@ -16,74 +17,90 @@ public class AssetSetter {
public void setObject() { public void setObject() {
int i = 0; int i = 0;
panel.obj[i] = new HeartObj(panel); panel.obj[Map.OVERWORLD.getIndex()][i] = new HeartObj(panel);
panel.obj[i].worldX = panel.tileSize*25; panel.obj[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*25;
panel.obj[i].worldY = panel.tileSize*23; panel.obj[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*23;
i++; i++;
panel.obj[i] = new CoinObj(panel); panel.obj[Map.OVERWORLD.getIndex()][i] = new CoinObj(panel);
panel.obj[i].worldX = panel.tileSize*21; panel.obj[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*21;
panel.obj[i].worldY = panel.tileSize*19; panel.obj[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*19;
i++; i++;
panel.obj[i] = new AxeObj(panel); panel.obj[Map.OVERWORLD.getIndex()][i] = new AxeObj(panel);
panel.obj[i].worldX = panel.tileSize*33; panel.obj[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*33;
panel.obj[i].worldY = panel.tileSize*21; panel.obj[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*21;
i++; i++;
panel.obj[i] = new IronShieldObj(panel); panel.obj[Map.OVERWORLD.getIndex()][i] = new IronShieldObj(panel);
panel.obj[i].worldX = panel.tileSize*35; panel.obj[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*35;
panel.obj[i].worldY = panel.tileSize*21; panel.obj[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*21;
i++; i++;
panel.obj[i] = new PotionObj(panel); panel.obj[Map.OVERWORLD.getIndex()][i] = new PotionObj(panel);
panel.obj[i].worldX = panel.tileSize*22; panel.obj[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*22;
panel.obj[i].worldY = panel.tileSize*27; panel.obj[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*27;
i++; i++;
} }
public void setNPC() { public void setNPC() {
panel.npc[0] = new OldManNPC(panel); panel.npc[Map.OVERWORLD.getIndex()][0] = new OldManNPC(panel);
panel.npc[0].worldX = panel.tileSize*21; panel.npc[Map.OVERWORLD.getIndex()][0].worldX = panel.tileSize*21;
panel.npc[0].worldY = panel.tileSize*21; panel.npc[Map.OVERWORLD.getIndex()][0].worldY = panel.tileSize*21;
panel.npc[Map.HUT.getIndex()][0] = new OldManNPC(panel);
panel.npc[Map.HUT.getIndex()][0].worldX = panel.tileSize*12;
panel.npc[Map.HUT.getIndex()][0].worldY = panel.tileSize*7;
} }
public void setMonster() { public void setMonster() {
int i = 0; int i = 0;
panel.monster[i] = new GreenSlimeMON(panel); panel.monster[Map.OVERWORLD.getIndex()][i] = new GreenSlimeMON(panel);
panel.monster[i].worldX = panel.tileSize*23; panel.monster[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*23;
panel.monster[i].worldY = panel.tileSize*36; panel.monster[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*36;
i++; i++;
panel.monster[i] = new GreenSlimeMON(panel); panel.monster[Map.OVERWORLD.getIndex()][i] = new GreenSlimeMON(panel);
panel.monster[i].worldX = panel.tileSize*23; panel.monster[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*23;
panel.monster[i].worldY = panel.tileSize*37; panel.monster[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*37;
i++; i++;
panel.monster[i] = new GreenSlimeMON(panel); panel.monster[Map.OVERWORLD.getIndex()][i] = new GreenSlimeMON(panel);
panel.monster[i].worldX = panel.tileSize*24; panel.monster[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*24;
panel.monster[i].worldY = panel.tileSize*37; panel.monster[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*37;
i++; i++;
panel.monster[i] = new GreenSlimeMON(panel); panel.monster[Map.OVERWORLD.getIndex()][i] = new GreenSlimeMON(panel);
panel.monster[i].worldX = panel.tileSize*34; panel.monster[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*34;
panel.monster[i].worldY = panel.tileSize*42; panel.monster[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*42;
i++; i++;
panel.monster[i] = new GreenSlimeMON(panel); panel.monster[Map.OVERWORLD.getIndex()][i] = new GreenSlimeMON(panel);
panel.monster[i].worldX = panel.tileSize*38; panel.monster[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*38;
panel.monster[i].worldY = panel.tileSize*42; panel.monster[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*42;
} }
public void setITiles() { public void setITiles() {
int i = 0; int i = 0;
panel.iTile[i] = new DryTreeTI(panel,27,12);i++; panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,27,12);i++;
panel.iTile[i] = new DryTreeTI(panel,28,12);i++; panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,28,12);i++;
panel.iTile[i] = new DryTreeTI(panel,29,12);i++; panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,29,12);i++;
panel.iTile[i] = new DryTreeTI(panel,30,12);i++; panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,30,12);i++;
panel.iTile[i] = new DryTreeTI(panel,31,12);i++; panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,31,12);i++;
panel.iTile[i] = new DryTreeTI(panel,32,12);i++; panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,32,12);i++;
panel.iTile[i] = new DryTreeTI(panel,33,12);i++; panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,33,12);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,18,40);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,17,40);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,16,40);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,15,40);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,14,40);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,13,40);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,13,41);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,12,41);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,11,41);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,10,41);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,10,40);i++;
} }
} }

View File

@@ -28,26 +28,26 @@ public class CollisionHandler {
switch(entity.direction) { switch(entity.direction) {
case UP: case UP:
entityTopRow = (entityTopWorldY - entity.speed)/panel.tileSize; entityTopRow = (entityTopWorldY - entity.speed)/panel.tileSize;
tileNum1 = panel.tileM.mapTileNum[entityLeftCol][entityTopRow]; tileNum1 = panel.tileM.mapTileNum[panel.currentMap.getIndex()][entityLeftCol][entityTopRow];
tileNum2 = panel.tileM.mapTileNum[entityRightCol][entityTopRow]; tileNum2 = panel.tileM.mapTileNum[panel.currentMap.getIndex()][entityRightCol][entityTopRow];
if(panel.tileM.tile[tileNum1].collision || panel.tileM.tile[tileNum2].collision) entity.collisionOn = true; if(panel.tileM.tile[tileNum1].collision || panel.tileM.tile[tileNum2].collision) entity.collisionOn = true;
break; break;
case DOWN: case DOWN:
entityBottomRow = (entityBottomWorldY + entity.speed)/panel.tileSize; entityBottomRow = (entityBottomWorldY + entity.speed)/panel.tileSize;
tileNum1 = panel.tileM.mapTileNum[entityLeftCol][entityBottomRow]; tileNum1 = panel.tileM.mapTileNum[panel.currentMap.getIndex()][entityLeftCol][entityBottomRow];
tileNum2 = panel.tileM.mapTileNum[entityRightCol][entityBottomRow]; tileNum2 = panel.tileM.mapTileNum[panel.currentMap.getIndex()][entityRightCol][entityBottomRow];
if(panel.tileM.tile[tileNum1].collision || panel.tileM.tile[tileNum2].collision) entity.collisionOn = true; if(panel.tileM.tile[tileNum1].collision || panel.tileM.tile[tileNum2].collision) entity.collisionOn = true;
break; break;
case LEFT: case LEFT:
entityLeftCol = (entityLeftWorldX - entity.speed)/panel.tileSize; entityLeftCol = (entityLeftWorldX - entity.speed)/panel.tileSize;
tileNum1 = panel.tileM.mapTileNum[entityLeftCol][entityTopRow]; tileNum1 = panel.tileM.mapTileNum[panel.currentMap.getIndex()][entityLeftCol][entityTopRow];
tileNum2 = panel.tileM.mapTileNum[entityLeftCol][entityBottomRow]; tileNum2 = panel.tileM.mapTileNum[panel.currentMap.getIndex()][entityLeftCol][entityBottomRow];
if(panel.tileM.tile[tileNum1].collision || panel.tileM.tile[tileNum2].collision) entity.collisionOn = true; if(panel.tileM.tile[tileNum1].collision || panel.tileM.tile[tileNum2].collision) entity.collisionOn = true;
break; break;
case RIGHT: case RIGHT:
entityRightCol = (entityRightWorldX + entity.speed)/panel.tileSize; entityRightCol = (entityRightWorldX + entity.speed)/panel.tileSize;
tileNum1 = panel.tileM.mapTileNum[entityRightCol][entityTopRow]; tileNum1 = panel.tileM.mapTileNum[panel.currentMap.getIndex()][entityRightCol][entityTopRow];
tileNum2 = panel.tileM.mapTileNum[entityRightCol][entityBottomRow]; tileNum2 = panel.tileM.mapTileNum[panel.currentMap.getIndex()][entityRightCol][entityBottomRow];
if(panel.tileM.tile[tileNum1].collision || panel.tileM.tile[tileNum2].collision) entity.collisionOn = true; if(panel.tileM.tile[tileNum1].collision || panel.tileM.tile[tileNum2].collision) entity.collisionOn = true;
break; break;
} }
@@ -56,7 +56,7 @@ public class CollisionHandler {
int index = 999; int index = 999;
int c = -1; int c = -1;
for(Entity obj : panel.obj) { for(Entity obj : panel.obj[panel.currentMap.getIndex()]) {
c++; c++;
if (obj != null) { if (obj != null) {

View File

@@ -3,34 +3,40 @@ package de.miaurizius.jgame2d.core.handlers;
import de.miaurizius.jgame2d.core.GamePanel; import de.miaurizius.jgame2d.core.GamePanel;
import de.miaurizius.jgame2d.core.enums.Direction; import de.miaurizius.jgame2d.core.enums.Direction;
import de.miaurizius.jgame2d.core.enums.GameState; import de.miaurizius.jgame2d.core.enums.GameState;
import de.miaurizius.jgame2d.core.enums.Map;
import java.awt.*; import java.awt.*;
public class EventHandler { public class EventHandler {
GamePanel panel; GamePanel panel;
EventRect[][] eventRect; EventRect[][][] eventRect;
int prevEventX, prevEventY; int prevEventX, prevEventY;
boolean canTouchEvent = true; boolean canTouchEvent = true;
public EventHandler(GamePanel panel) { public EventHandler(GamePanel panel) {
this.panel = panel; this.panel = panel;
eventRect = new EventRect[panel.maxWorldCol][panel.maxWorldRow]; eventRect = new EventRect[Map.values().length][panel.maxWorldCol][panel.maxWorldRow];
int map = 0;
int col = 0; int col = 0;
int row = 0; int row = 0;
while(col < panel.maxWorldCol && row < panel.maxWorldRow) { while(map < Map.values().length && col < panel.maxWorldCol && row < panel.maxWorldRow) {
eventRect[col][row] = new EventRect(); eventRect[map][col][row] = new EventRect();
eventRect[col][row].x = 23; eventRect[map][col][row].x = 23;
eventRect[col][row].y = 23; eventRect[map][col][row].y = 23;
eventRect[col][row].width = 2; eventRect[map][col][row].width = 2;
eventRect[col][row].height = 2; eventRect[map][col][row].height = 2;
eventRect[col][row].eventRectDefaultX = eventRect[col][row].x; eventRect[map][col][row].eventRectDefaultX = eventRect[map][col][row].x;
eventRect[col][row].eventRectDefaultY = eventRect[col][row].y; eventRect[map][col][row].eventRectDefaultY = eventRect[map][col][row].y;
col++; col++;
if(col == panel.maxWorldCol) { if(col == panel.maxWorldCol) {
col = 0; col = 0;
row++; row++;
if(row == panel.maxWorldRow) {
row = 0;
map++;
}
} }
} }
} }
@@ -43,23 +49,27 @@ public class EventHandler {
if(distance > panel.tileSize) canTouchEvent = true; if(distance > panel.tileSize) canTouchEvent = true;
if(!canTouchEvent) return; if(!canTouchEvent) return;
if(hit(27,16, Direction.RIGHT)) damagePit(GameState.DIALOGUE); if(hit(Map.OVERWORLD, 27,16, Direction.RIGHT)) damagePit(GameState.DIALOGUE);
if(hit(23,12, null)) healingPool(GameState.DIALOGUE); else if(hit(Map.OVERWORLD, 23,12, null)) healingPool(GameState.DIALOGUE);
// HUT
else if(hit(Map.OVERWORLD, 10, 39, null)) changeMap(Map.HUT, 12, 13);
else if(hit(Map.HUT, 12, 13, null)) changeMap(Map.OVERWORLD, 10, 39);
} }
/** /**
* @param reqDirection Set to null if no direction is required * @param reqDirection Set to null if no direction is required
*/ */
public boolean hit(int eventCol, int eventRow, Direction reqDirection) { public boolean hit(Map map, int eventCol, int eventRow, Direction reqDirection) {
boolean hit = false; boolean hit = false;
panel.player.solidArea.x = panel.player.worldX + panel.player.solidArea.x; panel.player.solidArea.x = panel.player.worldX + panel.player.solidArea.x;
panel.player.solidArea.y = panel.player.worldY + panel.player.solidArea.y; panel.player.solidArea.y = panel.player.worldY + panel.player.solidArea.y;
eventRect[eventCol][eventRow].x = eventCol*panel.tileSize + eventRect[eventCol][eventRow].x; eventRect[map.getIndex()][eventCol][eventRow].x = eventCol*panel.tileSize + eventRect[map.getIndex()][eventCol][eventRow].x;
eventRect[eventCol][eventRow].y = eventRow*panel.tileSize + eventRect[eventCol][eventRow].y; eventRect[map.getIndex()][eventCol][eventRow].y = eventRow*panel.tileSize + eventRect[map.getIndex()][eventCol][eventRow].y;
if( if(
panel.player.solidArea.intersects(eventRect[eventCol][eventRow]) && panel.player.solidArea.intersects(eventRect[map.getIndex()][eventCol][eventRow]) &&
(reqDirection == null || panel.player.direction == reqDirection) && (reqDirection == null || panel.player.direction == reqDirection) &&
!eventRect[eventCol][eventRow].eventDone !eventRect[map.getIndex()][eventCol][eventRow].eventDone
) { ) {
hit = true; hit = true;
prevEventX = panel.player.worldX; prevEventX = panel.player.worldX;
@@ -67,8 +77,8 @@ public class EventHandler {
} }
panel.player.solidArea.x = panel.player.solidAreaDefaultX; panel.player.solidArea.x = panel.player.solidAreaDefaultX;
panel.player.solidArea.y = panel.player.solidAreaDefaultY; panel.player.solidArea.y = panel.player.solidAreaDefaultY;
eventRect[eventCol][eventRow].x = eventRect[eventCol][eventRow].eventRectDefaultX; eventRect[map.getIndex()][eventCol][eventRow].x = eventRect[map.getIndex()][eventCol][eventRow].eventRectDefaultX;
eventRect[eventCol][eventRow].y = eventRect[eventCol][eventRow].eventRectDefaultY; eventRect[map.getIndex()][eventCol][eventRow].y = eventRect[map.getIndex()][eventCol][eventRow].eventRectDefaultY;
return hit; return hit;
} }
@@ -79,7 +89,6 @@ public class EventHandler {
panel.player.life -= 1; panel.player.life -= 1;
canTouchEvent = false; canTouchEvent = false;
} }
public void healingPool(GameState gameState) { public void healingPool(GameState gameState) {
if(!panel.keyH.spacePressed) return; if(!panel.keyH.spacePressed) return;
panel.gameState = gameState; panel.gameState = gameState;
@@ -90,6 +99,15 @@ public class EventHandler {
canTouchEvent = false; canTouchEvent = false;
panel.assetSetter.setMonster(); panel.assetSetter.setMonster();
} }
public void changeMap(Map map, int col, int row) {
panel.currentMap = map;
panel.player.worldX = panel.tileSize*col;
panel.player.worldY = panel.tileSize*row;
prevEventX = panel.player.worldX;
prevEventY = panel.player.worldY;
canTouchEvent = false;
panel.playSE(13);
}
static private class EventRect extends Rectangle { static private class EventRect extends Rectangle {
int eventRectDefaultX, eventRectDefaultY; int eventRectDefaultX, eventRectDefaultY;

View File

@@ -3,6 +3,7 @@ package de.miaurizius.jgame2d.core.handlers;
import de.miaurizius.jgame2d.core.GamePanel; import de.miaurizius.jgame2d.core.GamePanel;
import de.miaurizius.jgame2d.core.UI; import de.miaurizius.jgame2d.core.UI;
import de.miaurizius.jgame2d.core.enums.GameState; import de.miaurizius.jgame2d.core.enums.GameState;
import de.miaurizius.jgame2d.core.enums.Map;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
@@ -54,7 +55,7 @@ public class KeyHandler implements KeyListener {
// DEBUG OPTIONS // DEBUG OPTIONS
case KeyEvent.VK_T -> debug = !debug; case KeyEvent.VK_T -> debug = !debug;
case KeyEvent.VK_R -> panel.tileM.loadMap(panel.currentMap); case KeyEvent.VK_R -> {for(Map m : Map.values()) panel.tileM.loadMap(m);}
// GAME STATES // GAME STATES
case KeyEvent.VK_ESCAPE -> { case KeyEvent.VK_ESCAPE -> {
@@ -172,6 +173,7 @@ public class KeyHandler implements KeyListener {
case KeyEvent.VK_SPACE: case KeyEvent.VK_SPACE:
if(panel.ui.commandNum == 0) { if(panel.ui.commandNum == 0) {
panel.gameState = GameState.PLAY; panel.gameState = GameState.PLAY;
panel.playMusic(0);
panel.retry(); panel.retry();
} }
if(panel.ui.commandNum == 1) { if(panel.ui.commandNum == 1) {

View File

@@ -33,6 +33,7 @@ public class Sound {
load(10, "assets/sounds/burning.wav"); load(10, "assets/sounds/burning.wav");
load(11, "assets/sounds/cuttree.wav"); load(11, "assets/sounds/cuttree.wav");
load(12, "assets/sounds/gameover.wav"); load(12, "assets/sounds/gameover.wav");
load(13, "assets/sounds/stairs.wav");
} }
@Deprecated @Deprecated
@@ -46,6 +47,7 @@ public class Sound {
} }
} }
// MANAGER
private void load(int index, String path) { private void load(int index, String path) {
try { try {
AudioInputStream ais = AudioSystem.getAudioInputStream(new File(path)); AudioInputStream ais = AudioSystem.getAudioInputStream(new File(path));
@@ -55,11 +57,9 @@ public class Sound {
Boot.logger.log(Level.SEVERE, "Could not load Sound File: " + soundURL[index], e); Boot.logger.log(Level.SEVERE, "Could not load Sound File: " + soundURL[index], e);
} }
} }
public void stop() { public void stop() {
clip.stop(); clip.stop();
} }
public void checkVolume() { public void checkVolume() {
switch(volumeScale) { switch(volumeScale) {
case 0 -> volume = -80f; case 0 -> volume = -80f;

View File

@@ -85,9 +85,9 @@ public class Entity {
collisionOn = false; collisionOn = false;
panel.collisionH.checkTile(this); panel.collisionH.checkTile(this);
panel.collisionH.checkObject(this, false); panel.collisionH.checkObject(this, false);
panel.collisionH.checkEntity(this, panel.npc); panel.collisionH.checkEntity(this, panel.npc[panel.currentMap.getIndex()]);
panel.collisionH.checkEntity(this, panel.monster); panel.collisionH.checkEntity(this, panel.monster[panel.currentMap.getIndex()]);
panel.collisionH.checkEntity(this, panel.iTile); panel.collisionH.checkEntity(this, panel.iTile[panel.currentMap.getIndex()]);
boolean contactPlayer = panel.collisionH.checkPlayer(this); boolean contactPlayer = panel.collisionH.checkPlayer(this);
if(this.type == EntityType.MONSTER && contactPlayer) damagePlayer(attack); if(this.type == EntityType.MONSTER && contactPlayer) damagePlayer(attack);
@@ -205,11 +205,11 @@ public class Entity {
} }
public void dropItem(Entity droppedItem) { public void dropItem(Entity droppedItem) {
for(int i = 0; i < panel.obj.length; i++) { for(int i = 0; i < panel.obj[panel.currentMap.getIndex()].length; i++) {
if(panel.obj[i] == null) { if(panel.obj[panel.currentMap.getIndex()][i] == null) {
panel.obj[i] = droppedItem; panel.obj[panel.currentMap.getIndex()][i] = droppedItem;
panel.obj[i].worldX = worldX; panel.obj[panel.currentMap.getIndex()][i].worldX = worldX;
panel.obj[i].worldY = worldY; panel.obj[panel.currentMap.getIndex()][i].worldY = worldY;
break; break;
} }
} }

View File

@@ -72,15 +72,15 @@ public class Player extends Entity {
pickObject(objIndex); pickObject(objIndex);
// CHECK ENTITY COLLISION // CHECK ENTITY COLLISION
int npcIndex = panel.collisionH.checkEntity(this, panel.npc); int npcIndex = panel.collisionH.checkEntity(this, panel.npc[panel.currentMap.getIndex()]);
interactNPC(npcIndex); interactNPC(npcIndex);
// CHECK MONSTER COLLISION // CHECK MONSTER COLLISION
int monsterIndex = panel.collisionH.checkEntity(this, panel.monster); int monsterIndex = panel.collisionH.checkEntity(this, panel.monster[panel.currentMap.getIndex()]);
interactMonster(monsterIndex); interactMonster(monsterIndex);
// CHECK INTERACTIVE TILE COLLISION // CHECK INTERACTIVE TILE COLLISION
int iTileIndex = panel.collisionH.checkEntity(this, panel.iTile); int iTileIndex = panel.collisionH.checkEntity(this, panel.iTile[panel.currentMap.getIndex()]);
// CHECK EVENT // CHECK EVENT
panel.eventH.checkEvent(); panel.eventH.checkEvent();
@@ -128,17 +128,19 @@ public class Player extends Entity {
if(life <= 0) { if(life <= 0) {
panel.gameState = GameState.GAMEOVER; panel.gameState = GameState.GAMEOVER;
panel.ui.commandNum = -1;
panel.stopMusic();
panel.playSE(12); panel.playSE(12);
} }
} }
// INTERACTION // INTERACTION
public void pickObject(int index) { public void pickObject(int index) {
if(index == 999 || panel.obj[index] == null) return; if(index == 999 || panel.obj[panel.currentMap.getIndex()][index] == null) return;
// PICKUP ONLY // PICKUP ONLY
if(panel.obj[index].type == EntityType.PICKUP) { if(panel.obj[panel.currentMap.getIndex()][index].type == EntityType.PICKUP) {
panel.obj[index].use(this); panel.obj[panel.currentMap.getIndex()][index].use(this);
} }
// INVENTORY ITEMS // INVENTORY ITEMS
else { else {
@@ -146,18 +148,18 @@ public class Player extends Entity {
panel.ui.addMessage("Your inventory is full!"); panel.ui.addMessage("Your inventory is full!");
return; return;
} }
inventory.add(panel.obj[index]); inventory.add(panel.obj[panel.currentMap.getIndex()][index]);
panel.playSE(1); panel.playSE(1);
panel.ui.addMessage("Picked up " + panel.obj[index].name + "!"); panel.ui.addMessage("Picked up " + panel.obj[panel.currentMap.getIndex()][index].name + "!");
} }
panel.obj[index] = null; panel.obj[panel.currentMap.getIndex()][index] = null;
} }
public void interactMonster(int index) { public void interactMonster(int index) {
if(index == 999) return; if(index == 999) return;
if(invincible || panel.monster[index].dying || !panel.monster[index].alive) return; if(invincible || panel.monster[panel.currentMap.getIndex()][index].dying || !panel.monster[panel.currentMap.getIndex()][index].alive) return;
int damage = panel.monster[index].attack - defense; int damage = panel.monster[panel.currentMap.getIndex()][index].attack - defense;
if(damage > 0) { if(damage > 0) {
panel.playSE(6); panel.playSE(6);
@@ -186,10 +188,10 @@ public class Player extends Entity {
solidArea.width = attackArea.width; solidArea.width = attackArea.width;
solidArea.height = attackArea.height; solidArea.height = attackArea.height;
int monsterIndex = panel.collisionH.checkEntity(this, panel.monster); int monsterIndex = panel.collisionH.checkEntity(this, panel.monster[panel.currentMap.getIndex()]);
damageMonster(monsterIndex, attack); damageMonster(monsterIndex, attack);
int iTileIndex = panel.collisionH.checkEntity(this, panel.iTile); int iTileIndex = panel.collisionH.checkEntity(this, panel.iTile[panel.currentMap.getIndex()]);
interactTile(iTileIndex); interactTile(iTileIndex);
worldX = currentWorldX; worldX = currentWorldX;
@@ -206,32 +208,32 @@ public class Player extends Entity {
} }
public void damageMonster(int index, int attack) { public void damageMonster(int index, int attack) {
if(index == 999) return; if(index == 999) return;
if(panel.monster[index].invincible) return; if(panel.monster[panel.currentMap.getIndex()][index].invincible) return;
int damage = attack - panel.monster[index].defense; int damage = attack - panel.monster[panel.currentMap.getIndex()][index].defense;
if(damage > 0) { if(damage > 0) {
panel.playSE(5); panel.playSE(5);
panel.monster[index].life -= damage; panel.monster[panel.currentMap.getIndex()][index].life -= damage;
panel.monster[index].invincible = true; panel.monster[panel.currentMap.getIndex()][index].invincible = true;
} }
panel.monster[index].damageReaction(); panel.monster[panel.currentMap.getIndex()][index].damageReaction();
if(panel.monster[index].life <= 0) { if(panel.monster[panel.currentMap.getIndex()][index].life <= 0) {
panel.monster[index].dying = true; panel.monster[panel.currentMap.getIndex()][index].dying = true;
panel.ui.addMessage("Gained +" + panel.monster[index].exp + " XP!"); panel.ui.addMessage("Gained +" + panel.monster[panel.currentMap.getIndex()][index].exp + " XP!");
exp += panel.monster[index].exp; exp += panel.monster[panel.currentMap.getIndex()][index].exp;
checkLevelUp(); checkLevelUp();
} }
} }
public void interactTile(int index) { public void interactTile(int index) {
if(index == 999 || !panel.iTile[index].destructible || panel.iTile[index].invincible) return; if(index == 999 || !panel.iTile[panel.currentMap.getIndex()][index].destructible || panel.iTile[panel.currentMap.getIndex()][index].invincible) return;
if(!panel.iTile[index].meetItemReq(this)) return; if(!panel.iTile[panel.currentMap.getIndex()][index].meetItemReq(this)) return;
panel.iTile[index].playSE(); panel.iTile[panel.currentMap.getIndex()][index].playSE();
panel.iTile[index].life--; panel.iTile[panel.currentMap.getIndex()][index].life--;
panel.iTile[index].invincible = true; panel.iTile[panel.currentMap.getIndex()][index].invincible = true;
generateParticle(panel.iTile[index], panel.iTile[index]); generateParticle(panel.iTile[panel.currentMap.getIndex()][index], panel.iTile[panel.currentMap.getIndex()][index]);
if(panel.iTile[index].life == 0) panel.iTile[index] = panel.iTile[index].getDestroyedForm(); if(panel.iTile[panel.currentMap.getIndex()][index].life == 0) panel.iTile[panel.currentMap.getIndex()][index] = panel.iTile[panel.currentMap.getIndex()][index].getDestroyedForm();
} }
public void interactNPC(int index) { public void interactNPC(int index) {
@@ -239,7 +241,7 @@ public class Player extends Entity {
//if(!panel.keyH.spacePressed) return; //Only uncomment if text should only appear if player hits space //if(!panel.keyH.spacePressed) return; //Only uncomment if text should only appear if player hits space
attackCancel = true; attackCancel = true;
panel.gameState = GameState.DIALOGUE; panel.gameState = GameState.DIALOGUE;
panel.npc[index].speak(); panel.npc[panel.currentMap.getIndex()][index].speak();
} }
public void speak() { public void speak() {
//This method only exists for character specific things later... //This method only exists for character specific things later...

View File

@@ -25,10 +25,10 @@ public class Projectile extends Entity {
public void update() { public void update() {
if(user.type == EntityType.PLAYER) { if(user.type == EntityType.PLAYER) {
int monsterIndex = panel.collisionH.checkEntity(this, panel.monster); int monsterIndex = panel.collisionH.checkEntity(this, panel.monster[panel.currentMap.getIndex()]);
if(monsterIndex != 999) { if(monsterIndex != 999) {
panel.player.damageMonster(monsterIndex, attack); panel.player.damageMonster(monsterIndex, attack);
generateParticle(user.projectile, panel.monster[monsterIndex]); generateParticle(user.projectile, panel.monster[panel.currentMap.getIndex()][monsterIndex]);
alive = false; alive = false;
} }
} }

View File

@@ -3,6 +3,7 @@ package de.miaurizius.jgame2d.tile;
import de.miaurizius.jgame2d.core.Boot; import de.miaurizius.jgame2d.core.Boot;
import de.miaurizius.jgame2d.core.GamePanel; import de.miaurizius.jgame2d.core.GamePanel;
import de.miaurizius.jgame2d.core.Utility; import de.miaurizius.jgame2d.core.Utility;
import de.miaurizius.jgame2d.core.enums.Map;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import java.awt.*; import java.awt.*;
@@ -13,14 +14,14 @@ public class TileManager {
GamePanel panel; GamePanel panel;
public Tile[] tile; public Tile[] tile;
public int[][] mapTileNum; public int[][][] mapTileNum;
public TileManager(GamePanel panel) { public TileManager(GamePanel panel) {
this.panel = panel; this.panel = panel;
tile = new Tile[50]; tile = new Tile[50];
mapTileNum = new int[panel.maxWorldCol][panel.maxWorldRow]; mapTileNum = new int[Map.values().length][panel.maxWorldCol][panel.maxWorldRow];
getTileImage(); getTileImage();
loadMap(panel.currentMap); for(Map m : Map.values()) loadMap(m);
} }
public void initializeTile(int i, String name, boolean col) { public void initializeTile(int i, String name, boolean col) {
@@ -85,15 +86,20 @@ public class TileManager {
initializeTile(40, "wall", true); initializeTile(40, "wall", true);
initializeTile(41, "tree", true); initializeTile(41, "tree", true);
//
initializeTile(42, "hut", false);
initializeTile(43, "floor01", false);
initializeTile(44, "table01", true);
for (Tile tile : tile) { for (Tile tile : tile) {
if(tile == null) continue; if(tile == null) continue;
tile.image = Utility.scaleImage(tile.image, panel.tileSize, panel.tileSize); tile.image = Utility.scaleImage(tile.image, panel.tileSize, panel.tileSize);
} }
} }
public void loadMap(String map) { public void loadMap(Map map) {
try { try {
InputStream stream = new FileInputStream("assets/maps/"+map+".map"); InputStream stream = new FileInputStream("assets/maps/"+map.getName()+".map");
BufferedReader bReader = new BufferedReader(new InputStreamReader(stream)); BufferedReader bReader = new BufferedReader(new InputStreamReader(stream));
int col = 0; int col = 0;
int row = 0; int row = 0;
@@ -102,7 +108,7 @@ public class TileManager {
while(col < panel.maxWorldCol) { while(col < panel.maxWorldCol) {
String[] numbers = line.split(" "); String[] numbers = line.split(" ");
int num = Integer.parseInt(numbers[col]); int num = Integer.parseInt(numbers[col]);
mapTileNum[col][row] = num; mapTileNum[map.getIndex()][col][row] = num;
col++; col++;
} }
if(col == panel.maxWorldCol) { if(col == panel.maxWorldCol) {
@@ -121,7 +127,7 @@ public class TileManager {
int worldRow = 0; int worldRow = 0;
while(worldCol < panel.maxWorldCol && worldRow < panel.maxWorldRow) { while(worldCol < panel.maxWorldCol && worldRow < panel.maxWorldRow) {
int tileNum = mapTileNum[worldCol][worldRow]; int tileNum = mapTileNum[panel.currentMap.getIndex()][worldCol][worldRow];
int worldX = worldCol * panel.tileSize; int worldX = worldCol * panel.tileSize;
int worldY = worldRow * panel.tileSize; int worldY = worldRow * panel.tileSize;