shithub: battleship

Download patch

ref: b6bc5d9b2c4fdb5b49042a98541e6f9758debe66
parent: f343924623cdddc0037bdad31adaf593ab8c2719
author: rodri <rgl@antares-labs.eu>
date: Fri Sep 15 11:56:10 EDT 2023

draw the game's title.

diff: cannot open b/assets/font/gunmetal//null: file does not exist: 'b/assets/font/gunmetal//null' diff: cannot open b/assets/font//null: file does not exist: 'b/assets/font//null' diff: cannot open b/assets//null: file does not exist: 'b/assets//null'
binary files /dev/null b/assets/font/gunmetal/gunmetal.48.0-0 differ
binary files /dev/null b/assets/font/gunmetal/gunmetal.48.20-3B differ
binary files /dev/null b/assets/font/gunmetal/gunmetal.48.2018-2019 differ
binary files /dev/null b/assets/font/gunmetal/gunmetal.48.201C-201D differ
binary files /dev/null b/assets/font/gunmetal/gunmetal.48.2022-2022 differ
binary files /dev/null b/assets/font/gunmetal/gunmetal.48.3D-3D differ
binary files /dev/null b/assets/font/gunmetal/gunmetal.48.3F-3F differ
binary files /dev/null b/assets/font/gunmetal/gunmetal.48.41-5A differ
binary files /dev/null b/assets/font/gunmetal/gunmetal.48.5C-5C differ
binary files /dev/null b/assets/font/gunmetal/gunmetal.48.5E-5F differ
binary files /dev/null b/assets/font/gunmetal/gunmetal.48.61-7A differ
binary files /dev/null b/assets/font/gunmetal/gunmetal.48.E0-E0 differ
binary files /dev/null b/assets/font/gunmetal/gunmetal.48.FFFD-FFFD differ
--- /dev/null
+++ b/assets/font/gunmetal/gunmetal.48.font
@@ -1,0 +1,14 @@
+51   40
+0x20	0x3B	gunmetal.48.20-3B
+0x3D	0x3D	gunmetal.48.3D-3D
+0x3F	0x3F	gunmetal.48.3F-3F
+0x41	0x5A	gunmetal.48.41-5A
+0x5C	0x5C	gunmetal.48.5C-5C
+0x5E	0x5F	gunmetal.48.5E-5F
+0x61	0x7A	gunmetal.48.61-7A
+0xE0	0xE0	gunmetal.48.E0-E0
+0x2018	0x2019	gunmetal.48.2018-2019
+0x201C	0x201D	gunmetal.48.201C-201D
+0x2022	0x2022	gunmetal.48.2022-2022
+0x0	0x0	gunmetal.48.0-0
+0xFFFD	0xFFFD	gunmetal.48.FFFD-FFFD
--- a/bts.c
+++ b/bts.c
@@ -64,6 +64,8 @@
 	}
 };
 char deffont[] = "/lib/font/bit/pelm/unicode.9.font";
+char titlefontpath[] = "assets/font/gunmetal/gunmetal.48.font";
+Font *titlefont;
 char winspec[32];
 char uid[8+1], oid[8+1];
 Channel *drawchan;
@@ -252,6 +254,14 @@
 }
 
 void
+drawtitle(Image *dst)
+{
+	static char s[] = "BATTLESHIP";
+
+	string(dst, Pt(SCRW/2 - stringwidth(titlefont, s)/2, 0), display->white, ZP, titlefont, s);
+}
+
+void
 drawgameoptions(Image *dst)
 {
 	static char s[] = "press p to play, w to watch";
@@ -327,6 +337,7 @@
 	draw(screenb, screenb->r, display->black, nil, ZP);
 	switch(game.state){
 	case Waiting0:
+		drawtitle(screenb);
 		drawgameoptions(screenb);
 		break;
 	default:
@@ -878,6 +889,10 @@
 	worldrf.p = Pt2(0,0,1);
 	worldrf.bx = Vec2(1,0);
 	worldrf.by = Vec2(0,1);
+
+	titlefont = openfont(display, titlefontpath);
+	if(titlefont == nil)
+		sysfatal("openfont: %r");
 
 	inittiles();
 	initboards();