diff options
author | David Phillips <david@sighup.nz> | 2019-04-03 22:06:00 +1300 |
---|---|---|
committer | David Phillips <david@sighup.nz> | 2019-04-03 22:06:00 +1300 |
commit | 3dc61fd55d97a407e18a3306263b7013302f4130 (patch) | |
tree | 9ebb99b14f8634f421098041c0bf6b873faa562e /plot.c | |
parent | 3c395d1abb65f525ba83ca5d61654ffd1497facf (diff) | |
download | tetris-3dc61fd55d97a407e18a3306263b7013302f4130.tar.xz |
Add lines counter/scoring
Diffstat (limited to 'plot.c')
-rw-r--r-- | plot.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -1,4 +1,5 @@ #include <SDL.h> +#include <SDL_ttf.h> #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 */ |