22
33import com .redomar .game .Game ;
44import com .redomar .game .InputHandler ;
5+ import com .redomar .game .entities .efx .Swim ;
56import com .redomar .game .gfx .Colours ;
67import com .redomar .game .gfx .Screen ;
78import com .redomar .game .level .LevelHandler ;
@@ -13,10 +14,12 @@ public class Player extends Mob {
1314
1415 private InputHandler input ;
1516 private static Name customeName = new Name ();
17+ private Swim swim ;
1618
1719 private int colour = Colours .get (-1 , 111 , 240 , 310 );
1820 private int tickCount = 0 ;
1921 private String userName ;
22+
2023
2124 public static String guestPlayerName = customeName .setName ("Player " );
2225
@@ -58,39 +61,23 @@ public void tick() {
5861 } else {
5962 isMoving = false ;
6063 }
61-
62- if (level .getTile (this .getX () >> 3 , this .getY () >> 3 ).getId () == 4 ) {
63- isSwimming = true ;
64- }
65-
66- if (isSwimming
67- && level .getTile (this .getX () >> 3 , this .getY () >> 3 ).getId () != 4 ) {
68- isSwimming = false ;
69- }
64+
65+ Swimming ();
7066
7167 if (level .getTile (this .getX () >> 3 , this .getY () >> 3 ).getId () == 11 ) {
7268 changeLevels = true ;
7369 }
7470
75- if (level .getTile (this .getX () >> 3 , this .getY () >> 3 ).getId () == 12 ) {
76- isMagma = true ;
77- }
71+ tickCount ++;
72+ }
7873
79- if (isMagma
80- && level .getTile (this .getX () >> 3 , this .getY () >> 3 ).getId () != 12 ) {
81- isMagma = false ;
82- }
83-
84- if (level .getTile (this .getX () >> 3 , this .getY () >> 3 ).getId () == 14 ){
85- isMuddy = true ;
86- }
87-
88- if (isMuddy
89- && level .getTile (this .getX () >> 3 , this .getY () >> 3 ).getId () != 14 ){
90- isMuddy = false ;
91- }
74+ private void Swimming () {
9275
93- tickCount ++;
76+ setSwim (new Swim (level , getX (), getY ()));
77+
78+ isSwimming = getSwim ().water (isSwimming );
79+ isMagma = getSwim ().magma (isMagma );
80+ isMuddy = getSwim ().mud (isMuddy );
9481 }
9582
9683 public void render (Screen screen ) {
@@ -261,4 +248,12 @@ public String getSantizedUsername() {
261248 return this .getUsername ();
262249 }
263250
251+ public Swim getSwim () {
252+ return swim ;
253+ }
254+
255+ public void setSwim (Swim swim ) {
256+ this .swim = swim ;
257+ }
258+
264259}
0 commit comments