@@ -13,7 +13,8 @@ public class Player extends Mob {
1313 private int tickCount = 0 ;
1414 private String userName ;
1515
16- public Player (LevelHandler level , int x , int y , InputHandler input , String userName ) {
16+ public Player (LevelHandler level , int x , int y , InputHandler input ,
17+ String userName ) {
1718 super (level , "Player" , x , y , 1 );
1819 this .input = input ;
1920 this .userName = userName ;
@@ -23,7 +24,7 @@ public void tick() {
2324 int xa = 0 ;
2425 int ya = 0 ;
2526
26- if (input != null ){
27+ if (input != null ) {
2728 if (input .up .isPressed ()) {
2829 ya --;
2930 }
@@ -44,15 +45,15 @@ public void tick() {
4445 } else {
4546 isMoving = false ;
4647 }
47-
48+
4849 if (level .getTile (this .x >> 3 , this .y >> 3 ).getId () == 4 ) {
4950 isSwimming = true ;
5051 }
5152
5253 if (isSwimming && level .getTile (this .x >> 3 , this .y >> 3 ).getId () != 4 ) {
5354 isSwimming = false ;
5455 }
55-
56+
5657 tickCount ++;
5758 }
5859
@@ -73,13 +74,13 @@ public void render(Screen screen) {
7374 int modifier = 8 * scale ;
7475 int xOffset = x - modifier / 2 ;
7576 int yOffset = y - modifier / 2 - 4 ;
76-
77- if (isSwimming ){
77+
78+ if (isSwimming ) {
7879 int waterColour = 0 ;
7980 yOffset += 4 ;
80-
81+
8182 colour = Colours .get (-1 , 111 , -1 , 310 );
82-
83+
8384 if (tickCount % 60 < 15 ) {
8485 waterColour = Colours .get (-1 , -1 , 255 , -1 );
8586 } else if (15 <= tickCount % 60 && tickCount % 60 < 30 ) {
@@ -91,21 +92,32 @@ public void render(Screen screen) {
9192 yOffset --;
9293 waterColour = Colours .get (-1 , -1 , 225 , 115 );
9394 }
94-
95- screen .render (xOffset , yOffset + 3 , 31 + 31 * 32 , waterColour , 0x00 , 1 );
96- screen .render (xOffset + 8 , yOffset + 3 , 31 + 31 * 32 , waterColour , 0x01 , 1 );
95+
96+ screen .render (xOffset , yOffset + 3 , 31 + 31 * 32 , waterColour ,
97+ 0x00 , 1 );
98+ screen .render (xOffset + 8 , yOffset + 3 , 31 + 31 * 32 , waterColour ,
99+ 0x01 , 1 );
97100 }
98101
99- screen .render ((xOffset + (modifier * flipTop )), yOffset , (xTile + yTile * 32 ), colour , flipTop , scale );
100- screen .render ((xOffset + modifier - (modifier * flipTop )), yOffset , ((xTile + 1 ) + yTile * 32 ), colour , flipTop , scale );
101- if (!isSwimming ){
102- screen .render ((xOffset + (modifier * flipBottom )), (yOffset + modifier ), (xTile + (yTile + 1 ) * 32 ), colour , flipBottom , scale );
103- screen .render ((xOffset + modifier - (modifier * flipBottom )), (yOffset + modifier ), ((xTile + 1 ) + (yTile + 1 ) * 32 ), colour , flipBottom , scale );
104- colour = Colours .get (-1 , 111 , 240 , 310 );;
102+ screen .render ((xOffset + (modifier * flipTop )), yOffset ,
103+ (xTile + yTile * 32 ), colour , flipTop , scale );
104+ screen .render ((xOffset + modifier - (modifier * flipTop )), yOffset ,
105+ ((xTile + 1 ) + yTile * 32 ), colour , flipTop , scale );
106+ if (!isSwimming ) {
107+ screen .render ((xOffset + (modifier * flipBottom )),
108+ (yOffset + modifier ), (xTile + (yTile + 1 ) * 32 ), colour ,
109+ flipBottom , scale );
110+ screen .render ((xOffset + modifier - (modifier * flipBottom )),
111+ (yOffset + modifier ), ((xTile + 1 ) + (yTile + 1 ) * 32 ),
112+ colour , flipBottom , scale );
113+ colour = Colours .get (-1 , 111 , 240 , 310 );
114+ ;
105115 }
106-
107- if (userName != null ){
108- Font .render (userName , screen , xOffset - ((userName .length () - 1 ) / 2 * 8 ), yOffset - 10 , Colours .get (-1 , -1 , -1 , 555 ), 1 );
116+
117+ if (userName != null ) {
118+ Font .render (userName , screen , xOffset
119+ - ((userName .length () - 1 ) / 2 * 8 ), yOffset - 10 ,
120+ Colours .get (-1 , -1 , -1 , 555 ), 1 );
109121 }
110122 }
111123
@@ -141,8 +153,8 @@ public boolean hasCollided(int xa, int ya) {
141153
142154 return false ;
143155 }
144-
145- public String getUsername (){
156+
157+ public String getUsername () {
146158 return this .userName ;
147159 }
148160
0 commit comments