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;
import de.miaurizius.jgame2d.core.enums.GameState;
import de.miaurizius.jgame2d.core.enums.Map;
import de.miaurizius.jgame2d.core.handlers.*;
import de.miaurizius.jgame2d.entity.Entity;
import de.miaurizius.jgame2d.entity.Player;
@@ -37,7 +38,7 @@ public class GamePanel extends JPanel implements Runnable {
// WORLD SETTINGS
public final int maxWorldCol = 50;
public final int maxWorldRow = 50;
public final String currentMap = "testmap2";
public Map currentMap = Map.OVERWORLD;
//FPS
final int FPS = 60;
@@ -57,10 +58,10 @@ public class GamePanel extends JPanel implements Runnable {
// ENTITY AND OBJECT
public Player player = new Player(this, keyH);
public Entity[] obj = new Entity[20];
public Entity[] npc = new Entity[10];
public Entity[] monster = new Entity[20];
public InteractiveTile[] iTile = new InteractiveTile[50];
public Entity[][] obj = new Entity[Map.values().length][20];
public Entity[][] npc = new Entity[Map.values().length][10];
public Entity[][] monster = new Entity[Map.values().length][20];
public InteractiveTile[][] iTile = new InteractiveTile[Map.values().length][50];
public ArrayList<Entity> projectileList = new ArrayList<>();
public ArrayList<Entity> particleList = new ArrayList<>();
ArrayList<Entity> entityList = new ArrayList<>();
@@ -117,14 +118,14 @@ public class GamePanel extends JPanel implements Runnable {
switch(gameState) {
case PLAY:
player.update();
for(Entity entity : npc) if(entity != null) entity.update();
for(int i = 0; i < monster.length; i++) {
Entity m = monster[i];
for(Entity entity : npc[currentMap.getIndex()]) if(entity != null) entity.update();
for(int i = 0; i < monster[currentMap.getIndex()].length; i++) {
Entity m = monster[currentMap.getIndex()][i];
if(m != null) {
if(m.alive && !m.dying) m.update();
if(!m.alive) {
monster[i].checkDrop();
monster[i] = null;
monster[currentMap.getIndex()][i].checkDrop();
monster[currentMap.getIndex()][i] = null;
}
}
}
@@ -142,7 +143,7 @@ public class GamePanel extends JPanel implements Runnable {
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;
case PAUSE:
break;
@@ -161,13 +162,13 @@ public class GamePanel extends JPanel implements Runnable {
// GAME
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
entityList.add(player);
for(Entity entity : npc) if(entity != null) entityList.add(entity);
for(Entity entity : obj) if(entity != null) entityList.add(entity);
for(Entity entity : monster) if(entity != null) entityList.add(entity);
for(Entity entity : npc[currentMap.getIndex()]) if(entity != null) entityList.add(entity);
for(Entity entity : obj[currentMap.getIndex()]) 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 : particleList) if(entity != null) entityList.add(entity);
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;
import de.miaurizius.jgame2d.core.GamePanel;
import de.miaurizius.jgame2d.core.enums.Map;
import de.miaurizius.jgame2d.entity.item.*;
import de.miaurizius.jgame2d.entity.npc.OldManNPC;
import de.miaurizius.jgame2d.entity.monster.GreenSlimeMON;
@@ -16,74 +17,90 @@ public class AssetSetter {
public void setObject() {
int i = 0;
panel.obj[i] = new HeartObj(panel);
panel.obj[i].worldX = panel.tileSize*25;
panel.obj[i].worldY = panel.tileSize*23;
panel.obj[Map.OVERWORLD.getIndex()][i] = new HeartObj(panel);
panel.obj[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*25;
panel.obj[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*23;
i++;
panel.obj[i] = new CoinObj(panel);
panel.obj[i].worldX = panel.tileSize*21;
panel.obj[i].worldY = panel.tileSize*19;
panel.obj[Map.OVERWORLD.getIndex()][i] = new CoinObj(panel);
panel.obj[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*21;
panel.obj[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*19;
i++;
panel.obj[i] = new AxeObj(panel);
panel.obj[i].worldX = panel.tileSize*33;
panel.obj[i].worldY = panel.tileSize*21;
panel.obj[Map.OVERWORLD.getIndex()][i] = new AxeObj(panel);
panel.obj[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*33;
panel.obj[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*21;
i++;
panel.obj[i] = new IronShieldObj(panel);
panel.obj[i].worldX = panel.tileSize*35;
panel.obj[i].worldY = panel.tileSize*21;
panel.obj[Map.OVERWORLD.getIndex()][i] = new IronShieldObj(panel);
panel.obj[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*35;
panel.obj[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*21;
i++;
panel.obj[i] = new PotionObj(panel);
panel.obj[i].worldX = panel.tileSize*22;
panel.obj[i].worldY = panel.tileSize*27;
panel.obj[Map.OVERWORLD.getIndex()][i] = new PotionObj(panel);
panel.obj[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*22;
panel.obj[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*27;
i++;
}
public void setNPC() {
panel.npc[0] = new OldManNPC(panel);
panel.npc[0].worldX = panel.tileSize*21;
panel.npc[0].worldY = panel.tileSize*21;
panel.npc[Map.OVERWORLD.getIndex()][0] = new OldManNPC(panel);
panel.npc[Map.OVERWORLD.getIndex()][0].worldX = 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() {
int i = 0;
panel.monster[i] = new GreenSlimeMON(panel);
panel.monster[i].worldX = panel.tileSize*23;
panel.monster[i].worldY = panel.tileSize*36;
panel.monster[Map.OVERWORLD.getIndex()][i] = new GreenSlimeMON(panel);
panel.monster[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*23;
panel.monster[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*36;
i++;
panel.monster[i] = new GreenSlimeMON(panel);
panel.monster[i].worldX = panel.tileSize*23;
panel.monster[i].worldY = panel.tileSize*37;
panel.monster[Map.OVERWORLD.getIndex()][i] = new GreenSlimeMON(panel);
panel.monster[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*23;
panel.monster[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*37;
i++;
panel.monster[i] = new GreenSlimeMON(panel);
panel.monster[i].worldX = panel.tileSize*24;
panel.monster[i].worldY = panel.tileSize*37;
panel.monster[Map.OVERWORLD.getIndex()][i] = new GreenSlimeMON(panel);
panel.monster[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*24;
panel.monster[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*37;
i++;
panel.monster[i] = new GreenSlimeMON(panel);
panel.monster[i].worldX = panel.tileSize*34;
panel.monster[i].worldY = panel.tileSize*42;
panel.monster[Map.OVERWORLD.getIndex()][i] = new GreenSlimeMON(panel);
panel.monster[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*34;
panel.monster[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*42;
i++;
panel.monster[i] = new GreenSlimeMON(panel);
panel.monster[i].worldX = panel.tileSize*38;
panel.monster[i].worldY = panel.tileSize*42;
panel.monster[Map.OVERWORLD.getIndex()][i] = new GreenSlimeMON(panel);
panel.monster[Map.OVERWORLD.getIndex()][i].worldX = panel.tileSize*38;
panel.monster[Map.OVERWORLD.getIndex()][i].worldY = panel.tileSize*42;
}
public void setITiles() {
int i = 0;
panel.iTile[i] = new DryTreeTI(panel,27,12);i++;
panel.iTile[i] = new DryTreeTI(panel,28,12);i++;
panel.iTile[i] = new DryTreeTI(panel,29,12);i++;
panel.iTile[i] = new DryTreeTI(panel,30,12);i++;
panel.iTile[i] = new DryTreeTI(panel,31,12);i++;
panel.iTile[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,27,12);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,28,12);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,29,12);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,30,12);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,31,12);i++;
panel.iTile[Map.OVERWORLD.getIndex()][i] = new DryTreeTI(panel,32,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) {
case UP:
entityTopRow = (entityTopWorldY - entity.speed)/panel.tileSize;
tileNum1 = panel.tileM.mapTileNum[entityLeftCol][entityTopRow];
tileNum2 = panel.tileM.mapTileNum[entityRightCol][entityTopRow];
tileNum1 = panel.tileM.mapTileNum[panel.currentMap.getIndex()][entityLeftCol][entityTopRow];
tileNum2 = panel.tileM.mapTileNum[panel.currentMap.getIndex()][entityRightCol][entityTopRow];
if(panel.tileM.tile[tileNum1].collision || panel.tileM.tile[tileNum2].collision) entity.collisionOn = true;
break;
case DOWN:
entityBottomRow = (entityBottomWorldY + entity.speed)/panel.tileSize;
tileNum1 = panel.tileM.mapTileNum[entityLeftCol][entityBottomRow];
tileNum2 = panel.tileM.mapTileNum[entityRightCol][entityBottomRow];
tileNum1 = panel.tileM.mapTileNum[panel.currentMap.getIndex()][entityLeftCol][entityBottomRow];
tileNum2 = panel.tileM.mapTileNum[panel.currentMap.getIndex()][entityRightCol][entityBottomRow];
if(panel.tileM.tile[tileNum1].collision || panel.tileM.tile[tileNum2].collision) entity.collisionOn = true;
break;
case LEFT:
entityLeftCol = (entityLeftWorldX - entity.speed)/panel.tileSize;
tileNum1 = panel.tileM.mapTileNum[entityLeftCol][entityTopRow];
tileNum2 = panel.tileM.mapTileNum[entityLeftCol][entityBottomRow];
tileNum1 = panel.tileM.mapTileNum[panel.currentMap.getIndex()][entityLeftCol][entityTopRow];
tileNum2 = panel.tileM.mapTileNum[panel.currentMap.getIndex()][entityLeftCol][entityBottomRow];
if(panel.tileM.tile[tileNum1].collision || panel.tileM.tile[tileNum2].collision) entity.collisionOn = true;
break;
case RIGHT:
entityRightCol = (entityRightWorldX + entity.speed)/panel.tileSize;
tileNum1 = panel.tileM.mapTileNum[entityRightCol][entityTopRow];
tileNum2 = panel.tileM.mapTileNum[entityRightCol][entityBottomRow];
tileNum1 = panel.tileM.mapTileNum[panel.currentMap.getIndex()][entityRightCol][entityTopRow];
tileNum2 = panel.tileM.mapTileNum[panel.currentMap.getIndex()][entityRightCol][entityBottomRow];
if(panel.tileM.tile[tileNum1].collision || panel.tileM.tile[tileNum2].collision) entity.collisionOn = true;
break;
}
@@ -56,7 +56,7 @@ public class CollisionHandler {
int index = 999;
int c = -1;
for(Entity obj : panel.obj) {
for(Entity obj : panel.obj[panel.currentMap.getIndex()]) {
c++;
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.enums.Direction;
import de.miaurizius.jgame2d.core.enums.GameState;
import de.miaurizius.jgame2d.core.enums.Map;
import java.awt.*;
public class EventHandler {
GamePanel panel;
EventRect[][] eventRect;
EventRect[][][] eventRect;
int prevEventX, prevEventY;
boolean canTouchEvent = true;
public EventHandler(GamePanel 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 row = 0;
while(col < panel.maxWorldCol && row < panel.maxWorldRow) {
eventRect[col][row] = new EventRect();
eventRect[col][row].x = 23;
eventRect[col][row].y = 23;
eventRect[col][row].width = 2;
eventRect[col][row].height = 2;
eventRect[col][row].eventRectDefaultX = eventRect[col][row].x;
eventRect[col][row].eventRectDefaultY = eventRect[col][row].y;
while(map < Map.values().length && col < panel.maxWorldCol && row < panel.maxWorldRow) {
eventRect[map][col][row] = new EventRect();
eventRect[map][col][row].x = 23;
eventRect[map][col][row].y = 23;
eventRect[map][col][row].width = 2;
eventRect[map][col][row].height = 2;
eventRect[map][col][row].eventRectDefaultX = eventRect[map][col][row].x;
eventRect[map][col][row].eventRectDefaultY = eventRect[map][col][row].y;
col++;
if(col == panel.maxWorldCol) {
col = 0;
row++;
if(row == panel.maxWorldRow) {
row = 0;
map++;
}
}
}
}
@@ -43,23 +49,27 @@ public class EventHandler {
if(distance > panel.tileSize) canTouchEvent = true;
if(!canTouchEvent) return;
if(hit(27,16, Direction.RIGHT)) damagePit(GameState.DIALOGUE);
if(hit(23,12, null)) healingPool(GameState.DIALOGUE);
if(hit(Map.OVERWORLD, 27,16, Direction.RIGHT)) damagePit(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
*/
public boolean hit(int eventCol, int eventRow, Direction reqDirection) {
public boolean hit(Map map, int eventCol, int eventRow, Direction reqDirection) {
boolean hit = false;
panel.player.solidArea.x = panel.player.worldX + panel.player.solidArea.x;
panel.player.solidArea.y = panel.player.worldY + panel.player.solidArea.y;
eventRect[eventCol][eventRow].x = eventCol*panel.tileSize + eventRect[eventCol][eventRow].x;
eventRect[eventCol][eventRow].y = eventRow*panel.tileSize + eventRect[eventCol][eventRow].y;
eventRect[map.getIndex()][eventCol][eventRow].x = eventCol*panel.tileSize + eventRect[map.getIndex()][eventCol][eventRow].x;
eventRect[map.getIndex()][eventCol][eventRow].y = eventRow*panel.tileSize + eventRect[map.getIndex()][eventCol][eventRow].y;
if(
panel.player.solidArea.intersects(eventRect[eventCol][eventRow]) &&
panel.player.solidArea.intersects(eventRect[map.getIndex()][eventCol][eventRow]) &&
(reqDirection == null || panel.player.direction == reqDirection) &&
!eventRect[eventCol][eventRow].eventDone
!eventRect[map.getIndex()][eventCol][eventRow].eventDone
) {
hit = true;
prevEventX = panel.player.worldX;
@@ -67,8 +77,8 @@ public class EventHandler {
}
panel.player.solidArea.x = panel.player.solidAreaDefaultX;
panel.player.solidArea.y = panel.player.solidAreaDefaultY;
eventRect[eventCol][eventRow].x = eventRect[eventCol][eventRow].eventRectDefaultX;
eventRect[eventCol][eventRow].y = eventRect[eventCol][eventRow].eventRectDefaultY;
eventRect[map.getIndex()][eventCol][eventRow].x = eventRect[map.getIndex()][eventCol][eventRow].eventRectDefaultX;
eventRect[map.getIndex()][eventCol][eventRow].y = eventRect[map.getIndex()][eventCol][eventRow].eventRectDefaultY;
return hit;
}
@@ -79,7 +89,6 @@ public class EventHandler {
panel.player.life -= 1;
canTouchEvent = false;
}
public void healingPool(GameState gameState) {
if(!panel.keyH.spacePressed) return;
panel.gameState = gameState;
@@ -90,6 +99,15 @@ public class EventHandler {
canTouchEvent = false;
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 {
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.UI;
import de.miaurizius.jgame2d.core.enums.GameState;
import de.miaurizius.jgame2d.core.enums.Map;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
@@ -54,7 +55,7 @@ public class KeyHandler implements KeyListener {
// DEBUG OPTIONS
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
case KeyEvent.VK_ESCAPE -> {
@@ -172,6 +173,7 @@ public class KeyHandler implements KeyListener {
case KeyEvent.VK_SPACE:
if(panel.ui.commandNum == 0) {
panel.gameState = GameState.PLAY;
panel.playMusic(0);
panel.retry();
}
if(panel.ui.commandNum == 1) {

View File

@@ -33,6 +33,7 @@ public class Sound {
load(10, "assets/sounds/burning.wav");
load(11, "assets/sounds/cuttree.wav");
load(12, "assets/sounds/gameover.wav");
load(13, "assets/sounds/stairs.wav");
}
@Deprecated
@@ -46,6 +47,7 @@ public class Sound {
}
}
// MANAGER
private void load(int index, String path) {
try {
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);
}
}
public void stop() {
clip.stop();
}
public void checkVolume() {
switch(volumeScale) {
case 0 -> volume = -80f;

View File

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

View File

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

View File

@@ -25,10 +25,10 @@ public class Projectile extends Entity {
public void update() {
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) {
panel.player.damageMonster(monsterIndex, attack);
generateParticle(user.projectile, panel.monster[monsterIndex]);
generateParticle(user.projectile, panel.monster[panel.currentMap.getIndex()][monsterIndex]);
alive = false;
}
}

View File

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