Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SDL.h>
- #include <SDL_image.h>
- #include <SDL_ttf.h>
- #include <iostream>
- using namespace std;
- void draw();
- int main(int argc, char** argv)
- {
- const string name = "TerraCraft";
- const char pathSeparator =
- #ifdef _WIN32
- '\\';
- #else
- '/';
- #endif
- SDL_Window *screen;
- SDL_Surface *text;
- SDL_Rect position;
- SDL_Event event;
- TTF_Font *font;
- SDL_Color blackColor = {0, 0, 0};
- bool opened = true;
- SDL_Init(SDL_INIT_VIDEO);
- TTF_Init();
- screen = SDL_CreateWindow(name.c_str(), 100, 100, 1920, 400, SDL_WINDOW_MAXIMIZED | SDL_WINDOW_RESIZABLE);
- while(opened)
- {
- SDL_WaitEvent(&event);
- switch(event.type)
- {
- case SDL_QUIT:
- opened = 0;
- break;
- case SDL_WINDOWEVENT:
- if(event.window.event == SDL_WINDOWEVENT_RESIZED)
- {
- SDL_Surface *pSurf = SDL_GetWindowSurface(screen);
- font = TTF_OpenFont("arial.ttf", 55);
- text = TTF_RenderText_Blended(font, "etc", blackColor);
- SDL_FillRect(pSurf, NULL, SDL_MapRGB(pSurf->format, 255, 255, 255));
- position.x = 0;
- position.y = 0;
- SDL_BlitSurface(IMG_Load("parc.png"), NULL, pSurf, &position);
- position.x = 60;
- position.y = 370;
- SDL_BlitSurface(text, NULL, pSurf, &position);
- SDL_UpdateWindowSurface(screen);
- break;
- }
- }
- }
- TTF_CloseFont(font);
- TTF_Quit();
- SDL_FreeSurface(text);
- SDL_Quit();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement