38
38
import com .github .tommyettinger .ds .ObjectDeque ;
39
39
import com .github .tommyettinger .ds .ObjectList ;
40
40
import com .github .tommyettinger .random .ChopRandom ;
41
+ import com .github .tommyettinger .textra .Font ;
42
+ import com .github .tommyettinger .textra .Layout ;
41
43
import com .github .yellowstonegames .core .DescriptiveColor ;
42
44
import com .github .yellowstonegames .core .FullPalette ;
43
45
import com .github .yellowstonegames .grid .*;
@@ -126,7 +128,8 @@ private boolean onGrid(int screenX, int screenY) {
126
128
return screenX >= 0 && screenX < placeWidth && screenY >= 0 && screenY < placeHeight ;
127
129
}
128
130
129
- private BitmapFont font ;
131
+ private Font font ;
132
+ private Layout gameOver ;
130
133
private Viewport mainViewport ;
131
134
private Viewport guiViewport ;
132
135
private Camera camera ;
@@ -324,6 +327,14 @@ public void restart(long seed) {
324
327
lang = '"' + Language .DEMONIC .sentence (rng , 4 , 7 ,
325
328
new String []{"," , "," , "," , " -" }, new String []{"...\" " , ", heh...\" " , ", nyehehe...\" " , "!\" " , "!\" " , "!\" " , "!\" *PTOOEY!*" ,}, 0.2 );
326
329
330
+ gameOver .clear ();
331
+
332
+ gameOver .setTargetWidth (shownWidth * cellWidth );
333
+ font .markup ("[RED]YOUR CRAWL IS OVER!\n " +
334
+ "[GRAY]A monster sniffs your corpse and says,\n [FOREST]" +
335
+ lang + "\n [GRAY]q to quit.\n [YELLOW]r to restart." , gameOver );
336
+ font .regenerateLayout (gameOver );
337
+
327
338
}
328
339
329
340
@ Override
@@ -349,12 +360,18 @@ public void create() {
349
360
350
361
// Stores all images we use here efficiently, as well as the font image
351
362
atlas = new TextureAtlas (Gdx .files .internal ("dawnlike/Dawnlike.atlas" ), Gdx .files .internal ("dawnlike" ));
352
- font = new BitmapFont (Gdx .files .internal ("dawnlike/font.fnt" ), atlas .findRegion ("font" ));
353
- // font = new BitmapFont(Gdx.files.internal("dawnlike/PlainAndSimplePlus.fnt"), atlas.findRegion("PlainAndSimplePlus")) ;
354
- font .getData (). markupEnabled = true ;
355
- font .setUseIntegerPositions ( false );
356
- font . getData (). setScale ( 3 );
363
+ // font = new BitmapFont(Gdx.files.internal("dawnlike/font.fnt"), atlas.findRegion("font"));
364
+ // font.getData().markupEnabled = true ;
365
+ // font.setUseIntegerPositions(false) ;
366
+ // font.getData().setScale(3 );
367
+
357
368
// font = generateFreetypeFont(48);
369
+
370
+ font = new Font (Gdx .files .internal ("dawnlike/font.fnt" ), atlas .findRegion ("font" ), Font .DistanceFieldType .STANDARD , 0 , 0 , 0 , 0 , false );
371
+ font .scale (3 , 3 );
372
+
373
+ gameOver = new Layout (font );
374
+
358
375
vision .rememberedColor = OKLAB_MEMORY ;
359
376
360
377
// Pixmap pCursor = new Pixmap(cellWidth, cellHeight, Pixmap.Format.RGBA8888);
@@ -756,13 +773,14 @@ public void render() {
756
773
batch .setProjectionMatrix (guiViewport .getCamera ().combined );
757
774
batch .begin ();
758
775
float wide = guiViewport .getWorldWidth (),
759
- x = playerSprite .getX () - guiViewport . getWorldWidth () * 0.5f ,
776
+ x = playerSprite .getX () - wide * 0.4f ,
760
777
y = playerSprite .getY ();
761
- font .draw (batch , "[RED]YOUR CRAWL IS OVER!" , x , y + 2 * font .getLineHeight (), wide , Align .center , true );
762
- font .draw (batch , "[GRAY]A monster sniffs your corpse and says," , x , y + font .getLineHeight (), wide , Align .center , true );
763
- font .draw (batch , "[FOREST]" + lang , x , y , wide , Align .center , true );
764
- font .draw (batch , "[GRAY]q to quit." , x , y - 2 * font .getLineHeight (), wide , Align .center , true );
765
- font .draw (batch , "[YELLOW]r to restart." , x , y - 4 * font .getLineHeight (), wide , Align .center , true );
778
+ font .drawGlyphs (batch , gameOver , x , y + 2 * font .cellHeight , Align .left );
779
+ // font.draw(batch, "[RED]YOUR CRAWL IS OVER!", x, y + 2 * font.getLineHeight(), wide, Align.center, true);
780
+ // font.draw(batch, "[GRAY]A monster sniffs your corpse and says,", x, y + font.getLineHeight(), wide, Align.center, true);
781
+ // font.draw(batch, "[FOREST]" + lang, x, y, wide, Align.center, true);
782
+ // font.draw(batch, "[GRAY]q to quit.", x, y - 2 * font.getLineHeight(), wide, Align.center, true);
783
+ // font.draw(batch, "[YELLOW]r to restart.", x, y - 4 * font.getLineHeight(), wide, Align.center, true);
766
784
batch .end ();
767
785
if (input .isKeyPressed (Q ))
768
786
Gdx .app .exit ();
@@ -819,9 +837,9 @@ public void render() {
819
837
guiViewport .apply (false );
820
838
batch .setProjectionMatrix (guiViewport .getCamera ().combined );
821
839
batch .begin ();
822
- pos .set (10 , Gdx .graphics .getHeight () - font .getLineHeight () );
840
+ pos .set (10 , Gdx .graphics .getHeight () - font .cellHeight );
823
841
guiViewport .unproject (pos );
824
- font .draw (batch , "[GRAY]Current Health: [RED]" + health + "[WHITE] at "
842
+ font .drawMarkupText (batch , "[GRAY]Current Health: [RED]" + health + "[WHITE] at "
825
843
+ Gdx .graphics .getFramesPerSecond () + " FPS" , pos .x , pos .y );
826
844
827
845
// pos.set(input.getDeltaX(), -input.getDeltaY());
0 commit comments