API Reference › Screen — drawing › Screen.draw_text
method

Screen.draw_text

Screen.draw_text(x, y, text, color, scale)

Draws a string using Ludic's built-in bitmap font, starting at the top-left pixel (x, y). The scale is an integer multiplier: 1 is the native font size, 2 is double-height and double-width, and so on — there are no fractional sizes. Use it for labels, menus, and messages such as titles or "GAME OVER"; for numbers that change every frame prefer Screen.draw_number, which needs no string conversion. The text is drawn in the given color over whatever is already on screen.

Parameters

xthe left edge of the first character, in pixels
ythe top edge of the text, in pixels
textthe string to draw
colorthe text color, e.g. a Color.* name or a 0xRRGGBB literal
scaleinteger size multiplier (1 = native size)

Example

program TitleScreen {
  var elapsed_frames: int = 0

  handler CountFrames phase Update {
    elapsed_frames = elapsed_frames + 1
  }

  handler DrawWorld phase Render {
    Screen.clear(Color.MidnightBlue)
    Screen.draw_text(x: 40, y: 60, text: "CHRONORIFT", color: Color.Gold, scale: 3)
    Screen.draw_text(x: 64, y: 120, text: "PRESS ANY KEY", color: Color.White, scale: 1)
    Screen.show()
  }
}
← All symbols