ludic/docs/language/screen/screen-draw_text.md

1.6 KiB

id name category kind tokens sig tip order ns member
screen-draw_text Screen.draw_text screen namespace-method Screen.draw_text Screen.draw_text(x, y, text, color, scale) Draw a string with the built-in font at an integer scale. 4 Screen draw_text

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:

  • x — the left edge of the first character, in pixels
  • y — the top edge of the text, in pixels
  • text — the string to draw
  • color — the text color, e.g. a Color.* name or a 0xRRGGBB literal
  • scale — integer size multiplier (1 = native size)
program TitleScreen {
  state TitleScreenState {
    elapsed_frames: int = 0
  }

  handler CountFrames(title_screen_st: mut TitleScreenState) phase Update {
    title_screen_st.elapsed_frames = title_screen_st.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()
  }
}