Skip to content

Commit 4e2a1d8

Browse files
committed
Merge pull request #3 from posmicanomaly/master
Improved userName Centering above player's sprite.
2 parents bc16a68 + 3f37b8e commit 4e2a1d8

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/com/redomar/game/entities/Player.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,19 @@ public void render(Screen screen) {
157157
;
158158
}
159159

160-
if (userName != null) {
161-
Font.render(userName, screen, xOffset
162-
- ((userName.length() - 1) / 2 * 8), yOffset - 10,
160+
if (userName != null) {
161+
/*
162+
* Improved userName centering above player's sprite.
163+
* Using player's own x value cast to int with an adjusted formula
164+
* -posmicanomaly
165+
*/
166+
int fontCharSize = 8;
167+
Font.render(userName,
168+
screen,
169+
(int)x - ((userName.length() /2) * fontCharSize),
170+
yOffset - 10,
163171
Colours.get(-1, -1, -1, 555), 1);
172+
164173
}
165174
}
166175

0 commit comments

Comments
 (0)