gamnit: support partial line forward and backward
authorAlexis Laferrière <alexis.laf@xymus.net>
Mon, 8 May 2017 23:44:56 +0000 (19:44 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Tue, 9 May 2017 00:58:51 +0000 (20:58 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/gamnit/tileset.nit

index f932f61..ecb40a2 100644 (file)
@@ -83,6 +83,12 @@ class TileSetFont
        # A negative value may display overlapped tiles.
        var vspace: Numeric = 0.0 is writable
 
+       # Line spacing modifier for `pld` and `plu`
+       #
+       # This value acts as multiplier to `height + vspace`.
+       # Defaults to 0.4, so a `pld` moves chars down by about half a line.
+       var partial_line_mod: Numeric = 0.4 is writable
+
        # The glyph/tile/texture associated to `char`
        #
        # Returns null if `char` is not in `chars`.
@@ -164,6 +170,12 @@ class TextSprites
                                dy -= font.height.to_f + font.vspace.to_f
                                dx = font.advance/2.0
                                continue
+                       else if c == pld then
+                               dy -= (font.height.to_f + font.vspace.to_f) * font.partial_line_mod.to_f
+                               continue
+                       else if c == plu then
+                               dy += (font.height.to_f + font.vspace.to_f) * font.partial_line_mod.to_f
+                               continue
                        else if c.is_whitespace then
                                dx += font.advance
                                continue
@@ -184,3 +196,9 @@ class TextSprites
                target_sprite_set.add_all sprites
        end
 end
+
+# Partial line forward (U+008B)
+fun pld: Char do return '\8b'
+
+# Partial line backward (U+008C)
+fun plu: Char do return '\8c'