From 3dc61fd55d97a407e18a3306263b7013302f4130 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Wed, 3 Apr 2019 22:06:00 +1300 Subject: Add lines counter/scoring --- plot.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'plot.c') diff --git a/plot.c b/plot.c index 3cf2c0d..7a7a54e 100644 --- a/plot.c +++ b/plot.c @@ -1,4 +1,5 @@ #include +#include #include "colour.h" #include "plot.h" @@ -40,6 +41,30 @@ plot_cell(unsigned int x, unsigned int y, struct colour *c) } void +plot_text(const char *message, TTF_Font *font, SDL_Color color, int x, int y) +{ + SDL_Texture *texture = NULL; + SDL_Rect dst; + dst.x = x; + dst.y = y; + SDL_Surface *surf = TTF_RenderUTF8_Blended(font, message, color); + if (!surf) { + printf("Error in TTF_RenderUTF8_Blended\n"); + return; + } + texture = SDL_CreateTextureFromSurface(renderer, surf); + if (!texture){ + printf("Error in SDL_CreateTextureFromSurface\n"); + } + SDL_FreeSurface(surf); + + SDL_QueryTexture(texture, NULL, NULL, &dst.w, &dst.h); + SDL_RenderCopy(renderer, texture, NULL, &dst); + + SDL_DestroyTexture(texture); +} + +void plot_clear(void) { /* blank out the background with black */ -- cgit v1.1