Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void animate::write(const char *msg,int x,int y,int r,int g,int b,int Size)
- {
- TTF_Font *font = TTF_OpenFont("Sans.ttf" , Size);
- SDL_Color color = {r,g,b};
- SDL_Rect rect;
- SDL_Surface *surf = TTF_RenderText_Solid(font,msg,color);
- SDL_Texture *tex = SDL_CreateTextureFromSurface(render,surf);
- rect.x=x;
- rect.y=y;
- rect.w=surf->w;
- rect.w=surf->h;
- SDL_FreeSurface(surf);
- SDL_RenderCopy(render,tex,NULL,&rect);
- SDL_DestroyTexture(tex);
- }
- void animate::Render()
- {
- SDL_SetRenderDrawColor(render,150,170,190,255);
- rect.x=rect.y=0;
- rect.w=windowWidth;
- rect.h=windowHeight;
- SDL_RenderFillRect(render,&rect);
- draw(face);
- write("hello",20,30,0,255,0,24); // Getting error on adding this
- frameCount++;
- int timerFPS = SDL_GetTicks() + lastFrame;
- if(timerFPS < 1000/60)
- {
- SDL_Delay((1000/60) - timerFPS);
- }
- SDL_RenderPresent(render);
- }
- SDL_FreeSurface(surf);
- SDL_RenderCopy(render,tex,NULL,&rect);`
- SDL_RenderCopy(render,tex,NULL,&rect);
- SDL_FreeSurface(surf);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement